vibe64 0.1.65 → 0.1.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/run.js +2004 -1363
- package/bin/server.js +282 -276
- package/bin/upgrade-state.js +4673 -4470
- package/dist/assets/{GithubBrowserTabs-D21Nl3QI.js → GithubBrowserTabs-CW3GBeJu.js} +1 -1
- package/dist/assets/{LocalDatabaseServer-POxY1K1U.js → LocalDatabaseServer-DYh3UF9q.js} +1 -1
- package/dist/assets/{SelectField-Dezd0B3y.js → SelectField-Df50ZFLj.js} +1 -1
- package/dist/assets/{ShellOutlet-DfF9vsWA.js → ShellOutlet-DkLdtzJW.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-I3ufyScN.js → Vibe64AuthSettingsButton-Cksj7FS6.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-DFfFPrd7.css → Vibe64AuthSettingsButton-DfKYI6ZS.css} +1 -1
- package/dist/assets/{Vibe64ConversationLog-C04oOQ2g.js → Vibe64ConversationLog-BC0eDtUP.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-BbrOUmRD.js → Vibe64DashboardShell-DX5dOXAB.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-VPEM2o1v.js → Vibe64DatabaseWorkspace-8i-RDc9y.js} +1 -1
- package/dist/assets/{Vibe64FileArea-C_nC2bPk.js → Vibe64FileArea-EK5yUio3.js} +1 -1
- package/dist/assets/{Vibe64OutputControls-DTO3Fw3x.js → Vibe64OutputControls--LB4G83q.js} +1 -1
- package/dist/assets/{Vibe64RepositoryWorkspace-B8xcCOvL.js → Vibe64RepositoryWorkspace-D6uJCype.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-Cb9Mxsyq.js → Vibe64SessionFiles-DVHGc7hd.js} +1 -1
- package/dist/assets/{Vibe64SessionSourceEditor-CVQ3NRjh.js → Vibe64SessionSourceEditor-Bws5ihr-.js} +1 -1
- package/dist/assets/{Vibe64UiStoryboardView-BV4JFgcZ.js → Vibe64UiStoryboardView-BmABkyG4.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-DGQAxYE-.js → Vibe64UnavailableSessions-C6Bkwsqk.js} +1 -1
- package/dist/assets/{_pageId_-CkG15vv4.js → _pageId_-FjW-3sqF.js} +1 -1
- package/dist/assets/{_sessionId_-Bka3RUmK.js → _sessionId_-4cH83Bfi.js} +1 -1
- package/dist/assets/_slug_-Cazfy5ui.js +14 -0
- package/dist/assets/_slug_-DQDycgFK.css +1 -0
- package/dist/assets/{access-Xo3unxGO.js → access-mxcxtn7b.js} +1 -1
- package/dist/assets/{app-B0spNegd.js → app-8zP_FAuO.js} +1 -1
- package/dist/assets/assistantRouting-Bbxguvre.js +3 -0
- package/dist/assets/{changes-DFv4tuoO.js → changes-cmlEyHug.js} +1 -1
- package/dist/assets/{client-4uCr4dYG.js → client-BJBzomgt.js} +1 -1
- package/dist/assets/{client-CVuXqm4b.js → client-C1i-bIgL.js} +1 -1
- package/dist/assets/{client-Dlg1kjjO.js → client-C7yZ1hEm.js} +1 -1
- package/dist/assets/{client-CevjVK2b.js → client-CQ49uWhR.js} +1 -1
- package/dist/assets/{client-DR0w56e8.js → client-D46Uu-YO.js} +2 -2
- package/dist/assets/{client-BjMjS6lX.js → client-DKNTl1to.js} +2 -2
- package/dist/assets/{conversation-OkWbkHjm.js → conversation-CFJRkeTj.js} +3 -3
- package/dist/assets/{conversation-DReMq0MF.css → conversation-COcuIkcD.css} +1 -1
- package/dist/assets/conversation-CexAK3Qk.js +1 -0
- package/dist/assets/{dashboard-CAca9MQn.js → dashboard-CMtWKazq.js} +1 -1
- package/dist/assets/{english-definitions-BtX8KA5g.js → english-definitions-DiyU9O9D.js} +1 -1
- package/dist/assets/{env-DrNyBVkB.js → env-LUc22Wgd.js} +1 -1
- package/dist/assets/{error-BqMxhgpB.js → error-BccdQn04.js} +1 -1
- package/dist/assets/{error-BQ7r64JO.js → error-DPDAz9Td.js} +1 -1
- package/dist/assets/{errorMessageHelpers-B49LyMJi.js → errorMessageHelpers-G32Hjqfm.js} +1 -1
- package/dist/assets/{health-B5yTW5Tt.js → health-CfMjMJFf.js} +1 -1
- package/dist/assets/{history-S3anp6xg.js → history-hX_kNskf.js} +1 -1
- package/dist/assets/{httpClient-Bwitq9Xf.js → httpClient-C71X5grL.js} +1 -1
- package/dist/assets/{i18n-BuXRXGaO.js → i18n-5EHeMSvt.js} +1 -1
- package/dist/assets/{i18n-DQPYjuW7.js → i18n-BSfPKqM3.js} +1 -1
- package/dist/assets/{i18n-Dm74yE_M.js → i18n-Dq-ep9n7.js} +1 -1
- package/dist/assets/index-BJWiPV6i.css +1 -0
- package/dist/assets/index-FVeEbKiO.js +134 -0
- package/dist/assets/{integrations-C7dj7el_.js → integrations-Ccb8EOEO.js} +14 -15
- package/dist/assets/{integrations-CwgrZgmM.css → integrations-CtnIjM1Y.css} +1 -1
- package/dist/assets/{issues-OkV4v4GX.js → issues-Bxtt7oqi.js} +1 -1
- package/dist/assets/{learning-lW9nBGjT.js → learning-BUx9jo91.js} +1 -1
- package/dist/assets/{pages-shOT9IVe.js → pages-D43zM2UW.js} +1 -1
- package/dist/assets/{project-files-D_K1N0JF.js → project-files-BX3zZCcl.js} +1 -1
- package/dist/assets/{publish-Bxe4ZCqe.js → publish-DatierL2.js} +1 -1
- package/dist/assets/{pull-requests-CQvk0TeH.js → pull-requests-DNkOjcuy.js} +1 -1
- package/dist/assets/{repository-CI2CqDwF.js → repository-0EKOcyTL.js} +1 -1
- package/dist/assets/{settings-DIVrFrs4.js → settings-DbR9JIc3.js} +1 -1
- package/dist/assets/{studioGateApi-UqmdV50W.js → studioGateApi-B9EUTtMx.js} +1 -1
- package/dist/assets/{studioUrls-k_pQIuPs.js → studioUrls-BR4ZL-TN.js} +1 -1
- package/dist/assets/{useArchivedVibe64Sessions-BkWrTOzg.js → useArchivedVibe64Sessions-B8VDhA9F.js} +1 -1
- package/dist/assets/useAssistantAttachments-C9kAnWqw.js +2 -0
- package/dist/assets/useCommand-CfqxMb4C.js +1 -0
- package/dist/assets/{useEndpointResource-DZTjr9gg.js → useEndpointResource-BwGXpV2u.js} +1 -1
- package/dist/assets/{useUiFeedback-BU4NyMq8.js → useUiFeedback-8Wvg7A_S.js} +1 -1
- package/dist/assets/{useVibe64ConversationLog-BADhWyNY.js → useVibe64ConversationLog-7wgLlKG5.js} +2 -2
- package/dist/assets/useVibe64Learning-DkneotqS.js +5 -0
- package/dist/assets/{useVibe64SessionData-DvFvAJC-.js → useVibe64SessionData-DuJ-dHR8.js} +1 -1
- package/dist/assets/{useVibe64SessionSelection-BukDTAxb.js → useVibe64SessionSelection-BwjtqeIR.js} +1 -1
- package/dist/assets/{vibe64FileUpload-BDkcaUyk.js → vibe64FileUpload-D_rOa1R8.js} +1 -1
- package/dist/assets/{vibe64RepositoryRealtime-DX2DEqIz.js → vibe64RepositoryRealtime-CVGNqwxz.js} +1 -1
- package/dist/assets/vibe64SavedEnvValues-CCZew0j7.js +1 -0
- package/dist/assets/{vibe64SessionFocus-CzuP3qPT.js → vibe64SessionFocus-B4diopOJ.js} +1 -1
- package/dist/index.html +23 -23
- package/docs/colleague-usage/ai-accounts.md +7 -7
- package/docs/colleague-usage/ai-model-setups.md +1 -1
- package/docs/colleague-usage/ai-tasks.md +2 -1
- package/docs/colleague-usage/auto-workflow.md +67 -44
- package/docs/colleague-usage/chat-settings.md +115 -114
- package/docs/colleague-usage/coding-agent-goal-pause.md +34 -12
- package/docs/colleague-usage/coding-agent-goals.md +33 -16
- package/docs/colleague-usage/coding-agent-history.md +9 -0
- package/docs/colleague-usage/coding-agent-questions.md +7 -0
- package/docs/colleague-usage/coding-agent-recovery.md +3 -0
- package/docs/colleague-usage/coding-agents.md +10 -4
- package/docs/colleague-usage/connected-repositories.md +4 -1
- package/docs/colleague-usage/developing-vibe64.md +11 -5
- package/docs/colleague-usage/development-env.md +74 -32
- package/docs/colleague-usage/github-work.md +39 -5
- package/docs/colleague-usage/integrations.md +2 -2
- package/docs/colleague-usage/main-chat-approvals.md +7 -6
- package/docs/colleague-usage/message-delivery-recovery.md +1 -1
- package/docs/colleague-usage/passes.md +260 -0
- package/docs/colleague-usage/plans.md +27 -16
- package/docs/colleague-usage/session-timeline.md +93 -0
- package/docs/colleague-usage/temporary-chats.md +6 -0
- package/docs/colleague-usage/ui-pass.md +30 -32
- package/docs/colleague-usage/workspace-preparation.md +51 -0
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +12 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +2 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +5 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +1 -1
- package/node_modules/@jskit-ai/connector-google-calendar/patterns/calendar-cli/example/.env.example +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +1 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/api-key-connection/PATTERN.md +4 -1
- package/node_modules/@jskit-ai/connectors-catalog/patterns/oauth-connection/PATTERN.md +3 -1
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/connectors-core/README.md +3 -1
- package/node_modules/@jskit-ai/connectors-core/package.json +1 -1
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +6 -0
- package/node_modules/@jskit-ai/kernel/package.json +3 -4
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +1 -1
- package/node_modules/@jskit-ai/payments-core/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +1 -0
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/patterns/realtime-application/example/.env.example +1 -0
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/package.json +1 -1
- package/node_modules/@local/vibe64-core/package.json +2 -0
- package/node_modules/@local/vibe64-execution/package.json +1 -0
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +715 -666
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +989 -847
- package/node_modules/@local/vibe64-genesis/src/server/agentSpecs.js +129 -107
- package/node_modules/@local/vibe64-genesis/src/server/index.js +632 -614
- package/node_modules/@local/vibe64-genesis/src/server/packaging.js +27 -28
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +172 -162
- package/node_modules/@local/vibe64-runtime/package.json +1 -0
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +1042 -898
- package/node_modules/@local/vibe64-terminals/package.json +2 -1
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +560 -420
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +586 -581
- package/package.json +15 -15
- package/server.bundle.mjs +44592 -44103
- package/dist/assets/_slug_-7Oo7pGKn.js +0 -14
- package/dist/assets/_slug_-BaxjtsgP.css +0 -1
- package/dist/assets/assistantRouting-B9cub38g.js +0 -3
- package/dist/assets/conversation-D7T_us2O.js +0 -1
- package/dist/assets/index-DSyb-mRJ.css +0 -1
- package/dist/assets/index-JBqyg0mr.js +0 -134
- package/dist/assets/useAssistantAttachments-DqlNFiha.js +0 -2
- package/dist/assets/useCommand-D-MIMmhp.js +0 -1
- package/dist/assets/useVibe64Learning-CbsI-XHB.js +0 -5
- package/dist/assets/vibe64SavedEnvValues-CgfMvj_h.js +0 -1
|
@@ -1,31 +1,31 @@
|
|
|
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
|
|
5
|
-
enumerable:!(r=
|
|
6
|
-
exports={BINARY_TYPES:
|
|
3
|
+
var Xa=Object.create;var _o=Object.defineProperty;var Ya=Object.getOwnPropertyDescriptor;var Za=Object.getOwnPropertyNames;var Qa=Object.getPrototypeOf,ec=Object.prototype.hasOwnProperty;var U=(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 X=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(n){throw e=0,n}};var tc=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Za(e))!ec.call(t,o)&&o!==n&&_o(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(r=Ya(e,o))||r.enumerable});return t};var fe=(t,e,n)=>(n=t!=null?Xa(Qa(t)):{},tc(e||!t||!t.__esModule?_o(n,"default",{value:t,enumerable:!0}):n,t));var ie=X((Wh,No)=>{"use strict";var Po=["nodebuffer","arraybuffer","fragments"],ko=typeof Blob<"u";ko&&Po.push("blob");No.
|
|
6
|
+
exports={BINARY_TYPES:Po,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ko,
|
|
7
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
8
|
-
"websocket"),NOOP:()=>{}}});var
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var st=X((Kh,Mt)=>{"use strict";var{EMPTY_BUFFER:gc}=ie(),Or=Buffer[Symbol.species];function vc(t,e){if(t.length===0)return gc;
|
|
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
|
-
return r<e?new
|
|
11
|
-
for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function
|
|
12
|
-
t.byteOffset+t.length)}function
|
|
13
|
-
e=new
|
|
14
|
-
{concat:
|
|
15
|
-
exports.mask=function(e,n,r,o,s){s<48?
|
|
16
|
-
n):t.unmask(e,n)}}catch{}});var
|
|
17
|
-
this[
|
|
18
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[
|
|
19
|
-
from([0,0,255,255]),
|
|
20
|
-
|
|
10
|
+
return r<e?new Or(n.buffer,n.byteOffset,r):n}function Mo(t,e,n,r,o){for(let s=0;s<o;s++)n[r+s]=t[s]^e[s&3]}function jo(t,e){
|
|
11
|
+
for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function wc(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
|
|
12
|
+
t.byteOffset+t.length)}function Rr(t){if(Rr.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?
|
|
13
|
+
e=new Or(t):ArrayBuffer.isView(t)?e=new Or(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Rr.readOnly=!1),e}Mt.exports=
|
|
14
|
+
{concat:vc,mask:Mo,toArrayBuffer:wc,toBuffer:Rr,unmask:jo};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=U("bufferutil");Mt.
|
|
15
|
+
exports.mask=function(e,n,r,o,s){s<48?Mo(e,n,r,o,s):t.mask(e,n,r,o,s)},Mt.exports.unmask=function(e,n){e.length<32?jo(e,
|
|
16
|
+
n):t.unmask(e,n)}}catch{}});var Lo=X((Jh,zo)=>{"use strict";var Do=Symbol("kDone"),Pr=Symbol("kRun"),kr=class{constructor(e){this[Do]=()=>{this.pending--,
|
|
17
|
+
this[Pr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Pr]()}[Pr](){if(this.pending!==
|
|
18
|
+
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Do])}}};zo.exports=kr});var De=X((Xh,$o)=>{"use strict";var it=U("zlib"),Uo=st(),yc=Lo(),{kStatusCode:Fo}=ie(),Ic=Buffer[Symbol.species],Sc=Buffer.
|
|
19
|
+
from([0,0,255,255]),Dt=Symbol("permessage-deflate"),ae=Symbol("total-length"),Me=Symbol("callback"),he=Symbol("buffers"),
|
|
20
|
+
je=Symbol("error"),jt,Nr=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,!jt){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
|
+
10;jt=new yc(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=
|
|
27
27
|
this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this.
|
|
28
|
-
_inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[
|
|
28
|
+
_inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Me];this._deflate.close(),this._deflate=
|
|
29
29
|
null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,
|
|
30
30
|
r=e.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===
|
|
31
31
|
!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits==
|
|
@@ -44,53 +44,53 @@ 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){jt.add(o=>{this._decompress(e,n,(s,i)=>{o(),r(s,i)})})}compress(e,n,r){jt.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
|
-
window_bits`,i=typeof this.params[s]!="number"?
|
|
50
|
-
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[
|
|
51
|
-
_inflate.on("error",
|
|
52
|
-
this._inflate.flush(()=>{let s=this._inflate[
|
|
53
|
-
this._inflate[
|
|
54
|
-
(this._inflate[
|
|
49
|
+
window_bits`,i=typeof this.params[s]!="number"?it.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=it.createInflateRaw(
|
|
50
|
+
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[Dt]=this,this._inflate[ae]=0,this._inflate[he]=[],this.
|
|
51
|
+
_inflate.on("error",bc),this._inflate.on("data",qo)}this._inflate[Me]=r,this._inflate.write(e),n&&this._inflate.write(Sc),
|
|
52
|
+
this._inflate.flush(()=>{let s=this._inflate[je];if(s){this._inflate.close(),this._inflate=null,r(s);return}let i=Uo.concat(
|
|
53
|
+
this._inflate[he],this._inflate[ae]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):
|
|
54
|
+
(this._inflate[ae]=0,this._inflate[he]=[],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
|
-
|
|
57
|
-
this._deflate[
|
|
58
|
-
flush(
|
|
59
|
-
buffer,s.byteOffset,s.length-4)),this._deflate[
|
|
60
|
-
_context_takeover`]&&this._deflate.reset(),r(null,s)})}}
|
|
61
|
-
function
|
|
62
|
-
new RangeError("Max payload size exceeded"),this[
|
|
63
|
-
"data",
|
|
64
|
-
t)}});var
|
|
56
|
+
it.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=it.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
|
|
57
|
+
this._deflate[ae]=0,this._deflate[he]=[],this._deflate.on("data",xc)}this._deflate[Me]=r,this._deflate.write(e),this._deflate.
|
|
58
|
+
flush(it.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=Uo.concat(this._deflate[he],this._deflate[ae]);n&&(s=new Ic(s.
|
|
59
|
+
buffer,s.byteOffset,s.length-4)),this._deflate[Me]=null,this._deflate[ae]=0,this._deflate[he]=[],n&&this.params[`${o}_no\
|
|
60
|
+
_context_takeover`]&&this._deflate.reset(),r(null,s)})}};$o.exports=Nr;function xc(t){this[he].push(t),this[ae]+=t.length}
|
|
61
|
+
function qo(t){if(this[ae]+=t.length,this[Dt]._maxPayload<1||this[ae]<=this[Dt]._maxPayload){this[he].push(t);return}this[je]=
|
|
62
|
+
new RangeError("Max payload size exceeded"),this[je].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[je][Fo]=1009,this.removeListener(
|
|
63
|
+
"data",qo),this.reset()}function bc(t){if(this[Dt]._inflate=null,this[je]){this[Me](this[je]);return}t[Fo]=1007,this[Me](
|
|
64
|
+
t)}});var ze=X((Yh,zt)=>{"use strict";var{isUtf8:Bo}=U("buffer"),{hasBlob:Tc}=ie(),_c=[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
|
|
67
|
-
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}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 Cc(t){return t>=
|
|
67
|
+
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Mr(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 Ac(t){return Tc&&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")}
|
|
74
|
-
exports.isValidUTF8=function(t){return t.length<24?
|
|
75
|
-
|
|
76
|
-
{concat:
|
|
77
|
-
|
|
78
|
-
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||
|
|
73
|
+
"Blob"||t[Symbol.toStringTag]==="File")}zt.exports={isBlob:Ac,isValidStatusCode:Cc,isValidUTF8:Mr,tokenChars:_c};if(Bo)zt.
|
|
74
|
+
exports.isValidUTF8=function(t){return t.length<24?Mr(t):Bo(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=U("utf-8-validate");
|
|
75
|
+
zt.exports.isValidUTF8=function(e){return e.length<32?Mr(e):t(e)}}catch{}});var Ur=X((Zh,Xo)=>{"use strict";var{Writable:Ec}=U("stream"),Ho=De(),{BINARY_TYPES:Oc,EMPTY_BUFFER:Vo,kStatusCode:Rc,kWebSocket:Pc}=ie(),
|
|
76
|
+
{concat:jr,toArrayBuffer:kc,unmask:Nc}=st(),{isValidStatusCode:Mc,isValidUTF8:Go}=ze(),Lt=Buffer[Symbol.species],Z=0,Wo=1,
|
|
77
|
+
Ko=2,Jo=3,Dr=4,zr=5,Ut=6,Lr=class extends Ec{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
78
|
+
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Oc[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[Pc]=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
|
-
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=
|
|
83
|
-
if(this._opcode===8&&this._state==
|
|
82
|
+
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Z}_write(e,n,r){
|
|
83
|
+
if(this._opcode===8&&this._state==Z)return r();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
|
|
84
84
|
r(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=
|
|
85
85
|
e.length,this._buffers.push(e),this.startLoop(r)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this.
|
|
86
|
-
_buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new
|
|
87
|
-
e,r.length-e),new
|
|
88
|
-
n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new
|
|
89
|
-
e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case
|
|
90
|
-
break;case
|
|
91
|
-
this.getData(e);break;case
|
|
86
|
+
_buffers.shift();if(e<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Lt(r.buffer,r.byteOffset+
|
|
87
|
+
e,r.length-e),new Lt(r.buffer,r.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let r=this._buffers[0],o=n.length-e;e>=r.length?
|
|
88
|
+
n.set(this._buffers.shift(),o):(n.set(new Uint8Array(r.buffer,r.byteOffset,e),o),this._buffers[0]=new Lt(r.buffer,r.byteOffset+
|
|
89
|
+
e,r.length-e)),e-=r.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case Z:this.getInfo(e);
|
|
90
|
+
break;case Wo:this.getPayloadLength16(e);break;case Ko:this.getPayloadLength64(e);break;case Jo:this.getMask();break;case Dr:
|
|
91
|
+
this.getData(e);break;case zr:case Ut: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
|
-
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[
|
|
93
|
+
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let r=(n[0]&64)===64;if(r&&!this._extensions[Ho.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]&
|
|
95
95
|
128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let o=this.createError(RangeError,"\
|
|
96
96
|
RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,
|
|
@@ -104,615 +104,617 @@ LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcod
|
|
|
104
104
|
ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,
|
|
105
105
|
this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(
|
|
106
106
|
o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");
|
|
107
|
-
e(o);return}this._payloadLength===126?this._state=
|
|
107
|
+
e(o);return}this._payloadLength===126?this._state=Wo:this._payloadLength===127?this._state=Ko:this.haveLength(e)}getPayloadLength16(e){
|
|
108
108
|
if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){
|
|
109
109
|
if(this._bufferedBytes<8){this._loop=!1;return}let n=this.consume(8),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let o=this.
|
|
110
110
|
createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD\
|
|
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=
|
|
115
|
-
4),this._state=
|
|
114
|
+
this._masked?this._state=Jo:this._state=Dr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
115
|
+
4),this._state=Dr}getData(e){let n=Vo;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
|
+
Nc(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=
|
|
120
|
-
push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[
|
|
119
|
+
_compressed){this._state=zr,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.
|
|
120
|
+
push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[Ho.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
|
-
this.dataMessage(n),this._state===
|
|
123
|
+
this.dataMessage(n),this._state===Z&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=Z;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=
|
|
126
|
-
_binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=
|
|
127
|
-
|
|
128
|
-
!
|
|
129
|
-
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=
|
|
130
|
-
age",o,!1),this._state=
|
|
131
|
-
emit("conclude",1005,
|
|
132
|
-
tatus code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new
|
|
133
|
-
_skipUTF8Validation&&!
|
|
134
|
-
this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=
|
|
135
|
-
9?"ping":"pong",e),this._state=
|
|
136
|
-
|
|
137
|
-
n);return Error.captureStackTrace(i,this.createError),i.code=s,i[
|
|
138
|
-
|
|
139
|
-
"kByteLength")
|
|
125
|
+
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=jr(r,n):this._binaryType==="arraybuffer"?o=kc(jr(r,n)):this.
|
|
126
|
+
_binaryType==="blob"?o=new Blob(r):o=r,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=Z):(this._state=
|
|
127
|
+
Ut,setImmediate(()=>{this.emit("message",o,!0),this._state=Z,this.startLoop(e)}))}else{let o=jr(r,n);if(!this._skipUTF8Validation&&
|
|
128
|
+
!Go(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===zr||
|
|
129
|
+
this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=Z):(this._state=Ut,setImmediate(()=>{this.emit("mess\
|
|
130
|
+
age",o,!1),this._state=Z,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.
|
|
131
|
+
emit("conclude",1005,Vo),this.end();else{let r=e.readUInt16BE(0);if(!Mc(r)){let s=this.createError(RangeError,`invalid s\
|
|
132
|
+
tatus code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(s);return}let o=new Lt(e.buffer,e.byteOffset+2,e.length-2);if(!this.
|
|
133
|
+
_skipUTF8Validation&&!Go(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(s);return}
|
|
134
|
+
this._loop=!1,this.emit("conclude",r,o),this.end()}this._state=Z;return}this._allowSynchronousEvents?(this.emit(this._opcode===
|
|
135
|
+
9?"ping":"pong",e),this._state=Z):(this._state=Ut,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
|
|
136
|
+
Z,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[Rc]=o,i}};Xo.exports=Lr});var $r=X((eg,Qo)=>{"use strict";var{Duplex:Qh}=U("stream"),{randomFillSync:jc}=U("crypto"),{types:{isUint8Array:Dc}}=U("util"),
|
|
138
|
+
Yo=De(),{EMPTY_BUFFER:zc,kWebSocket:Lc,NOOP:Uc}=ie(),{isBlob:Le,isValidStatusCode:Fc}=ze(),{mask:Zo,toBuffer:be}=st(),Q=Symbol(
|
|
139
|
+
"kByteLength"),qc=Buffer.alloc(4),Ft=8*1024,Te,Ue=Ft,te=0,$c=1,Bc=2,Fr=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=
|
|
142
|
-
(r=n.maskBuffer
|
|
143
|
-
|
|
144
|
-
i)&&n[
|
|
141
|
+
_bufferedBytes=0,this._queue=[],this._state=te,this.onerror=Uc,this[Lc]=void 0}static frame(e,n){let r,o=!1,s=2,i=!1;n.mask&&
|
|
142
|
+
(r=n.maskBuffer||qc,n.generateMask?n.generateMask(r):(Ue===Ft&&(Te===void 0&&(Te=Buffer.alloc(Ft)),jc(Te,0,Ft),Ue=0),r[0]=
|
|
143
|
+
Te[Ue++],r[1]=Te[Ue++],r[2]=Te[Ue++],r[3]=Te[Ue++]),i=(r[0]|r[1]|r[2]|r[3])===0,s=6);let a;typeof e=="string"?(!n.mask||
|
|
144
|
+
i)&&n[Q]!==void 0?a=n[Q]:(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?(Zo(e,r,d,s,a),[d]):(Zo(e,r,e,0,a),[d,e])):[d,e]}close(e,n,r,o){let s;if(e===void 0)s=zc;else{
|
|
148
|
+
if(typeof e!="number"||!Fc(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(Dc(n))s.set(n,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let i={[Q]:s.
|
|
152
152
|
length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==
|
|
153
|
-
|
|
154
|
-
byteLength(e),s=!1):
|
|
155
|
-
ust not be greater than 125 bytes");let i={[
|
|
156
|
-
opcode:9,readOnly:s,rsv1:!1};
|
|
157
|
-
this._state!==
|
|
158
|
-
string"?(o=Buffer.byteLength(e),s=!1):
|
|
159
|
-
"The data size must not be greater than 125 bytes");let i={[
|
|
160
|
-
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};
|
|
161
|
-
e,!1,i,r):this._state!==
|
|
162
|
-
extensionName],s=n.binary?2:1,i=n.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
_state!==
|
|
168
|
-
_bufferedBytes+=r[
|
|
169
|
-
closed while the blob was being read");process.nextTick(
|
|
170
|
-
dispatch(i,n,r,o):(this._state=
|
|
171
|
-
if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
dequeue()})}dequeue(){for(;this._state===
|
|
175
|
-
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][
|
|
176
|
-
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.
|
|
177
|
-
n)}};
|
|
178
|
-
length-1];typeof s=="function"&&s(e)}}function
|
|
179
|
-
"kError"),
|
|
180
|
-
this[
|
|
181
|
-
arget",{enumerable:!0});Object.defineProperty(
|
|
182
|
-
super(e),this[
|
|
183
|
-
return this[
|
|
184
|
-
{enumerable:!0});Object.defineProperty(
|
|
185
|
-
an",{enumerable:!0});var
|
|
186
|
-
n.message===void 0?"":n.message}get error(){return this[
|
|
187
|
-
"error",{enumerable:!0});Object.defineProperty(
|
|
188
|
-
super(e),this[
|
|
189
|
-
var
|
|
190
|
-
age")r=function(s,i){let a=new
|
|
191
|
-
let a=new
|
|
192
|
-
e,this,a)};else if(t==="error")r=function(s){let i=new
|
|
193
|
-
"open")r=function(){let s=new
|
|
194
|
-
this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[
|
|
195
|
-
|
|
196
|
-
t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var
|
|
197
|
-
let e=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,
|
|
198
|
-
m),i===void 0)if(
|
|
199
|
-
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);
|
|
200
|
-
v,n),n=Object.create(null)):i=v,c=
|
|
201
|
-
if(
|
|
202
|
-
`Unexpected character at index ${m}`);
|
|
203
|
-
c=
|
|
204
|
-
if(
|
|
205
|
-
1)c===-1&&(c=m);else if(d===34&&c!==-1)s=!1,
|
|
206
|
-
index ${m}`);else if(d===34&&t.charCodeAt(m-1)===61)s=!0;else if(
|
|
207
|
-
d===9))
|
|
208
|
-
(
|
|
209
|
-
void 0,c=
|
|
210
|
-
"Unexpected end of input");
|
|
211
|
-
|
|
153
|
+
te?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
|
+
byteLength(e),s=!1):Le(e)?(o=e.size,s=!1):(e=be(e),o=e.length,s=be.readOnly),o>125)throw new RangeError("The data size m\
|
|
155
|
+
ust not be greater than 125 bytes");let i={[Q]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,
|
|
156
|
+
opcode:9,readOnly:s,rsv1:!1};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(e,!1,i,r):
|
|
157
|
+
this._state!==te?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}pong(e,n,r){let o,s;if(typeof e==
|
|
158
|
+
"string"?(o=Buffer.byteLength(e),s=!1):Le(e)?(o=e.size,s=!1):(e=be(e),o=e.length,s=be.readOnly),o>125)throw new RangeError(
|
|
159
|
+
"The data size must not be greater than 125 bytes");let i={[Q]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this.
|
|
160
|
+
_maskBuffer,opcode:10,readOnly:s,rsv1:!1};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,!1,i,r]):this.getBlobData(
|
|
161
|
+
e,!1,i,r):this._state!==te?this.enqueue([this.dispatch,e,!1,i,r]):this.sendFrame(t.frame(e,i),r)}send(e,n,r){let o=this.
|
|
162
|
+
_extensions[Yo.extensionName],s=n.binary?2:1,i=n.compress,a,c;typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Le(e)?(a=
|
|
163
|
+
e.size,c=!1):(e=be(e),a=e.length,c=be.readOnly),this._firstFragment?(this._firstFragment=!1,i&&o&&o.params[o._isServer?"\
|
|
164
|
+
server_no_context_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i):(i=!1,s=0),n.fin&&(this.
|
|
165
|
+
_firstFragment=!0);let d={[Q]:a,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:s,
|
|
166
|
+
readOnly:c,rsv1:i};Le(e)?this._state!==te?this.enqueue([this.getBlobData,e,this._compress,d,r]):this.getBlobData(e,this.
|
|
167
|
+
_compress,d,r):this._state!==te?this.enqueue([this.dispatch,e,this._compress,d,r]):this.dispatch(e,this._compress,d,r)}getBlobData(e,n,r,o){
|
|
168
|
+
this._bufferedBytes+=r[Q],this._state=Bc,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket\
|
|
169
|
+
was closed while the blob was being read");process.nextTick(qr,this,a,o);return}this._bufferedBytes-=r[Q];let i=be(s);n?
|
|
170
|
+
this.dispatch(i,n,r,o):(this._state=te,this.sendFrame(t.frame(i,r),o),this.dequeue())}).catch(s=>{process.nextTick(Hc,this,
|
|
171
|
+
s,o)})}dispatch(e,n,r,o){if(!n){this.sendFrame(t.frame(e,r),o);return}let s=this._extensions[Yo.extensionName];this._bufferedBytes+=
|
|
172
|
+
r[Q],this._state=$c,s.compress(e,r.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while d\
|
|
173
|
+
ata was being compressed");qr(this,c,o);return}this._bufferedBytes-=r[Q],this._state=te,r.readOnly=!1,this.sendFrame(t.frame(
|
|
174
|
+
a,r),o),this.dequeue()})}dequeue(){for(;this._state===te&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=
|
|
175
|
+
e[3][Q],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Q],this._queue.push(e)}sendFrame(e,n){
|
|
176
|
+
e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.
|
|
177
|
+
write(e[0],n)}};Qo.exports=Fr;function qr(t,e,n){typeof n=="function"&&n(e);for(let r=0;r<t._queue.length;r++){let o=t._queue[r],
|
|
178
|
+
s=o[o.length-1];typeof s=="function"&&s(e)}}function Hc(t,e,n){qr(t,e,n),t.onerror(e)}});var cs=X((tg,as)=>{"use strict";var{kForOnEventAttribute:at,kListener:Br}=ie(),es=Symbol("kCode"),ts=Symbol("kData"),rs=Symbol(
|
|
179
|
+
"kError"),ns=Symbol("kMessage"),os=Symbol("kReason"),Fe=Symbol("kTarget"),ss=Symbol("kType"),is=Symbol("kWasClean"),ce=class{constructor(e){
|
|
180
|
+
this[Fe]=null,this[ss]=e}get target(){return this[Fe]}get type(){return this[ss]}};Object.defineProperty(ce.prototype,"t\
|
|
181
|
+
arget",{enumerable:!0});Object.defineProperty(ce.prototype,"type",{enumerable:!0});var _e=class extends ce{constructor(e,n={}){
|
|
182
|
+
super(e),this[es]=n.code===void 0?0:n.code,this[os]=n.reason===void 0?"":n.reason,this[is]=n.wasClean===void 0?!1:n.wasClean}get code(){
|
|
183
|
+
return this[es]}get reason(){return this[os]}get wasClean(){return this[is]}};Object.defineProperty(_e.prototype,"code",
|
|
184
|
+
{enumerable:!0});Object.defineProperty(_e.prototype,"reason",{enumerable:!0});Object.defineProperty(_e.prototype,"wasCle\
|
|
185
|
+
an",{enumerable:!0});var qe=class extends ce{constructor(e,n={}){super(e),this[rs]=n.error===void 0?null:n.error,this[ns]=
|
|
186
|
+
n.message===void 0?"":n.message}get error(){return this[rs]}get message(){return this[ns]}};Object.defineProperty(qe.prototype,
|
|
187
|
+
"error",{enumerable:!0});Object.defineProperty(qe.prototype,"message",{enumerable:!0});var ct=class extends ce{constructor(e,n={}){
|
|
188
|
+
super(e),this[ts]=n.data===void 0?null:n.data}get data(){return this[ts]}};Object.defineProperty(ct.prototype,"data",{enumerable:!0});
|
|
189
|
+
var Vc={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[at]&&o[Br]===e&&!o[at])return;let r;if(t==="mess\
|
|
190
|
+
age")r=function(s,i){let a=new ct("message",{data:i?s:s.toString()});a[Fe]=this,qt(e,this,a)};else if(t==="close")r=function(s,i){
|
|
191
|
+
let a=new _e("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Fe]=this,qt(
|
|
192
|
+
e,this,a)};else if(t==="error")r=function(s){let i=new qe("error",{error:s,message:s.message});i[Fe]=this,qt(e,this,i)};else if(t===
|
|
193
|
+
"open")r=function(){let s=new ce("open");s[Fe]=this,qt(e,this,s)};else return;r[at]=!!n[at],r[Br]=e,n.once?this.once(t,r):
|
|
194
|
+
this.on(t,r)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[Br]===e&&!n[at]){this.removeListener(t,n);break}}};
|
|
195
|
+
as.exports={CloseEvent:_e,ErrorEvent:qe,Event:ce,EventTarget:Vc,MessageEvent:ct};function qt(t,e,n){typeof t=="object"&&
|
|
196
|
+
t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var $t=X((rg,ds)=>{"use strict";var{tokenChars:dt}=ze();function oe(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Gc(t){
|
|
197
|
+
let e=Object.create(null),n=Object.create(null),r=!1,o=!1,s=!1,i,a,c=-1,d=-1,u=-1,m=0;for(;m<t.length;m++)if(d=t.charCodeAt(
|
|
198
|
+
m),i===void 0)if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(m!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=m);else if(d===59||d===
|
|
199
|
+
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);u===-1&&(u=m);let v=t.slice(c,u);d===44?(oe(e,
|
|
200
|
+
v,n),n=Object.create(null)):i=v,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(a===void 0)
|
|
201
|
+
if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(d===32||d===9)u===-1&&c!==-1&&(u=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
|
|
202
|
+
`Unexpected character at index ${m}`);u===-1&&(u=m),oe(n,t.slice(c,u),!0),d===44&&(oe(e,i,n),n=Object.create(null),i=void 0),
|
|
203
|
+
c=u=-1}else if(d===61&&c!==-1&&u===-1)a=t.slice(c,m),c=u=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){
|
|
204
|
+
if(dt[d]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);c===-1?c=m:r||(r=!0),o=!1}else if(s)if(dt[d]===
|
|
205
|
+
1)c===-1&&(c=m);else if(d===34&&c!==-1)s=!1,u=m;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
|
|
206
|
+
index ${m}`);else if(d===34&&t.charCodeAt(m-1)===61)s=!0;else if(u===-1&&dt[d]===1)c===-1&&(c=m);else if(c!==-1&&(d===32||
|
|
207
|
+
d===9))u===-1&&(u=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);u===-1&&
|
|
208
|
+
(u=m);let v=t.slice(c,u);r&&(v=v.replace(/\\/g,""),r=!1),oe(n,a,v),d===44&&(oe(e,i,n),n=Object.create(null),i=void 0),a=
|
|
209
|
+
void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
|
|
210
|
+
"Unexpected end of input");u===-1&&(u=m);let p=t.slice(c,u);return i===void 0?oe(e,p,n):(a===void 0?oe(n,p,!0):r?oe(n,a,
|
|
211
|
+
p.replace(/\\/g,"")):oe(n,a,p),oe(e,i,n)),e}function Wc(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(", ")}
|
|
214
|
-
{Duplex:
|
|
215
|
-
EMPTY_BUFFER:
|
|
216
|
-
removeEventListener:
|
|
217
|
-
NG","OPEN","CLOSING","CLOSED"],
|
|
218
|
-
_binaryType=
|
|
213
|
+
=${i}`).join("; ")})).join("; ")).join(", ")}).join(", ")}ds.exports={format:Wc,parse:Gc}});var Gt=X((sg,Ss)=>{"use strict";var Kc=U("events"),Jc=U("https"),Xc=U("http"),ps=U("net"),Yc=U("tls"),{randomBytes:Zc,createHash:Qc}=U("crypto"),
|
|
214
|
+
{Duplex:ng,Readable:og}=U("stream"),{URL:Hr}=U("url"),ge=De(),ed=Ur(),td=$r(),{isBlob:rd}=ze(),{BINARY_TYPES:us,CLOSE_TIMEOUT:nd,
|
|
215
|
+
EMPTY_BUFFER:Bt,GUID:od,kForOnEventAttribute:Vr,kListener:sd,kStatusCode:id,kWebSocket:B,NOOP:fs}=ie(),{EventTarget:{addEventListener:ad,
|
|
216
|
+
removeEventListener:cd}}=cs(),{format:dd,parse:ud}=$t(),{toBuffer:ld}=st(),ms=Symbol("kAborted"),Gr=[8,13],de=["CONNECTI\
|
|
217
|
+
NG","OPEN","CLOSING","CLOSED"],pd=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,j=class t extends Kc{constructor(e,n,r){super(),this.
|
|
218
|
+
_binaryType=us[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bt,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?
|
|
221
|
-
n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n])
|
|
222
|
-
r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){
|
|
221
|
+
n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(r=n,n=[]):n=[n]),hs(this,e,n,r)):(this._autoPong=r.autoPong,this._closeTimeout=
|
|
222
|
+
r.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){us.includes(e)&&(this._binaryType=
|
|
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 ed(
|
|
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",
|
|
231
|
-
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",
|
|
232
|
-
"end",
|
|
233
|
-
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[
|
|
229
|
+
s=new td(e,this._extensions,r.generateMask);this._receiver=o,this._sender=s,this._socket=e,o[B]=this,s[B]=this,e[B]=this,
|
|
230
|
+
o.on("conclude",hd),o.on("drain",gd),o.on("error",vd),o.on("message",wd),o.on("ping",yd),o.on("pong",Id),s.onerror=Sd,e.
|
|
231
|
+
setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",ws),e.on("data",Vt),e.on(
|
|
232
|
+
"end",ys),e.on("error",Is),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
|
|
233
|
+
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ge.extensionName]&&this._extensions[ge.extensionName].
|
|
234
234
|
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){
|
|
235
|
-
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
235
|
+
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Y(this,this._req,"WebSocket was closed before the conn\
|
|
236
236
|
ection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver.
|
|
237
237
|
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,n,!this._isServer,
|
|
238
238
|
r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
|
|
239
|
-
|
|
239
|
+
vs(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,r){
|
|
240
240
|
if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="func\
|
|
241
241
|
tion"?(r=e,e=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
242
|
-
|
|
242
|
+
Wr(this,e,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Bt,n,r)}pong(e,n,r){if(this.readyState===t.CONNECTING)
|
|
243
243
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(r=e,e=n=void 0):typeof n=="\
|
|
244
|
-
function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
245
|
-
(n=!this._isServer),this._sender.pong(e||
|
|
244
|
+
function"&&(r=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Wr(this,e,r);return}n===void 0&&
|
|
245
|
+
(n=!this._isServer),this._sender.pong(e||Bt,n,r)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this.
|
|
246
246
|
_paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,r){if(this.readyState===t.CONNECTING)
|
|
247
247
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof e=="numbe\
|
|
248
|
-
r"&&(e=e.toString()),this.readyState!==t.OPEN){
|
|
249
|
-
compress:!0,fin:!0,...n};this._extensions[
|
|
250
|
-
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
251
|
-
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(
|
|
252
|
-
NNECTING",{enumerable:!0,value:
|
|
253
|
-
value:
|
|
254
|
-
|
|
255
|
-
"CLOSING")});Object.defineProperty(
|
|
256
|
-
|
|
248
|
+
r"&&(e=e.toString()),this.readyState!==t.OPEN){Wr(this,e,r);return}let o={binary:typeof e!="string",mask:!this._isServer,
|
|
249
|
+
compress:!0,fin:!0,...n};this._extensions[ge.extensionName]||(o.compress=!1),this._sender.send(e||Bt,o,r)}terminate(){if(this.
|
|
250
|
+
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Y(this,this._req,"WebSocket was closed before the connection w\
|
|
251
|
+
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(j,"CO\
|
|
252
|
+
NNECTING",{enumerable:!0,value:de.indexOf("CONNECTING")});Object.defineProperty(j.prototype,"CONNECTING",{enumerable:!0,
|
|
253
|
+
value:de.indexOf("CONNECTING")});Object.defineProperty(j,"OPEN",{enumerable:!0,value:de.indexOf("OPEN")});Object.defineProperty(
|
|
254
|
+
j.prototype,"OPEN",{enumerable:!0,value:de.indexOf("OPEN")});Object.defineProperty(j,"CLOSING",{enumerable:!0,value:de.indexOf(
|
|
255
|
+
"CLOSING")});Object.defineProperty(j.prototype,"CLOSING",{enumerable:!0,value:de.indexOf("CLOSING")});Object.defineProperty(
|
|
256
|
+
j,"CLOSED",{enumerable:!0,value:de.indexOf("CLOSED")});Object.defineProperty(j.prototype,"CLOSED",{enumerable:!0,value:de.
|
|
257
257
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
258
|
-
defineProperty(
|
|
259
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[
|
|
260
|
-
listeners(t))if(n[
|
|
261
|
-
prototype.addEventListener=
|
|
262
|
-
autoPong:!0,closeTimeout:
|
|
258
|
+
defineProperty(j.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(j.prototype,
|
|
259
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Vr])return e[sd];return null},set(e){for(let n of this.
|
|
260
|
+
listeners(t))if(n[Vr]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[Vr]:!0})}})});j.
|
|
261
|
+
prototype.addEventListener=ad;j.prototype.removeEventListener=cd;Ss.exports=j;function hs(t,e,n,r){let o={allowSynchronousEvents:!0,
|
|
262
|
+
autoPong:!0,closeTimeout:nd,protocolVersion:Gr[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
|
-
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!
|
|
265
|
-
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${
|
|
266
|
-
", ")})`);let s;if(e instanceof
|
|
264
|
+
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Gr.includes(
|
|
265
|
+
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Gr.join(
|
|
266
|
+
", ")})`);let s;if(e instanceof Hr)s=e;else try{s=new Hr(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
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;
|
|
271
|
-
v;if(o.createConnection=o.createConnection||(i?
|
|
270
|
+
c);if(t._redirects===0)throw T;Ht(t,T);return}let d=i?443:80,u=Zc(16).toString("base64"),m=i?Jc.request:Xc.request,p=new Set,
|
|
271
|
+
v;if(o.createConnection=o.createConnection||(i?md:fd),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
|
-
-WebSocket-Key":
|
|
274
|
-
(v=new
|
|
275
|
-
offer()})),n.length){for(let T of n){if(typeof T!="string"||!
|
|
276
|
-
uplicated subprotocol was specified");
|
|
273
|
+
-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
|
|
274
|
+
(v=new ge({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=dd({[ge.extensionName]:v.
|
|
275
|
+
offer()})),n.length){for(let T of n){if(typeof T!="string"||!pd.test(T)||p.has(T))throw new SyntaxError("An invalid or d\
|
|
276
|
+
uplicated subprotocol was specified");p.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 T=o.path.split(":");o.socketPath=T[0],o.path=T[1]}let
|
|
278
|
+
:${s.password}`),a){let T=o.path.split(":");o.socketPath=T[0],o.path=T[1]}let y;if(o.followRedirects){if(t._redirects===
|
|
279
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,
|
|
280
|
+
headers:{}},T)for(let[O,N]of Object.entries(T))r.headers[O.toLowerCase()]=N}else if(t.listenerCount("redirect")===0){let T=a?
|
|
281
281
|
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!T||
|
|
282
282
|
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,T||delete o.headers.host,o.auth=void 0)}
|
|
283
|
-
o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),
|
|
284
|
-
t._redirects&&t.emit("redirect",t.url,
|
|
285
|
-
timed out")}),
|
|
286
|
-
statusCode;if(O&&o.followRedirects&&
|
|
287
|
-
return}
|
|
288
|
-
t.emit("unexpected-response",
|
|
289
|
-
emit("upgrade",T),t.readyState!==
|
|
290
|
-
"websocket"){
|
|
291
|
-
socket-accept"]!==
|
|
292
|
-
void 0?
|
|
293
|
-
size&&(
|
|
294
|
-
if(
|
|
295
|
-
try{
|
|
296
|
-
|
|
297
|
-
|
|
283
|
+
o.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),y=t._req=m(o),
|
|
284
|
+
t._redirects&&t.emit("redirect",t.url,y)}else y=t._req=m(o);o.timeout&&y.on("timeout",()=>{Y(t,y,"Opening handshake has \
|
|
285
|
+
timed out")}),y.on("error",T=>{y===null||y[ms]||(y=t._req=null,Ht(t,T))}),y.on("response",T=>{let O=T.headers.location,N=T.
|
|
286
|
+
statusCode;if(O&&o.followRedirects&&N>=300&&N<400){if(++t._redirects>o.maxRedirects){Y(t,y,"Maximum redirects exceeded");
|
|
287
|
+
return}y.abort();let z;try{z=new Hr(O,e)}catch{let q=new SyntaxError(`Invalid URL: ${O}`);Ht(t,q);return}hs(t,z,n,r)}else
|
|
288
|
+
t.emit("unexpected-response",y,T)||Y(t,y,`Unexpected server response: ${T.statusCode}`)}),y.on("upgrade",(T,O,N)=>{if(t.
|
|
289
|
+
emit("upgrade",T),t.readyState!==j.CONNECTING)return;y=t._req=null;let z=T.headers.upgrade;if(z===void 0||z.toLowerCase()!==
|
|
290
|
+
"websocket"){Y(t,O,"Invalid Upgrade header");return}let L=Qc("sha1").update(u+od).digest("base64");if(T.headers["sec-web\
|
|
291
|
+
socket-accept"]!==L){Y(t,O,"Invalid Sec-WebSocket-Accept header");return}let q=T.headers["sec-websocket-protocol"],H;if(q!==
|
|
292
|
+
void 0?p.size?p.has(q)||(H="Server sent an invalid subprotocol"):H="Server sent a subprotocol but none was requested":p.
|
|
293
|
+
size&&(H="Server sent no subprotocol"),H){Y(t,O,H);return}q&&(t._protocol=q);let R=T.headers["sec-websocket-extensions"];
|
|
294
|
+
if(R!==void 0){if(!v){Y(t,O,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let P;
|
|
295
|
+
try{P=ud(R)}catch{Y(t,O,"Invalid Sec-WebSocket-Extensions header");return}let A=Object.keys(P);if(A.length!==1||A[0]!==ge.
|
|
296
|
+
extensionName){Y(t,O,"Server indicated an extension that was not requested");return}try{v.accept(P[ge.extensionName])}catch{
|
|
297
|
+
Y(t,O,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ge.extensionName]=v}t.setSocket(O,N,{allowSynchronousEvents:o.
|
|
298
298
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
299
|
-
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(
|
|
300
|
-
|
|
301
|
-
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=
|
|
302
|
-
t._readyState=
|
|
303
|
-
destroyed&&e.socket.destroy(),process.nextTick(
|
|
304
|
-
se",t.emitClose.bind(t)))}function
|
|
305
|
-
t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${
|
|
306
|
-
nextTick(n,r)}}function
|
|
307
|
-
(n._socket.removeListener("data",
|
|
308
|
-
t.isPaused||t._socket.resume()}function
|
|
309
|
-
process.nextTick(
|
|
310
|
-
emitClose()}function
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
e.emit("error",t)))}function
|
|
314
|
-
let t=this[
|
|
315
|
-
|
|
316
|
-
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[
|
|
299
|
+
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(y,t):y.end()}function Ht(t,e){t._readyState=
|
|
300
|
+
j.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function fd(t){return t.path=t.socketPath,ps.connect(t)}function md(t){
|
|
301
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ps.isIP(t.host)?"":t.host),Yc.connect(t)}function Y(t,e,n){
|
|
302
|
+
t._readyState=j.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Y),e.setHeader?(e[ms]=!0,e.abort(),e.socket&&!e.socket.
|
|
303
|
+
destroyed&&e.socket.destroy(),process.nextTick(Ht,t,r)):(e.destroy(r),e.once("error",t.emit.bind(t,"error")),e.once("clo\
|
|
304
|
+
se",t.emitClose.bind(t)))}function Wr(t,e,n){if(e){let r=rd(e)?e.size:ld(e).length;t._socket?t._sender._bufferedBytes+=r:
|
|
305
|
+
t._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${t.readyState} (${de[t.readyState]})`);process.
|
|
306
|
+
nextTick(n,r)}}function hd(t,e){let n=this[B];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[B]!==void 0&&
|
|
307
|
+
(n._socket.removeListener("data",Vt),process.nextTick(gs,n._socket),t===1005?n.close():n.close(t,e))}function gd(){let t=this[B];
|
|
308
|
+
t.isPaused||t._socket.resume()}function vd(t){let e=this[B];e._socket[B]!==void 0&&(e._socket.removeListener("data",Vt),
|
|
309
|
+
process.nextTick(gs,e._socket),e.close(t[id])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function ls(){this[B].
|
|
310
|
+
emitClose()}function wd(t,e){this[B].emit("message",t,e)}function yd(t){let e=this[B];e._autoPong&&e.pong(t,!this._isServer,
|
|
311
|
+
fs),e.emit("ping",t)}function Id(t){this[B].emit("pong",t)}function gs(t){t.resume()}function Sd(t){let e=this[B];e.readyState!==
|
|
312
|
+
j.CLOSED&&(e.readyState===j.OPEN&&(e._readyState=j.CLOSING,vs(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
|
|
313
|
+
e.emit("error",t)))}function vs(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function ws(){
|
|
314
|
+
let t=this[B];if(this.removeListener("close",ws),this.removeListener("data",Vt),this.removeListener("end",ys),t._readyState=
|
|
315
|
+
j.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.
|
|
316
|
+
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[B]=void 0,clearTimeout(
|
|
317
317
|
t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
|
|
318
|
-
"error",
|
|
319
|
-
t._readyState=
|
|
320
|
-
"error",
|
|
321
|
-
this._writableState.finished&&this.destroy()}function
|
|
322
|
-
"error")===0&&this.emit("error",t)}function
|
|
318
|
+
"error",ls),t._receiver.on("finish",ls))}function Vt(t){this[B]._receiver.write(t)||this.pause()}function ys(){let t=this[B];
|
|
319
|
+
t._readyState=j.CLOSING,t._receiver.end(),this.end()}function Is(){let t=this[B];this.removeListener("error",Is),this.on(
|
|
320
|
+
"error",fs),t&&(t._readyState=j.CLOSING,this.destroy())}});var _s=X((ag,Ts)=>{"use strict";var ig=Gt(),{Duplex:xd}=U("stream");function xs(t){t.emit("close")}function bd(){!this.destroyed&&
|
|
321
|
+
this._writableState.finished&&this.destroy()}function bs(t){this.removeListener("error",bs),this.destroy(),this.listenerCount(
|
|
322
|
+
"error")===0&&this.emit("error",t)}function Td(t,e){let n=!0,r=new xd({...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
|
-
if(t.readyState===t.CLOSED){s(o),process.nextTick(
|
|
326
|
-
lose",function(){i||s(o),process.nextTick(
|
|
325
|
+
if(t.readyState===t.CLOSED){s(o),process.nextTick(xs,r);return}let i=!1;t.once("error",function(c){i=!0,s(c)}),t.once("c\
|
|
326
|
+
lose",function(){i||s(o),process.nextTick(xs,r)}),n&&t.terminate()},r._final=function(o){if(t.readyState===t.CONNECTING){
|
|
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",
|
|
331
|
-
let i=t.charCodeAt(o);if(r===-1&&
|
|
330
|
+
r.on("end",bd),r.on("error",bs),r}Ts.exports=Td});var Kr=X((cg,Cs)=>{"use strict";var{tokenChars:_d}=ze();function Cd(t){let e=new Set,n=-1,r=-1,o=0;for(o;o<t.length;o++){
|
|
331
|
+
let i=t.charCodeAt(o);if(r===-1&&_d[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}
|
|
336
|
-
|
|
335
|
+
`The "${s}" subprotocol is duplicated`);return e.add(s),e}Cs.exports={parse:Cd}});var Ns=X((ug,ks)=>{"use strict";var Ad=U("events"),Wt=U("http"),{Duplex:dg}=U("stream"),{createHash:Ed}=U("crypto"),As=$t(),
|
|
336
|
+
Ce=De(),Od=Kr(),Rd=Gt(),{CLOSE_TIMEOUT:Pd,GUID:kd,kWebSocket:Nd}=ie(),Md=/^[+/0-9A-Za-z]{22}==$/,Es=0,Os=1,Ps=2,Jr=class extends Ad{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:Pd,verifyClient:null,
|
|
339
|
+
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Rd,...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
|
-
, or "noServer" options must be specified');if(e.port!=null?(this._server=
|
|
341
|
+
, or "noServer" options must be specified');if(e.port!=null?(this._server=Wt.createServer((r,o)=>{let s=Wt.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
|
+
jd(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
|
-
!1),this.options=e,this._state=
|
|
347
|
-
er" mode');return this._server?this._server.address():null}close(e){if(this._state===
|
|
348
|
-
"The server is not running"))}),process.nextTick(
|
|
349
|
-
|
|
350
|
-
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(
|
|
351
|
-
_server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{
|
|
346
|
+
!1),this.options=e,this._state=Es}address(){if(this.options.noServer)throw new Error('The server is operating in "noServ\
|
|
347
|
+
er" mode');return this._server?this._server.address():null}close(e){if(this._state===Ps){e&&this.once("close",()=>{e(new Error(
|
|
348
|
+
"The server is not running"))}),process.nextTick(ut,this);return}if(e&&this.once("close",e),this._state!==Os)if(this._state=
|
|
349
|
+
Os,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=
|
|
350
|
+
null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(ut,this):process.nextTick(ut,this);else{let n=this.
|
|
351
|
+
_server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{ut(this)})}}shouldHandle(e){if(this.
|
|
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
|
-
n.on("error",
|
|
354
|
-
"GET"){
|
|
355
|
-
lid Upgrade header");return}if(s===void 0||!
|
|
356
|
-
if(a!==13&&a!==8){
|
|
357
|
-
if(!this.shouldHandle(e)){
|
|
358
|
-
c)}catch{
|
|
359
|
-
if(this.options.perMessageDeflate&&
|
|
360
|
-
options.maxPayload});try{let v=
|
|
361
|
-
|
|
353
|
+
n.on("error",Rs);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.headers["sec-websocket-version"];if(e.method!==
|
|
354
|
+
"GET"){Ae(this,e,n,405,"Invalid HTTP method");return}if(i===void 0||i.toLowerCase()!=="websocket"){Ae(this,e,n,400,"Inva\
|
|
355
|
+
lid Upgrade header");return}if(s===void 0||!Md.test(s)){Ae(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}
|
|
356
|
+
if(a!==13&&a!==8){Ae(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
|
|
357
|
+
if(!this.shouldHandle(e)){lt(n,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=Od.parse(
|
|
358
|
+
c)}catch{Ae(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=e.headers["sec-websocket-extensions"],m={};
|
|
359
|
+
if(this.options.perMessageDeflate&&u!==void 0){let p=new Ce({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
|
|
360
|
+
options.maxPayload});try{let v=As.parse(u);v[Ce.extensionName]&&(p.accept(v[Ce.extensionName]),m[Ce.extensionName]=p)}catch{
|
|
361
|
+
Ae(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={
|
|
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(
|
|
364
|
-
m,s,d,e,n,r,o)});return}if(!this.options.verifyClient(
|
|
365
|
-
if(!s.readable||!s.writable)return s.destroy();if(s[
|
|
366
|
-
e with the same socket, possibly due to a misconfiguration");if(this._state>
|
|
367
|
-
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${
|
|
368
|
-
se64")}`],
|
|
369
|
-
handleProtocols(r,o):r.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),
|
|
370
|
-
let m=e[
|
|
363
|
+
options.verifyClient.length===2){this.options.verifyClient(p,(v,y,T,O)=>{if(!v)return lt(n,y||401,T,O);this.completeUpgrade(
|
|
364
|
+
m,s,d,e,n,r,o)});return}if(!this.options.verifyClient(p))return lt(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[Nd])throw new Error("server.handleUpgrade() was called more than onc\
|
|
366
|
+
e with the same socket, possibly due to a misconfiguration");if(this._state>Es)return lt(s,503);let d=["HTTP/1.1 101 Swi\
|
|
367
|
+
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ed("sha1").update(n+kd).digest("ba\
|
|
368
|
+
se64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let m=this.options.handleProtocols?this.options.
|
|
369
|
+
handleProtocols(r,o):r.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),u._protocol=m)}if(e[Ce.extensionName]){
|
|
370
|
+
let m=e[Ce.extensionName].params,p=As.format({[Ce.extensionName]:[m]});d.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=
|
|
371
371
|
e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
372
372
|
`).join(`\r
|
|
373
|
-
`)),s.removeListener("error",
|
|
373
|
+
`)),s.removeListener("error",Rs),u.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
374
374
|
options.maxBufferedChunks,maxFragments:this.options.maxFragments,maxPayload:this.options.maxPayload,skipUTF8Validation:this.
|
|
375
|
-
options.skipUTF8Validation}),this.clients&&(this.clients.add(
|
|
376
|
-
!this.clients.size&&process.nextTick(
|
|
377
|
-
n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function
|
|
378
|
-
function
|
|
379
|
-
l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${
|
|
375
|
+
options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&
|
|
376
|
+
!this.clients.size&&process.nextTick(ut,this)})),a(u,o)}};ks.exports=Jr;function jd(t,e){for(let n of Object.keys(e))t.on(
|
|
377
|
+
n,e[n]);return function(){for(let r of Object.keys(e))t.removeListener(r,e[r])}}function ut(t){t._state=Ps,t.emit("close")}
|
|
378
|
+
function Rs(){this.destroy()}function lt(t,e,n,r){n=n||Wt.STATUS_CODES[e],r={Connection:"close","Content-Type":"text/htm\
|
|
379
|
+
l","Content-Length":Buffer.byteLength(n),...r},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Wt.STATUS_CODES[e]}\r
|
|
380
380
|
`+Object.keys(r).map(o=>`${o}: ${r[o]}`).join(`\r
|
|
381
381
|
`)+`\r
|
|
382
382
|
\r
|
|
383
|
-
`+n)}function
|
|
384
|
-
"wsClientError",i,n,e)}else
|
|
385
|
-
e===null}var
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
383
|
+
`+n)}function Ae(t,e,n,r,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,Ae),t.emit(
|
|
384
|
+
"wsClientError",i,n,e)}else lt(n,r,o,s)}});function b(t){return String(t??"").trim()}function At(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||
|
|
385
|
+
e===null}var ym=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function w(t,{fallback:e=""}={}){return String(t||"").trim()||e}function ne(t,{fallback:e=""}={}){return w(t,{fallback:e}).toLowerCase()}function K(t,{fallback:e={}}={}){return x(t)?t:{...e}}function x(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}function Et(t,{fallback:e=null}={}){return t==null?e:typeof t=="string"?t.trim()||e:typeof t=="number"?Number.isFinite(t)?
|
|
386
|
+
String(t):e:typeof t=="bigint"?String(t):e}var Sm=Object.freeze({interrupted:Object.freeze({text:"Stopped.",messageCode:"assistant.turn.stopped"}),failed:Object.freeze(
|
|
387
|
+
{text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});function Ot(t){return x(t)?{...t}:{}}var F=class extends Error{constructor(e,n,r={}){super(n,r.cause===void 0?void 0:{cause:r.cause}),this.name="AppError",this.
|
|
388
|
+
status=Number(e)||500,this.statusCode=this.status,this.code=r.code||"APP_ERROR",this.params=Ot(r.params),r.messageCode&&
|
|
389
|
+
(this.messageCode=String(r.messageCode),this.messageParams=Ot(r.messageParams)),this.details=r.details,this.headers=r.headers||
|
|
390
|
+
{}}};var Xm=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
391
|
+
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var G=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
392
|
+
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),nh=new Set(Object.values(G)),oh=new Set([G.CANCELLED,
|
|
393
|
+
G.COMPLETED,G.FAILED,G.INTERRUPTED,G.TIMED_OUT]),sh=new Set([G.ACTIVE,G.FINALIZING,G.STARTING]);import{execFile as nc}from"node:child_process";import{readFile as Cr,readdir as oc}from"node:fs/promises";import{setTimeout as Ao}from"node:timers/promises";import{promisify as sc}from"node:util";var ic=sc(nc),Eo=32;async function ac(t){
|
|
394
|
+
let{stdout:e}=await ic("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function kt({runtimeTokenEnvironmentName:t="\
|
|
394
395
|
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=
|
|
396
|
-
{linux:"linux-proc",darwin:"darwin"}),
|
|
397
|
-
{ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(
|
|
398
|
-
isSafeInteger(Number(
|
|
399
|
-
let
|
|
400
|
-
let
|
|
401
|
-
kill(-
|
|
402
|
-
|
|
403
|
-
""),f
|
|
404
|
-
|
|
405
|
-
test(
|
|
406
|
-
|
|
407
|
-
version||0)}}function
|
|
408
|
-
test(
|
|
409
|
-
test(
|
|
410
|
-
let
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
let H=["Jan","Feb","Mar","
|
|
415
|
-
|
|
416
|
-
h
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
let
|
|
420
|
-
,
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
processGroupIds:[]
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
{processGroupIds:
|
|
435
|
-
async function
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
Date.now()
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
E.
|
|
443
|
-
|
|
444
|
-
return{
|
|
445
|
-
|
|
446
|
-
identityStatus:
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
status
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
396
|
+
native_process_identity_unavailable",platform:o=process.platform,ps:s=ac}={}){let a=o==="darwin"?100:25,c=1,d=Object.freeze(
|
|
397
|
+
{linux:"linux-proc",darwin:"darwin"}),u=d[o]||"",m=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),p=Object.freeze(
|
|
398
|
+
{ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});function v(l={}){return!!(Number.
|
|
399
|
+
isSafeInteger(Number(l.pid))&&Number(l.pid)>0&&L(l.processIdentity)&&[m.RUNNING,m.STOPPED].includes(l.processState))}function y(l){
|
|
400
|
+
let f=Number(l);if(!Number.isSafeInteger(f)||f<=0)return!1;try{return process.kill(f,0),!0}catch{return!1}}function T(l){
|
|
401
|
+
let f=Number(l);if(!Number.isSafeInteger(f)||f<=0)return!1;if(process.platform==="win32")return y(f);try{return process.
|
|
402
|
+
kill(-f,0),!0}catch{return!1}}function O(l,f){let h=Number(l),g=process.platform==="win32"?h:-h;try{return process.kill(
|
|
403
|
+
g,f),!0}catch(I){if(!["ESRCH","EPERM"].includes(String(I?.code||"")))throw I;return!1}}function N(l=""){let f=String(l||
|
|
404
|
+
""),h=f.lastIndexOf(")");if(h<0)return null;let g=f.slice(h+1).trim().split(/\s+/u),I=String(g[0]||""),S=Number(g[1]),C=Number(
|
|
405
|
+
g[2]),k=String(g[19]||"");return!/^[A-Z]$/u.test(I)||!Number.isSafeInteger(S)||S<0||!Number.isSafeInteger(C)||C<=0||!/^\d+$/u.
|
|
406
|
+
test(k)?null:{parentPid:S,processGroupId:C,startTimeTicks:k,state:I}}function z(l={}){let f=x(l)?l:{};return{commandHash:b(
|
|
407
|
+
f.commandHash),platform:b(f.platform),runtimeToken:b(f.runtimeToken),startTimeTicks:b(f.startTimeTicks),version:Number(f.
|
|
408
|
+
version||0)}}function L(l={}){let f=z(l);return!!(f.version===c&&Object.values(d).includes(f.platform)&&/^[a-f0-9]{12}$/u.
|
|
409
|
+
test(f.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(f.runtimeToken)&&/^\d+$/u.
|
|
410
|
+
test(f.startTimeTicks))}function q(l=[],f=""){let h=l.find(g=>g.startsWith(`${f}=`));return h?h.slice(f.length+1):""}async function H(l){
|
|
411
|
+
let f=await Cr(`/proc/${l}/stat`,"utf8").catch(()=>""),h=N(f);if(!h||h.state==="Z")return null;let g=null,I=!0;try{g=await Cr(
|
|
412
|
+
`/proc/${l}/environ`)}catch(C){if(String(C?.code||"")==="ENOENT")return null;I=!1}let S=I?g.toString("utf8").split("\0"):
|
|
413
|
+
[];return{...h,commandHash:q(S,e),environmentReadable:I,pid:Number(l),runtimeToken:q(S,t)}}async function R(){let l=(await oc(
|
|
414
|
+
"/proc",{withFileTypes:!0}).catch(()=>[])).filter(h=>h.isDirectory()&&/^\d+$/u.test(h.name)).map(h=>h.name),f=[];for(let h=0;h<
|
|
415
|
+
l.length;h+=Eo)for(let g of await Promise.all(l.slice(h,h+Eo).map(H)))g&&f.push(g);return f}let P=["Jan","Feb","Mar","Ap\
|
|
416
|
+
r","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(l=""){let f=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.
|
|
417
|
+
exec(String(l).trim()),h=f?P.indexOf(f[1]):-1;if(h<0)return"";let[,,g,I,S,C,k]=f.map(Number);return String(Date.UTC(k,h,
|
|
418
|
+
g,I,S,C)/1e3)}function M(l=""){let f=new Map;for(let h of String(l).split(`
|
|
419
|
+
`)){let g=/^\s*(\d+) (.*)$/u.exec(h);g&&f.set(Number(g[1]),g[2])}return f}function W(l,f){if(l===void 0||!f?.startsWith(
|
|
420
|
+
l))return null;let h=f.slice(l.length).split(/\s+/u).filter(g=>/^[^=\s]+=/u.test(g));return h.length?h:null}async function Ie(){
|
|
421
|
+
let l=process.getuid(),f=["-x","-U",String(l),"-ww","-o","pid=,command="],[h,g,I]=await Promise.all([s(["-ax","-o","pid=\
|
|
422
|
+
,pgid=,uid=,stat=,lstart="]),s(f),s(["-E",...f])]),S=M(g),C=M(I),k=[];for(let D of String(h).split(`
|
|
423
|
+
`)){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(D);if(!E||E[4].startsWith(
|
|
424
|
+
"Z"))continue;let se=Number(E[1]),pe=Number(E[3])===l?W(S.get(se),C.get(se)):null;k.push({commandHash:q(pe||[],e),environmentReadable:!!pe,
|
|
425
|
+
pid:se,processGroupId:Number(E[2]),runtimeToken:q(pe||[],t),startTimeTicks:A(E[5])})}return k}function tt(l){let f=Object.
|
|
426
|
+
values(p).includes(l?.status)?l.status:p.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(l?.processGroupIds)?
|
|
427
|
+
l.processGroupIds:[]).map(Number).filter(h=>Number.isSafeInteger(h)&&h>0))],status:f}}async function yr(l={}){if(!v(l))return{
|
|
428
|
+
processGroupIds:[],status:p.INVALID};if(l.processState===m.STOPPED)return{processGroupIds:[],status:p.ABSENT};let f=l.processIdentity,
|
|
429
|
+
h=f.platform!==u?null:o==="darwin"?await Ie().catch(()=>null):await R();if(!h)return{processGroupIds:[],status:p.AMBIGUOUS};
|
|
430
|
+
let g=Number(l.pid),I=h.filter(({processGroupId:E})=>E===g),S=[],C=I.some(({environmentReadable:E})=>!E);for(let E of h)
|
|
431
|
+
E.environmentReadable&&E.runtimeToken===f.runtimeToken&&E.commandHash===f.commandHash&&S.push(E);let k=S.find(({pid:E})=>E===
|
|
432
|
+
g);if(k&&k.startTimeTicks!==f.startTimeTicks)return{processGroupIds:[],status:p.AMBIGUOUS};if(S.length===0)return C?{processGroupIds:[],
|
|
433
|
+
status:p.AMBIGUOUS}:{processGroupIds:[],status:I.length>0||T(g)?p.MISMATCH:p.ABSENT};let D=[...new Set(S.map(({processGroupId:E})=>E))];
|
|
434
|
+
for(let E of D)if(h.filter(pe=>pe.processGroupId===E).some(pe=>!pe.environmentReadable||!S.some(({pid:Ja})=>Ja===pe.pid)))
|
|
435
|
+
return{processGroupIds:[],status:p.AMBIGUOUS};return I.some(E=>!S.some(({pid:se})=>se===E.pid))?{processGroupIds:[],status:p.
|
|
436
|
+
AMBIGUOUS}:{processGroupIds:D,status:p.EXACT}}async function Se(l={},f={}){let h=f.processIdentityInspector??yr;return tt(
|
|
437
|
+
await h(l))}async function _t(l={},f={},h=0){let g=Date.now()+h,I=await Se(l,f);for(;Date.now()<g&&I.status===p.EXACT;)await Ao(
|
|
438
|
+
100),I=await Se(l,f);return I}async function ke(l={},f={}){let h=V(f.processIdentitySettleTimeoutMs,{fallback:1e3}),g=V(
|
|
439
|
+
f.processIdentitySettlePollMs,{fallback:a}),I=Date.now()+h,S=await Se(l,f);for(;S.status===p.AMBIGUOUS&&Date.now()<I;)await Ao(
|
|
440
|
+
Math.min(g,Math.max(1,I-Date.now()))),S=await Se(l,f);return S}async function Ct(l={},f="SIGTERM",h={}){let g=h.signalProcessGroup??
|
|
441
|
+
O,I=await ke(l,h);if(I.status!==p.EXACT)return{inspection:I,signaledProcessGroups:[]};let S=Number(l.pid),C=[...I.processGroupIds.
|
|
442
|
+
filter(D=>D!==S),...I.processGroupIds.filter(D=>D===S)],k=[];for(let D of C){let E=await ke(l,h);if(E.status===p.ABSENT||
|
|
443
|
+
E.status===p.MISMATCH)return{inspection:E,signaledProcessGroups:k};if(E.status!==p.EXACT)return{inspection:E,signaledProcessGroups:k};
|
|
444
|
+
E.processGroupIds.includes(D)&&(g(D,f),k.push(D))}return{inspection:await ke(l,h),signaledProcessGroups:k}}async function Ir(l={},f={}){
|
|
445
|
+
if(!v(l))return{identityStatus:p.INVALID,processExitVerified:!1,stopped:!1};if(l.processState===m.STOPPED&&l.processExitVerifiedAt)
|
|
446
|
+
return{alreadyStopped:!0,identityStatus:p.ABSENT,processExitVerified:!0,stopped:!1};let h=await ke(l,f);if(h.status===p.
|
|
447
|
+
ABSENT||h.status===p.MISMATCH)return{identityStatus:h.status,processExitVerified:!0,stopped:!1};if(h.status!==p.EXACT)return{
|
|
448
|
+
identityStatus:h.status,processExitVerified:!1,stopped:!1};let g=await Ct(l,"SIGTERM",f);if(g.inspection.status===p.AMBIGUOUS)
|
|
449
|
+
return{identityStatus:g.inspection.status,processExitVerified:!1,signaledProcessGroups:g.signaledProcessGroups,stopped:!1};
|
|
450
|
+
let I=await _t(l,f,V(f.termTimeoutMs,{fallback:3e3})),S=[...g.signaledProcessGroups];if(I.status===p.EXACT){let k=await Ct(
|
|
451
|
+
l,"SIGKILL",f);if(S=[...new Set([...S,...k.signaledProcessGroups])],k.inspection.status===p.AMBIGUOUS)return{identityStatus:k.
|
|
452
|
+
inspection.status,processExitVerified:!1,signaledProcessGroups:S,stopped:!1};I=await _t(l,f,V(f.killTimeoutMs,{fallback:1e3}))}
|
|
453
|
+
let C=[p.ABSENT,p.MISMATCH].includes(I.status);return{descendantProcessGroups:S.filter(k=>k!==Number(l.pid)),identityStatus:I.
|
|
454
|
+
status,pid:Number(l.pid),processExitVerified:C,signaledProcessGroups:S,stopped:C&&S.length>0}}async function Sr(l){if(o!==
|
|
455
|
+
"darwin")return N(await Cr(`/proc/${l}/stat`,"utf8").catch(()=>""));let f=String(await s(["-o","pgid=,lstart=","-p",String(
|
|
456
|
+
l)]).catch(()=>"")),h=/^\s*(\d+)\s+(.+?)\s*$/u.exec(f);return h?{processGroupId:Number(h[1]),startTimeTicks:A(h[2])}:null}
|
|
457
|
+
async function xr({commandHash:l="",pid:f=null,reportedIdentity:h=null,runtimeToken:g=""}={}){let I=b(l),S=b(g),C=z(h);if(L(
|
|
458
|
+
C)&&C.commandHash===I&&C.runtimeToken===S)return C;let k=Number(f),D=u&&Number.isSafeInteger(k)&&k>0?await Sr(k):null;if(!D?.
|
|
459
|
+
startTimeTicks||D.processGroupId!==k){let E=new Error(`${n} process identity could not be captured.`);throw E.code=r,E}return{
|
|
460
|
+
commandHash:I,platform:u,runtimeToken:S,startTimeTicks:D.startTimeTicks,version:c}}return Object.freeze({normalize:z,isValid:L,
|
|
461
|
+
normalizeInspection:tt,capture:xr,inspect:Se,stop:Ir,isProcessAlive:y})}import{execFile as dc}from"node:child_process";import{promisify as uc}from"node:util";var Sh=Object.freeze(["plugins","apps","daemon_auto_start"]);var xh=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 Eh=uc(dc);function xe(t=""){return Array.from(String(t)).some(e=>{let n=e.codePointAt(0);return n<=31||n===127})}var Nt=(t,e,n,r={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(n),...r}),lc=Object.freeze([Object.freeze(
|
|
460
462
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
461
|
-
webSearch:!1,models:Object.freeze([
|
|
462
|
-
|
|
463
|
+
webSearch:!1,models:Object.freeze([Nt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
464
|
+
Nt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
|
|
463
465
|
coding-plan",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
|
|
464
|
-
webSearch:!1,models:Object.freeze([
|
|
466
|
+
webSearch:!1,models:Object.freeze([Nt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
|
|
465
467
|
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:
|
|
468
|
-
UNREACHABLE:"unreachable"}),
|
|
469
|
-
SUSPECT:"suspect"}),
|
|
470
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
471
|
-
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var
|
|
472
|
-
|
|
468
|
+
webSearch:!1,models:Object.freeze([Nt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);function nt(t){return lc.find(e=>e.id===t)||null}var Mh=32*1024*1024,jh=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
469
|
+
deepseek:nt("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":nt("zai-coding-plan").baseUrl,zai:nt("zai").baseUrl});var Ar=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),Vh=kt();var Er=Object.freeze({UNIX:"unix"});var fc=process.platform==="linux"?107:103,Oo=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
470
|
+
UNREACHABLE:"unreachable"}),mc=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
471
|
+
SUSPECT:"suspect"}),ot=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),Ro=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
472
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var hc=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
|
|
473
|
+
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var Dd=fe(_s(),1),zd=fe($t(),1),Ld=fe(De(),1),Ud=fe(Ur(),1),Fd=fe($r(),1),qd=fe(Kr(),1),$d=fe(Gt(),1),Bd=fe(Ns(),1);var lw=32*1024,pw=2*1024*1024;var tr=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
474
|
+
Mw=new Set(Object.values(tr)),jw=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
473
475
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
474
|
-
|
|
476
|
+
Dw=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),zw=Object.freeze(["accountIde\
|
|
475
477
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
476
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
478
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),Lw=Object.freeze(["userAgent"]);import mu from"node:path";var hu=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
477
479
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
478
480
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
479
481
|
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))
|
|
482
|
+
"unified_exec_zsh_fork","view_image"]);function Zs(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.
|
|
483
|
+
values(t))Zs(e);return Object.freeze(t)}function gu(t="",e={}){let n=new Error(b(t)||"Codex cannot prove the helper exec\
|
|
482
484
|
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=
|
|
485
|
-
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:
|
|
486
|
-
1024}={},createError:
|
|
487
|
-
f8")}catch{throw
|
|
488
|
-
n oversized ${h}.`)}function T(
|
|
489
|
-
annot verify the app-server connection generation.");let f=
|
|
490
|
-
f<=0)throw
|
|
491
|
-
currentHelperExecutionContext!="function")throw
|
|
492
|
-
currentHelperExecutionContext(),h=
|
|
493
|
-
h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw
|
|
494
|
-
{accountIdentitySignature:g,cwd:h,executionMode:"helper"})}function
|
|
495
|
-
if(!f)return null;let h=f.slice(1).map(g=>Number.parseInt(g,10));return h.every(Number.isSafeInteger)?h:null}function
|
|
496
|
-
let f=
|
|
497
|
-
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?
|
|
498
|
-
"function")throw
|
|
499
|
-
let f=
|
|
500
|
-
er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),
|
|
501
|
-
-1&&h[S]<
|
|
502
|
-
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function
|
|
503
|
-
|
|
504
|
-
if(f==null)return[];if(
|
|
505
|
-
configuration.");let h=Object.keys(f);if(h.length>o||h.some(g=>!g||g.length>s||
|
|
506
|
-
ceived an oversized or invalid MCP server inventory.");return h.sort()}function
|
|
507
|
-
!Array.isArray(
|
|
508
|
-
"Codex helper execution received an unexpected hook inventory.");let h=
|
|
509
|
-
isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw
|
|
510
|
-
an incomplete hook inventory.");if(h.errors.length>0)throw
|
|
511
|
-
ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let b
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
currentHash:
|
|
515
|
-
localeCompare(
|
|
516
|
-
|
|
517
|
-
mcpServerNames:g=[]}={}){let
|
|
518
|
-
|
|
519
|
-
include_permissions_instructions:!1,...
|
|
520
|
-
fromEntries(g.map(
|
|
485
|
+
["code","details","message","name"].includes(r)||(n[r]=o);return n}function vu({clientName:t="jskit",minimumVersion:e="0\
|
|
486
|
+
.151.0",disabledFeatures:n=hu,limits:{userAgentMaxLength:r=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
487
|
+
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:u=256*1024,hookResponseMaxBytes:m=512*
|
|
488
|
+
1024}={},createError:p=gu}={}){let v=new WeakSet;function y(l,f,h){let g=0;try{g=Buffer.byteLength(JSON.stringify(l),"ut\
|
|
489
|
+
f8")}catch{throw p(`Codex helper execution received an invalid ${h}.`)}if(g>f)throw p(`Codex helper execution received a\
|
|
490
|
+
n oversized ${h}.`)}function T(l){if(typeof l?.currentConnectionGeneration!="function")throw p("Codex helper execution c\
|
|
491
|
+
annot verify the app-server connection generation.");let f=l.currentConnectionGeneration();if(!Number.isSafeInteger(f)||
|
|
492
|
+
f<=0)throw p("Codex helper execution found no active app-server connection.");return f}async function O(l){if(typeof l?.
|
|
493
|
+
currentHelperExecutionContext!="function")throw p("Codex helper execution requires its dedicated isolated provider.");let f=await l.
|
|
494
|
+
currentHelperExecutionContext(),h=b(f?.cwd),g=b(f?.accountIdentitySignature);if(f?.executionMode!=="helper"||!h||!mu.isAbsolute(
|
|
495
|
+
h)||!/^sha256:[a-f0-9]{64}$/u.test(g))throw p("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
496
|
+
{accountIdentitySignature:g,cwd:h,executionMode:"helper"})}function N(l=""){let f=b(l).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
|
|
497
|
+
if(!f)return null;let h=f.slice(1).map(g=>Number.parseInt(g,10));return h.every(Number.isSafeInteger)?h:null}function z(l=""){
|
|
498
|
+
let f=b(l);if(!f||f.length>r||xe(f))return null;let h=`${t}/`;if(!f.startsWith(h))return null;let g=f.slice(h.length).match(
|
|
499
|
+
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return g?N(g[1]):null}function L(l){if(typeof l?.currentServerInfo!=
|
|
500
|
+
"function")throw p("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
501
|
+
let f=b(l.currentServerInfo()?.userAgent),h=z(f);if(!h)throw p("Codex helper execution received an unrecognised app-serv\
|
|
502
|
+
er version. Update Codex and retry.",{minimumVersion:e});let g=h.join("."),I=N(e),S=h.findIndex((C,k)=>C!==I[k]);if(S!==
|
|
503
|
+
-1&&h[S]<I[S])throw p(`Codex helper execution requires app-server ${e} or newer; current version is ${g}. Update Codex a\
|
|
504
|
+
nd retry.`,{actualVersion:g,minimumVersion:e});return Object.freeze({minimumVersion:e,version:g})}function q(l=null){if(!At(
|
|
505
|
+
l?.config))throw p("Codex helper execution could not read the effective app-server configuration.");let f=l.config.mcp_servers;
|
|
506
|
+
if(f==null)return[];if(y(f,i,"MCP configuration"),!At(f))throw p("Codex helper execution received an invalid MCP server \
|
|
507
|
+
configuration.");let h=Object.keys(f);if(h.length>o||h.some(g=>!g||g.length>s||xe(g)))throw p("Codex helper execution re\
|
|
508
|
+
ceived an oversized or invalid MCP server inventory.");return h.sort()}function H(l=null,f=""){if(y(l,m,"hook inventory"),
|
|
509
|
+
!Array.isArray(l?.data))throw p("Codex helper execution could not enumerate app-server hooks.");if(l.data.length!==1)throw p(
|
|
510
|
+
"Codex helper execution received an unexpected hook inventory.");let h=l.data[0];if(b(h?.cwd)!==f||b(h?.cwd).length>d||!Array.
|
|
511
|
+
isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw p("Codex helper execution received\
|
|
512
|
+
an incomplete hook inventory.");if(h.errors.length>0)throw p("Codex helper execution cannot continue while hook discove\
|
|
513
|
+
ry has errors.",{hookErrorCount:h.errors.length});let g=h.hooks.map(S=>{let C=b(S?.key),k=b(S?.currentHash),D=b(S?.handlerType),
|
|
514
|
+
E=b(S?.sourcePath);if(!C||[C,k,D,E].some(se=>se.length>d||xe(se)))throw p("Codex helper execution found an invalid hook \
|
|
515
|
+
inventory entry.");if(S?.isManaged===!0&&S?.enabled===!0)throw p("Codex helper execution cannot disable a managed hook.");
|
|
516
|
+
return{currentHash:k,enabled:S?.enabled===!0,handlerType:D,isManaged:S?.isManaged===!0,key:C,sourcePath:E}}).sort((S,C)=>S.
|
|
517
|
+
key.localeCompare(C.key)),I=JSON.stringify(g);if(I.length>u)throw p("Codex helper execution received an oversized hook i\
|
|
518
|
+
nventory.");return{fingerprint:I,hookKeys:g.filter(S=>!S.isManaged).map(S=>S.key)}}function R({effort:l="",summary:f="",
|
|
519
|
+
hookKeys:h=[],mcpServerNames:g=[]}={}){let I={features:Object.fromEntries(n.map(C=>[C,!1])),hooks:{state:Object.fromEntries(
|
|
520
|
+
h.map(C=>[C,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
521
|
+
include_permissions_instructions:!1,...l?{model_reasoning_effort:l}:{},...f?{model_reasoning_summary:f}:{},mcp_servers:Object.
|
|
522
|
+
fromEntries(g.map(C=>[C,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
521
523
|
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
|
|
524
|
-
summary:
|
|
525
|
-
"function"||typeof
|
|
526
|
-
let g=await O(
|
|
527
|
-
cted during helper policy verification.");let
|
|
528
|
-
cted during helper policy verification.");let{mcpServerNames:
|
|
529
|
-
freeze({accountIdentitySignature:g.accountIdentitySignature,config:
|
|
530
|
-
fingerprint,hookKeys:Object.freeze([...
|
|
531
|
-
accountIdentitySignature===f?.accountIdentitySignature&&
|
|
532
|
-
f?.executionCwd&&
|
|
533
|
-
[])}function
|
|
534
|
-
|
|
535
|
-
codexAppServerHelperThreadCleanupRequired=!0,
|
|
536
|
-
threadId:h=""}={}){let g=null;try{await f.deleteThread(h)}catch(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
await
|
|
540
|
-
"function")throw
|
|
541
|
-
h.settings),
|
|
542
|
-
|
|
543
|
-
"Codex helper execution cannot safely resume and clean up its app-server thread.");let g=
|
|
544
|
-
r resume requires a controller-owned thread id.");let
|
|
545
|
-
|
|
546
|
-
return
|
|
547
|
-
sandbox:S,systemPrompt:
|
|
548
|
-
null,dynamicTools:[],environments:[],model:
|
|
549
|
-
return{...
|
|
550
|
-
baseInstructions,config:
|
|
551
|
-
sandbox:
|
|
524
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},S=Zs(I);return v.add(
|
|
525
|
+
S),S}function P(l,f,h,{effort:g="",summary:I=""}={}){let S=q(l),C=H(f,h);return{mcpServerNames:S,hookState:C,config:R({effort:g,
|
|
526
|
+
summary:I,hookKeys:C.hookKeys,mcpServerNames:S})}}async function A(l,{effort:f="",summary:h=""}={}){if(L(l),typeof l?.readConfig!=
|
|
527
|
+
"function"||typeof l?.listHooks!="function")throw p("Codex helper execution cannot inventory configuration and hooks.");
|
|
528
|
+
let g=await O(l),I=T(l),S=await l.readConfig({cwd:g.cwd,includeLayers:!1});if(T(l)!==I)throw p("Codex app-server reconne\
|
|
529
|
+
cted during helper policy verification.");let C=await l.listHooks([g.cwd]);if(T(l)!==I)throw p("Codex app-server reconne\
|
|
530
|
+
cted during helper policy verification.");let{mcpServerNames:k,hookState:D,config:E}=P(S,C,g.cwd,{effort:f,summary:h});return Object.
|
|
531
|
+
freeze({accountIdentitySignature:g.accountIdentitySignature,config:E,connectionGeneration:I,executionCwd:g.cwd,hookFingerprint:D.
|
|
532
|
+
fingerprint,hookKeys:Object.freeze([...D.hookKeys]),mcpServerNames:Object.freeze([...k])})}function M(l=null,f=null){return l?.
|
|
533
|
+
accountIdentitySignature===f?.accountIdentitySignature&&l?.connectionGeneration===f?.connectionGeneration&&l?.executionCwd===
|
|
534
|
+
f?.executionCwd&&l?.hookFingerprint===f?.hookFingerprint&&JSON.stringify(l?.mcpServerNames||[])===JSON.stringify(f?.mcpServerNames||
|
|
535
|
+
[])}function W(l,f,h=""){let g=b(h);if(!f)return l.codexAppServerHelperThreadId=g,l.codexAppServerHelperThreadRetired=!0,
|
|
536
|
+
l;let I=p("Codex could not retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:g});return I.
|
|
537
|
+
codexAppServerHelperThreadCleanupRequired=!0,I.codexAppServerHelperThreadId=g,I}async function Ie({error:l=null,provider:f=null,
|
|
538
|
+
threadId:h=""}={}){let g=null;try{await f.deleteThread(h)}catch(I){g=I}throw W(l,g,h)}async function tt(l,f,h,g,I){try{let S=await A(
|
|
539
|
+
l,{effort:f.config.model_reasoning_effort,summary:f.config.model_reasoning_summary});if(!M(f,S))throw p(`Codex execution\
|
|
540
|
+
surfaces changed while the helper thread was ${I}.`);return Object.freeze({enforcement:S,thread:h,threadId:g})}catch(S){
|
|
541
|
+
await Ie({error:S,provider:l,threadId:g})}}async function yr(l,f){if(typeof l?.startThread!="function"||typeof l?.deleteThread!=
|
|
542
|
+
"function")throw p("Codex helper execution cannot own and clean up its app-server thread.");let h=await f(),g=await l.startThread(
|
|
543
|
+
h.settings),I=b(g?.id);if(!I)throw p("Codex app-server did not return a helper thread id.");return tt(l,h.enforcement,g,
|
|
544
|
+
I,"starting")}async function Se(l,f,h){if(typeof l?.resumeThread!="function"||typeof l?.deleteThread!="function")throw p(
|
|
545
|
+
"Codex helper execution cannot safely resume and clean up its app-server thread.");let g=b(f);if(!g)throw p("Codex helpe\
|
|
546
|
+
r resume requires a controller-owned thread id.");let I=await h(),S=I.enforcement,C=await l.resumeThread(g,I.settings);return tt(
|
|
547
|
+
l,S,C,g,"resuming")}function _t(l){return v.has(l)}function ke({configResult:l,hookResult:f,workdir:h,effort:g="",summary:I=""}){
|
|
548
|
+
return P(l,f,h,{effort:g,summary:I}).config}function Ct({approvalPolicy:l,baseInstructions:f,config:h,cwd:g,effectiveSettings:I,
|
|
549
|
+
sandbox:S,systemPrompt:C}){return{allowProviderModelFallback:!1,approvalPolicy:l,baseInstructions:f,config:h,cwd:g,systemPrompt:C||
|
|
550
|
+
null,dynamicTools:[],environments:[],model:I.model,runtimeWorkspaceRoots:[],sandbox:S,selectedCapabilityRoots:[]}}function Ir(l,f){
|
|
551
|
+
return{...l,sessionStartSource:"startup",threadSource:f}}function Sr(l){return{approvalPolicy:l.approvalPolicy,baseInstructions:l.
|
|
552
|
+
baseInstructions,config:l.config,cwd:l.cwd,systemPrompt:l.systemPrompt,model:l.model,runtimeWorkspaceRoots:l.runtimeWorkspaceRoots,
|
|
553
|
+
sandbox:l.sandbox}}function xr({approvalPolicy:l,cwd:f,effectiveSettings:h,outputSchema:g}){let I={approvalPolicy:l,cwd:f,
|
|
552
554
|
environments:[],model:h.model,outputSchema:g,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"\
|
|
553
|
-
none"};return h.request.reasoning&&(
|
|
554
|
-
inspect:
|
|
555
|
-
start:
|
|
555
|
+
none"};return h.request.reasoning&&(I.effort=h.thinking),I}return Object.freeze({assertCompatibility:L,executionContext:O,
|
|
556
|
+
inspect:A,configuration:ke,hasConfiguration:_t,threadSettings:Ct,threadStartSettings:Ir,threadResumeSettings:Sr,turnSettings:xr,
|
|
557
|
+
start:yr,resume:Se})}var ay=vu();var OS=Object.freeze({PROVIDER_FAILURE:"provider_failure",RESPONSE_DELIVERY_FAILURE:"response_delivery_failure",SERVICE_RESTART:"\
|
|
556
558
|
service_restart",USER_CANCELLED:"user_cancelled",CONTROL_RECONFIGURATION:"control_reconfiguration",INTERRUPTED:"interrup\
|
|
557
|
-
ted"});var
|
|
559
|
+
ted"});var HS=Number.MAX_SAFE_INTEGER;var Du=(Number(process.env.AGENT_REPLY_MINUTES)||15)*60*1e3;function mn(t){return{stoppedShort:`(Check from ${t}: your reply ended by saying what you'd do next, and then stopped, s\
|
|
558
560
|
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
561
|
say plainly why.)`,markup:`(Check from ${t}: your last message contained raw markup, such as a tool call written out as\
|
|
560
562
|
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
563
|
what's left, then reply in plain words.)`,unsupported:e=>`(Check from ${t}: your reply says ${e.map(n=>`"${n}"`).join(",\
|
|
562
564
|
")}, 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
565
|
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
|
|
566
|
+
are above and what they did stays done. Carry on from where you got to, without redoing them, and finish the job.)"}}var px=["You check an assistant's reply against a record of what its tools did while writing that reply.","List each sta\
|
|
565
567
|
tement in the reply that says something was done in this reply (made, saved, sent, attached, added, changed, deleted, bo\
|
|
566
568
|
oked, set up, fixed, run, tested) that the record doesn't support.","A claim is supported if a tool call and its answer \
|
|
567
569
|
in the record show it happened. Ignore plans, offers, questions, advice, facts about the person, things said to have hap\
|
|
568
570
|
pened earlier in the conversation, and descriptions of what a file or app contains.",'Reply with JSON only: {"unsupporte\
|
|
569
571
|
d": ["short quote of each unsupported claim"]}, with [] when every claim is supported.'].join(`
|
|
570
|
-
`);var
|
|
571
|
-
|
|
572
|
-
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function
|
|
573
|
-
let{items:n}=e;if(
|
|
574
|
-
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function
|
|
575
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(
|
|
572
|
+
`);var Lx=64*1024;var Zu="the app",Vx=mn(Zu);var Wx=16*1024*1024;function $(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
573
|
+
Qu(e)}function Qu(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function wn(t){return t!==null&&typeof t=="object"&&$(t.structure)&&$(t.operations)&&typeof t.validateWith=="function"&&
|
|
574
|
+
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function rr(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
575
|
+
let{items:n}=e;if(wn(n))return{kind:"schema",schema:n};if(!$(n)||typeof n.type!="string")throw new Error(`Array field "${t}\
|
|
576
|
+
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:n}}function vt(t,e){
|
|
577
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:n}=e;if(wn(n))return{kind:"schema",schema:n};if(!$(n)||typeof n.type!=
|
|
576
578
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
577
|
-
t.`);return{kind:"definition",definition:n}}function
|
|
579
|
+
t.`);return{kind:"definition",definition:n}}function nr(t,e){let n=Object.hasOwn(e,"schema"),r=Object.hasOwn(e,"values"),
|
|
578
580
|
o=Object.hasOwn(e,"additionalProperties");if(n&&r)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
579
581
|
ues.`);if(o&&e.additionalProperties!==!0)throw new Error(`Object field "${t}" only supports additionalProperties: true.`);
|
|
580
582
|
if(r&&e.additionalProperties===!0)throw new Error(`Object field "${t}" cannot define both values and additionalPropertie\
|
|
581
|
-
s: true.`);if(n){if(!
|
|
582
|
-
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:
|
|
583
|
-
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function
|
|
584
|
-
if(
|
|
583
|
+
s: true.`);if(n){if(!wn(e.schema))throw new Error(`Object field "${t}" must define schema as a Schema instance.`);return{
|
|
584
|
+
kind:"nested",schema:e.schema,allowAdditionalProperties:e.additionalProperties===!0}}return r?{kind:"map",valuesConfig:vt(
|
|
585
|
+
t,e)}:e.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Ve(t){return t?.type==="number"||t?.type==="integer"||t?.type==="epochMilliseconds"||t?.type==="epochSeconds"}function yn(t,e=""){
|
|
586
|
+
if($(t))for(let[n,r]of Object.entries(t)){if(!$(r))continue;let o=e?`${e}.${n}`:n;for(let s of["minItems","maxItems"]){if(!Object.
|
|
585
587
|
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\
|
|
586
588
|
e a non-negative integer on an array field.`)}if(r.minItems>r.maxItems)throw new Error(`Field "${o}" minItems (${r.minItems}\
|
|
587
|
-
) is above its maxItems (${r.maxItems}).`);r.type==="array"
|
|
588
|
-
o)}}var
|
|
589
|
-
|
|
590
|
-
$`,
|
|
591
|
-
))?${
|
|
592
|
-
0)}function
|
|
593
|
-
1&&o<=12&&s>=1&&s<=
|
|
594
|
-
`temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function
|
|
595
|
-
t.length<=e}function
|
|
596
|
-
if(typeof t!="string")return!1;let n=
|
|
597
|
-
let n=
|
|
598
|
-
"":`(?:\\.\\d{1,${t}})?`}function
|
|
599
|
-
return`^${
|
|
600
|
-
test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var
|
|
601
|
-
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function
|
|
602
|
-
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function
|
|
603
|
-
let o=n?
|
|
589
|
+
) is above its maxItems (${r.maxItems}).`);r.type==="array"&&$(r.items)&&typeof r.items.type=="string"&&yn({"[]":r.items},
|
|
590
|
+
o)}}var In="^(?:0|-?[1-9]\\d*)$",ii="\\d{4}",ai="0[1-9]|1[0-2]",ci="0[1-9]|[12]\\d|3[01]",di="[01]\\d|2[0-3]",Ge="[0-5]\\d",
|
|
591
|
+
or=`(?:${di}):${Ge}`,ui=`(?:Z|[+-](?:${di}):${Ge})`,li=`(${ii})-(${ai})-(${ci})`,pi=`${ii}-(?:${ai})-(?:${ci})`,fi=`^${pi}\
|
|
592
|
+
$`,el=new RegExp(`^${li}$`),tl=new RegExp(`^${or}(?::${Ge}(?:\\.(\\d+))?)?$`),rl=new RegExp(`^${li}T${or}:${Ge}(?:\\.(\\d+\
|
|
593
|
+
))?${ui}$`),nl=new RegExp(In),ol=[31,28,31,30,31,30,31,31,30,31,30,31];function sl(t){return t%4===0&&(t%100!==0||t%400===
|
|
594
|
+
0)}function il(t,e){return e===2?sl(t)?29:28:ol[e-1]}function mi(t,e,n){let r=Number(t),o=Number(e),s=Number(n);return o>=
|
|
595
|
+
1&&o<=12&&s>=1&&s<=il(r,o)}function wt(t,e){let n=t.temporalPrecision;if(n!==void 0){if(!Number.isInteger(n)||n<0)throw new Error(
|
|
596
|
+
`temporalPrecision for "${e}" must be a non-negative integer.`);return n}}function hi(t,e){return t===void 0?!0:e===void 0||
|
|
597
|
+
t.length<=e}function gi(t){if(typeof t!="string")return!1;let e=el.exec(t);return e!==null&&mi(e[1],e[2],e[3])}function vi(t,e){
|
|
598
|
+
if(typeof t!="string")return!1;let n=tl.exec(t);return n!==null&&hi(n[1],e)}function wi(t,e){if(typeof t!="string")return!1;
|
|
599
|
+
let n=rl.exec(t);return n===null?!1:mi(n[1],n[2],n[3])&&hi(n[4],e)}function yi(t){return t===void 0?"(?:\\.\\d+)?":t===0?
|
|
600
|
+
"":`(?:\\.\\d{1,${t}})?`}function Ii(t,e){let n=wt(t,e);return`^${or}(?::${Ge}${yi(n)})?$`}function Si(t,e){let n=wt(t,e);
|
|
601
|
+
return`^${pi}T${or}:${Ge}${yi(n)}${ui}$`}function Sn(t,e){let n;if(typeof t=="number")n=t;else if(typeof t=="string"&&nl.
|
|
602
|
+
test(t))n=Number(t);else return null;return!Number.isSafeInteger(n)||n<-e||n>e?null:n===0?0:n}var al=new Set(["__proto__","prototype","constructor"]);function _(t,e,n){Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0})}function cl(t,e){if(al.
|
|
603
|
+
has(t))throw new Error(`${e}() received unsafe path segment "${t}".`)}function dl(t){return typeof t!="string"?t:t.replace(
|
|
604
|
+
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function xn(t,e,{normalize:n=!1,allowEmpty:r=!1}={}){
|
|
605
|
+
let o=n?dl(t):t;if(typeof o!="string"||o.trim()===""){if(r&&o==="")return[];throw new Error(`${e}() expects a non-empty \
|
|
604
606
|
dotted path string.`)}let s=o.split(".");if(s.some(i=>i===""))throw new Error(`${e}() received an invalid path "${o}".`);
|
|
605
|
-
for(let i of s)
|
|
606
|
-
|
|
607
|
-
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:
|
|
608
|
-
none:()=>({type:
|
|
607
|
+
for(let i of s)cl(i,e);return s}var ul="http://json-schema.org/draft-07/schema#",we="x-json-rest-schema",bn=["object","array","string","number","boolean"],
|
|
608
|
+
Tn=Symbol("json-rest-schema.exportContext"),ll=["true","1","yes","y","on"],pl=["false","0","no","n","off"];function xi(t){
|
|
609
|
+
return{anyOf:[{type:"integer",minimum:-t,maximum:t},{type:"string",pattern:In}]}}function Oe(t,e){return{[we]:{[t]:e}}}var fl={
|
|
610
|
+
none:()=>({type:bn}),blob:()=>({type:bn}),serialize:()=>({type:bn}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
609
611
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
610
|
-
eger","string"]}),epochMilliseconds:()=>
|
|
611
|
-
type:"string",format:"date-time",pattern:
|
|
612
|
-
fieldName:e})=>({type:"string",pattern:
|
|
613
|
-
let e=new Set([...
|
|
612
|
+
eger","string"]}),epochMilliseconds:()=>xi(864e13),epochSeconds:()=>xi(864e10),dateTime:({definition:t,fieldName:e})=>({
|
|
613
|
+
type:"string",format:"date-time",pattern:Si(t,e)}),date:()=>({type:"string",format:"date",pattern:fi}),time:({definition:t,
|
|
614
|
+
fieldName:e})=>({type:"string",pattern:Ii(t,e)}),boolean:({definition:t})=>{if(t.strictBoolean===!0)return{type:"boolean"};
|
|
615
|
+
let e=new Set([...ll,String(t.stringTrueWhen||"true").trim().toLowerCase()]),n=new Set([...pl,String(t.stringFalseWhen||
|
|
614
616
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...n,...e]}]}},
|
|
615
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
617
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},ml={minLength:({definition:t,parameterValue:e})=>t.
|
|
616
618
|
type==="string"?{minLength:e}:null,maxLength:({definition:t,parameterValue:e})=>t.type==="string"?{maxLength:e}:null,min:({
|
|
617
|
-
definition:t,parameterValue:e})=>
|
|
619
|
+
definition:t,parameterValue:e})=>Ve(t)?{minimum:e}:null,max:({definition:t,parameterValue:e})=>Ve(t)?{maximum:e}:null,pattern:({
|
|
618
620
|
definition:t,parameterValue:e})=>t.type==="string"?{pattern:e instanceof RegExp?e.source:e}:null,enum:({parameterValue:t})=>({
|
|
619
621
|
enum:t}),minItems:({definition:t,parameterValue:e})=>t.type==="array"?{minItems:e}:null,maxItems:({definition:t,parameterValue:e})=>t.
|
|
620
622
|
type==="array"?{maxItems:e}:null,notEmpty:({parameterValue:t,definition:e})=>!t||e.type==="array"?null:{minLength:1},uppercase:({
|
|
621
|
-
parameterValue:t})=>t?
|
|
622
|
-
null,length:({parameterValue:t})=>
|
|
623
|
-
null,precision:({parameterValue:t})=>
|
|
624
|
-
parameterValue:t})=>
|
|
625
|
-
defaultTo:()=>null};function
|
|
626
|
-
"object"&&!Array.isArray(r)&&!Array.isArray(o)){
|
|
623
|
+
parameterValue:t})=>t?Oe("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?Oe("transforms",{lowercase:!0}):
|
|
624
|
+
null,length:({parameterValue:t})=>Oe("transforms",{length:t}),unsigned:({parameterValue:t})=>t?Oe("metadata",{unsigned:!0}):
|
|
625
|
+
null,precision:({parameterValue:t})=>Oe("metadata",{precision:t}),scale:({parameterValue:t})=>Oe("metadata",{scale:t}),temporalPrecision:({
|
|
626
|
+
parameterValue:t})=>Oe("metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,
|
|
627
|
+
defaultTo:()=>null};function En(t,e){for(let n of Object.keys(e)){let r=e[n],o=t[n];if(r&&o&&typeof r=="object"&&typeof o==
|
|
628
|
+
"object"&&!Array.isArray(r)&&!Array.isArray(o)){En(o,r);continue}t[n]=r}}function hl(t,e){if(!e||typeof e!="object"||Array.
|
|
627
629
|
isArray(e))throw new Error("JSON Schema export hooks must return an object or null.");for(let n of Object.keys(e)){if(n===
|
|
628
|
-
|
|
629
|
-
t[n]=e[n]}}function
|
|
630
|
-
1?t:{anyOf:r}}function
|
|
631
|
-
let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=
|
|
632
|
-
`Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function
|
|
633
|
-
hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=
|
|
630
|
+
we&&t[n]&&typeof t[n]=="object"&&typeof e[n]=="object"&&!Array.isArray(t[n])&&!Array.isArray(e[n])){En(t[n],e[n]);continue}
|
|
631
|
+
t[n]=e[n]}}function gl(t,e){let r=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return r.length===
|
|
632
|
+
1?t:{anyOf:r}}function vl(t,e){if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);
|
|
633
|
+
let n=t.types[e.type];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let r=fl[e.type];if(!r)throw new Error(
|
|
634
|
+
`Type '${e.type}' cannot be exported to JSON Schema without a toJsonSchema hook.`);return r}function wl(t,e,n){if(!Object.
|
|
635
|
+
hasOwn(t.validators,e))return null;let r=t.validators[e];if(typeof r.toJsonSchema=="function")return r.toJsonSchema;let o=ml[e];
|
|
634
636
|
if(o)return o;throw new Error(`Validator '${e}' on field '${n}' cannot be exported to JSON Schema without a toJsonSchema\
|
|
635
|
-
hook.`)}function
|
|
636
|
-
`Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
637
|
-
void 0&&e.operation!==void 0){let n=
|
|
637
|
+
hook.`)}function bi(t){if(t===void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(
|
|
638
|
+
`Unsupported JSON Schema export mode '${t}'. Expected 'create', 'replace', or 'patch'.`)}function yl(t,e={}){if(e.mode!==
|
|
639
|
+
void 0&&e.operation!==void 0){let n=bi(e.mode);if(n!==e.operation)throw new Error(`Conflicting JSON Schema export option\
|
|
638
640
|
s: mode '${n}' does not match operation '${e.operation}'.`)}if(e.operation!==void 0){if(!Object.hasOwn(t.operations,e.operation))
|
|
639
|
-
throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return
|
|
641
|
+
throw new Error(`Unknown JSON Schema export operation '${e.operation}'.`);return e.operation}return bi(e.mode)}function Il(t,e={}){
|
|
640
642
|
if(e.operationName!==void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,operation:e.operationDescriptor};
|
|
641
|
-
let n=
|
|
642
|
-
e,
|
|
643
|
-
t[
|
|
644
|
-
"_").replace(/^_+|_+$/g,"")||"operation"}function
|
|
645
|
-
function
|
|
646
|
-
n&&s.operation===r&&s.additionalProperties===o)||null}function
|
|
647
|
-
return t.nextDefinitionId+=1,r}function
|
|
643
|
+
let n=yl(t,e);return{operationName:n,operation:t.operations[n]}}function Sl(t={}){let e={...t};return Object.defineProperty(
|
|
644
|
+
e,Tn,{value:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function ir(t={}){return t[Tn]?
|
|
645
|
+
t[Tn]:{definitions:{},nodes:[],nextDefinitionId:1,rootNode:null}}function xl(t){return String(t).replace(/[^a-zA-Z0-9]+/g,
|
|
646
|
+
"_").replace(/^_+|_+$/g,"")||"operation"}function _n(t){return $(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}
|
|
647
|
+
function sr(t){return _n(t)?{allOf:[t]}:t}function bl(t,e,n,r,o){return t.nodes.find(s=>s.schema===e&&s.operationName===
|
|
648
|
+
n&&s.operation===r&&s.additionalProperties===o)||null}function Tl(t,e){let n=xl(e),r=`SchemaNode_${t.nextDefinitionId}_${n}`;
|
|
649
|
+
return t.nextDefinitionId+=1,r}function Ti(t,e,n,r,o,{root:s=!1}={}){let i=ir(e),a=bl(i,t,n,r,o);if(a)return s&&(a.pointer=
|
|
648
650
|
"#",i.rootNode=a),a;let c={schema:t,operationName:n,operation:r,additionalProperties:o,status:"new",definitionName:s?null:
|
|
649
|
-
|
|
650
|
-
if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=
|
|
651
|
-
ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=
|
|
652
|
-
return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function
|
|
653
|
-
let s=
|
|
654
|
-
referenceBacked:e}}function
|
|
651
|
+
Tl(i,n),pointer:s?"#":null};return s?i.rootNode=c:c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function _i(t,e){
|
|
652
|
+
if(t.status==="built")return{$ref:t.pointer};if(t.status==="building")return{$ref:t.pointer};let n=ir(e);t.status="build\
|
|
653
|
+
ing",t.pointer!=="#"&&(n.definitions[t.definitionName]={});let r=_l(t.schema,e,t.operationName,t.operation,t.additionalProperties);
|
|
654
|
+
return t.status="built",t.pointer==="#"?r:(n.definitions[t.definitionName]=r,{$ref:t.pointer})}function On(t,e,n,r,o=!1){
|
|
655
|
+
let s=ir(e),i=Ti(t,e,n,r,o);return s.rootNode===i?{$ref:"#"}:_i(i,e)}function yt(t,{referenceBacked:e=!1}={}){return{schema:t,
|
|
656
|
+
referenceBacked:e}}function _l(t,e,n,r,o=!1){let s={},i=[];for(let[c,d]of Object.entries(t.structure))_(s,c,Rn(t,c,d,e,n,
|
|
655
657
|
r)),r.enforceRequired&&d.required===!0&&i.push(c);let a={type:"object",properties:s,additionalProperties:o};return i.length>
|
|
656
|
-
0&&(a.required=i),a}function
|
|
657
|
-
r,"replace",i.schema.operations.replace,!1)),[
|
|
658
|
-
"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return
|
|
659
|
-
let i=
|
|
660
|
-
[
|
|
661
|
-
place"?t.operations.replace:s;return
|
|
662
|
-
e,n);if(a.kind==="nested")return
|
|
663
|
-
"opaque")return
|
|
664
|
-
t,e,n,r,o,s)})}let i=
|
|
658
|
+
0&&(a.required=i),a}function Cl(t,e,n,r,o,s){let i=rr(e,n);if(!i)return null;if(i.kind==="schema")return{...sr(On(i.schema,
|
|
659
|
+
r,"replace",i.schema.operations.replace,!1)),[we]:{castType:"object"}};let a=n.items.type==="object"&&Object.hasOwn(n.items,
|
|
660
|
+
"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Rn(t,`${e}[]`,n.items,r,a,c)}function Al(t,e,n,r,o,s){
|
|
661
|
+
let i=vt(e,n);if(!i)return null;if(i.kind==="schema")return{...sr(On(i.schema,r,"replace",i.schema.operations.replace,!1)),
|
|
662
|
+
[we]:{castType:"object"}};let a=i.definition.type==="object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="re\
|
|
663
|
+
place"?t.operations.replace:s;return Rn(t,`${e}.*`,i.definition,r,a,c)}function El(t,e,n,r,o,s){if(n.type==="object"){let a=nr(
|
|
664
|
+
e,n);if(a.kind==="nested")return yt(On(a.schema,r,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind===
|
|
665
|
+
"opaque")return yt({type:"object",additionalProperties:!0});if(a.kind==="map")return yt({type:"object",additionalProperties:Al(
|
|
666
|
+
t,e,n,r,o,s)})}let i=vl(t,n)({schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r});if(!i||typeof i!="object"||
|
|
665
667
|
Array.isArray(i))throw new Error(`Type '${n.type}' on field '${e}' returned an invalid JSON Schema fragment.`);if(n.type===
|
|
666
|
-
"array"){let a=
|
|
667
|
-
function
|
|
668
|
-
|
|
669
|
-
continue;let v=
|
|
670
|
-
c[
|
|
671
|
-
let m=
|
|
668
|
+
"array"){let a=Cl(t,e,n,r,o,s);if(a)return yt({...i,items:a},{referenceBacked:_n(i)})}return yt(i,{referenceBacked:_n(i)})}
|
|
669
|
+
function Rn(t,e,n,r,o,s){let i={schema:t,fieldName:e,definition:n,operation:o,mode:o,options:r},a=El(t,e,n,r,o,s),c=a.referenceBacked?
|
|
670
|
+
sr(a.schema):{...a.schema},d={castType:n.type};for(let p of Object.keys(n)){if(p==="type"||!Object.hasOwn(t.validators,p))
|
|
671
|
+
continue;let v=wl(t,p,e);if(!v)continue;let y=v({...i,parameterName:p,parameterValue:n[p],fieldSchema:{...c}});y&&hl(c,y)}
|
|
672
|
+
c[we]&&(En(d,c[we]),delete c[we]);let u=[];n.nullable===!0&&u.push({type:"null"}),n.nullOnEmpty===!0&&u.push({const:""});
|
|
673
|
+
let m=sr(gl(c,u));if(n.defaultTo!==void 0&&s.applyDefaults)if(typeof n.defaultTo!="function"){let p=t._normalizeDefault(
|
|
672
674
|
n,n.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},options:{},settings:t._buildOperationSettings(
|
|
673
|
-
o,s,{})});if(Object.keys(
|
|
674
|
-
nvalid (${v.code}).`)}m.default=
|
|
675
|
-
e),{operationName:r,operation:o}=
|
|
676
|
-
o,s,{root:!0}),c={$schema:
|
|
677
|
-
|
|
678
|
-
.${String(e)}`}function
|
|
679
|
-
startsWith(n)?t.slice(n.length):null}function
|
|
680
|
-
{...r,field:o})}return n}function
|
|
681
|
-
o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||_(o,i,
|
|
682
|
-
return e}function
|
|
683
|
-
function
|
|
675
|
+
o,s,{})});if(Object.keys(p.errors).length>0){let v=Object.values(p.errors)[0];throw new Error(`defaultTo for "${e}" is i\
|
|
676
|
+
nvalid (${v.code}).`)}m.default=p.value}else d.defaults={providedByFunction:!0};return m[we]=d,m}function Ci(t,e={}){let n=Sl(
|
|
677
|
+
e),{operationName:r,operation:o}=Il(t,n),s=n.additionalProperties===void 0?!1:n.additionalProperties,i=ir(n),a=Ti(t,n,r,
|
|
678
|
+
o,s,{root:!0}),c={$schema:ul,..._i(a,n)};return Object.keys(i.definitions).length>0&&(c.definitions=i.definitions),c}function Ai(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Dn(t){return t instanceof
|
|
679
|
+
Je}function Ol(){return{self:!1,children:{}}}function Ei(t){return Object.keys(t.children).length>0}function Re(t,e){return`${t}\
|
|
680
|
+
.${String(e)}`}function Mi(t,e){return t===""?String(e):Re(t,e)}function Oi(t,e){if(t===e)return"";let n=`${e}.`;return t.
|
|
681
|
+
startsWith(n)?t.slice(n.length):null}function We(t,e){let n={};for(let r of Object.values(t)){let o=Re(e,r.field);_(n,o,
|
|
682
|
+
{...r,field:o})}return n}function Mn(t){return xn(t,"validatePath")}function Ri(t){let e={};for(let n of t){let r=Mn(n),
|
|
683
|
+
o=e;for(let s=0;s<r.length;s++){let i=r[s];Object.hasOwn(o,i)||_(o,i,Ol()),s===r.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
684
|
+
return e}function Rl(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}
|
|
685
|
+
function ar(t){return t===null?!0:Array.isArray(t)||$(t)?Object.keys(t).length>0:t!==void 0}function Pi(t){return[...t].
|
|
684
686
|
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)})}
|
|
685
|
-
function
|
|
687
|
+
function Pl(t){return/^[0-9]+$/.test(t)}function kl(t,e=new WeakMap){if(e.has(t))return e.get(t);let n=Object.create(Je.
|
|
686
688
|
prototype);return e.set(t,n),n.structure=null,n.types=t.types,n.validators=t.validators,n.operations=t.operations,n.structure=
|
|
687
|
-
|
|
688
|
-
"object")return t;if(
|
|
689
|
+
dr(cr(t.structure,e)),n._installOperationMethods(),Object.freeze(n)}function cr(t,e=new WeakMap){if(t===null||typeof t!=
|
|
690
|
+
"object")return t;if(Dn(t))return kl(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let r=new RegExp(
|
|
689
691
|
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);
|
|
690
|
-
for(let o of t)r.push(
|
|
691
|
-
o,e));return n}function
|
|
692
|
-
isArray(t))for(let n of t)
|
|
693
|
-
return
|
|
694
|
-
if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=
|
|
695
|
-
function
|
|
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(!
|
|
697
|
-
let a=
|
|
698
|
-
function
|
|
699
|
-
"");r.length>0?n.skipFields=r:delete n.skipFields}if(
|
|
700
|
-
let i=
|
|
692
|
+
for(let o of t)r.push(cr(o,e));return r}if(!$(t))return t;let n={};e.set(t,n);for(let[r,o]of Object.entries(t))_(n,r,cr(
|
|
693
|
+
o,e));return n}function dr(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Dn(t))return t;if(e.add(t),Array.
|
|
694
|
+
isArray(t))for(let n of t)dr(n,e);else for(let n of Reflect.ownKeys(t))dr(t[n],e);return Object.freeze(t)}function Pn(t){
|
|
695
|
+
return dr(cr(t))}var kn=new WeakMap;function jn(t,e,n=""){if(!Dn(t)||!Array.isArray(e)||e.length<1)return null;let[r,...o]=e;
|
|
696
|
+
if(!Object.hasOwn(t.structure,r))return null;let s=t.structure[r];if(o.length<1)return s;let i=Mi(n,r);return ji(t,s,o,i)}
|
|
697
|
+
function ji(t,e,n,r){if(e?.type==="object"){let o=t._resolveObjectFieldMode(r,e);return o.kind!=="nested"?null:jn(o.schema,
|
|
698
|
+
n,r)}if(e?.type==="array"){let o=t._resolveArrayItemsConfig(r,e);if(!o||n.length<1)return null;let[s,...i]=n;if(!Pl(s))return null;
|
|
699
|
+
let a=Re(r,s);return o.kind==="schema"?i.length<1?null:jn(o.schema,i,a):i.length<1?o.definition:ji(t,o.definition,i,a)}return null}
|
|
700
|
+
function Ke(t,e){let n={...t};if(Array.isArray(t.skipFields)){let r=t.skipFields.map(o=>Oi(o,e)).filter(o=>o!==null&&o!==
|
|
701
|
+
"");r.length>0?n.skipFields=r:delete n.skipFields}if($(t.skipParams)){let r={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
702
|
+
let i=Oi(o,e);i===null||i===""||_(r,i,s)}Object.keys(r).length>0?n.skipParams=r:delete n.skipParams}return n}var Nl=Object.
|
|
701
703
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
702
704
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
703
705
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
704
|
-
function
|
|
705
|
-
", ")}.`)}function
|
|
706
|
-
must define ${n} as a boolean.`)}function
|
|
707
|
-
eration "${t}" must be an object.`);return
|
|
708
|
-
pplyDefaults"),
|
|
706
|
+
function ki(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(
|
|
707
|
+
", ")}.`)}function Nn(t,e,n,r=!0){let o=e[n];if(!(o===void 0&&!r)&&typeof o!="boolean")throw new Error(`Operation "${t}"\
|
|
708
|
+
must define ${n} as a boolean.`)}function Ml(t,e){if(typeof e!="object"||e===null||Array.isArray(e))throw new Error(`Op\
|
|
709
|
+
eration "${t}" must be an object.`);return ki(t,e,"targetFields",["schema","input"]),Nn(t,e,"enforceRequired"),Nn(t,e,"a\
|
|
710
|
+
pplyDefaults"),ki(t,e,"outputFields",["validated","input"]),Nn(t,e,"rejectExplicitUndefined",!1),Object.freeze({targetFields:e.
|
|
709
711
|
targetFields,enforceRequired:e.enforceRequired,applyDefaults:e.applyDefaults,outputFields:e.outputFields,rejectExplicitUndefined:e.
|
|
710
|
-
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function
|
|
712
|
+
rejectExplicitUndefined===void 0?!0:e.rejectExplicitUndefined})}function jl(t={}){if(typeof t!="object"||t===null||Array.
|
|
711
713
|
isArray(t))throw new Error("Schema operations must be an object.");let e=Object.create(null);for(let[n,r]of Object.entries(
|
|
712
|
-
|
|
713
|
-
null);for(let[n,r]of Object.entries(t))_(e,n,r);return Object.freeze(e)}function
|
|
714
|
-
delete e.mode,e}var
|
|
715
|
-
operations=
|
|
714
|
+
Nl))_(e,n,r);for(let[n,r]of Object.entries(t))_(e,n,Ml(n,r));return Object.freeze(e)}function Ni(t){let e=Object.create(
|
|
715
|
+
null);for(let[n,r]of Object.entries(t))_(e,n,r);return Object.freeze(e)}function Dl(t){let e={...t};return delete e.operation,
|
|
716
|
+
delete e.mode,e}var Je=class{constructor(e,n,r,o={}){yn(e),this.structure=e,this.types=Ni(n),this.validators=Ni(r),this.
|
|
717
|
+
operations=jl(o),this._installOperationMethods()}_typeError(e){return this._paramError(e,"TYPE_CAST_FAILED","Value could\
|
|
716
718
|
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,
|
|
717
719
|
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){
|
|
718
720
|
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){
|
|
@@ -723,50 +725,50 @@ tion"))throw new Error("Unsupported validation option `operation`. Call `validat
|
|
|
723
725
|
.")}_buildOperationSettings(e,n,r){return{operationName:e,operation:n,targetFieldNames:n.targetFields==="input"?Object.keys(
|
|
724
726
|
r):Object.keys(this.structure),outputFieldNames:n.outputFields==="input"?Object.keys(r):Object.keys(this.structure),enforceRequired:n.
|
|
725
727
|
enforceRequired,applyDefaults:n.applyDefaults,rejectExplicitUndefined:n.rejectExplicitUndefined,defaultedFields:new Set,
|
|
726
|
-
isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(
|
|
728
|
+
isFieldPresent:o=>Object.hasOwn(r,o)}}_assertPlainObjectInput(e,n){if(!$(n))throw new Error(`${e}() expects a plain obje\
|
|
727
729
|
ct input.`)}_resolvePathValidationRequest(e={}){let n=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
728
730
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
729
731
|
oth are provided.");if(!Object.hasOwn(this.operations,n))throw new Error(`Unknown operation "${n}".`);let r=this.operations[n];
|
|
730
|
-
return{operationName:n,operation:r,validationOptions:
|
|
732
|
+
return{operationName:n,operation:r,validationOptions:Dl(e)}}_buildOperationResult(e,n,r){let o={};for(let s of r.outputFieldNames){
|
|
731
733
|
if(!Object.hasOwn(this.structure,s))continue;let i=r.isFieldPresent(s);(n[s]!==void 0||i&&e[s]===null||r.defaultedFields.
|
|
732
|
-
has(s))&&(!i&&!r.defaultedFields.has(s)||_(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return
|
|
733
|
-
return
|
|
734
|
+
has(s))&&(!i&&!r.defaultedFields.has(s)||_(o,s,n[s]))}return o}_resolveObjectFieldMode(e,n){return nr(e,n)}_resolveArrayItemsConfig(e,n){
|
|
735
|
+
return rr(e,n)}_resolveObjectValuesConfig(e,n){return vt(e,n)}_buildArrayItemSettings(e,n){return e.type==="object"&&Object.
|
|
734
736
|
hasOwn(e,"schema")?{...n,operationName:"replace",operation:this.operations.replace}:n}_castValue(e,n,r,o,s,i,a,c){let d=e.
|
|
735
|
-
nullable===!0||a.nullable===!0,
|
|
737
|
+
nullable===!0||a.nullable===!0,u=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
736
738
|
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(n===null)return d?(_(o,s,null),{errors:{},shouldContinue:!1}):
|
|
737
739
|
{errors:this._singleErrorMap({field:r,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
738
|
-
if(n===""&&
|
|
740
|
+
if(n===""&&u)return _(o,s,null),{errors:{},shouldContinue:!1};let p={schema:this,definition:e,value:n,fieldName:r,object:o,
|
|
739
741
|
objectBeforeCast:i,valueBeforeCast:n,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
740
|
-
nullable:d||
|
|
741
|
-
r,v,
|
|
742
|
-
s,v),
|
|
743
|
-
errors:{},context:
|
|
742
|
+
nullable:d||u,nullOnEmpty:u},throwTypeError:()=>{throw this._typeError(r)},throwParamError:(v,y,T)=>{throw this._paramError(
|
|
743
|
+
r,v,y,T)}};try{let v=m(p);if(Ai(v))throw new Error(`Type handler for "${e.type}" must be synchronous.`);v!==void 0&&(_(o,
|
|
744
|
+
s,v),p.value=v)}catch(v){if(v.errorObject)return{errors:this._singleErrorMap(v.errorObject),shouldContinue:!1};throw v}return{
|
|
745
|
+
errors:{},context:p,shouldContinue:!0}}_runFieldValidators(e,n,r,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
744
746
|
_paramToBeSkipped(a,i.skipParams,n)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
745
|
-
a,s.parameterValue=e[a];let d=c(s);if(
|
|
747
|
+
a,s.parameterValue=e[a];let d=c(s);if(Ai(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
746
748
|
(_(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){
|
|
747
749
|
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{
|
|
748
|
-
context:
|
|
749
|
-
e,r,o,s,
|
|
750
|
+
context:u}=d,m=this._validateNestedValue(e,r,o,s,a,c);return Object.keys(m).length>0?m:(u.value=o[s],this._runFieldValidators(
|
|
751
|
+
e,r,o,s,u,a))}_normalizeDefault(e,n,{fieldPath:r,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
750
752
|
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){
|
|
751
753
|
if(e.type==="object"){let c=this._resolveObjectFieldMode(n,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
752
754
|
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.
|
|
753
755
|
_resolveArrayItemsConfig(n,e);return a?this._validateArrayItems(n,r,o,a,s,i):{}}_validateNestedObjectSchema(e,n,r,o,s,i){
|
|
754
756
|
let a=r[o],c=e.allowAdditionalProperties?this._extractKnownObjectFields(a,e.schema):a,d=e.schema._validateWithOperation(
|
|
755
|
-
i.operationName,i.operation,c
|
|
756
|
-
a,e.schema,d.validatedObject):d.validatedObject),
|
|
757
|
+
i.operationName,i.operation,c,Ke(s,n));return _(r,o,e.allowAdditionalProperties?this._mergeKnownAndPassthroughObjectFields(
|
|
758
|
+
a,e.schema,d.validatedObject):d.validatedObject),We(d.errors,n)}_extractKnownObjectFields(e,n){let r={};for(let[o,s]of Object.
|
|
757
759
|
entries(e))Object.hasOwn(n.structure,o)&&_(r,o,s);return r}_mergeKnownAndPassthroughObjectFields(e,n,r){let o={};for(let s of Object.
|
|
758
760
|
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
|
|
760
|
-
keys(a)){let m=
|
|
761
|
-
_mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[
|
|
762
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,
|
|
763
|
-
d,
|
|
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
|
|
765
|
-
c.length;
|
|
766
|
-
this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[
|
|
767
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[
|
|
768
|
-
d,
|
|
769
|
-
o.definition,i));this._mergeErrors(d,
|
|
761
|
+
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 u of Object.
|
|
762
|
+
keys(a)){let m=Re(e,u);if(this._fieldToBeSkipped(m,s))continue;let p=c[u];if(p===void 0){i.rejectExplicitUndefined?this.
|
|
763
|
+
_mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[u];continue}if(o.kind==="schema"){let y=o.
|
|
764
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,p,Ke(s,m));_(c,u,y.validatedObject),this._mergeErrors(
|
|
765
|
+
d,We(y.errors,m));continue}let v=this._normalizeAndValidateValue(o.definition,p,m,c,u,a,s,this._buildArrayItemSettings(o.
|
|
766
|
+
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 u=0;u<
|
|
767
|
+
c.length;u++){let m=Re(e,u);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,u)||c[u]===void 0){i.rejectExplicitUndefined?
|
|
768
|
+
this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[u];continue}if(o.kind==="schema"){let v=o.
|
|
769
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[u],Ke(s,m));_(c,u,v.validatedObject),this._mergeErrors(
|
|
770
|
+
d,We(v.errors,m));continue}let p=this._normalizeAndValidateValue(o.definition,c[u],m,c,u,a,s,this._buildArrayItemSettings(
|
|
771
|
+
o.definition,i));this._mergeErrors(d,p)}return d}_validateField(e,n,r,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
770
772
|
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&&
|
|
771
773
|
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
772
774
|
Field is required",params:{}}):a?d?s.rejectExplicitUndefined?this._singleErrorMap(this._typeError(e).errorObject):{}:this.
|
|
@@ -774,90 +776,90 @@ _normalizeAndValidateValue(i,c,e,r,e,n,o,s):{}}_validateWithOperation(e,n,r,o){t
|
|
|
774
776
|
i={...r},a=this._buildOperationSettings(e,n,r);for(let c of Object.keys(r))Object.hasOwn(this.structure,c)||_(s,c,{field:c,
|
|
775
777
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
776
778
|
c,r,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
777
|
-
this.structure[c].defaultTo!==void 0){let d=this.structure[c],
|
|
778
|
-
m=this._normalizeDefault(d,
|
|
779
|
+
this.structure[c].defaultTo!==void 0){let d=this.structure[c],u=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
780
|
+
m=this._normalizeDefault(d,u,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:r,options:o,settings:a});if(this.
|
|
779
781
|
_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
|
|
781
|
-
let d=
|
|
782
|
-
c,e[c],n,a,r,o,d);this._mergeErrors(i,
|
|
783
|
-
hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,
|
|
784
|
-
let m=Object.hasOwn(r,e),
|
|
782
|
+
_buildOperationResult(r,i,a),errors:s}}_validateSelectedTree(e,n,r,o,s=""){let i={},a={};for(let c of Pi(Object.keys(e))){
|
|
783
|
+
let d=Mi(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let u=this._validateSelectedField(
|
|
784
|
+
c,e[c],n,a,r,o,d);this._mergeErrors(i,u)}return{validatedObject:a,errors:i}}_validateSelectedField(e,n,r,o,s,i,a){if(!Object.
|
|
785
|
+
hasOwn(this.structure,e))return{};let c=this.structure[e],d=n.self===!0,u=Ei(n);if(this._fieldToBeSkipped(a,s))return{};
|
|
786
|
+
let m=Object.hasOwn(r,e),p=r[e],v={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
785
787
|
a)&&this._mergeErrors(v,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
786
|
-
c.defaultTo!==void 0){let
|
|
787
|
-
currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,
|
|
788
|
-
length===0&&_(o,e,
|
|
789
|
-
a).errorObject):{};let
|
|
790
|
-
|
|
788
|
+
c.defaultTo!==void 0){let N=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,z=this._normalizeDefault(c,N,{fieldPath:a,
|
|
789
|
+
currentObject:o,containerKey:e,objectBeforeCast:r,options:s,settings:i});this._mergeErrors(v,z.errors),Object.keys(z.errors).
|
|
790
|
+
length===0&&_(o,e,z.value)}return v}if(p===void 0)return d&&i.rejectExplicitUndefined?this._singleErrorMap(this._typeError(
|
|
791
|
+
a).errorObject):{};let y={[e]:p};if(d){let N=this._normalizeAndValidateValue(c,p,a,y,e,r,s,i);return Object.hasOwn(y,e)&&
|
|
792
|
+
y[e]!==void 0?_(o,e,y[e]):y[e]===null&&_(o,e,null),N}if(!u)return{};let T=this._castValue(c,p,a,y,e,r,s,i);if(Object.keys(
|
|
791
793
|
T.errors).length>0)return T.errors;if(!T.shouldContinue)return{};let O=this._validateSelectedDescendants(c,n.children,a,
|
|
792
|
-
|
|
793
|
-
r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(
|
|
794
|
-
d))return{};let
|
|
795
|
-
|
|
794
|
+
y,e,s,i);return ar(y[e])&&_(o,e,y[e]),O}_validateSelectedDescendants(e,n,r,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
795
|
+
r,e);if(c.kind!=="nested")throw new Error(`Schema path "${r}" does not support nested field selection.`);let d=o[s];if(!$(
|
|
796
|
+
d))return{};let u=c.schema._validateSelectedTree(n,d,Ke(i,r),{...a,defaultedFields:new Set});return _(o,s,u.validatedObject),
|
|
797
|
+
We(u.errors,r)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(r,e);if(!c)throw new Error(`Schema path "${r}" d\
|
|
796
798
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(r,o,s,c,n,i,a)}throw new Error(
|
|
797
799
|
`Schema path "${r}" does not support nested field selection.`)}_validateSelectedArrayItems(e,n,r,o,s,i,a){let c=[],d=n[r],
|
|
798
|
-
|
|
799
|
-
id because array segments must use numeric indexes.`);let
|
|
800
|
-
v,i))continue;if(!Object.hasOwn(d,
|
|
801
|
-
if(
|
|
802
|
-
let
|
|
803
|
-
this._mergeErrors(
|
|
804
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});
|
|
805
|
-
this._mergeErrors(
|
|
806
|
-
o.definition,
|
|
807
|
-
continue}if(!O)continue;let
|
|
808
|
-
|
|
809
|
-
i,
|
|
800
|
+
u={};_(n,r,c);for(let m of Pi(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${Re(e,m)}" is inval\
|
|
801
|
+
id because array segments must use numeric indexes.`);let p=Number(m),v=Re(e,p),y=s[m],T=y.self===!0,O=Ei(y);if(this._fieldToBeSkipped(
|
|
802
|
+
v,i))continue;if(!Object.hasOwn(d,p)){T&&a.rejectExplicitUndefined&&_(u,v,this._typeError(v).errorObject);continue}let N=d[p];
|
|
803
|
+
if(N===void 0){T&&a.rejectExplicitUndefined&&_(u,v,this._typeError(v).errorObject);continue}if(o.kind==="schema"){if(T){
|
|
804
|
+
let P=o.schema._validateWithOperation("replace",o.schema.operations.replace,N,Ke(i,v));ar(P.validatedObject)&&_(c,p,P.validatedObject),
|
|
805
|
+
this._mergeErrors(u,We(P.errors,v));continue}if(!O)continue;let R=o.schema._validateSelectedTree(y.children,N,Ke(i,v),{...a,
|
|
806
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});ar(R.validatedObject)&&_(c,p,R.validatedObject),
|
|
807
|
+
this._mergeErrors(u,We(R.errors,v));continue}let z=this._buildArrayItemSettings(o.definition,a),L=[N];if(T){let R=this._normalizeAndValidateValue(
|
|
808
|
+
o.definition,N,v,L,0,d,i,z);Object.hasOwn(L,0)&&L[0]!==void 0?_(c,p,L[0]):L[0]===null&&_(c,p,null),this._mergeErrors(u,R);
|
|
809
|
+
continue}if(!O)continue;let q=this._castValue(o.definition,N,v,L,0,d,i,z);if(Object.keys(q.errors).length>0){this._mergeErrors(
|
|
810
|
+
u,q.errors);continue}if(!q.shouldContinue)continue;let H=this._validateSelectedDescendants(o.definition,y.children,v,L,0,
|
|
811
|
+
i,z);ar(L[0])&&_(c,p,L[0]),this._mergeErrors(u,H)}return u}validateWith(e,n,r={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
810
812
|
`Unknown operation "${e}".`);let o=this.operations[e];return this._assertPlainObjectInput(e,n),this._validateWithOperation(
|
|
811
|
-
e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=
|
|
812
|
-
_resolvePathValidationRequest(r),c=this._validateSelectedTree(
|
|
813
|
+
e,o,n,r)}validateAt(e,n,r={}){this._assertPlainObjectInput("validateAt",n);let o=Mn(e),{operationName:s,operation:i,validationOptions:a}=this.
|
|
814
|
+
_resolvePathValidationRequest(r),c=this._validateSelectedTree(Ri([e]),n,a,this._buildOperationSettings(s,i,n));return{validatedValue:Rl(
|
|
813
815
|
c.validatedObject,o),errors:c.errors}}validatePaths(e,n,r={}){if(this._assertPlainObjectInput("validatePaths",n),!Array.
|
|
814
816
|
isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty array of schema paths.");let{operationName:o,
|
|
815
|
-
operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(
|
|
817
|
+
operation:s,validationOptions:i}=this._resolvePathValidationRequest(r);return this._validateSelectedTree(Ri(e),n,i,this.
|
|
816
818
|
_buildOperationSettings(o,s,n))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
817
819
|
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(n,r={})=>this.validateWith(e,n,r)}}toJsonSchema(e={}){
|
|
818
|
-
return
|
|
819
|
-
if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=
|
|
820
|
-
return n===null?null:
|
|
821
|
-
messages===null?Object.freeze({}):
|
|
822
|
-
o)&&this.structure[o][n]&&_(r,o,e[o]);return r}};var{parse:
|
|
823
|
-
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=
|
|
824
|
-
m;let
|
|
825
|
-
"object"||typeof t=="function")&&typeof t.then=="function"}function
|
|
820
|
+
return Ci(this,e)}getFieldDefinitions(){return kn.has(this)||kn.set(this,Pn(this.structure)),kn.get(this)}getFieldDefinition(e){
|
|
821
|
+
if(typeof e!="string"||e.trim()==="")throw new Error("Field path must be a non-empty string.");let n=jn(this,Mn(e.trim()));
|
|
822
|
+
return n===null?null:Pn(n)}getFieldMessages(e){let n=this.getFieldDefinition(e);return!n||typeof n.messages!="object"||n.
|
|
823
|
+
messages===null?Object.freeze({}):Pn(n.messages)}cleanup(e,n){let r={};for(let o of Object.keys(e))Object.hasOwn(this.structure,
|
|
824
|
+
o)&&this.structure[o][n]&&_(r,o,e[o]);return r}};var{parse:hb,stringify:zl}=JSON,{keys:gb}=Object,Ll=String,Ul="string";var Di="object",Fl=(t,e)=>e;var zi=(t,e,n)=>{let r=Ll(e.push(n)-1);return t.set(n,r),r};var Li=(t,e,n)=>{let r=e&&typeof e===Di?(u,m)=>u===""||-1<e.indexOf(u)?m:void 0:e||Fl,o=new Map,s=[],i=[],a=+zi(o,s,r.call(
|
|
825
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=zl(s[a++],d,n);return"["+i.join(",")+"]";function d(u,m){if(c)return c=!c,
|
|
826
|
+
m;let p=r.call(this,u,m);switch(typeof p){case Di:if(p===null)return p;case Ul:return o.get(p)||zi(o,s,p)}return p}};var $l=new Set(["true","1","yes","y","on"]),Bl=new Set(["false","0","no","n","off"]);function Hl(t){return t!==null&&(typeof t==
|
|
827
|
+
"object"||typeof t=="function")&&typeof t.then=="function"}function Ui(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
826
828
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
827
|
-
if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function
|
|
829
|
+
if(e==="")return null;let n=Number(e);return Number.isFinite(n)?n:null}return null}function zn(t,e){if(Object.is(t,e))return!0;
|
|
828
830
|
if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.
|
|
829
831
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
830
|
-
e.length)return!1;for(let o=0;o<t.length;o++)if(!
|
|
832
|
+
e.length)return!1;for(let o=0;o<t.length;o++)if(!zn(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
831
833
|
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let n=Object.keys(t),r=Object.keys(
|
|
832
|
-
e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!
|
|
834
|
+
e);if(n.length!==r.length)return!1;for(let o of n)if(!Object.hasOwn(e,o)||!zn(t[o],e[o]))return!1;return!0}var Vl={install(t){
|
|
833
835
|
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;
|
|
834
836
|
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),
|
|
835
837
|
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();
|
|
836
|
-
return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=
|
|
837
|
-
null&&r.throwTypeError(),o}),e("integer",r=>{let o=
|
|
838
|
-
o}),e("epochMilliseconds",r=>{let o=
|
|
839
|
-
r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=
|
|
840
|
-
value,o)||r.throwTypeError(),r.value}),e("date",r=>(
|
|
841
|
-
r.fieldName);return
|
|
842
|
-
r.value)?[r.value]:r.value),e("object",r=>(
|
|
843
|
-
r.value)}catch{try{return
|
|
838
|
+
return r.definition.noTrim?i:i.trim()}r.throwTypeError()}),e("blob",r=>r.value),e("number",r=>{let o=Ui(r.value);return o===
|
|
839
|
+
null&&r.throwTypeError(),o}),e("integer",r=>{let o=Ui(r.value);return(o===null||!Number.isInteger(o))&&r.throwTypeError(),
|
|
840
|
+
o}),e("epochMilliseconds",r=>{let o=Sn(r.value,864e13);return o===null&&r.throwTypeError(),o}),e("epochSeconds",r=>{let o=Sn(
|
|
841
|
+
r.value,864e10);return o===null&&r.throwTypeError(),o}),e("dateTime",r=>{let o=wt(r.definition,r.fieldName);return wi(r.
|
|
842
|
+
value,o)||r.throwTypeError(),r.value}),e("date",r=>(gi(r.value)||r.throwTypeError(),r.value)),e("time",r=>{let o=wt(r.definition,
|
|
843
|
+
r.fieldName);return vi(r.value,o)||r.throwTypeError(),r.value}),e("array",r=>r.definition.type==="array"&&!Array.isArray(
|
|
844
|
+
r.value)?[r.value]:r.value),e("object",r=>($(r.value)||r.throwTypeError(),r.value)),e("serialize",r=>{try{return JSON.stringify(
|
|
845
|
+
r.value)}catch{try{return Li(r.value)}catch{r.throwTypeError()}}}),e("boolean",r=>{if(typeof r.value=="boolean")return r.
|
|
844
846
|
value;if(typeof r.value=="number"){if(r.value===1)return!0;if(r.value===0)return!1;r.throwTypeError()}if(typeof r.value==
|
|
845
847
|
"bigint"){if(r.value===1n)return!0;if(r.value===0n)return!1;r.throwTypeError()}if(typeof r.value=="string"){let o=String(
|
|
846
848
|
r.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(r.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
847
|
-
i=r.value.trim().toLowerCase(),a=new Set([...
|
|
849
|
+
i=r.value.trim().toLowerCase(),a=new Set([...Bl,o]),c=new Set([...$l,s]);if(a.has(i))return!1;if(c.has(i))return!0}r.throwTypeError()}),
|
|
848
850
|
e("id",r=>{if(typeof r.value=="number"){if(Number.isSafeInteger(r.value)&&r.value>0)return r.value;r.throwTypeError()}if(typeof r.
|
|
849
851
|
value=="bigint"){if(r.value>0n&&r.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(r.value);r.throwTypeError()}if(typeof r.
|
|
850
852
|
value=="string"){let o=r.value.trim();/^[1-9][0-9]*$/.test(o)||r.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
851
853
|
s)||r.throwTypeError(),s}r.throwTypeError()}),n("minLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.
|
|
852
854
|
toString&&r.value.toString().length<r.parameterValue&&r.throwParamError("MIN_LENGTH",`Length must be at least ${r.parameterValue}\
|
|
853
|
-
characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&
|
|
855
|
+
characters.`,{min:r.parameterValue,actual:r.value.toString().length})}),n("min",r=>{r.value!==void 0&&Ve(r.definition)&&
|
|
854
856
|
typeof r.value=="number"&&r.value<r.parameterValue&&r.throwParamError("MIN_VALUE",`Value must be at least ${r.parameterValue}\
|
|
855
857
|
.`,{min:r.parameterValue,actual:r.value})}),n("maxLength",r=>{r.value!==void 0&&r.definition.type==="string"&&r.value.toString&&
|
|
856
858
|
r.value.toString().length>r.parameterValue&&r.throwParamError("MAX_LENGTH",`Length must be no more than ${r.parameterValue}\
|
|
857
|
-
characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&
|
|
859
|
+
characters.`,{max:r.parameterValue,actual:r.value.toString().length})}),n("max",r=>{r.value!==void 0&&Ve(r.definition)&&
|
|
858
860
|
typeof r.value=="number"&&r.value>r.parameterValue&&r.throwParamError("MAX_VALUE",`Value must be no more than ${r.parameterValue}\
|
|
859
861
|
.`,{max:r.parameterValue,actual:r.value})}),n("enum",r=>{if(!Array.isArray(r.parameterValue))throw new Error(`Enum for ${r.
|
|
860
|
-
fieldName} must be an array.`);r.parameterValue.some(s=>
|
|
862
|
+
fieldName} must be an array.`);r.parameterValue.some(s=>zn(s,r.value))||r.throwParamError("ENUM_VALUE","Value must match\
|
|
861
863
|
one of the allowed enum values.",{allowed:r.parameterValue})}),n("pattern",r=>{if(r.value===void 0||r.definition.type!==
|
|
862
864
|
"string"||typeof r.value!="string")return;let o=r.parameterValue,s=o instanceof RegExp?new RegExp(o.source,o.flags):typeof o==
|
|
863
865
|
"string"?new RegExp(o):null;if(!s)throw new Error(`Pattern for ${r.fieldName} must be a string or RegExp.`);s.test(r.value)||
|
|
@@ -865,7 +867,7 @@ r.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
865
867
|
parameterValue){if(r.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${r.
|
|
866
868
|
fieldName}).`);typeof r.valueBeforeCast!="boolean"&&r.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),n(
|
|
867
869
|
"validator",r=>{if(typeof r.parameterValue!="function")throw new Error(`Validator for ${r.fieldName} must be a function.`);
|
|
868
|
-
let o=r.parameterValue(r.value,r.object,r);if(
|
|
870
|
+
let o=r.parameterValue(r.value,r.object,r);if(Hl(o))throw new Error(`Custom validator for "${r.fieldName}" must be synch\
|
|
869
871
|
ronous.`);typeof o=="string"&&r.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),n("uppercase",r=>{if(typeof r.value=="str\
|
|
870
872
|
ing")return r.value.toUpperCase()}),n("lowercase",r=>{if(typeof r.value=="string")return r.value.toLowerCase()}),n("leng\
|
|
871
873
|
th",r=>{if(typeof r.value=="string")return r.value.substr(0,r.parameterValue);Number.isInteger(Number(r.valueBeforeCast))&&
|
|
@@ -877,74 +879,65 @@ r.throwParamError("MAX_ITEMS",`Must have no more than ${r.parameterValue} items.
|
|
|
877
879
|
n("notEmpty",r=>{r.parameterValue&&typeof r.value=="string"&&r.value===""&&r.throwParamError("NOT_EMPTY","Field cannot b\
|
|
878
880
|
e empty.")}),n("required",()=>{}),n("unsigned",()=>{}),n("precision",()=>{}),n("scale",()=>{}),n("temporalPrecision",r=>{
|
|
879
881
|
if(r.definition.type!=="time"&&r.definition.type!=="dateTime")throw new Error(`temporalPrecision can only be used on tim\
|
|
880
|
-
e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},
|
|
881
|
-
if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);_(t,e,n)}function
|
|
882
|
-
"function")throw new Error(`Validator handler for '${e}' must be a function.`);_(t,e,n)}function
|
|
883
|
-
null);for(let[n,r]of Object.entries(t))_(e,n,r);return e}function
|
|
884
|
-
"Plugin must have an install method.");t.install(e)}function
|
|
885
|
-
{value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
886
|
-
typeof t!="object"&&typeof t!="function")return null;let e=
|
|
882
|
+
e or dateTime fields (${r.fieldName}).`)}),n("nullable",()=>{}),n("nullOnEmpty",()=>{}),n("defaultTo",()=>{})}},Fi=Vl;var Hi=new WeakMap,Vi=new WeakMap,Gi=Symbol.for("json-rest-schema.registry-metadata"),ur=new WeakSet;function Gl(t,e,n){
|
|
883
|
+
if(typeof n!="function")throw new Error(`Type handler for '${e}' must be a function.`);_(t,e,n)}function Wl(t,e,n){if(typeof n!=
|
|
884
|
+
"function")throw new Error(`Validator handler for '${e}' must be a function.`);_(t,e,n)}function lr(t={}){let e=Object.create(
|
|
885
|
+
null);for(let[n,r]of Object.entries(t))_(e,n,r);return e}function qi(t,e){if(typeof t.install!="function")throw new Error(
|
|
886
|
+
"Plugin must have an install method.");t.install(e)}function $i(t,e,n){Hi.set(t,e),Vi.set(t,n),Object.defineProperty(t,Gi,
|
|
887
|
+
{value:Object.freeze({getTypes:()=>e,getValidators:()=>n}),enumerable:!1,configurable:!1,writable:!1})}function Kl(t){if(!t||
|
|
888
|
+
typeof t!="object"&&typeof t!="function")return null;let e=Hi.get(t),n=Vi.get(t);if(e&&n)return{types:e,validators:n};let r=t[Gi];
|
|
887
889
|
return r&&typeof r.getTypes=="function"&&typeof r.getValidators=="function"?{types:r.getTypes(),validators:r.getValidators()}:
|
|
888
890
|
typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.validators=="object"&&typeof t.create=="fu\
|
|
889
891
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
890
|
-
validators}:null}function
|
|
891
|
-
entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(
|
|
892
|
-
factories with conflicting ${n} "${r}".`)}_(t,r,o)}}function
|
|
893
|
-
types:
|
|
894
|
-
"Factory sources must be schema instances or schema factories created by json-rest-schema.");
|
|
895
|
-
validators,"validator")}return{types:o,validators:s}}function
|
|
896
|
-
t),o=
|
|
897
|
-
s.addValidator=(i,a)=>{
|
|
898
|
-
let a=
|
|
899
|
-
addType(i,a)},addValidator:(i,a)=>{
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
"
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
`${
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
(
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
"
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
ation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxValue"},PATTERN:{messageKey:"pattern",
|
|
940
|
-
code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.validation.field.enumValue"},FIELD_NOT_ALLOWED:{
|
|
941
|
-
messageKey:"additionalProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"valida\
|
|
942
|
-
tor",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"\
|
|
943
|
-
default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.not\
|
|
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:"\
|
|
892
|
+
validators}:null}function Jl(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Bi(t,e,n){for(let[r,o]of Object.
|
|
893
|
+
entries(e)){if(Object.hasOwn(t,r)&&t[r]!==o){if(ur.has(o))continue;if(!ur.has(t[r]))throw new Error(`Cannot merge schema\
|
|
894
|
+
factories with conflicting ${n} "${r}".`)}_(t,r,o)}}function Xl(t,e,n){let r=Jl(n).filter(Boolean);if(r.length<1)return{
|
|
895
|
+
types:lr(t),validators:lr(e)};let o=Object.create(null),s=Object.create(null);for(let i of r){let a=Kl(i);if(!a)throw new Error(
|
|
896
|
+
"Factory sources must be schema instances or schema factories created by json-rest-schema.");Bi(o,a.types,"type"),Bi(s,a.
|
|
897
|
+
validators,"validator")}return{types:o,validators:s}}function Wi({types:t={},validators:e={},installCore:n=!0}={}){let r=lr(
|
|
898
|
+
t),o=lr(e),s=(i,a={})=>{let c=new Je(i,r,o,a.operations);return $i(c,r,o),c};return $i(s,r,o),s.addType=(i,a)=>{Gl(r,i,a)},
|
|
899
|
+
s.addValidator=(i,a)=>{Wl(o,i,a)},s.use=i=>{qi(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{
|
|
900
|
+
let a=Xl(r,o,i);return Wi({types:a.types,validators:a.validators,installCore:!1})},n&&qi(Fi,{addType:(i,a)=>{ur.add(a),s.
|
|
901
|
+
addType(i,a)},addValidator:(i,a)=>{ur.add(a),s.addValidator(i,a)}}),s}var re=Wi({installCore:!0});function Pe(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let n of Object.getOwnPropertyNames(
|
|
902
|
+
t))Pe(t[n],e);return Object.freeze(t)}var Yl=new Set(["create","replace","patch"]),Zl=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.f\
|
|
903
|
+
ield.required"},TYPE_CAST_FAILED:{messageKey:"default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"\
|
|
904
|
+
default",code:"kernel.validation.field.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.mi\
|
|
905
|
+
nLength"},MAX_LENGTH:{messageKey:"maxLength",code:"kernel.validation.field.maxLength"},MIN_ITEMS:{messageKey:"minItems",
|
|
906
|
+
code:"kernel.validation.field.minItems"},MAX_ITEMS:{messageKey:"maxItems",code:"kernel.validation.field.maxItems"},MIN_VALUE:{
|
|
907
|
+
messageKey:"min",code:"kernel.validation.field.minValue"},MAX_VALUE:{messageKey:"max",code:"kernel.validation.field.maxV\
|
|
908
|
+
alue"},PATTERN:{messageKey:"pattern",code:"kernel.validation.field.pattern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.\
|
|
909
|
+
validation.field.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additionalProperties",code:"kernel.validation.field.notAllow\
|
|
910
|
+
ed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"validator",code:""},STRICT_BOOLEAN:{messageKey:"default",code:"kernel.validati\
|
|
911
|
+
on.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"default",code:"kernel.validation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"\
|
|
912
|
+
default",code:"kernel.validation.field.notEmpty"}}),Ql=Object.freeze({code:"kernel.validation.invalid",message:"Invalid \
|
|
913
|
+
value."}),ep=Object.freeze(["create","replace","patch","toJsonSchema"]);function pr(t){return!!t&&typeof t=="object"&&ep.
|
|
914
|
+
every(e=>typeof t[e]=="function")}function Ji(t=null,{defaultMode:e="create",context:n="schema definition.mode"}={}){let r=K(t),o=w(e).toLowerCase()||"cre\
|
|
915
|
+
ate",s=Object.prototype.hasOwnProperty.call(r,"mode")?w(r.mode).toLowerCase():"";if(!s)return o;if(!Yl.has(s))throw new TypeError(
|
|
916
|
+
`${n} must be one of: create, replace, patch.`);return s}function Xi(t=null,e=""){let n=w(e);if(!n)return{};let r=K(t);return pr(r.schema)?K(r.schema.getFieldMessages(n)):{}}function tp(t=null,e=""){
|
|
917
|
+
let n=w(e).split(".").filter(Boolean);return n.length<2?{}:(n.pop(),Xi(t,n.join(".")))}function Ki(t,e){let n=e?t[e]:void 0;
|
|
918
|
+
if(typeof n=="string"){let s=w(n);return s?{message:s}:null}if(!x(n))return null;let r=w(n.message);if(!r)return null;let o=w(
|
|
919
|
+
n.code);return o?{message:r,code:o,params:K(n.params)}:{message:r}}function rp(t,e,n=null){let r=w(e?.code).toUpperCase(),
|
|
920
|
+
o=Zl[r]||{},s=K(e?.params),i=Xi(n,t),a=r==="FIELD_NOT_ALLOWED"&&Object.keys(i).length<1?tp(n,t):i,c=Ki(a,o.messageKey)||
|
|
921
|
+
Ki(a,"default");if(c)return c.code?{message:c.message,code:c.code,params:{...s,...c.params}}:{message:c.message};let d=w(
|
|
922
|
+
e?.message);if(d)return o.code?{message:d,code:o.code,params:s}:{message:d};let u=w(e?.code);return u?{message:u}:{...Ql,
|
|
923
|
+
params:{}}}function Ln(t={},e=null){let n=K(t),r={},o={};for(let[s,i]of Object.entries(n)){let a=w(s);if(!a)continue;if(typeof i==
|
|
924
|
+
"string"){r[a]=i;continue}let{message:c,code:d,params:u}=rp(a,i,e);r[a]=c,d&&(o[a]={code:d,params:u})}return{fieldErrors:r,
|
|
925
|
+
fieldErrorCodes:o}}function np(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&(Object.prototype.hasOwnProperty.call(t,"schema")||Object.
|
|
926
|
+
prototype.hasOwnProperty.call(t,"mode"))}function Xe(t,{context:e="schema definition",defaultMode:n=""}={}){if(t==null)return null;
|
|
927
|
+
if(!np(t))throw new TypeError(`${e} must be a schema definition object.`);let r=K(t);if(!Object.prototype.hasOwnProperty.
|
|
928
|
+
call(r,"schema"))throw new TypeError(`${e}.schema is required.`);if(!pr(r.schema))throw new TypeError(`${e}.schema must \
|
|
929
|
+
be a json-rest-schema schema instance.`);let o={schema:r.schema},s=w(n).toLowerCase();return o.mode=Ji(r,{defaultMode:s||
|
|
930
|
+
"patch",context:`${e}.mode`}),Object.freeze(o)}function Un(t,e,{context:n="schema definition",defaultMode:r=""}={}){let o=Xe(t,{context:n,defaultMode:r});return o?o.schema[o.
|
|
931
|
+
mode](e):null}var op=re({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),sp=Object.freeze({schema:op,
|
|
932
|
+
mode:"patch"});var Yi=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),ip=Object.freeze(
|
|
933
|
+
{...Yi,nullable:!0});var Zi="Schema validation failed.";function Qi({message:t=Zi,fieldErrors:e=null,fieldErrorCodes:n=null,errors:r=null,cause:o,
|
|
934
|
+
statusCode:s=null}={}){let i=new Error(t,o?{cause:o}:void 0);if(t===Zi&&(i.messageCode="kernel.validation.schemaFailed",
|
|
935
|
+
i.messageParams={}),Number.isInteger(s)&&s>=400&&s<=599&&(i.statusCode=s),x(e)){let a=x(n)&&Object.keys(n).length>0?n:null;
|
|
936
|
+
i.fieldErrors=e,a&&(i.fieldErrorCodes=a),i.details={...i.details||{},fieldErrors:e,...a?{fieldErrorCodes:a}:{}}}else r!=
|
|
937
|
+
null&&(i.details={...i.details||{},errors:r});return i}function It(t,e,{phase:n="input",context:r="schema definition",statusCode:o=null}={}){
|
|
938
|
+
if(t==null)return e;let s=Un(t,e,{defaultMode:n==="output"?"replace":"patch",context:r}),{fieldErrors:i,fieldErrorCodes:a}=Ln(
|
|
939
|
+
s.errors,t);if(Object.keys(i).length>0)throw Qi({fieldErrors:i,fieldErrorCodes:a,statusCode:o});return s.validatedObject??
|
|
940
|
+
e}var iT=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
|
|
948
941
|
minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
|
|
949
942
|
m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
|
|
950
943
|
kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
|
|
@@ -956,62 +949,211 @@ additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems
|
|
|
956
949
|
perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
|
|
957
950
|
kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
|
|
958
951
|
ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
|
|
959
|
-
t,e]));var
|
|
960
|
-
...
|
|
961
|
-
itive integer string."}}}}),mode:"patch"});
|
|
962
|
-
|
|
952
|
+
t,e]));var ea="^[1-9][0-9]*$",Fn=Pe({type:"string",minLength:1,pattern:ea}),ap=Pe({...Fn,nullable:!0}),cp=Pe({schema:re({recordId:{
|
|
953
|
+
...Fn,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
|
|
954
|
+
itive integer string."}}}}),mode:"patch"});function ye(t){let e=Array.isArray(t)?t:[t],n=new Set;for(let r of e){let o=w(r);o&&n.add(o)}return[...n]}function ta(t=[],e=""){
|
|
955
|
+
let n=w(e);if(!n)return!0;let r=ye(t);if(r.includes("*")||r.includes(n))return!0;for(let o of r){if(!o.endsWith(".*"))continue;
|
|
956
|
+
let s=o.slice(0,-2);if(s&&n.startsWith(`${s}.`))return!0}return!1}function qn(t,e,n){if(t==="all"){let r=e.find(o=>!ta(n,
|
|
957
|
+
o));return r===void 0?null:{permission:r}}return e.some(r=>ta(n,r))?null:{requiredPermissions:e}}var St=/^[a-z][a-z0-9_.-]*$/u,lp=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function pp(t){return String(t||"").trim().toLowerCase()}
|
|
958
|
+
function Bn(t,e){let n=pp(t);if(!St.test(n))throw new TypeError(`${e} must match ${St.toString()}.`);return n}function fr(t,e){
|
|
959
|
+
if(t==null)return Object.freeze({});if(!x(t))throw new TypeError(`${e} must be an object mapping local names to capabili\
|
|
960
|
+
ty ids.`);let n={},r=new Set;for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!lp.test(i))throw new TypeError(
|
|
961
|
+
`${e} local name "${i}" must be a JavaScript identifier.`);let a=Bn(s,`${e}.${i}`);if(r.has(a))throw new TypeError(`${e}\
|
|
962
|
+
declares capability "${a}" more than once.`);r.add(a),n[i]=a}return Object.freeze(n)}function fp(t,e,n){if(t==null)return Object.
|
|
963
|
+
freeze({});if(!x(t))throw new TypeError(`${n}.hints must be an object mapping required capability ids to what to registe\
|
|
964
|
+
r.`);let r=new Set(Object.values(e)),o={};for(let[s,i]of Object.entries(t)){let a=Bn(s,`${n}.hints key`);if(!r.has(a))throw new TypeError(
|
|
965
|
+
`${n}.hints names "${a}", which the provider does not require.`);if(typeof i!="string"||!i.trim())throw new TypeError(`${n}\
|
|
966
|
+
.hints["${a}"] must be the text that says what to register.`);o[a]=i.trim()}return Object.freeze(o)}function mp(t){let e=new Map;
|
|
967
|
+
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}\
|
|
968
|
+
" is declared by both ${e.get(o)} and ${n}.`);e.set(o,n)}}function hp(t,e,n){for(let r of Object.values(e))for(let[o,s]of Object.
|
|
969
|
+
entries(n))if(Object.values(s).includes(r))throw new TypeError(o==="provides"?`Provider "${t}" cannot late-require capab\
|
|
970
|
+
ility "${r}" that it provides.`:`Provider "${t}" names capability "${r}" under both late and ${o}.`)}function $n(t,e){if(t==
|
|
971
|
+
null)return null;if(typeof t!="function")throw new TypeError(`${e} must be a function when provided.`);return t}function Ye({
|
|
972
|
+
id:t,requires:e={},optional:n={},late:r={},provides:o={},hints:s={},setup:i,boot:a=null,shutdown:c=null}={}){let d=Bn(t,
|
|
973
|
+
"Provider id"),u=fr(e,`${d}.requires`),m=fr(n,`${d}.optional`),p=fr(r,`${d}.late`),v=fr(o,`${d}.provides`);mp({requires:u,
|
|
974
|
+
optional:m,late:p,provides:v}),hp(d,p,{provides:v,requires:u,optional:m});let y=$n(i,`${d}.setup`);if(!y)throw new TypeError(
|
|
975
|
+
`${d}.setup is required.`);return Object.freeze({id:d,requires:u,optional:m,late:p,provides:v,hints:fp(s,{...u,...p},d),
|
|
976
|
+
setup:y,boot:$n(a,`${d}.boot`),shutdown:$n(c,`${d}.shutdown`)})}var Hn=new WeakSet;function ra(t,e){return t===null||typeof t!="object"||Hn.has(t)||e.has(t)?!0:Object.isFrozen(t)?(e.add(
|
|
977
|
+
t),Reflect.ownKeys(t).every(n=>{let r=Object.getOwnPropertyDescriptor(t,n);return!Object.hasOwn(r,"value")||ra(r.value,e)})):
|
|
978
|
+
!1}function na(t){if(t===null||typeof t!="object"||Hn.has(t))return!0;if(!Object.isFrozen(t))return!1;let e=new Set;if(!ra(
|
|
979
|
+
t,e))return!1;for(let n of e)Hn.add(n);return!0}var gp=Object.freeze(["query","command","stream"]),ia=Object.freeze(["none","authenticated","all","any"]),vp=new Set(gp),
|
|
980
|
+
wp=new Set(ia),aa="create",ca=Object.freeze({required:!0,defaultMode:aa,refuseOneOf:!0}),J=class extends Error{constructor(e,n,r={}){
|
|
981
|
+
super(n),this.name="ActionRuntimeError",this.status=Number(e)||500,this.statusCode=this.status,this.code=String(r.code||
|
|
982
|
+
"ACTION_RUNTIME_ERROR"),this.params=r.params&&typeof r.params=="object"?{...r.params}:{},this.details=r.details,this.headers=
|
|
983
|
+
r.headers||{},this.cause=r.cause}};function da(t,{context:e="domain"}={}){let n=w(t).toLowerCase();if(!n)throw new Error(
|
|
984
|
+
`${e} is required.`);if(!St.test(n))throw new Error(`${e} must match ${St.toString()} (lowercase letters, digits, _, -, \
|
|
985
|
+
.).`);return n}function oa(t,e){let n=Array.isArray(t)?t:[],r=Array.from(new Set(n.map(o=>w(o).toLowerCase()).filter(Boolean)));
|
|
986
|
+
if(r.length<1)throw new Error(`Action definition ${e} must include at least one value.`);return r}function Vn(t){return t&&
|
|
987
|
+
typeof t.getFieldDefinitions=="function"?t.getFieldDefinitions():null}var sa=new WeakSet;function Gn(t,e,n=""){for(let[r,
|
|
988
|
+
o]of Object.entries(t))Wn(o,e,n?`${n}.${r}`:r)}function Wn(t,e,n){let r=Vn(t);if(r){Gn(r,e,n);return}if(x(t)){if(Object.
|
|
989
|
+
hasOwn(t,"oneOf"))throw new Error(`Action definition ${e} field "${n}" declares oneOf, which does not restrict its value\
|
|
990
|
+
; list the allowed values with enum.`);Gn(Vn(t.schema)||{},e,n),Object.hasOwn(t,"items")&&Wn(t.items,e,`${n}[]`),Object.
|
|
991
|
+
hasOwn(t,"values")&&Wn(t.values,e,`${n}.*`)}}function Kn(t,e,{required:n=!1,defaultMode:r="",refuseOneOf:o=!1}={}){if(t==
|
|
992
|
+
null){if(!n)return null;throw new Error(`Action definition ${e} is required.`)}if(Array.isArray(t))throw new Error(`Acti\
|
|
993
|
+
on definition ${e} must be a single schema definition.`);if(!x(t))throw new Error(`Action definition ${e} must be a json\
|
|
994
|
+
-rest-schema schema definition.`);let s;try{s=Xe(t,{context:`Action definition ${e}`,defaultMode:r})}catch(i){throw new Error(
|
|
995
|
+
i?.message||`Action definition ${e} is invalid.`)}return o&&!sa.has(s.schema)&&(Gn(Vn(s.schema)||{},e),na(s.schema)&&sa.
|
|
996
|
+
add(s.schema)),s}function yp(t,e){if(t==null)return Object.freeze({require:"none",permissions:Object.freeze([]),message:"",
|
|
997
|
+
code:""});if(!x(t))throw new Error(`Action definition "${e}" permission must be an object when provided.`);let n=w(t.require||
|
|
998
|
+
"authenticated").toLowerCase();if(!wp.has(n))throw new Error(`Action definition "${e}" permission.require must be one of\
|
|
999
|
+
: ${ia.join(", ")}.`);return Object.freeze({require:n,permissions:Object.freeze(ye(t.permissions)),message:w(t.message),
|
|
1000
|
+
code:w(t.code)})}function Ip(t){if(t==null)return Object.freeze({});if(!x(t))throw new Error("Action definition extensio\
|
|
1001
|
+
ns must be an object when provided.");return Object.freeze({...t})}function Sp(t,e){if(t==null)return Object.freeze([]);
|
|
1002
|
+
if(!Array.isArray(t))throw new Error(`Action definition "${e}" events must be an array.`);return Object.freeze(t.map((n,r)=>{
|
|
1003
|
+
if(typeof n!="function")throw new Error(`Action definition "${e}" events[${r}] must be a function.`);return n}))}function xp(t,{
|
|
1004
|
+
contributorId:e="",contributorDomain:n=""}={}){let r=t&&typeof t=="object"?t:{},o=w(r.id);if(!o)throw new Error("Action \
|
|
1005
|
+
definition id is required.");let s=V(r.version,{fallback:1}),i=da(r.domain||n,{context:`Action definition "${o}" domain`}),
|
|
1006
|
+
a=w(r.kind||"command").toLowerCase();if(!vp.has(a))throw new Error(`Action definition "${o}" has unsupported kind "${a}"\
|
|
1007
|
+
.`);let c=oa(r.channels,"channels"),d=oa(r.surfaces,"surfaces");if(Object.hasOwn(r,"idempotency"))throw new Error(`Actio\
|
|
1008
|
+
n definition "${o}" declares idempotency. Action definitions no longer declare idempotency.`);if(typeof r.execute!="func\
|
|
1009
|
+
tion")throw new Error(`Action definition "${o}" execute handler is required.`);if(r.checkInput!=null&&typeof r.checkInput!=
|
|
1010
|
+
"function")throw new Error(`Action definition "${o}" checkInput must be a function when provided.`);return Object.freeze(
|
|
1011
|
+
{id:o,version:s,domain:i,kind:a,channels:c,surfaces:d,input:Kn(r.input,"input",ca),output:Kn(r.output,"output",{defaultMode:"\
|
|
1012
|
+
replace"}),permission:yp(r.permission,o),extensions:Ip(r.extensions),events:Sp(r.events,o),checkInput:r.checkInput??null,
|
|
1013
|
+
execute:r.execute,contributorId:w(e)})}function bp(t){let e=t&&typeof t=="object"?t:{},n=w(e.contributorId);if(!n)throw new Error(
|
|
1014
|
+
"Action contributor contributorId is required.");let r=da(e.domain,{context:`Action contributor "${n}" domain`}),s=(Array.
|
|
1015
|
+
isArray(e.actions)?e.actions:[]).map(i=>xp(i,{contributorId:n,contributorDomain:r}));return Object.freeze({contributorId:n,
|
|
1016
|
+
domain:r,actions:Object.freeze(s)})}function Tp(t,e){let n=e.input(t);return n===t.input?t:Object.freeze({...t,input:Kn(
|
|
1017
|
+
n,"input",ca)})}function ua(t,e){let{contributorId:n,domain:r,actions:o}=bp(t);return Object.freeze({contributorId:n,domain:r,
|
|
1018
|
+
actions:Object.freeze(o.map(s=>Object.freeze({declared:s,definition:Tp(s,e)})))})}function Jn(t,e){return`${w(t)}@v${V(e,
|
|
1019
|
+
{fallback:1})}`}function la(t){return t?.requestMeta?.request||null}function pa(t,e){let n=e||la(t);return t?.actor||n?.user||null}function Xn(t,e){
|
|
1020
|
+
return Et(pa(t,e)?.id)}var JT=Object.freeze({schema:re({}),mode:"replace"});function fa(t){let e=t.fieldErrorCodes||t.details?.fieldErrorCodes;return{fieldErrors:t.fieldErrors||t.details?.fieldErrors,
|
|
1021
|
+
...x(e)?{fieldErrorCodes:e}:{}}}function Yn({details:t,cause:e}){return new J(400,"Validation failed.",{code:"ACTION_VAL\
|
|
1022
|
+
IDATION_FAILED",details:t,cause:e})}function ha(t,e){let n=ne(e.channel);if(!n||!t.channels.includes(n))throw new J(403,
|
|
1023
|
+
"Forbidden.",{code:"ACTION_CHANNEL_FORBIDDEN",details:{actionId:t.id,channel:n}})}function ga(t,e){let n=ne(e.surface),r=t.
|
|
1024
|
+
surfaces;if(!r.includes("*")&&(!n||!r.includes(n)))throw new J(403,"Forbidden.",{code:"ACTION_SURFACE_FORBIDDEN",details:{
|
|
1025
|
+
actionId:t.id,surface:n}})}function va(t,e){let{permission:n}=t,r=n.require;if(r==="none")return;if(Xn(e)==null)throw new J(
|
|
1026
|
+
401,n.message||"Authentication required.",{code:n.code||"ACTION_AUTHENTICATION_REQUIRED",details:{actionId:t.id}});if(r===
|
|
1027
|
+
"authenticated")return;let s=n.permissions;if(s.length<1)return;let i=qn(r,s,ye(e.permissions));if(i)throw new J(403,n.message||
|
|
1028
|
+
"Forbidden.",{code:n.code||"ACTION_PERMISSION_DENIED",details:{actionId:t.id,...i}})}function ma(t){return x(t?.fieldErrors)||
|
|
1029
|
+
x(t?.details?.fieldErrors)}async function wa(t,e){let n;try{n=It(t.input,e,{phase:"input",context:`Action ${t.id} input`})}catch(r){
|
|
1030
|
+
throw ma(r)?Yn({details:fa(r),cause:r}):r?.code==="ACTION_VALIDATION_FAILED"?r:Yn({details:{error:String(r?.message||"In\
|
|
1031
|
+
valid input.")},cause:r})}if(t.checkInput)try{await t.checkInput(n)}catch(r){throw ma(r)?Yn({details:fa(r),cause:r}):r}return n}
|
|
1032
|
+
async function ya(t,e){if(!t.output)return e;try{return It(t.output,e,{phase:"output",context:`Action ${t.id} output`})}catch(n){
|
|
1033
|
+
throw new Error("Action output validation failed.",{cause:n})}}var _p=Object.freeze(["requestId","commandId","ip","userAgent"]);function Ia(t={}){let e=t&&typeof t=="object"?t:{},n={...e,
|
|
1034
|
+
request:e.request||null};for(let r of _p)n[r]=w(e[r]);return n}function Cp(t){return x(t)?{...t}:null}function Ap(t){let e=Cp(t);return e?(e.id==null&&(e.id=null),e):null}function Ep(t){
|
|
1035
|
+
let e=t&&typeof t=="object"?t:{};return{now:e.now instanceof Date?e.now:new Date,timezone:w(e.timezone),locale:w(e.locale)}}
|
|
1036
|
+
var Op=new Set(["actor","permissions","surface","channel","requestMeta","timeMeta"]);function Rp(t={}){let e={...t};for(let n of Op)
|
|
1037
|
+
delete e[n];return e}var Pp=Symbol("jskit.actions.unloggedExecution");function Zn(t){return!(t&&typeof t=="object"&&t[Pp]===!0)}function kp(t){return ne(t)||"internal"}function mr(t={}){let e=t&&
|
|
1038
|
+
typeof t=="object"?t:{},n=Rp(e);return Object.freeze({...n,actor:Ap(e.actor),permissions:ye(e.permissions),surface:ne(e.
|
|
1039
|
+
surface),channel:kp(e.channel),requestMeta:Ia(e.requestMeta),timeMeta:Ep(e.timeMeta)})}async function Np(t,e,n){for(let r of e){let o=await r(n),s=Array.isArray(o)?o:[o];for(let i of s)i!=null&&await t.publish(
|
|
1040
|
+
i)}}function Sa(t,{definition:e,context:n,outcome:r,startedAt:o,errorCode:s=null}){Zn(n)&&t.debug({action:e.id,version:e.
|
|
1041
|
+
version,channel:n.channel,surface:n.surface,requestId:n.requestMeta.requestId||null,durationMs:Date.now()-o,outcome:r,errorCode:s},
|
|
1042
|
+
"action.execution")}async function Qn({definition:t,declared:e,input:n,context:r,deps:o,events:s,logger:i,policy:a}){let c=mr(
|
|
1043
|
+
r),d=Date.now();try{ha(t,c),ga(t,c),va(t,c);let u=await wa(t,n),m=await a.execute(Object.freeze({definition:e,input:u,context:c,
|
|
1044
|
+
run:(v,y)=>t.execute(v,y,o)})),p=await ya(t,m);return await Np(s,t.events,Object.freeze({definition:t,input:u,result:p,context:c})),
|
|
1045
|
+
Sa(i,{definition:t,context:c,outcome:"success",startedAt:d}),p}catch(u){throw Sa(i,{definition:t,context:c,outcome:"fail\
|
|
1046
|
+
ure",startedAt:d,errorCode:String(u?.code||"ACTION_EXECUTION_FAILED").trim()}),u}}function to(t,e){let n=new Map;for(let{definition:r}of e.actions){let o=Jn(r.id,r.version),s=t.get(o)??n.get(o);if(s)throw new Error(
|
|
1047
|
+
`Action definition "${o}" is duplicated between contributors "${s.contributorId}" and "${e.contributorId}".`);n.set(o,r)}
|
|
1048
|
+
return n}function Mp(t){let e=[],n=new Map,r=new Map,o=new Map;for(let s of t){for(let[i,a]of to(n,s))n.set(i,a);for(let{
|
|
1049
|
+
definition:i,declared:a}of s.actions)o.set(i,a),e.push(i),r.has(i.id)||r.set(i.id,[]),r.get(i.id).push(i)}for(let s of r.
|
|
1050
|
+
values())s.sort((i,a)=>a.version-i.version);return{definitions:Object.freeze(e),byVersionKey:n,byActionId:r,declaredByDefinition:o}}
|
|
1051
|
+
function jp(t){let e=Number(t);if(!Number.isInteger(e)||e<1)throw new J(400,"Validation failed.",{code:"ACTION_VERSION_I\
|
|
1052
|
+
NVALID",details:{fieldErrors:{version:"version must be an integer >= 1."},fieldErrorCodes:{version:{code:"kernel.action.\
|
|
1053
|
+
versionInvalid",params:{}}}}});return e}function eo(t,e,n){let r=String(e||"").trim();if(!r)throw new J(400,"Validation \
|
|
1054
|
+
failed.",{code:"ACTION_ID_REQUIRED",details:{fieldErrors:{actionId:"actionId is required."},fieldErrorCodes:{actionId:{code:"\
|
|
1055
|
+
kernel.action.idRequired",params:{}}}}});if(n==null){let a=t.byActionId.get(r)||[];if(a.length<1)throw new J(404,"Not fo\
|
|
1056
|
+
und.",{code:"ACTION_NOT_FOUND",details:{actionId:r}});return a[0]}let o=jp(n),s=Jn(r,o),i=t.byVersionKey.get(s);if(!i)throw new J(
|
|
1057
|
+
404,"Not found.",{code:"ACTION_NOT_FOUND",details:{actionId:r,version:o}});return i}function xa({contributors:t,events:e,
|
|
1058
|
+
logger:n,policy:r}){let o=Mp(t);async function s({actionId:d,version:u,input:m,context:p,deps:v}){let y=eo(o,d,u);return Qn(
|
|
1059
|
+
{definition:y,declared:o.declaredByDefinition.get(y),input:m,context:p,deps:v,events:e,logger:n,policy:r})}async function i({
|
|
1060
|
+
actionId:d,version:u,input:m,context:p,deps:v}){let y=eo(o,d,u);if(y.kind!=="stream")throw new J(400,"Validation failed.",
|
|
1061
|
+
{code:"ACTION_STREAM_KIND_REQUIRED",details:{actionId:y.id,version:y.version,kind:y.kind}});return Qn({definition:y,declared:o.
|
|
1062
|
+
declaredByDefinition.get(y),input:m,context:p,deps:v,events:e,logger:n,policy:r})}function a(){return o.definitions.slice()}
|
|
1063
|
+
function c(d,u=null){return eo(o,d,u)}return Object.freeze({execute:s,executeStream:i,listDefinitions:a,getDefinition:c})}var hr=Object.freeze({input(t){return t.input},execute({input:t,context:e,run:n}){return n(t,e)}});function Dp(t){if(!x(t))throw new TypeError("Event listener must be an object.");let e=String(t.id||"").trim();if(!e)throw new TypeError(
|
|
1064
|
+
"Event listener id is required.");if(typeof t.handle!="function")throw new TypeError(`Event listener "${e}" requires han\
|
|
1065
|
+
dle().`);if(t.matches!=null&&typeof t.matches!="function")throw new TypeError(`Event listener "${e}" matches must be a f\
|
|
1066
|
+
unction when provided.`);return Object.freeze({id:e,handle:t.handle,matches:t.matches??null})}function zp(t){if(!x(t))throw new TypeError(
|
|
1067
|
+
"Published event must be an object.");let e=String(t.type||"").trim();if(!e)throw new TypeError("Published event type is\
|
|
1068
|
+
required.");return Object.freeze({...t,type:e})}function xt(){let t=[],e=new Set;function n(i){let a=Dp(i);if(e.has(a.id))
|
|
1069
|
+
throw new Error(`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function r(i){let a=zp(i);
|
|
1070
|
+
for(let c of t)c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.
|
|
1071
|
+
freeze(t.map(i=>i.id))})}let s=Object.freeze({register:n,publish:r,diagnostics:o});return s}var ba=Object.freeze({debug(){},info(){},warn(){},error(){}});function Lp(t){if(!x(t))throw new TypeError("Action catalogue registration must be an action contributor object.");return t}
|
|
1072
|
+
function ro({events:t=xt(),logger:e=ba,policy:n=hr}={}){let r=[],o=[],s=new Set,i=new Map,a=null,c=!1;function d(R){if(c)
|
|
1073
|
+
throw new Error("Action catalogue registration is closed after discovery or execution begins.");let P=ua(Lp(R),n);for(let[
|
|
1074
|
+
A,M]of to(i,P))i.set(A,M);return r.push(P),H}function u({id:R,contribute:P}={}){if(c)throw new Error("Action catalogue r\
|
|
1075
|
+
egistration is closed after discovery or execution begins.");let A=String(R||"").trim();if(!A)throw new TypeError("Actio\
|
|
1076
|
+
n context contributor id is required.");if(typeof P!="function")throw new TypeError(`Action context contributor "${A}" r\
|
|
1077
|
+
equires contribute().`);if(s.has(A))throw new Error(`Action context contributor "${A}" is duplicated.`);return s.add(A),
|
|
1078
|
+
o.push(Object.freeze({id:A,contribute:P})),H}function m(){return c=!0,a??=xa({contributors:r,events:t,logger:e,policy:n}),
|
|
1079
|
+
a}function p(R,P){let A={...R};for(let[M,W]of Object.entries(x(P)?P:{}))M==="requestMeta"?A.requestMeta={...x(W)?W:{},...x(
|
|
1080
|
+
A.requestMeta)?A.requestMeta:{}}:Object.hasOwn(A,M)||(A[M]=W);return A}async function v({definition:R,input:P,context:A}){
|
|
1081
|
+
let M={...x(A)?A:{}};for(let W of o){let Ie=await W.contribute(Object.freeze({actionId:R?.id??null,version:R?.version??null,
|
|
1082
|
+
definition:R,input:Object.freeze({...x(P)?P:{}}),context:Object.freeze({...M})}));M=p(M,Ie)}return Object.freeze(M)}function y({
|
|
1083
|
+
actionId:R,version:P,input:A,context:M}){return v({definition:m().getDefinition(R,P),input:A,context:M})}async function T({
|
|
1084
|
+
input:R,context:P}={}){return c=!0,mr(await v({definition:null,input:R,context:P}))}async function O(R,P={}){let A=P&&typeof P==
|
|
1085
|
+
"object"?P:{},M=A.input&&typeof A.input=="object"?A.input:{},W=A.version==null?null:A.version,Ie=await y({actionId:A.actionId,
|
|
1086
|
+
version:W,input:M,context:A.context});return m()[R]({actionId:A.actionId,version:W,input:M,context:Ie,deps:x(A.deps)?A.deps:
|
|
1087
|
+
{}})}function N(R){return O("execute",R)}function z(R){return O("executeStream",R)}function L(){return m().listDefinitions()}
|
|
1088
|
+
function q(R,P=null){return m().getDefinition(R,P)}let H=Object.freeze({register:d,registerContextContributor:u,execute:N,
|
|
1089
|
+
executeStream:z,contextFor:T,listDefinitions:L,getDefinition:q});return H}var Up=Ye({id:"runtime.actions",requires:{events:"runtime.events",logger:"runtime.logger"},optional:{policy:"runtime.act\
|
|
1090
|
+
ions.policy"},provides:{actions:"runtime.actions"},setup({events:t,logger:e,policy:n}){return{actions:ro({events:t,logger:e,
|
|
1091
|
+
policy:n??hr})}}});var Ta="public";var qp="/api",_a=`${qp}/bootstrap`;function no(){let t=[],e=new Set,n=!1;function r({id:a,order:c=0,contribute:d}={}){if(n)throw new Error("Bootstrap regis\
|
|
1092
|
+
tration is closed after the first payload is resolved.");let u=w(a);if(!u)throw new TypeError("Bootstrap contributor id \
|
|
1093
|
+
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${u}" requires contribute().`);if(e.has(
|
|
1094
|
+
u))throw new Error(`Bootstrap contributor "${u}" is duplicated.`);return e.add(u),t.push(Object.freeze({id:u,order:Number.
|
|
1095
|
+
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){n=!0;let c={},d=t.map((u,m)=>({entry:u,index:m})).sort(
|
|
1096
|
+
(u,m)=>u.entry.order-m.entry.order||u.index-m.index).map(({entry:u})=>u);for(let u of d){let m=await u.contribute(Object.
|
|
1097
|
+
freeze({...x(a)?a:{},payload:Object.freeze({...c})}));c={...c,...x(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
|
|
1098
|
+
freeze({sealed:n,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:r,resolve:o,diagnostics:s});
|
|
1099
|
+
return i}var $p=Ye({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({http:t}){
|
|
1100
|
+
let e=no();return t.router.register("GET",_a,{auth:Ta,meta:{tags:["bootstrap"],summary:"Resolve app bootstrap payload"}},
|
|
1101
|
+
async(n,r)=>{r.code(200).send(await e.resolve({request:n,reply:r,query:n.query||{}}))}),{bootstrap:e}}});var Bp=Ye({id:"runtime.events",provides:{events:"runtime.events"},setup(){return{events:xt()}}});var Vp=8,$C=Object.freeze({notOffered:"This assistant does not keep unsaved tool calls out of what it saves, so it is no\
|
|
1102
|
+
t offered here.",discoveryOnly:"Only the discovery tools are offered here, and an unsaved action is never discoverable.",
|
|
1103
|
+
directLimit:`At most ${Vp} actions are offered directly beside action discovery.`});var Ca=20,Gp=32*1024,Aa=48*1024,oo=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
1104
|
+
execute:"assistant_action_execute"}),so=Object.freeze({type:"object",additionalProperties:!0}),Wp=Object.freeze({type:"o\
|
|
963
1105
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
964
1106
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
965
1107
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
966
|
-
limit:{type:"integer",minimum:1,maximum:
|
|
967
|
-
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:
|
|
1108
|
+
limit:{type:"integer",minimum:1,maximum:Ca,description:"Maximum compact matches to return."}}}),Kp=Object.freeze({type:"\
|
|
1109
|
+
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:Ca,items:{
|
|
968
1110
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
969
1111
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
970
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
971
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
1112
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),Jp=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
1113
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),Xp=Object.
|
|
972
1114
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
973
1115
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
974
|
-
string"},inputSchema:
|
|
975
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:
|
|
1116
|
+
string"},inputSchema:so,outputSchema:so}}),Yp=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
1117
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:so}}),Zp=Object.
|
|
976
1118
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
977
|
-
g"},version:{type:"integer",minimum:1},result:{}}}),
|
|
1119
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),Ea=Object.freeze([Object.freeze({name:oo.search,description:"Discove\
|
|
978
1120
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
979
1121
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
980
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
981
|
-
outputSchema:
|
|
982
|
-
e action before executing it.",parameters:
|
|
983
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
984
|
-
attachments:!1,tools:!1,nativeTools:!1});var
|
|
1122
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:Wp,
|
|
1123
|
+
outputSchema:Kp}),Object.freeze({name:oo.contract,description:"Load the exact input and output contract for one availabl\
|
|
1124
|
+
e action before executing it.",parameters:Jp,outputSchema:Xp}),Object.freeze({name:oo.execute,description:"Execute one a\
|
|
1125
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:Yp,outputSchema:Zp})]);var GC=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var CA=new Error("A later Stop or turn superseded this Claude frame.");var sf=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
|
|
1126
|
+
attachments:!1,tools:!1,nativeTools:!1});var OE=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
985
1127
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
986
|
-
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),
|
|
987
|
-
1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",
|
|
988
|
-
elper authentication is unavailable. Reconnect Codex and retry.");return
|
|
989
|
-
|
|
990
|
-
label:
|
|
991
|
-
ex_helper_auth_invalid`,`${
|
|
992
|
-
sha256:${
|
|
993
|
-
"hex")}`}function i(d=""){return
|
|
994
|
-
let
|
|
1128
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})}),RE=Object.freeze({});var sO=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexRuntime.js",import.meta.url).href;import{createHash as ja}from"node:crypto";import{open as _f}from"node:fs/promises";import Da from"node:path";var uo=1024*1024,Cf=256*1024,za=512,Af=128,Ef=16*1024;function lo({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
1129
|
+
1",secretNamespace:n="codex-auth-secret-v1"}={}){function r(d="",u="",{messageCode:m}={}){let p=new Error(b(u)||"Codex h\
|
|
1130
|
+
elper authentication is unavailable. Reconnect Codex and retry.");return p.code=b(d)||`${t}codex_helper_auth_unavailable`,
|
|
1131
|
+
b(u)?m&&(p.messageCode=m):p.messageCode="assistant.codex.helperAuthUnavailable",p.messageCode&&(p.messageParams={}),p}function o(d,{
|
|
1132
|
+
label:u="Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw r(`${t}cod\
|
|
1133
|
+
ex_helper_auth_invalid`,`${u} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",u=""){return`\
|
|
1134
|
+
sha256:${ja("sha256").update(`${e}\0`,"utf8").update(b(d),"utf8").update("\0","utf8").update(String(u||""),"utf8").digest(
|
|
1135
|
+
"hex")}`}function i(d=""){return ja("sha256").update(`${n}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){
|
|
1136
|
+
let u=null;try{u=await _f(d,"r");let m=await u.stat();if(!m.isFile()||m.size>uo)throw r(`${t}codex_helper_auth_invalid`,
|
|
995
1137
|
"The selected Codex authentication record is invalid. Reconnect Codex and retry.",{messageCode:"assistant.codex.authReco\
|
|
996
|
-
rdInvalid"});let
|
|
997
|
-
break;v+=T}if(v>
|
|
998
|
-
nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let
|
|
999
|
-
f8"));if(!
|
|
1138
|
+
rdInvalid"});let p=Buffer.alloc(uo+1),v=0;for(;v<p.length;){let{bytesRead:T}=await u.read(p,v,p.length-v,null);if(T===0)
|
|
1139
|
+
break;v+=T}if(v>uo)throw r(`${t}codex_helper_auth_invalid`,"The selected Codex authentication record is too large. Recon\
|
|
1140
|
+
nect Codex and retry.",{messageCode:"assistant.codex.authRecordTooLarge"});let y=JSON.parse(p.subarray(0,v).toString("ut\
|
|
1141
|
+
f8"));if(!x(y))throw new Error("invalid authentication record");return y}catch(m){throw m?.code?.startsWith?.(`${t}codex\
|
|
1000
1142
|
_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
|
|
1002
|
-
async function c(d={}){let
|
|
1143
|
+
onnect Codex and retry.",{messageCode:"assistant.codex.authRecordUnreadable"})}finally{await u?.close().catch(()=>null)}}
|
|
1144
|
+
async function c(d={}){let u=b(d.toolHomeSource);if(!u||!Da.isAbsolute(u))throw r(`${t}codex_helper_auth_unavailable`,"T\
|
|
1003
1145
|
he selected Codex account is unavailable. Reconnect Codex and retry.",{messageCode:"assistant.codex.accountUnavailable"});
|
|
1004
|
-
let m=await a(
|
|
1005
|
-
{},
|
|
1006
|
-
O=v.chatgpt_plan_type??v.plan_type,
|
|
1007
|
-
{accessToken:T,accountId:
|
|
1008
|
-
ikey","api_key"].includes(
|
|
1146
|
+
let m=await a(Da.join(u,".codex","auth.json")),p=b(m.auth_mode).toLowerCase();if(p==="chatgpt"){let v=x(m.tokens)?m.tokens:
|
|
1147
|
+
{},y=o(v.account_id,{label:"Codex account identity",maxLength:za}),T=o(v.access_token,{label:"Codex access token",maxLength:Cf}),
|
|
1148
|
+
O=v.chatgpt_plan_type??v.plan_type,N=O==null||O===""?"":o(O,{label:"Codex plan type",maxLength:Af});return Object.freeze(
|
|
1149
|
+
{accessToken:T,accountId:y,authMode:"chatgpt",identitySignature:s("chatgpt",y),planType:N,secretSignature:i(T)})}if(["ap\
|
|
1150
|
+
ikey","api_key"].includes(p)){let v=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:Ef});return Object.freeze({apiKey:v,
|
|
1009
1151
|
authMode:"apiKey",identitySignature:s("apiKey",v),secretSignature:i(v)})}throw r(`${t}codex_helper_auth_invalid`,"The se\
|
|
1010
1152
|
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
|
|
1153
|
+
ported"})}return Object.freeze({error:r,identitySignature:s,readRecord:a,readSelected:c})}var CO=Object.freeze({label:"Checking the Codex sign-in",operationId:"codex-auth-preflight"});var NO=lo().error;var nR=4*1024*1024;var fP=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
1012
1154
|
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
1013
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var
|
|
1014
|
-
ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var
|
|
1155
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var yP=2*1024*1024,IP=32*1024*1024,SP=2*1024*1024;var Uk=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var Vk=256*1024;var Gk=2*1024*1024;var Wk=Ea.map(({name:t,description:e,parameters:n})=>({type:"function",function:{name:t,description:e,parameters:n}}));var b0=Object.freeze({});var j0=Object.freeze([]);var em=Object.freeze({resolve(){throw new F(400,"File attachments are not configured for this conversation.",{code:"conv\
|
|
1156
|
+
ersation_attachments_not_configured",messageCode:"assistant.conversation.attachmentsNotConfigured"})}});var H0=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
|
|
1015
1157
|
r increase the limit.",messageCode:"assistant.conversation.apiHistoryLimit"},{message:"The model reached its output toke\
|
|
1016
1158
|
n limit before completing the answer. Increase maxOutputTokens in the conversation limits.",messageCode:"assistant.conve\
|
|
1017
1159
|
rsation.outputTokenLimit"},{message:"The model stream ended without confirming its application tool calls.",messageCode:"\
|
|
@@ -1030,21 +1172,21 @@ t be saved. Restore storage access and retry saving.",messageCode:"assistant.con
|
|
|
1030
1172
|
Conversation progress could not be saved. Restore access to its storage before continuing.",messageCode:"assistant.conve\
|
|
1031
1173
|
rsation.progressUnsaved"},{message:"The conversation request exceeded its time limit.",messageCode:"assistant.conversati\
|
|
1032
1174
|
on.requestTimedOut"},{message:"Work stopped.",messageCode:"assistant.conversation.workStopped"},{message:"Stopped by use\
|
|
1033
|
-
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var
|
|
1034
|
-
type:"string",maxLength:
|
|
1175
|
+
r.",messageCode:"assistant.conversation.stoppedByUser"}]);var Qe=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var RN=re({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Qe.text,required:!1},toolName:{
|
|
1176
|
+
type:"string",maxLength:Qe.toolName,required:!1},arguments:{type:"string",maxLength:Qe.arguments,required:!1}}),PN={type:"\
|
|
1035
1177
|
object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
|
|
1036
|
-
eply","tool"]},text:{type:"string",maxLength:
|
|
1037
|
-
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:
|
|
1038
|
-
string",maxLength:
|
|
1039
|
-
readInstructions:e=
|
|
1178
|
+
eply","tool"]},text:{type:"string",maxLength:Qe.text,description:"The final reply, or a brief progress sentence for the \
|
|
1179
|
+
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Qe.toolName},arguments:{type:"\
|
|
1180
|
+
string",maxLength:Qe.arguments}}};var Pj=Object.freeze({});function um(){throw new TypeError("Hook delivery requires an instruction resolver.")}function So({resolveConversation:t,
|
|
1181
|
+
readInstructions:e=um}){if(typeof t!="function")throw new TypeError("Conversation hook delivery requires a binding resol\
|
|
1040
1182
|
ver.");return async function(r){if(r.scope!=="session")return{kind:"unclaimed"};let o=await t(r);if(!o)return{kind:"uncl\
|
|
1041
1183
|
aimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError("Unknown con\
|
|
1042
1184
|
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
|
|
1185
|
+
conversation instructions are unavailable.");return{kind:"delivery",text:s}}}var Mj=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
1044
1186
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
1045
1187
|
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"]),
|
|
1188
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as lm}from"node:fs/promises";import xo from"node:path";function wr(t){return String(t||"").trim()}var pm=Object.freeze(["main","temporary"]),Va=Object.freeze(["managedDatabaseRefresh","managedEnvironment","managedGit",
|
|
1189
|
+
"managedPreview"]),Ga=Object.freeze(["managedPages"]),fm=64*1024,pD=Object.freeze(["When user input is necessary, ask no\
|
|
1048
1190
|
more than three concise, high-impact questions at once.","Put multiple questions on separate lines as `[1] Question`, `\
|
|
1049
1191
|
[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answers:` and a short bullet list dir\
|
|
1050
1192
|
ectly beneath its own question, before the next one; never collect several questions' answers into one trailing list.","\
|
|
@@ -1057,7 +1199,7 @@ Possible answers:
|
|
|
1057
1199
|
[2] Tell the main agent before changes?
|
|
1058
1200
|
Possible answers:
|
|
1059
1201
|
- Yes, tell main first
|
|
1060
|
-
- No, proceed independently`]),
|
|
1202
|
+
- No, proceed independently`]),fD=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
1061
1203
|
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
1062
1204
|
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
1063
1205
|
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
@@ -1069,115 +1211,115 @@ from the app framework's own pattern as part of the work instead of merely offer
|
|
|
1069
1211
|
or confirms (you may propose existing app accounts) with `vibe64-helper preview identities save` (`vibe64-helper spec pr\
|
|
1070
1212
|
eview-identities`), then verify each with `vibe64-helper preview browser identity <name>`; a saved selector alone proves\
|
|
1071
1213
|
no access. Use existing sessions/permissions, reject missing/disabled accounts, and disable the adapter without Vibe64\u2019\
|
|
1072
|
-
s per-run enable flag and secret. Do not create users, change roles, reset passwords or weaken
|
|
1073
|
-
|
|
1074
|
-
credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview status`, `screenshot
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
`vibe64-helper playwright readiness` reports. The login state belongs to the host: pass `process.env.
|
|
1088
|
-
|
|
1089
|
-
(`vibe64-helper playwright` refuses such a config). If tests run signed out with it, that is a host defect:
|
|
1090
|
-
|
|
1091
|
-
values and inspect relevant locators or regions; screenshot at meaningful checkpoints or failures, not after
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
application must verify the server's actual test database and suppress real email, invoices, payments, and
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
disposable database before resetting it, prepare fixtures before reporting readiness, and make Playwright
|
|
1104
|
-
|
|
1105
|
-
missing, report that blocker. `vibe64-helper preview ensure --target <id> --wait --json` deliberately
|
|
1106
|
-
|
|
1107
|
-
or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local
|
|
1108
|
-
|
|
1109
|
-
excerpts. Retain startup, resource and Preview-restoration errors even if tests pass, and trailing wrapper
|
|
1110
|
-
separately from JSON. Do not rerun for output or reread unchanged logs.","Batch related browser tests in one
|
|
1111
|
-
|
|
1112
|
-
or target changes during a suite or restoration. Wait on the original execution, including background runs,
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
-helper preview status` is ready on the restored target. To stop, run `vibe64-helper playwright cancel <run-
|
|
1116
|
-
waits for cleanup/restoration; retry if cleanup needs attention. Never kill test/Preview PIDs or change locks
|
|
1117
|
-
exit alone does not prove tests stopped. Recheck status before reporting a busy blocker.","If a managed
|
|
1118
|
-
kernel task denials or a resource incident, report the blocker with its diagnostic and incident ID and ask
|
|
1119
|
-
operator to inspect that evidence before retrying; never raise test timeouts or weaken assertions to work
|
|
1120
|
-
|
|
1121
|
-
['Pages: `vibe64-helper pages publish <file.html|folder> [--title "Title"]` publishes an HTML page (one
|
|
1122
|
-
|
|
1123
|
-
Vibe64\'s Pages list; `vibe64-helper pages update <page-id> <file.html|folder>` gives a page a new
|
|
1124
|
-
link (it keeps ten; `vibe64-helper pages revert <page-id> <version>` brings one back); `vibe64-helper
|
|
1125
|
-
them. A page runs sandboxed and loads only its own files, never other addresses, CDNs or Vibe64 itself
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
exists, offer to add it there). Make or change a page only once they say yes.',"When the person says
|
|
1133
|
-
other people (a colleague, the team, a client, a manager, a meeting) or that they will come back to it
|
|
1134
|
-
|
|
1135
|
-
page can be kept up to date. When the person wants that, build it as the guide's \"A page that keeps
|
|
1136
|
-
says: index.html for the layout, data.json for the numbers, then `vibe64-helper pages refresh <page-id
|
|
1137
|
-
--daily. Choose --command with a small script that writes data.json, which needs no AI, whenever a
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
answers, code changes, or documents that belong in the repository. Offer at most once per topic; do not
|
|
1141
|
-
with access to the project can open a page: never put secrets in one, or anything not every project
|
|
1142
|
-
|
|
1143
|
-
bindings; use them in ordinary commands. Do not build environment injection or copy managed
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, run
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
generated (such as an application key) by generating it with the framework's own generator and piping it to `vibe64
|
|
1156
|
-
|
|
1157
|
-
function
|
|
1158
|
-
let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(`${n}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
"Vibe64 host guidance must be bounded text supplied by the host.");if(!
|
|
1162
|
-
"Vibe64 session context has an unknown conversationKind.");let e=
|
|
1163
|
-
...
|
|
1164
|
-
`Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of
|
|
1165
|
-
|
|
1166
|
-
conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function
|
|
1167
|
-
|
|
1168
|
-
"Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function
|
|
1169
|
-
scope==="session")return
|
|
1170
|
-
sion and ephemeral scopes only.")}async function
|
|
1214
|
+
s per-run enable flag and secret. Do not create users, change roles, reset passwords or weaken the application's own aut\
|
|
1215
|
+
h for import. If choices are deferred/declined, say access stays unconfigured and continue independent setup work withou\
|
|
1216
|
+
t repeated credential requests. Public/non-web apps need no adapter.","Use `vibe64-helper preview status`, `screenshot`,\
|
|
1217
|
+
`logs`, and `browser eval` (Playwright code on stdin) for rendered inspection.","When the person asks to see a page of \
|
|
1218
|
+
the app, run `vibe64-helper preview open <path>` with its path inside the app (for example `/orders/42?tab=notes`): it m\
|
|
1219
|
+
oves the Preview they have open to that page and says the AI opened it. Your managed browser is a separate copy and neve\
|
|
1220
|
+
r moves their pane. If it reports `moved: 0`, give them the path to type into the Preview address box.","The top Preview\
|
|
1221
|
+
toolbar Stop and `vibe64-helper preview stop` stop this session's application and managed browser, not chat or source. \
|
|
1222
|
+
Status reports the saved stopped choice. A status read, screenshot, browser inspection, source edit or session reopening\
|
|
1223
|
+
is not permission to restart it; use `vibe64-helper preview ensure --wait` only for a deliberate Start. Scoped browser \
|
|
1224
|
+
tests restore the prior stopped choice.","For interactive navigation, use the proxy URL from `vibe64-helper preview insp\
|
|
1225
|
+
ect-url` or status `currentPage.url` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your\
|
|
1226
|
+
-path', preview.url).href)`. The direct application endpoint under diagnostics bypasses Preview identity and is not a br\
|
|
1227
|
+
owser-navigation URL.","Use the managed preview browser for interactive browsing and `vibe64-helper playwright` only for\
|
|
1228
|
+
an existing configured project suite; never install another browser. Pin `@playwright/test` exactly to the `platformVer\
|
|
1229
|
+
sion` that `vibe64-helper playwright readiness` reports. The login state belongs to the host: pass `process.env.PLAYWRIG\
|
|
1230
|
+
HT_STORAGE_STATE` unchanged to `use.storageState`, and never read, parse or edit that file or its cookies in the Playwri\
|
|
1231
|
+
ght config (`vibe64-helper playwright` refuses such a config). If tests run signed out with it, that is a host defect: r\
|
|
1232
|
+
eport it with the evidence; do not work around it.","For browser evidence, batch related actions and assertions, return \
|
|
1233
|
+
only needed values and inspect relevant locators or regions; screenshot at meaningful checkpoints or failures, not after\
|
|
1234
|
+
every click. Reuse the managed browser when isolation permits, keep required viewport, identity and security checks, an\
|
|
1235
|
+
d use existing automated cases for repeat verification.","For browser tests that write or reset data, inspect `vibe64-he\
|
|
1236
|
+
lper preview targets --json` and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <decla\
|
|
1237
|
+
red-test-target> test <suite arguments>` (or `npm-run <script>` in place of `test`). Vibe64 starts that web target, wait\
|
|
1238
|
+
s for readiness, uses its declared application identity, and restores the previous Preview when the command finishes or \
|
|
1239
|
+
is cancelled; report restoration failures.","A target name is not proof of test isolation. Before running a destructive \
|
|
1240
|
+
suite, the application must verify the server's actual test database and suppress real email, invoices, payments, and ot\
|
|
1241
|
+
her external effects. Keep managed Env unchanged. The test launcher and its preview-identity command must use the same d\
|
|
1242
|
+
atabase. Follow the application's declared test resources and never invent a database name. Never spoof safety checks by\
|
|
1243
|
+
changing only the test runner's environment.","If no suitable test target exists, add one through the project's existin\
|
|
1244
|
+
g Outputs contract and application-owned test scripts within authorized scope; normal Preview stays the default. Validat\
|
|
1245
|
+
e the exact disposable database before resetting it, prepare fixtures before reporting readiness, and make Playwright us\
|
|
1246
|
+
e PLAYWRIGHT_BASE_URL (the started target's URL) without starting another server. If test resources or external-effect c\
|
|
1247
|
+
ontrols are missing, report that blocker. `vibe64-helper preview ensure --target <id> --wait --json` deliberately select\
|
|
1248
|
+
s an interactive target until changed. If browser startup is slow, measure migrations, fixtures and server startup befor\
|
|
1249
|
+
e retrying or extending deadlines.","Keep test output small: run relevant files/cases, save stdout/stderr to local artif\
|
|
1250
|
+
acts and keep exit status. Report counts, duration, failed cases, actionable errors and artifact paths, reading only nee\
|
|
1251
|
+
ded failure excerpts. Retain startup, resource and Preview-restoration errors even if tests pass, and trailing wrapper d\
|
|
1252
|
+
iagnostics separately from JSON. Do not rerun for output or reread unchanged logs.","Batch related browser tests in one \
|
|
1253
|
+
managed suite (one Preview switch and restore). Suites and live Preview actions are sequential: no browser actions, ensu\
|
|
1254
|
+
re/restart or target changes during a suite or restoration. Wait on the original execution, including background runs, t\
|
|
1255
|
+
hrough cleanup/restoration (empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input); read\
|
|
1256
|
+
-only status/logs stay available. Before live inspection, confirm `vibe64-helper playwright status` shows no active run \
|
|
1257
|
+
and `vibe64-helper preview status` is ready on the restored target. To stop, run `vibe64-helper playwright cancel <run-i\
|
|
1258
|
+
d>`, which waits for cleanup/restoration; retry if cleanup needs attention. Never kill test/Preview PIDs or change locks\
|
|
1259
|
+
; launcher exit alone does not prove tests stopped. Recheck status before reporting a busy blocker.","If a managed comma\
|
|
1260
|
+
nd reports kernel task denials or a resource incident, report the blocker with its diagnostic and incident ID and ask th\
|
|
1261
|
+
e platform operator to inspect that evidence before retrying; never raise test timeouts or weaken assertions to work aro\
|
|
1262
|
+
und a process/thread limit. A generic browser timeout without resource evidence does not establish a platform cause."]),
|
|
1263
|
+
mD=Object.freeze(['Pages: `vibe64-helper pages publish <file.html|folder> [--title "Title"]` publishes an HTML page (one\
|
|
1264
|
+
file, or a folder with index.html and its own scripts, styles, data and images) that everyone with access to this proje\
|
|
1265
|
+
ct can open from Vibe64\'s Pages list; `vibe64-helper pages update <page-id> <file.html|folder>` gives a page a new versi\
|
|
1266
|
+
on under the same link (it keeps ten; `vibe64-helper pages revert <page-id> <version>` brings one back); `vibe64-helper \
|
|
1267
|
+
pages list` lists them. A page runs sandboxed and loads only its own files, never other addresses, CDNs or Vibe64 itself\
|
|
1268
|
+
, so ship every script, style and data file inside it. Write page files outside the repository (for example in VIBE64_DR\
|
|
1269
|
+
OP_ZONE) unless they belong there. Give the printed link in the chat as a Markdown link; Vibe64 shows it as a card.',"Be\
|
|
1270
|
+
fore writing a page, read `vibe64-helper pages guide` in full and follow it: link `_vibe64/page.css` and build from its \
|
|
1271
|
+
components (a header, summary tiles first, sections of cards, status pills, tables for comparisons, inline SVG charts), \
|
|
1272
|
+
never a wall of text.",'After answering with a report, comparison, status or progress overview, dashboard, diagram, plan\
|
|
1273
|
+
or review, end the reply with a one-line offer, such as "Want this as a page everyone on the project can open?" (or, wh\
|
|
1274
|
+
en a related page exists, offer to add it there). Make or change a page only once they say yes.',"When the person says t\
|
|
1275
|
+
he result is for other people (a colleague, the team, a client, a manager, a meeting) or that they will come back to it,\
|
|
1276
|
+
make the page without asking and give its link.","When a page's content will change over time (test results, progress, \
|
|
1277
|
+
metrics), say the page can be kept up to date. When the person wants that, build it as the guide's \"A page that keeps it\
|
|
1278
|
+
self up to date\" says: index.html for the layout, data.json for the numbers, then `vibe64-helper pages refresh <page-id>\
|
|
1279
|
+
` with --every or --daily. Choose --command with a small script that writes data.json, which needs no AI, whenever a scr\
|
|
1280
|
+
ipt can gather the data; use --prompt only when gathering it needs judgement.","Before making a page, check `vibe64-help\
|
|
1281
|
+
er pages list`: when a page about the same subject already exists, update it instead of making a new one.","Do not offer\
|
|
1282
|
+
pages for quick answers, code changes, or documents that belong in the repository. Offer at most once per topic; do not\
|
|
1283
|
+
nag.","Everyone with access to the project can open a page: never put secrets in one, or anything not every project mem\
|
|
1284
|
+
ber should see."]),hD=Object.freeze(["Each managed shell command receives current development Env from Vibe64, including\
|
|
1285
|
+
declared resource bindings; use them in ordinary commands. Do not build environment injection or copy managed credentia\
|
|
1286
|
+
ls into source. Resource provisioning and application migrations remain separate preparation steps.","Use `vibe64-helper\
|
|
1287
|
+
env status [development|staging|all]` to inspect configured key names without revealing values.","Pipe an available val\
|
|
1288
|
+
ue to `vibe64-helper env set <development|staging> <KEY> [--secret]`; it drops the one final newline that `echo` or a ge\
|
|
1289
|
+
nerator prints and stores every other character exactly. Never put values in arguments, logs, or repository files. Use e\
|
|
1290
|
+
mpty stdin only when the user requested an empty value. The host decides whose session may change staging values; when i\
|
|
1291
|
+
t refuses, report its message instead of retrying.","When the person refers to a saved key, account or accounts hub, run\
|
|
1292
|
+
`vibe64-helper env saved` (names, descriptions and fields, never values) and link the matching field to the variable th\
|
|
1293
|
+
e application reads with `vibe64-helper env link <development|staging> <KEY> <saved-id> <field-id>` instead of asking fo\
|
|
1294
|
+
r the value.","Keep development and staging values separate. Never invent credentials, copy a value between scopes witho\
|
|
1295
|
+
ut explicit direction, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected scope a\
|
|
1296
|
+
nd key names, never their values, and claim success only when the command succeeded.","Store a secret the application ne\
|
|
1297
|
+
eds generated (such as an application key) by generating it with the framework's own generator and piping it to `vibe64-\
|
|
1298
|
+
helper env set <scope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file from E\
|
|
1299
|
+
nv."]);function bo(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must be an object.`);return t}
|
|
1300
|
+
function Tt(t,e,n){let r=new Set(e),o=Object.keys(t).filter(s=>!r.has(s));if(o.length>0)throw new TypeError(`${n} contai\
|
|
1301
|
+
ns unsupported fields: ${o.join(", ")}.`)}function mm(t){if(Tt(t,["conversationKind","scope","session","hostGuidance"],"\
|
|
1302
|
+
Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,"ut\
|
|
1303
|
+
f8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text supplied by the host.");if(!pm.includes(t.conversationKind))
|
|
1304
|
+
throw new TypeError("Vibe64 session context has an unknown conversationKind.");let e=bo(t.session,"Vibe64 session capabi\
|
|
1305
|
+
lities");Tt(e,[...Va,...Ga],"Vibe64 session capabilities");let n=Object.fromEntries(Va.map(r=>{if(typeof e[r]!="boolean")
|
|
1306
|
+
throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);return[r,e[r]]}));for(let r of Ga){if(e[r]!==void 0&&
|
|
1307
|
+
typeof e[r]!="boolean")throw new TypeError(`Vibe64 session capability ${r} must be boolean.`);e[r]===!0&&(n[r]=!0)}return{
|
|
1308
|
+
conversationKind:t.conversationKind,scope:"session",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:n}}function hm(t){
|
|
1309
|
+
Tt(t,["scope","stableContext"],"Vibe64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>fm)throw new TypeError(
|
|
1310
|
+
"Vibe64 ephemeral context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function gm(t){if(t.
|
|
1311
|
+
scope==="session")return mm(t);if(t.scope==="ephemeral")return hm(t);throw new TypeError("The Vibe64 driver supports ses\
|
|
1312
|
+
sion and ephemeral scopes only.")}async function Wa(t={},{readRegistry:e=lm,workdir:n=""}={}){let r=bo(t,"Vibe64 host resolver request");if(Tt(r,["data","\
|
|
1171
1313
|
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(r.scope))throw new TypeError(
|
|
1172
|
-
"The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=
|
|
1173
|
-
resolver data");
|
|
1314
|
+
"The Vibe64 host resolver scope must be session or turn.");if(r.scope==="turn")return null;let o=bo(r.data,"Vibe64 host \
|
|
1315
|
+
resolver data");Tt(o,["registryPath"],"Vibe64 host resolver data");let s=wr(o.registryPath);if(!xo.isAbsolute(s))throw new TypeError(
|
|
1174
1316
|
"Vibe64 host resolver data requires an absolute registryPath.");let i=JSON.parse(await e(s,"utf8"));if(!Array.isArray(i?.
|
|
1175
|
-
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=
|
|
1317
|
+
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=wr(r.providerSessionId);
|
|
1176
1318
|
if(r.parentSessionIds!==void 0&&(!Array.isArray(r.parentSessionIds)||r.parentSessionIds.length>32||r.parentSessionIds.some(
|
|
1177
|
-
|
|
1178
|
-
[]].filter(Boolean).map(
|
|
1179
|
-
|
|
1180
|
-
t directory.");return
|
|
1181
|
-
tion input exceeds 256 KiB.");var
|
|
1182
|
-
process.stdout.write(await t(
|
|
1183
|
-
native"}:null});process.stdout.write(JSON.stringify(await t(
|
|
1319
|
+
p=>typeof p!="string"||!p.trim())))throw new TypeError("Invalid native conversation ancestry.");let u=[c,...r.parentSessionIds||
|
|
1320
|
+
[]].filter(Boolean).map(p=>a.find(v=>wr(v?.upstreamSessionId)===p)).find(Boolean),m=u?.promptContext;if(!m)return null;if(n&&
|
|
1321
|
+
u.workdir&&xo.resolve(n)!==xo.resolve(u.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1322
|
+
t directory.");return gm(m)}var To="";for await(let t of process.stdin)if(To+=t,Buffer.byteLength(To)>256*1024)throw new Error("Conversation instruc\
|
|
1323
|
+
tion input exceeds 256 KiB.");var Ka=JSON.parse(To);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1324
|
+
process.stdout.write(await t(Ka))}else{let t=So({resolveConversation:async e=>await Wa(e,{workdir:process.cwd()})?{delivery:"\
|
|
1325
|
+
native"}:null});process.stdout.write(JSON.stringify(await t(Ka)))}
|