vibe64 0.1.47 → 0.1.49
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 +1734 -1687
- package/bin/server.js +75 -75
- package/bin/upgrade-state.js +4539 -4471
- package/dist/assets/GithubBrowserTabs-BwpiRS2u.js +1 -0
- package/dist/assets/{LocalDatabaseServer-6VzPWZxG.js → LocalDatabaseServer-u_Ky7bNS.js} +1 -1
- package/dist/assets/{Vibe64AuthSettingsButton-TLwqAxDo.js → Vibe64AuthSettingsButton-BCwswT1G.js} +1 -1
- package/dist/assets/{Vibe64DashboardShell-B4dQ-oHD.js → Vibe64DashboardShell-CWlgrR2B.js} +1 -1
- package/dist/assets/{Vibe64DatabaseWorkspace-Bh5WIPOj.js → Vibe64DatabaseWorkspace-Dhs8_H0P.js} +1 -1
- package/dist/assets/Vibe64OutputControls-Dn548CZa.js +8 -0
- package/dist/assets/{Vibe64RepositoryWorkspace-idDg94lc.js → Vibe64RepositoryWorkspace-C-8S4JUF.js} +1 -1
- package/dist/assets/{Vibe64SessionFiles-Z9zxosyl.js → Vibe64SessionFiles-Cx6J7DDN.js} +2 -3
- package/dist/assets/{Vibe64UiStoryboardView-CrCDWMdR.js → Vibe64UiStoryboardView-DHyhJiWS.js} +1 -1
- package/dist/assets/{Vibe64UnavailableSessions-TqsxvGSf.js → Vibe64UnavailableSessions-Da4RxIhA.js} +1 -1
- package/dist/assets/{_sessionId_-7F1VGOou.js → _sessionId_-DCpgDPSI.js} +1 -1
- package/dist/assets/_slug_-BbEWp01a.js +25 -0
- package/dist/assets/{_slug_-B16mTWjj.css → _slug_-DerKOisL.css} +1 -1
- package/dist/assets/{access-Cx9RH95J.js → access-D4di2sCr.js} +1 -1
- package/dist/assets/{app-DPx4KKOa.js → app-Adr9Iz8p.js} +1 -1
- package/dist/assets/asyncModuleRecovery-DJsn5NrL.js +1 -0
- package/dist/assets/{changes-DYsuQLFW.js → changes-3Dd1O8Lu.js} +1 -1
- package/dist/assets/client-BAXHGUOC.js +1 -0
- package/dist/assets/{client-BYsDPxR3.js → client-CCZIu6yc.js} +1 -1
- package/dist/assets/{conversation-3ln-WnbL.css → conversation-CSDHdGDb.css} +1 -1
- package/dist/assets/conversation-DG9lp25w.js +8 -0
- package/dist/assets/conversation-ErAO1CmH.js +13 -0
- package/dist/assets/{dashboard-CWswAbYP.js → dashboard-0tCzDYCX.js} +1 -1
- package/dist/assets/english-definitions-DeiQ-jTT.js +1 -0
- package/dist/assets/env-DsyQ2MFX.js +1 -0
- package/dist/assets/{health-C0f6s-G1.js → health-DyTXU-nb.js} +1 -1
- package/dist/assets/{history-BQjETNB9.js → history-BXGAdPMI.js} +1 -1
- package/dist/assets/{incoming-COpY201m.js → incoming-yajkdGBY.js} +1 -1
- package/dist/assets/{index-MWACm8Pp.css → index-B-dukXUB.css} +1 -1
- package/dist/assets/index-CGz4Yow6.js +136 -0
- package/dist/assets/{integrations-BBkvNRHu.js → integrations-BMrXET36.js} +10 -2
- package/dist/assets/issues-kc1XBZCK.js +1 -0
- package/dist/assets/{learning-B8_wHoe1.js → learning-CIE5ghYv.js} +1 -1
- package/dist/assets/linkPath-Ch9eft18.js +1 -0
- package/dist/assets/{placement-DXvgK433.js → placement-BNmlke_j.js} +1 -1
- package/dist/assets/placement-DYM3JJ-F.js +1 -0
- package/dist/assets/publish-DTh6amqi.js +3 -0
- package/dist/assets/pull-requests-CbfGSSIh.js +1 -0
- package/dist/assets/{repository-BNPt7UWc.js → repository-BstMh-bG.js} +1 -1
- package/dist/assets/settings-Bf8C6dls.js +1 -0
- package/dist/assets/{studioGateApi-BVdclhPL.js → studioGateApi-mkX1eOTX.js} +1 -1
- package/dist/assets/{studioUrls-CGKCbM_d.js → studioUrls-B0-GdWh8.js} +1 -1
- package/dist/assets/useArchivedVibe64Sessions-DIOpfUxD.js +1 -0
- package/dist/assets/useCommand-CVuya6vG.js +1 -0
- package/dist/assets/useEndpointResource-7-YDfAxX.js +1 -0
- package/dist/assets/usePaths-Y6UuQxmI.js +1 -0
- package/dist/assets/{useUiFeedback-B51xtCAK.js → useUiFeedback-Bd3rao6E.js} +1 -1
- package/dist/assets/useVibe64ConversationLog-ChJOU2SD.js +1 -0
- package/dist/assets/{useVibe64DatabaseTools-BE_yXZFn.js → useVibe64DatabaseTools-DKV-TeNJ.js} +1 -1
- package/dist/assets/{useVibe64ProjectScope-D7b8n1gx.js → useVibe64ProjectScope-DXjsKKhl.js} +1 -1
- package/dist/assets/useVibe64SessionData-BkIHUrP5.js +1 -0
- package/dist/assets/useVibe64SessionSelection-N8wX5oqo.js +1 -0
- package/dist/assets/{useVibe64SystemGraph-CDDcsye4.js → useVibe64SystemGraph-Db_eD-X8.js} +1 -1
- package/dist/assets/{useVibe64Terminal-Zr3Mig2L.js → useVibe64Terminal-B9EWJ9Ba.js} +2 -2
- package/dist/assets/vibe64ProjectScope.local-l5_-E6pq.js +1 -0
- package/dist/assets/vibe64RepositoryRealtime-CHT4-6VN.js +1 -0
- package/dist/assets/vibe64SessionFocus-CS6Ex53G.js +1 -0
- package/dist/assets/vibe64SessionFocus-CSm4YJQD.css +1 -0
- package/dist/assets/vibe64SessionRequestConfig-xIx-5jxQ.js +1 -0
- package/dist/index.html +26 -22
- package/docs/colleague-usage/ai-accounts.md +6 -2
- package/docs/colleague-usage/ai-balance-and-allowance.md +15 -2
- package/docs/colleague-usage/coding-agent-failures.md +2 -1
- package/docs/colleague-usage/coding-agent-goals.md +8 -3
- package/docs/colleague-usage/coding-agents.md +16 -0
- package/docs/colleague-usage/github-work.md +14 -0
- package/docs/colleague-usage/preview-browser-checks.md +5 -3
- package/docs/colleague-usage/project-setup.md +6 -3
- package/docs/colleague-usage/running-vibe64-on-your-computer.md +3 -1
- package/docs/colleague-usage/sessions.md +35 -7
- package/docs/colleague-usage/starter-apps.md +3 -0
- package/docs/colleague-usage/temporary-chat-context.md +2 -1
- package/docs/colleague-usage/temporary-chats.md +17 -5
- package/node_modules/@jskit-ai/assistant-core/CHANGELOG.md +539 -0
- package/node_modules/@jskit-ai/assistant-core/locales/en.json +383 -0
- package/node_modules/@jskit-ai/assistant-core/package.json +3 -2
- package/node_modules/@jskit-ai/assistant-runtime/CHANGELOG.md +138 -0
- package/node_modules/@jskit-ai/assistant-runtime/README.md +2 -1
- package/node_modules/@jskit-ai/assistant-runtime/locales/en.json +137 -0
- package/node_modules/@jskit-ai/assistant-runtime/package.json +3 -2
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/assistantConfigRepository.js +223 -203
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/conversationsRepository.js +286 -266
- package/node_modules/@jskit-ai/assistant-runtime/src/server/repositories/messagesRepository.js +270 -250
- package/node_modules/@jskit-ai/assistant-voice/locales/en.json +182 -0
- package/node_modules/@jskit-ai/assistant-voice/package.json +3 -2
- package/node_modules/@jskit-ai/connector-google-calendar/CHANGELOG.md +83 -0
- package/node_modules/@jskit-ai/connector-google-calendar/locales/en.json +91 -0
- package/node_modules/@jskit-ai/connector-google-calendar/package.json +4 -3
- package/node_modules/@jskit-ai/connectors-catalog/CHANGELOG.md +1722 -0
- package/node_modules/@jskit-ai/connectors-catalog/README.md +11 -0
- package/node_modules/@jskit-ai/connectors-catalog/locales/en.json +3139 -0
- package/node_modules/@jskit-ai/connectors-catalog/package.json +5 -4
- package/node_modules/@jskit-ai/connectors-core/CHANGELOG.md +183 -0
- package/node_modules/@jskit-ai/connectors-core/locales/en.json +92 -0
- package/node_modules/@jskit-ai/connectors-core/package.json +3 -2
- package/node_modules/@jskit-ai/http-runtime/CHANGELOG.md +31 -0
- package/node_modules/@jskit-ai/http-runtime/locales/en.json +14 -0
- package/node_modules/@jskit-ai/http-runtime/package.json +3 -2
- package/node_modules/@jskit-ai/kernel/CHANGELOG.md +182 -0
- package/node_modules/@jskit-ai/kernel/locales/en.json +94 -0
- package/node_modules/@jskit-ai/kernel/package.json +6 -2
- package/node_modules/@jskit-ai/payments-core/CHANGELOG.md +128 -0
- package/node_modules/@jskit-ai/payments-core/locales/en.json +77 -0
- package/node_modules/@jskit-ai/payments-core/package.json +3 -2
- package/node_modules/@jskit-ai/realtime/CHANGELOG.md +20 -0
- package/node_modules/@jskit-ai/realtime/locales/en.json +14 -0
- package/node_modules/@jskit-ai/realtime/package.json +3 -2
- package/node_modules/@jskit-ai/resource-core/package.json +1 -1
- package/node_modules/@jskit-ai/resource-crud-core/package.json +1 -1
- package/node_modules/@jskit-ai/uploads-runtime/CHANGELOG.md +35 -0
- package/node_modules/@jskit-ai/uploads-runtime/locales/en.json +15 -0
- package/node_modules/@jskit-ai/uploads-runtime/package.json +3 -2
- package/node_modules/@local/vibe64-execution/src/host/execHelper.js +49 -48
- package/node_modules/@local/vibe64-execution/src/server/gitTurnCheckpointCommand.js +1327 -0
- package/node_modules/@local/vibe64-genesis/bin/vibe64-genesis-host-context +430 -390
- package/node_modules/@local/vibe64-genesis/src/server/index.js +45 -45
- package/node_modules/@local/vibe64-genesis/src/server/promptContext.js +119 -119
- package/node_modules/@local/vibe64-runtime/src/server/codexAppServerProcess.js +57 -57
- package/node_modules/@local/vibe64-sessions/package.json +2 -1
- package/node_modules/@local/vibe64-terminals/src/server/opencodeSessionEnvironmentPlugin.js +195 -175
- package/node_modules/@local/vibe64-terminals/src/server/sessionWorkOperationCommand.js +1385 -1362
- package/package.json +15 -15
- package/server.bundle.mjs +44206 -42825
- package/dist/assets/GithubBrowserTabs-D-Z3TlA8.js +0 -1
- package/dist/assets/Vibe64OutputControls-DtybwgL3.js +0 -8
- package/dist/assets/_slug_-Bq84T_Iv.js +0 -24
- package/dist/assets/conversation-Bn7wpATa.js +0 -2
- package/dist/assets/conversation-CNcCrV-R.js +0 -16
- package/dist/assets/definitions-CEbi4qae.js +0 -1
- package/dist/assets/env-X7EOFLtl.js +0 -1
- package/dist/assets/index-CBo1BEk6.js +0 -138
- package/dist/assets/issues-BiSiUd5o.js +0 -1
- package/dist/assets/placement-B5T1LR7m.js +0 -1
- package/dist/assets/publish-CeLZE2AG.js +0 -3
- package/dist/assets/pull-requests-pTdQOT7i.js +0 -1
- package/dist/assets/settings-lecRzZ-r.js +0 -1
- package/dist/assets/useArchivedVibe64Sessions-DHYRnyJD.js +0 -1
- package/dist/assets/useCommand-Epd2yHhQ.js +0 -1
- package/dist/assets/useEndpointResource-DBRQISI_.js +0 -1
- package/dist/assets/usePaths-DdAnjVDj.js +0 -1
- package/dist/assets/useVibe64ConversationLog-DboM3tYN.js +0 -1
- package/dist/assets/useVibe64SessionData-CreWtQAO.js +0 -1
- package/dist/assets/useVibe64SessionSelection-CDaX4uwY.js +0 -1
- package/dist/assets/vibe64ProjectScope.local-BxTBYuRg.js +0 -1
- package/dist/assets/vibe64RepositoryRealtime-C-J0I5jY.js +0 -1
- package/dist/assets/vibe64SessionFocus-DSW5Irm6.css +0 -1
- package/dist/assets/vibe64SessionFocus-DzqbVq60.js +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
3
|
var Ws=Object.create;var on=Object.defineProperty;var Ks=Object.getOwnPropertyDescriptor;var Js=Object.getOwnPropertyNames;var Xs=Object.getPrototypeOf,Ys=Object.prototype.hasOwnProperty;var k=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){
|
|
4
|
-
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var
|
|
5
|
-
enumerable:!(n=Ks(e,o))||n.enumerable});return t};var se=(t,e,r)=>(r=t!=null?Ws(Xs(t)):{},Qs(e||!t||!t.__esModule?on(r,"default",{value:t,enumerable:!0}):r,t));var Q
|
|
4
|
+
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var $=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}};var Qs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Js(e))!Ys.call(t,o)&&o!==r&&on(t,o,{get:()=>e[o],
|
|
5
|
+
enumerable:!(n=Ks(e,o))||n.enumerable});return t};var se=(t,e,r)=>(r=t!=null?Ws(Xs(t)):{},Qs(e||!t||!t.__esModule?on(r,"default",{value:t,enumerable:!0}):r,t));var Q=$((Cl,un)=>{"use strict";var cn=["nodebuffer","arraybuffer","fragments"],dn=typeof Blob<"u";dn&&cn.push("blob");un.
|
|
6
6
|
exports={BINARY_TYPES:cn,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:dn,
|
|
7
7
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
8
|
-
"websocket"),NOOP:()=>{}}});var
|
|
8
|
+
"websocket"),NOOP:()=>{}}});var qe=$((_l,ct)=>{"use strict";var{EMPTY_BUFFER:Zs}=Q(),Gt=Buffer[Symbol.species];function ei(t,e){if(t.length===0)return Zs;
|
|
9
9
|
if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),n=0;for(let o=0;o<t.length;o++){let s=t[o];r.set(s,n),n+=s.length}
|
|
10
10
|
return n<e?new Gt(r.buffer,r.byteOffset,n):r}function ln(t,e,r,n,o){for(let s=0;s<o;s++)r[n+s]=t[s]^e[s&3]}function pn(t,e){
|
|
11
11
|
for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function ti(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,
|
|
@@ -13,11 +13,11 @@ t.byteOffset+t.length)}function Wt(t){if(Wt.readOnly=!0,Buffer.isBuffer(t))retur
|
|
|
13
13
|
e=new Gt(t):ArrayBuffer.isView(t)?e=new Gt(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Wt.readOnly=!1),e}ct.exports=
|
|
14
14
|
{concat:ei,mask:ln,toArrayBuffer:ti,toBuffer:Wt,unmask:pn};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=k("bufferutil");ct.
|
|
15
15
|
exports.mask=function(e,r,n,o,s){s<48?ln(e,r,n,o,s):t.mask(e,r,n,o,s)},ct.exports.unmask=function(e,r){e.length<32?pn(e,
|
|
16
|
-
r):t.unmask(e,r)}}catch{}});var
|
|
16
|
+
r):t.unmask(e,r)}}catch{}});var hn=$((Al,mn)=>{"use strict";var fn=Symbol("kDone"),Kt=Symbol("kRun"),Jt=class{constructor(e){this[fn]=()=>{this.pending--,
|
|
17
17
|
this[Kt]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Kt]()}[Kt](){if(this.pending!==
|
|
18
|
-
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[fn])}}};
|
|
18
|
+
this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[fn])}}};mn.exports=Jt});var _e=$((El,yn)=>{"use strict";var $e=k("zlib"),vn=qe(),ri=hn(),{kStatusCode:gn}=Q(),ni=Buffer[Symbol.species],oi=Buffer.
|
|
19
19
|
from([0,0,255,255]),ut=Symbol("permessage-deflate"),Z=Symbol("total-length"),be=Symbol("callback"),ie=Symbol("buffers"),
|
|
20
|
-
|
|
20
|
+
Ce=Symbol("error"),dt,Xt=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
22
|
null,this._inflate=null,this.params=null,!dt){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:
|
|
23
23
|
10;dt=new ri(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&
|
|
@@ -46,21 +46,21 @@ nvalid value for parameter "${n}": ${o}`);o=s}else if(n==="client_no_context_tak
|
|
|
46
46
|
if(o!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${o}`)}else throw new Error(`Unknown parameter "${n}"`);
|
|
47
47
|
r[n]=o})}),e}decompress(e,r,n){dt.add(o=>{this._decompress(e,r,(s,i)=>{o(),n(s,i)})})}compress(e,r,n){dt.add(o=>{this._compress(
|
|
48
48
|
e,r,(s,i)=>{o(),n(s,i)})})}_decompress(e,r,n){let o=this._isServer?"client":"server";if(!this._inflate){let s=`${o}_max_\
|
|
49
|
-
window_bits`,i=typeof this.params[s]!="number"
|
|
49
|
+
window_bits`,i=typeof this.params[s]!="number"?$e.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=$e.createInflateRaw(
|
|
50
50
|
{...this._options.zlibInflateOptions,windowBits:i}),this._inflate[ut]=this,this._inflate[Z]=0,this._inflate[ie]=[],this.
|
|
51
51
|
_inflate.on("error",ii),this._inflate.on("data",wn)}this._inflate[be]=n,this._inflate.write(e),r&&this._inflate.write(oi),
|
|
52
|
-
this._inflate.flush(()=>{let s=this._inflate[
|
|
52
|
+
this._inflate.flush(()=>{let s=this._inflate[Ce];if(s){this._inflate.close(),this._inflate=null,n(s);return}let i=vn.concat(
|
|
53
53
|
this._inflate[ie],this._inflate[Z]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this.
|
|
54
54
|
_inflate[Z]=0,this._inflate[ie]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),n(null,i)})}_compress(e,r,n){
|
|
55
55
|
let o=this._isServer?"server":"client";if(!this._deflate){let s=`${o}_max_window_bits`,i=typeof this.params[s]!="number"?
|
|
56
|
-
|
|
56
|
+
$e.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=$e.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:i}),
|
|
57
57
|
this._deflate[Z]=0,this._deflate[ie]=[],this._deflate.on("data",si)}this._deflate[be]=n,this._deflate.write(e),this._deflate.
|
|
58
|
-
flush(
|
|
58
|
+
flush($e.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=vn.concat(this._deflate[ie],this._deflate[Z]);r&&(s=new ni(s.buffer,
|
|
59
59
|
s.byteOffset,s.length-4)),this._deflate[be]=null,this._deflate[Z]=0,this._deflate[ie]=[],r&&this.params[`${o}_no_context\
|
|
60
60
|
_takeover`]&&this._deflate.reset(),n(null,s)})}};yn.exports=Xt;function si(t){this[ie].push(t),this[Z]+=t.length}function wn(t){
|
|
61
|
-
if(this[Z]+=t.length,this[ut]._maxPayload<1||this[Z]<=this[ut]._maxPayload){this[ie].push(t);return}this[
|
|
62
|
-
"Max payload size exceeded"),this[
|
|
63
|
-
ta",wn),this.reset()}function ii(t){if(this[ut]._inflate=null,this[
|
|
61
|
+
if(this[Z]+=t.length,this[ut]._maxPayload<1||this[Z]<=this[ut]._maxPayload){this[ie].push(t);return}this[Ce]=new RangeError(
|
|
62
|
+
"Max payload size exceeded"),this[Ce].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ce][gn]=1009,this.removeListener("da\
|
|
63
|
+
ta",wn),this.reset()}function ii(t){if(this[ut]._inflate=null,this[Ce]){this[be](this[Ce]);return}t[gn]=1007,this[be](t)}});var Ae=$((Ol,lt)=>{"use strict";var{isUtf8:In}=k("buffer"),{hasBlob:ai}=Q(),ci=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
64
64
|
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,
|
|
65
65
|
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 di(t){return t>=
|
|
66
66
|
1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Yt(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===
|
|
@@ -71,12 +71,12 @@ r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128
|
|
|
71
71
|
bject"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]===
|
|
72
72
|
"Blob"||t[Symbol.toStringTag]==="File")}lt.exports={isBlob:ui,isValidStatusCode:di,isValidUTF8:Yt,tokenChars:ci};if(In)lt.
|
|
73
73
|
exports.isValidUTF8=function(t){return t.length<24?Yt(t):In(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=k("utf-8-validate");
|
|
74
|
-
lt.exports.isValidUTF8=function(e){return e.length<32?Yt(e):t(e)}}catch{}});var rr
|
|
75
|
-
{concat:Qt,toArrayBuffer:
|
|
76
|
-
|
|
74
|
+
lt.exports.isValidUTF8=function(e){return e.length<32?Yt(e):t(e)}}catch{}});var rr=$((Rl,An)=>{"use strict";var{Writable:li}=k("stream"),Sn=_e(),{BINARY_TYPES:pi,EMPTY_BUFFER:xn,kStatusCode:fi,kWebSocket:mi}=Q(),
|
|
75
|
+
{concat:Qt,toArrayBuffer:hi,unmask:vi}=qe(),{isValidStatusCode:gi,isValidUTF8:Tn}=Ae(),pt=Buffer[Symbol.species],G=0,bn=1,
|
|
76
|
+
Cn=2,_n=3,Zt=4,er=5,ft=6,tr=class extends li{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==
|
|
77
77
|
void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||pi[0],this._extensions=e.extensions||{},this._isServer=
|
|
78
78
|
!!e.isServer,this._maxBufferedChunks=e.maxBufferedChunks|0,this._maxFragments=e.maxFragments|0,this._maxPayload=e.maxPayload|
|
|
79
|
-
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[
|
|
79
|
+
0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[mi]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=
|
|
80
80
|
!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=
|
|
81
81
|
0,this._messageLength=0,this._numFragments=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=G}_write(e,r,n){
|
|
82
82
|
if(this._opcode===8&&this._state==G)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){
|
|
@@ -86,7 +86,7 @@ _buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return thi
|
|
|
86
86
|
e,n.length-e),new pt(n.buffer,n.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let n=this._buffers[0],o=r.length-e;e>=n.length?
|
|
87
87
|
r.set(this._buffers.shift(),o):(r.set(new Uint8Array(n.buffer,n.byteOffset,e),o),this._buffers[0]=new pt(n.buffer,n.byteOffset+
|
|
88
88
|
e,n.length-e)),e-=n.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case G:this.getInfo(e);
|
|
89
|
-
break;case bn:this.getPayloadLength16(e);break;case
|
|
89
|
+
break;case bn:this.getPayloadLength16(e);break;case Cn:this.getPayloadLength64(e);break;case _n:this.getMask();break;case Zt:
|
|
90
90
|
this.getData(e);break;case er:case ft:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<
|
|
91
91
|
2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be\
|
|
92
92
|
clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let n=(r[0]&64)===64;if(n&&!this._extensions[Sn.extensionName]){
|
|
@@ -103,14 +103,14 @@ LOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcod
|
|
|
103
103
|
ID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,
|
|
104
104
|
this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(
|
|
105
105
|
o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");
|
|
106
|
-
e(o);return}this._payloadLength===126?this._state=bn:this._payloadLength===127?this._state=
|
|
106
|
+
e(o);return}this._payloadLength===126?this._state=bn:this._payloadLength===127?this._state=Cn:this.haveLength(e)}getPayloadLength16(e){
|
|
107
107
|
if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){
|
|
108
108
|
if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let o=this.
|
|
109
109
|
createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD\
|
|
110
110
|
_LENGTH");e(o);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&
|
|
111
111
|
this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>
|
|
112
112
|
0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}
|
|
113
|
-
this._masked?this._state=
|
|
113
|
+
this._masked?this._state=_n:this._state=Zt}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(
|
|
114
114
|
4),this._state=Zt}getData(e){let r=xn;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;
|
|
115
115
|
return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&
|
|
116
116
|
vi(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._maxFragments>0&&++this._numFragments>this._maxFragments){
|
|
@@ -121,7 +121,7 @@ o);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPa
|
|
|
121
121
|
RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(i);return}this._fragments.push(s)}
|
|
122
122
|
this.dataMessage(r),this._state===G&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=G;return}let r=this._messageLength,
|
|
123
123
|
n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._numFragments=0,this._fragments=
|
|
124
|
-
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Qt(n,r):this._binaryType==="arraybuffer"?o=
|
|
124
|
+
[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Qt(n,r):this._binaryType==="arraybuffer"?o=hi(Qt(n,r)):this.
|
|
125
125
|
_binaryType==="blob"?o=new Blob(n):o=n,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=G):(this._state=
|
|
126
126
|
ft,setImmediate(()=>{this.emit("message",o,!0),this._state=G,this.startLoop(e)}))}else{let o=Qt(n,r);if(!this._skipUTF8Validation&&
|
|
127
127
|
!Tn(o)){let s=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(s);return}this._state===er||
|
|
@@ -133,13 +133,13 @@ _skipUTF8Validation&&!Tn(o)){let s=this.createError(Error,"invalid UTF-8 sequenc
|
|
|
133
133
|
this._loop=!1,this.emit("conclude",n,o),this.end()}this._state=G;return}this._allowSynchronousEvents?(this.emit(this._opcode===
|
|
134
134
|
9?"ping":"pong",e),this._state=G):(this._state=ft,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=
|
|
135
135
|
G,this.startLoop(r)}))}createError(e,r,n,o,s){this._loop=!1,this._errored=!0;let i=new e(n?`Invalid WebSocket frame: ${r}`:
|
|
136
|
-
r);return Error.captureStackTrace(i,this.createError),i.code=s,i[fi]=o,i}};An.exports=tr});var sr
|
|
137
|
-
En=
|
|
138
|
-
"kByteLength"),bi=Buffer.alloc(4),
|
|
136
|
+
r);return Error.captureStackTrace(i,this.createError),i.code=s,i[fi]=o,i}};An.exports=tr});var sr=$((kl,Rn)=>{"use strict";var{Duplex:Pl}=k("stream"),{randomFillSync:wi}=k("crypto"),{types:{isUint8Array:yi}}=k("util"),
|
|
137
|
+
En=_e(),{EMPTY_BUFFER:Ii,kWebSocket:Si,NOOP:xi}=Q(),{isBlob:Ee,isValidStatusCode:Ti}=Ae(),{mask:On,toBuffer:fe}=qe(),W=Symbol(
|
|
138
|
+
"kByteLength"),bi=Buffer.alloc(4),mt=8*1024,me,Oe=mt,J=0,Ci=1,_i=2,nr=class t{constructor(e,r,n){this._extensions=r||{},
|
|
139
139
|
n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this.
|
|
140
140
|
_bufferedBytes=0,this._queue=[],this._state=J,this.onerror=xi,this[Si]=void 0}static frame(e,r){let n,o=!1,s=2,i=!1;r.mask&&
|
|
141
|
-
(n=r.maskBuffer||bi,r.generateMask?r.generateMask(n):(Oe===
|
|
142
|
-
|
|
141
|
+
(n=r.maskBuffer||bi,r.generateMask?r.generateMask(n):(Oe===mt&&(me===void 0&&(me=Buffer.alloc(mt)),wi(me,0,mt),Oe=0),n[0]=
|
|
142
|
+
me[Oe++],n[1]=me[Oe++],n[2]=me[Oe++],n[3]=me[Oe++]),i=(n[0]|n[1]|n[2]|n[3])===0,s=6);let a;typeof e=="string"?(!r.mask||
|
|
143
143
|
i)&&r[W]!==void 0?a=r[W]:(e=Buffer.from(e),a=e.length):(a=e.length,o=r.mask&&r.readOnly&&!i);let c=a;a>=65536?(s+=8,c=127):
|
|
144
144
|
a>125&&(s+=2,c=126);let d=Buffer.allocUnsafe(o?a+s:s);return d[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(d[0]|=64),d[1]=c,
|
|
145
145
|
c===126?d.writeUInt16BE(a,2):c===127&&(d[2]=d[3]=0,d.writeUIntBE(a,4,6)),r.mask?(d[1]|=128,d[s-4]=n[0],d[s-3]=n[1],d[s-2]=
|
|
@@ -164,61 +164,61 @@ t_takeover":"client_no_context_takeover"]&&(i=a>=o._threshold),this._compress=i)
|
|
|
164
164
|
!0);let d={[W]:a,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:s,readOnly:c,rsv1:i};
|
|
165
165
|
Ee(e)?this._state!==J?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this.
|
|
166
166
|
_state!==J?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,r,n,o){this.
|
|
167
|
-
_bufferedBytes+=n[W],this._state=
|
|
167
|
+
_bufferedBytes+=n[W],this._state=_i,e.arrayBuffer().then(s=>{if(this._socket.destroyed){let a=new Error("The socket was \
|
|
168
168
|
closed while the blob was being read");process.nextTick(or,this,a,o);return}this._bufferedBytes-=n[W];let i=fe(s);r?this.
|
|
169
169
|
dispatch(i,r,n,o):(this._state=J,this.sendFrame(t.frame(i,n),o),this.dequeue())}).catch(s=>{process.nextTick(Ai,this,s,o)})}dispatch(e,r,n,o){
|
|
170
170
|
if(!r){this.sendFrame(t.frame(e,n),o);return}let s=this._extensions[En.extensionName];this._bufferedBytes+=n[W],this._state=
|
|
171
|
-
|
|
171
|
+
Ci,s.compress(e,n.fin,(i,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being com\
|
|
172
172
|
pressed");or(this,c,o);return}this._bufferedBytes-=n[W],this._state=J,n.readOnly=!1,this.sendFrame(t.frame(a,n),o),this.
|
|
173
173
|
dequeue()})}dequeue(){for(;this._state===J&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][W],
|
|
174
174
|
Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][W],this._queue.push(e)}sendFrame(e,r){e.length===
|
|
175
175
|
2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],
|
|
176
176
|
r)}};Rn.exports=nr;function or(t,e,r){typeof r=="function"&&r(e);for(let n=0;n<t._queue.length;n++){let o=t._queue[n],s=o[o.
|
|
177
|
-
length-1];typeof s=="function"&&s(e)}}function Ai(t,e,r){or(t,e,r),t.onerror(e)}});var Fn
|
|
177
|
+
length-1];typeof s=="function"&&s(e)}}function Ai(t,e,r){or(t,e,r),t.onerror(e)}});var Fn=$((Ml,Ln)=>{"use strict";var{kForOnEventAttribute:Be,kListener:ir}=Q(),Pn=Symbol("kCode"),kn=Symbol("kData"),Mn=Symbol(
|
|
178
178
|
"kError"),Nn=Symbol("kMessage"),jn=Symbol("kReason"),Re=Symbol("kTarget"),Dn=Symbol("kType"),zn=Symbol("kWasClean"),ee=class{constructor(e){
|
|
179
179
|
this[Re]=null,this[Dn]=e}get target(){return this[Re]}get type(){return this[Dn]}};Object.defineProperty(ee.prototype,"t\
|
|
180
|
-
arget",{enumerable:!0});Object.defineProperty(ee.prototype,"type",{enumerable:!0});var
|
|
180
|
+
arget",{enumerable:!0});Object.defineProperty(ee.prototype,"type",{enumerable:!0});var he=class extends ee{constructor(e,r={}){
|
|
181
181
|
super(e),this[Pn]=r.code===void 0?0:r.code,this[jn]=r.reason===void 0?"":r.reason,this[zn]=r.wasClean===void 0?!1:r.wasClean}get code(){
|
|
182
|
-
return this[Pn]}get reason(){return this[jn]}get wasClean(){return this[zn]}};Object.defineProperty(
|
|
183
|
-
{enumerable:!0});Object.defineProperty(
|
|
182
|
+
return this[Pn]}get reason(){return this[jn]}get wasClean(){return this[zn]}};Object.defineProperty(he.prototype,"code",
|
|
183
|
+
{enumerable:!0});Object.defineProperty(he.prototype,"reason",{enumerable:!0});Object.defineProperty(he.prototype,"wasCle\
|
|
184
184
|
an",{enumerable:!0});var Pe=class extends ee{constructor(e,r={}){super(e),this[Mn]=r.error===void 0?null:r.error,this[Nn]=
|
|
185
185
|
r.message===void 0?"":r.message}get error(){return this[Mn]}get message(){return this[Nn]}};Object.defineProperty(Pe.prototype,
|
|
186
|
-
"error",{enumerable:!0});Object.defineProperty(Pe.prototype,"message",{enumerable:!0});var
|
|
187
|
-
super(e),this[kn]=r.data===void 0?null:r.data}get data(){return this[kn]}};Object.defineProperty(
|
|
188
|
-
var Ei={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[
|
|
189
|
-
age")n=function(s,i){let a=new
|
|
190
|
-
let a=new
|
|
191
|
-
e,this,a)};else if(t==="error")n=function(s){let i=new Pe("error",{error:s,message:s.message});i[Re]=this,
|
|
192
|
-
"open")n=function(){let s=new ee("open");s[Re]=this,
|
|
193
|
-
this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[ir]===e&&!r[
|
|
194
|
-
Ln.exports={CloseEvent:
|
|
195
|
-
t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var vt
|
|
196
|
-
let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,l=-1,
|
|
197
|
-
|
|
198
|
-
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${
|
|
199
|
-
r),r=Object.create(null)):i=g,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${
|
|
200
|
-
if(l===-1&&Ve[d]===1)c===-1&&(c=
|
|
201
|
-
`Unexpected character at index ${
|
|
202
|
-
c=l=-1}else if(d===61&&c!==-1&&l===-1)a=t.slice(c,
|
|
203
|
-
if(Ve[d]!==1)throw new SyntaxError(`Unexpected character at index ${
|
|
204
|
-
1)c===-1&&(c=
|
|
205
|
-
index ${
|
|
206
|
-
d===9))l===-1&&(l=
|
|
207
|
-
(l=
|
|
208
|
-
c=l=-1}else throw new SyntaxError(`Unexpected character at index ${
|
|
209
|
-
"Unexpected end of input");l===-1&&(l=
|
|
186
|
+
"error",{enumerable:!0});Object.defineProperty(Pe.prototype,"message",{enumerable:!0});var He=class extends ee{constructor(e,r={}){
|
|
187
|
+
super(e),this[kn]=r.data===void 0?null:r.data}get data(){return this[kn]}};Object.defineProperty(He.prototype,"data",{enumerable:!0});
|
|
188
|
+
var Ei={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Be]&&o[ir]===e&&!o[Be])return;let n;if(t==="mess\
|
|
189
|
+
age")n=function(s,i){let a=new He("message",{data:i?s:s.toString()});a[Re]=this,ht(e,this,a)};else if(t==="close")n=function(s,i){
|
|
190
|
+
let a=new he("close",{code:s,reason:i.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});a[Re]=this,ht(
|
|
191
|
+
e,this,a)};else if(t==="error")n=function(s){let i=new Pe("error",{error:s,message:s.message});i[Re]=this,ht(e,this,i)};else if(t===
|
|
192
|
+
"open")n=function(){let s=new ee("open");s[Re]=this,ht(e,this,s)};else return;n[Be]=!!r[Be],n[ir]=e,r.once?this.once(t,n):
|
|
193
|
+
this.on(t,n)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[ir]===e&&!r[Be]){this.removeListener(t,r);break}}};
|
|
194
|
+
Ln.exports={CloseEvent:he,ErrorEvent:Pe,Event:ee,EventTarget:Ei,MessageEvent:He};function ht(t,e,r){typeof t=="object"&&
|
|
195
|
+
t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var vt=$((Nl,Un)=>{"use strict";var{tokenChars:Ve}=Ae();function X(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Oi(t){
|
|
196
|
+
let e=Object.create(null),r=Object.create(null),n=!1,o=!1,s=!1,i,a,c=-1,d=-1,l=-1,m=0;for(;m<t.length;m++)if(d=t.charCodeAt(
|
|
197
|
+
m),i===void 0)if(l===-1&&Ve[d]===1)c===-1&&(c=m);else if(m!==0&&(d===32||d===9))l===-1&&c!==-1&&(l=m);else if(d===59||d===
|
|
198
|
+
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);l===-1&&(l=m);let g=t.slice(c,l);d===44?(X(e,g,
|
|
199
|
+
r),r=Object.create(null)):i=g,c=l=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);else if(a===void 0)
|
|
200
|
+
if(l===-1&&Ve[d]===1)c===-1&&(c=m);else if(d===32||d===9)l===-1&&c!==-1&&(l=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(
|
|
201
|
+
`Unexpected character at index ${m}`);l===-1&&(l=m),X(r,t.slice(c,l),!0),d===44&&(X(e,i,r),r=Object.create(null),i=void 0),
|
|
202
|
+
c=l=-1}else if(d===61&&c!==-1&&l===-1)a=t.slice(c,m),c=l=-1;else throw new SyntaxError(`Unexpected character at index ${m}`);else if(o){
|
|
203
|
+
if(Ve[d]!==1)throw new SyntaxError(`Unexpected character at index ${m}`);c===-1?c=m:n||(n=!0),o=!1}else if(s)if(Ve[d]===
|
|
204
|
+
1)c===-1&&(c=m);else if(d===34&&c!==-1)s=!1,l=m;else if(d===92)o=!0;else throw new SyntaxError(`Unexpected character at \
|
|
205
|
+
index ${m}`);else if(d===34&&t.charCodeAt(m-1)===61)s=!0;else if(l===-1&&Ve[d]===1)c===-1&&(c=m);else if(c!==-1&&(d===32||
|
|
206
|
+
d===9))l===-1&&(l=m);else if(d===59||d===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${m}`);l===-1&&
|
|
207
|
+
(l=m);let g=t.slice(c,l);n&&(g=g.replace(/\\/g,""),n=!1),X(r,a,g),d===44&&(X(e,i,r),r=Object.create(null),i=void 0),a=void 0,
|
|
208
|
+
c=l=-1}else throw new SyntaxError(`Unexpected character at index ${m}`);if(c===-1||s||d===32||d===9)throw new SyntaxError(
|
|
209
|
+
"Unexpected end of input");l===-1&&(l=m);let f=t.slice(c,l);return i===void 0?X(e,f,r):(a===void 0?X(r,f,!0):n?X(r,a,f.replace(
|
|
210
210
|
/\\/g,"")):X(r,a,f),X(e,i,r)),e}function Ri(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),
|
|
211
211
|
r.map(n=>[e].concat(Object.keys(n).map(o=>{let s=n[o];return Array.isArray(s)||(s=[s]),s.map(i=>i===!0?o:`${o}=${i}`).join(
|
|
212
|
-
"; ")})).join("; ")).join(", ")}).join(", ")}
|
|
213
|
-
{Duplex:
|
|
214
|
-
EMPTY_BUFFER:gt,GUID:
|
|
215
|
-
removeEventListener:Vi}}=Fn(),{format:Gi,parse:Wi}=vt(),{toBuffer:Ki}=
|
|
212
|
+
"; ")})).join("; ")).join(", ")}).join(", ")}Un.exports={format:Ri,parse:Oi}});var It=$((zl,Qn)=>{"use strict";var Pi=k("events"),ki=k("https"),Mi=k("http"),Bn=k("net"),Ni=k("tls"),{randomBytes:ji,createHash:Di}=k("crypto"),
|
|
213
|
+
{Duplex:jl,Readable:Dl}=k("stream"),{URL:ar}=k("url"),ae=_e(),zi=rr(),Li=sr(),{isBlob:Fi}=Ae(),{BINARY_TYPES:qn,CLOSE_TIMEOUT:Ui,
|
|
214
|
+
EMPTY_BUFFER:gt,GUID:qi,kForOnEventAttribute:cr,kListener:$i,kStatusCode:Bi,kWebSocket:D,NOOP:Hn}=Q(),{EventTarget:{addEventListener:Hi,
|
|
215
|
+
removeEventListener:Vi}}=Fn(),{format:Gi,parse:Wi}=vt(),{toBuffer:Ki}=qe(),Vn=Symbol("kAborted"),dr=[8,13],te=["CONNECTI\
|
|
216
216
|
NG","OPEN","CLOSING","CLOSED"],Ji=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,P=class t extends Pi{constructor(e,r,n){super(),this.
|
|
217
|
-
_binaryType=
|
|
217
|
+
_binaryType=qn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=gt,this._closeTimer=
|
|
218
218
|
null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=
|
|
219
219
|
null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?
|
|
220
220
|
r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Gn(this,e,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=
|
|
221
|
-
n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){
|
|
221
|
+
n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){qn.includes(e)&&(this._binaryType=
|
|
222
222
|
e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+
|
|
223
223
|
this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){
|
|
224
224
|
return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){
|
|
@@ -231,7 +231,7 @@ setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r
|
|
|
231
231
|
"end",Xn),e.on("error",Yn),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,
|
|
232
232
|
this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[ae.extensionName]&&this._extensions[ae.extensionName].
|
|
233
233
|
cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){
|
|
234
|
-
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
234
|
+
if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(this,this._req,"WebSocket was closed before the conn\
|
|
235
235
|
ection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver.
|
|
236
236
|
_writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,
|
|
237
237
|
n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),
|
|
@@ -246,7 +246,7 @@ _paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(
|
|
|
246
246
|
throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof e=="numbe\
|
|
247
247
|
r"&&(e=e.toString()),this.readyState!==t.OPEN){ur(this,e,n);return}let o={binary:typeof e!="string",mask:!this._isServer,
|
|
248
248
|
compress:!0,fin:!0,...r};this._extensions[ae.extensionName]||(o.compress=!1),this._sender.send(e||gt,o,n)}terminate(){if(this.
|
|
249
|
-
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){
|
|
249
|
+
readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){B(this,this._req,"WebSocket was closed before the connection w\
|
|
250
250
|
as established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(P,"CO\
|
|
251
251
|
NNECTING",{enumerable:!0,value:te.indexOf("CONNECTING")});Object.defineProperty(P.prototype,"CONNECTING",{enumerable:!0,
|
|
252
252
|
value:te.indexOf("CONNECTING")});Object.defineProperty(P,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProperty(
|
|
@@ -255,10 +255,10 @@ P.prototype,"OPEN",{enumerable:!0,value:te.indexOf("OPEN")});Object.defineProper
|
|
|
255
255
|
P,"CLOSED",{enumerable:!0,value:te.indexOf("CLOSED")});Object.defineProperty(P.prototype,"CLOSED",{enumerable:!0,value:te.
|
|
256
256
|
indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.
|
|
257
257
|
defineProperty(P.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(P.prototype,
|
|
258
|
-
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[cr])return e[
|
|
258
|
+
`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[cr])return e[$i];return null},set(e){for(let r of this.
|
|
259
259
|
listeners(t))if(r[cr]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[cr]:!0})}})});P.
|
|
260
|
-
prototype.addEventListener=
|
|
261
|
-
autoPong:!0,closeTimeout
|
|
260
|
+
prototype.addEventListener=Hi;P.prototype.removeEventListener=Vi;Qn.exports=P;function Gn(t,e,r,n){let o={allowSynchronousEvents:!0,
|
|
261
|
+
autoPong:!0,closeTimeout:Ui,protocolVersion:dr[1],maxBufferedChunks:262144,maxFragments:16384,maxPayload:104857600,skipUTF8Validation:!1,
|
|
262
262
|
perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,
|
|
263
263
|
method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!dr.includes(
|
|
264
264
|
o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${dr.join(
|
|
@@ -266,7 +266,7 @@ o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.proto
|
|
|
266
266
|
"http:"?s.protocol="ws:":s.protocol==="https:"&&(s.protocol="wss:"),t._url=s.href;let i=s.protocol==="wss:",a=s.protocol===
|
|
267
267
|
"ws+unix:",c;if(s.protocol!=="ws:"&&!i&&!a?c=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws\
|
|
268
268
|
+unix:"`:a&&!s.pathname?c="The URL's pathname is empty":s.hash&&(c="The URL contains a fragment identifier"),c){let S=new SyntaxError(
|
|
269
|
-
c);if(t._redirects===0)throw S;wt(t,S);return}let d=i?443:80,l=ji(16).toString("base64"),
|
|
269
|
+
c);if(t._redirects===0)throw S;wt(t,S);return}let d=i?443:80,l=ji(16).toString("base64"),m=i?ki.request:Mi.request,f=new Set,
|
|
270
270
|
g;if(o.createConnection=o.createConnection||(i?Yi:Xi),o.defaultPort=o.defaultPort||d,o.port=s.port||d,o.host=s.hostname.
|
|
271
271
|
startsWith("[")?s.hostname.slice(1,-1):s.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec\
|
|
272
272
|
-WebSocket-Key":l,Connection:"Upgrade",Upgrade:"websocket"},o.path=s.pathname+s.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&
|
|
@@ -279,44 +279,44 @@ uplicated subprotocol was specified");f.add(S)}o.headers["Sec-WebSocket-Protocol
|
|
|
279
279
|
headers:{}},S)for(let[A,O]of Object.entries(S))n.headers[A.toLowerCase()]=O}else if(t.listenerCount("redirect")===0){let S=a?
|
|
280
280
|
t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:s.host===t._originalHostOrSocketPath;(!S||
|
|
281
281
|
t._originalSecure&&!i)&&(delete o.headers.authorization,delete o.headers.cookie,S||delete o.headers.host,o.auth=void 0)}
|
|
282
|
-
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),I=t._req=
|
|
283
|
-
t._redirects&&t.emit("redirect",t.url,I)}else I=t._req=
|
|
282
|
+
o.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),I=t._req=m(o),
|
|
283
|
+
t._redirects&&t.emit("redirect",t.url,I)}else I=t._req=m(o);o.timeout&&I.on("timeout",()=>{B(t,I,"Opening handshake has \
|
|
284
284
|
timed out")}),I.on("error",S=>{I===null||I[Vn]||(I=t._req=null,wt(t,S))}),I.on("response",S=>{let A=S.headers.location,O=S.
|
|
285
|
-
statusCode;if(A&&o.followRedirects&&O>=300&&O<400){if(++t._redirects>o.maxRedirects){
|
|
285
|
+
statusCode;if(A&&o.followRedirects&&O>=300&&O<400){if(++t._redirects>o.maxRedirects){B(t,I,"Maximum redirects exceeded");
|
|
286
286
|
return}I.abort();let N;try{N=new ar(A,e)}catch{let z=new SyntaxError(`Invalid URL: ${A}`);wt(t,z);return}Gn(t,N,r,n)}else
|
|
287
|
-
t.emit("unexpected-response",I,S)||
|
|
287
|
+
t.emit("unexpected-response",I,S)||B(t,I,`Unexpected server response: ${S.statusCode}`)}),I.on("upgrade",(S,A,O)=>{if(t.
|
|
288
288
|
emit("upgrade",S),t.readyState!==P.CONNECTING)return;I=t._req=null;let N=S.headers.upgrade;if(N===void 0||N.toLowerCase()!==
|
|
289
|
-
"websocket"){
|
|
290
|
-
socket-accept"]!==j){
|
|
289
|
+
"websocket"){B(t,A,"Invalid Upgrade header");return}let j=Di("sha1").update(l+qi).digest("base64");if(S.headers["sec-web\
|
|
290
|
+
socket-accept"]!==j){B(t,A,"Invalid Sec-WebSocket-Accept header");return}let z=S.headers["sec-websocket-protocol"],K;if(z!==
|
|
291
291
|
void 0?f.size?f.has(z)||(K="Server sent an invalid subprotocol"):K="Server sent a subprotocol but none was requested":f.
|
|
292
|
-
size&&(K="Server sent no subprotocol"),K){
|
|
293
|
-
if(
|
|
294
|
-
try{
|
|
295
|
-
ae.extensionName){
|
|
296
|
-
|
|
292
|
+
size&&(K="Server sent no subprotocol"),K){B(t,A,K);return}z&&(t._protocol=z);let H=S.headers["sec-websocket-extensions"];
|
|
293
|
+
if(H!==void 0){if(!g){B(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let q;
|
|
294
|
+
try{q=Wi(H)}catch{B(t,A,"Invalid Sec-WebSocket-Extensions header");return}let ne=Object.keys(q);if(ne.length!==1||ne[0]!==
|
|
295
|
+
ae.extensionName){B(t,A,"Server indicated an extension that was not requested");return}try{g.accept(q[ae.extensionName])}catch{
|
|
296
|
+
B(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ae.extensionName]=g}t.setSocket(A,O,{allowSynchronousEvents:o.
|
|
297
297
|
allowSynchronousEvents,generateMask:o.generateMask,maxBufferedChunks:o.maxBufferedChunks,maxFragments:o.maxFragments,maxPayload:o.
|
|
298
298
|
maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(I,t):I.end()}function wt(t,e){t._readyState=
|
|
299
|
-
P.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Xi(t){return t.path=t.socketPath,
|
|
300
|
-
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=
|
|
301
|
-
t._readyState=P.CLOSING;let n=new Error(r);Error.captureStackTrace(n,
|
|
299
|
+
P.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Xi(t){return t.path=t.socketPath,Bn.connect(t)}function Yi(t){
|
|
300
|
+
return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Bn.isIP(t.host)?"":t.host),Ni.connect(t)}function B(t,e,r){
|
|
301
|
+
t._readyState=P.CLOSING;let n=new Error(r);Error.captureStackTrace(n,B),e.setHeader?(e[Vn]=!0,e.abort(),e.socket&&!e.socket.
|
|
302
302
|
destroyed&&e.socket.destroy(),process.nextTick(wt,t,n)):(e.destroy(n),e.once("error",t.emit.bind(t,"error")),e.once("clo\
|
|
303
303
|
se",t.emitClose.bind(t)))}function ur(t,e,r){if(e){let n=Fi(e)?e.size:Ki(e).length;t._socket?t._sender._bufferedBytes+=n:
|
|
304
304
|
t._bufferedAmount+=n}if(r){let n=new Error(`WebSocket is not open: readyState ${t.readyState} (${te[t.readyState]})`);process.
|
|
305
305
|
nextTick(r,n)}}function Qi(t,e){let r=this[D];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[D]!==void 0&&
|
|
306
306
|
(r._socket.removeListener("data",yt),process.nextTick(Wn,r._socket),t===1005?r.close():r.close(t,e))}function Zi(){let t=this[D];
|
|
307
307
|
t.isPaused||t._socket.resume()}function ea(t){let e=this[D];e._socket[D]!==void 0&&(e._socket.removeListener("data",yt),
|
|
308
|
-
process.nextTick(Wn,e._socket),e.close(t[
|
|
308
|
+
process.nextTick(Wn,e._socket),e.close(t[Bi])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $n(){this[D].
|
|
309
309
|
emitClose()}function ta(t,e){this[D].emit("message",t,e)}function ra(t){let e=this[D];e._autoPong&&e.pong(t,!this._isServer,
|
|
310
|
-
|
|
310
|
+
Hn),e.emit("ping",t)}function na(t){this[D].emit("pong",t)}function Wn(t){t.resume()}function oa(t){let e=this[D];e.readyState!==
|
|
311
311
|
P.CLOSED&&(e.readyState===P.OPEN&&(e._readyState=P.CLOSING,Kn(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,
|
|
312
312
|
e.emit("error",t)))}function Kn(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Jn(){
|
|
313
313
|
let t=this[D];if(this.removeListener("close",Jn),this.removeListener("data",yt),this.removeListener("end",Xn),t._readyState=
|
|
314
314
|
P.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.
|
|
315
315
|
length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[D]=void 0,clearTimeout(
|
|
316
316
|
t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on(
|
|
317
|
-
"error"
|
|
317
|
+
"error",$n),t._receiver.on("finish",$n))}function yt(t){this[D]._receiver.write(t)||this.pause()}function Xn(){let t=this[D];
|
|
318
318
|
t._readyState=P.CLOSING,t._receiver.end(),this.end()}function Yn(){let t=this[D];this.removeListener("error",Yn),this.on(
|
|
319
|
-
"error",
|
|
319
|
+
"error",Hn),t&&(t._readyState=P.CLOSING,this.destroy())}});var ro=$((Fl,to)=>{"use strict";var Ll=It(),{Duplex:sa}=k("stream");function Zn(t){t.emit("close")}function ia(){!this.destroyed&&
|
|
320
320
|
this._writableState.finished&&this.destroy()}function eo(t){this.removeListener("error",eo),this.destroy(),this.listenerCount(
|
|
321
321
|
"error")===0&&this.emit("error",t)}function aa(t,e){let r=!0,n=new sa({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});
|
|
322
322
|
return t.on("message",function(s,i){let a=!i&&n._readableState.objectMode?s.toString():s;n.push(a)||t.pause()}),t.once("\
|
|
@@ -326,15 +326,15 @@ lose",function(){i||s(o),process.nextTick(Zn,n)}),r&&t.terminate()},n._final=fun
|
|
|
326
326
|
t.once("open",function(){n._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),n._readableState.
|
|
327
327
|
endEmitted&&n.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},n._read=function(){t.isPaused&&t.resume()},
|
|
328
328
|
n._write=function(o,s,i){if(t.readyState===t.CONNECTING){t.once("open",function(){n._write(o,s,i)});return}t.send(o,i)},
|
|
329
|
-
n.on("end",ia),n.on("error",eo),n}to.exports=aa});var lr
|
|
329
|
+
n.on("end",ia),n.on("error",eo),n}to.exports=aa});var lr=$((Ul,no)=>{"use strict";var{tokenChars:ca}=Ae();function da(t){let e=new Set,r=-1,n=-1,o=0;for(o;o<t.length;o++){
|
|
330
330
|
let i=t.charCodeAt(o);if(n===-1&&ca[i]===1)r===-1&&(r=o);else if(o!==0&&(i===32||i===9))n===-1&&r!==-1&&(n=o);else if(i===
|
|
331
331
|
44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let a=t.slice(r,n);if(e.has(a))throw new SyntaxError(
|
|
332
332
|
`The "${a}" subprotocol is duplicated`);e.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
333
333
|
if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let s=t.slice(r,o);if(e.has(s))throw new SyntaxError(
|
|
334
|
-
`The "${s}" subprotocol is duplicated`);return e.add(s),e}no.exports={parse:da}});var lo
|
|
335
|
-
ve=
|
|
334
|
+
`The "${s}" subprotocol is duplicated`);return e.add(s),e}no.exports={parse:da}});var lo=$(($l,uo)=>{"use strict";var ua=k("events"),St=k("http"),{Duplex:ql}=k("stream"),{createHash:la}=k("crypto"),oo=vt(),
|
|
335
|
+
ve=_e(),pa=lr(),fa=It(),{CLOSE_TIMEOUT:ma,GUID:ha,kWebSocket:va}=Q(),ga=/^[+/0-9A-Za-z]{22}==$/,so=0,io=1,co=2,pr=class extends ua{constructor(e,r){
|
|
336
336
|
if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*1024,maxPayload:100*1024*
|
|
337
|
-
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:
|
|
337
|
+
1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:ma,verifyClient:null,
|
|
338
338
|
noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:fa,...e},e.port==null&&!e.server&&!e.noServer||
|
|
339
339
|
e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server"\
|
|
340
340
|
, or "noServer" options must be specified');if(e.port!=null?(this._server=St.createServer((n,o)=>{let s=St.STATUS_CODES[426];
|
|
@@ -354,19 +354,19 @@ r.on("error",ao);let s=e.headers["sec-websocket-key"],i=e.headers.upgrade,a=+e.h
|
|
|
354
354
|
lid Upgrade header");return}if(s===void 0||!ga.test(s)){ge(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}
|
|
355
355
|
if(a!==13&&a!==8){ge(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}
|
|
356
356
|
if(!this.shouldHandle(e)){We(r,400);return}let c=e.headers["sec-websocket-protocol"],d=new Set;if(c!==void 0)try{d=pa.parse(
|
|
357
|
-
c)}catch{ge(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],
|
|
357
|
+
c)}catch{ge(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let l=e.headers["sec-websocket-extensions"],m={};
|
|
358
358
|
if(this.options.perMessageDeflate&&l!==void 0){let f=new ve({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.
|
|
359
|
-
options.maxPayload});try{let g=oo.parse(l);g[ve.extensionName]&&(f.accept(g[ve.extensionName]),
|
|
359
|
+
options.maxPayload});try{let g=oo.parse(l);g[ve.extensionName]&&(f.accept(g[ve.extensionName]),m[ve.extensionName]=f)}catch{
|
|
360
360
|
ge(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let f={
|
|
361
361
|
origin:e.headers[`${a===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.
|
|
362
362
|
options.verifyClient.length===2){this.options.verifyClient(f,(g,I,S,A)=>{if(!g)return We(r,I||401,S,A);this.completeUpgrade(
|
|
363
|
-
|
|
363
|
+
m,s,d,e,r,n,o)});return}if(!this.options.verifyClient(f))return We(r,401)}this.completeUpgrade(m,s,d,e,r,n,o)}completeUpgrade(e,r,n,o,s,i,a){
|
|
364
364
|
if(!s.readable||!s.writable)return s.destroy();if(s[va])throw new Error("server.handleUpgrade() was called more than onc\
|
|
365
365
|
e with the same socket, possibly due to a misconfiguration");if(this._state>so)return We(s,503);let d=["HTTP/1.1 101 Swi\
|
|
366
|
-
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${la("sha1").update(r+
|
|
367
|
-
se64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(n.size){let
|
|
368
|
-
handleProtocols(n,o):n.values().next().value;
|
|
369
|
-
let
|
|
366
|
+
tching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${la("sha1").update(r+ha).digest("ba\
|
|
367
|
+
se64")}`],l=new this.options.WebSocket(null,void 0,this.options);if(n.size){let m=this.options.handleProtocols?this.options.
|
|
368
|
+
handleProtocols(n,o):n.values().next().value;m&&(d.push(`Sec-WebSocket-Protocol: ${m}`),l._protocol=m)}if(e[ve.extensionName]){
|
|
369
|
+
let m=e[ve.extensionName].params,f=oo.format({[ve.extensionName]:[m]});d.push(`Sec-WebSocket-Extensions: ${f}`),l._extensions=
|
|
370
370
|
e}this.emit("headers",d,o),s.write(d.concat(`\r
|
|
371
371
|
`).join(`\r
|
|
372
372
|
`)),s.removeListener("error",ao),l.setSocket(s,i,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxBufferedChunks:this.
|
|
@@ -380,182 +380,183 @@ l","Content-Length":Buffer.byteLength(r),...n},t.once("finish",t.destroy),t.end(
|
|
|
380
380
|
`)+`\r
|
|
381
381
|
\r
|
|
382
382
|
`+r)}function ge(t,e,r,n,o,s){if(t.listenerCount("wsClientError")){let i=new Error(o);Error.captureStackTrace(i,ge),t.emit(
|
|
383
|
-
"wsClientError",i,r,e)}else We(r,n,o,s)}});function T(t){return String(t??"").trim()}var
|
|
383
|
+
"wsClientError",i,r,e)}else We(r,n,o,s)}});function T(t){return String(t??"").trim()}var Hu=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function L(t,{fallback:e=""}={}){return String(t||"").trim()||e}function E(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function V(t,{fallback:e=0}={}){let r=Number(t);return!Number.isInteger(r)||r<1?e:r}var Gu=Object.freeze({interrupted:Object.freeze({text:"Stopped.",messageCode:"assistant.turn.stopped"}),failed:Object.freeze(
|
|
384
|
+
{text:"Assistant stopped with an error.",messageCode:"assistant.turn.failed"})});var dl=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(t=>["compact","compacted","compaction",
|
|
384
385
|
"truncate","truncated","truncation"].flatMap(e=>[`${t}_${e}`,`${e}_${t}`]))]);var F=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
385
|
-
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),
|
|
386
|
-
F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),
|
|
387
|
-
rename as
|
|
386
|
+
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),ml=new Set(Object.values(F)),hl=new Set([F.CANCELLED,
|
|
387
|
+
F.COMPLETED,F.FAILED,F.INTERRUPTED,F.TIMED_OUT]),vl=new Set([F.ACTIVE,F.FINALIZING,F.STARTING]);var ya=se(ro(),1),Ia=se(vt(),1),Sa=se(_e(),1),xa=se(rr(),1),Ta=se(sr(),1),ba=se(lr(),1),Ca=se(It(),1),_a=se(lo(),1);import{createHash as po}from"node:crypto";import{execFile as Ea}from"node:child_process";import{open as Oa,readFile as Yl,
|
|
388
|
+
rename as Ql,rm as Zl,writeFile as ep}from"node:fs/promises";import mr from"node:path";import{promisify as Ra}from"node:util";var sp=Ra(Ea);var Pa=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
388
389
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
389
390
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
390
391
|
ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
|
|
391
392
|
"unified_exec_zsh_fork","view_image"]);function Ke(t=""){return Array.from(String(t)).some(e=>{let r=e.codePointAt(0);return r<=
|
|
392
393
|
31||r===127})}function fo(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===
|
|
393
|
-
Object.prototype||e===null}function
|
|
394
|
-
t))
|
|
394
|
+
Object.prototype||e===null}function mo(t){if(!t||typeof t!="object"||Object.isFrozen(t))return t;for(let e of Object.values(
|
|
395
|
+
t))mo(e);return Object.freeze(t)}function ka(t="",e={}){let r=new Error(T(t)||"Codex cannot prove the helper execution p\
|
|
395
396
|
olicy.");r.code="codex_policy_unenforceable",r.details=Object.freeze({...e});for(let[n,o]of Object.entries(r.details))["\
|
|
396
397
|
code","details","message","name"].includes(n)||(r[n]=o);return r}function Ma({clientName:t="jskit",minimumVersion:e="0.1\
|
|
397
398
|
51.0",disabledFeatures:r=Pa,limits:{userAgentMaxLength:n=512,mcpServerMaxCount:o=128,mcpServerNameMaxLength:s=256,configResponseMaxBytes:i=256*
|
|
398
|
-
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:l=256*1024,hookResponseMaxBytes:
|
|
399
|
-
1024}={},createError:f=ka}={}){let g=new WeakSet;function I(u,p,
|
|
400
|
-
f8")}catch{throw f(`Codex helper execution received an invalid ${
|
|
401
|
-
n oversized ${
|
|
399
|
+
1024,hookMaxCount:a=256,hookErrorMaxCount:c=256,hookFieldMaxLength:d=2048,hookFingerprintMaxLength:l=256*1024,hookResponseMaxBytes:m=512*
|
|
400
|
+
1024}={},createError:f=ka}={}){let g=new WeakSet;function I(u,p,h){let v=0;try{v=Buffer.byteLength(JSON.stringify(u),"ut\
|
|
401
|
+
f8")}catch{throw f(`Codex helper execution received an invalid ${h}.`)}if(v>p)throw f(`Codex helper execution received a\
|
|
402
|
+
n oversized ${h}.`)}function S(u){if(typeof u?.currentConnectionGeneration!="function")throw f("Codex helper execution c\
|
|
402
403
|
annot verify the app-server connection generation.");let p=u.currentConnectionGeneration();if(!Number.isSafeInteger(p)||
|
|
403
404
|
p<=0)throw f("Codex helper execution found no active app-server connection.");return p}async function A(u){if(typeof u?.
|
|
404
405
|
currentHelperExecutionContext!="function")throw f("Codex helper execution requires its dedicated isolated provider.");let p=await u.
|
|
405
|
-
currentHelperExecutionContext(),
|
|
406
|
-
|
|
407
|
-
{accountIdentitySignature:v,cwd:
|
|
408
|
-
if(!p)return null;let
|
|
409
|
-
let p=T(u);if(!p||p.length>n||Ke(p))return null;let
|
|
406
|
+
currentHelperExecutionContext(),h=T(p?.cwd),v=T(p?.accountIdentitySignature);if(p?.executionMode!=="helper"||!h||!mr.isAbsolute(
|
|
407
|
+
h)||!/^sha256:[a-f0-9]{64}$/u.test(v))throw f("Codex helper runtime isolation could not be verified.");return Object.freeze(
|
|
408
|
+
{accountIdentitySignature:v,cwd:h,executionMode:"helper"})}function O(u=""){let p=T(u).match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/u);
|
|
409
|
+
if(!p)return null;let h=p.slice(1).map(v=>Number.parseInt(v,10));return h.every(Number.isSafeInteger)?h:null}function N(u=""){
|
|
410
|
+
let p=T(u);if(!p||p.length>n||Ke(p))return null;let h=`${t}/`;if(!p.startsWith(h))return null;let v=p.slice(h.length).match(
|
|
410
411
|
/^((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:$|[ \t].*$)/u);return v?O(v[1]):null}function j(u){if(typeof u?.currentServerInfo!=
|
|
411
412
|
"function")throw f("Codex helper execution cannot verify the app-server version. Update Codex and retry.",{minimumVersion:e});
|
|
412
|
-
let p=T(u.currentServerInfo()?.userAgent),
|
|
413
|
-
er version. Update Codex and retry.",{minimumVersion:e});let v=
|
|
414
|
-
-1&&
|
|
413
|
+
let p=T(u.currentServerInfo()?.userAgent),h=N(p);if(!h)throw f("Codex helper execution received an unrecognised app-serv\
|
|
414
|
+
er version. Update Codex and retry.",{minimumVersion:e});let v=h.join("."),y=O(e),w=h.findIndex((b,_)=>b!==y[_]);if(w!==
|
|
415
|
+
-1&&h[w]<y[w])throw f(`Codex helper execution requires app-server ${e} or newer; current version is ${v}. Update Codex a\
|
|
415
416
|
nd retry.`,{actualVersion:v,minimumVersion:e});return Object.freeze({minimumVersion:e,version:v})}function z(u=null){if(!fo(
|
|
416
417
|
u?.config))throw f("Codex helper execution could not read the effective app-server configuration.");let p=u.config.mcp_servers;
|
|
417
418
|
if(p==null)return[];if(I(p,i,"MCP configuration"),!fo(p))throw f("Codex helper execution received an invalid MCP server \
|
|
418
|
-
configuration.");let
|
|
419
|
-
ceived an oversized or invalid MCP server inventory.");return
|
|
419
|
+
configuration.");let h=Object.keys(p);if(h.length>o||h.some(v=>!v||v.length>s||Ke(v)))throw f("Codex helper execution re\
|
|
420
|
+
ceived an oversized or invalid MCP server inventory.");return h.sort()}function K(u=null,p=""){if(I(u,m,"hook inventory"),
|
|
420
421
|
!Array.isArray(u?.data))throw f("Codex helper execution could not enumerate app-server hooks.");if(u.data.length!==1)throw f(
|
|
421
|
-
"Codex helper execution received an unexpected hook inventory.");let
|
|
422
|
-
isArray(
|
|
423
|
-
an incomplete hook inventory.");if(
|
|
424
|
-
ry has errors.",{hookErrorCount:
|
|
425
|
-
|
|
422
|
+
"Codex helper execution received an unexpected hook inventory.");let h=u.data[0];if(T(h?.cwd)!==p||T(h?.cwd).length>d||!Array.
|
|
423
|
+
isArray(h.hooks)||!Array.isArray(h.errors)||h.hooks.length>a||h.errors.length>c)throw f("Codex helper execution received\
|
|
424
|
+
an incomplete hook inventory.");if(h.errors.length>0)throw f("Codex helper execution cannot continue while hook discove\
|
|
425
|
+
ry has errors.",{hookErrorCount:h.errors.length});let v=h.hooks.map(w=>{let b=T(w?.key),_=T(w?.currentHash),R=T(w?.handlerType),
|
|
426
|
+
C=T(w?.sourcePath);if(!b||[b,_,R,C].some(Y=>Y.length>d||Ke(Y)))throw f("Codex helper execution found an invalid hook inv\
|
|
426
427
|
entory entry.");if(w?.isManaged===!0&&w?.enabled===!0)throw f("Codex helper execution cannot disable a managed hook.");return{
|
|
427
|
-
currentHash:
|
|
428
|
+
currentHash:_,enabled:w?.enabled===!0,handlerType:R,isManaged:w?.isManaged===!0,key:b,sourcePath:C}}).sort((w,b)=>w.key.
|
|
428
429
|
localeCompare(b.key)),y=JSON.stringify(v);if(y.length>l)throw f("Codex helper execution received an oversized hook inven\
|
|
429
|
-
tory.");return{fingerprint:y,hookKeys:v.filter(w=>!w.isManaged).map(w=>w.key)}}function
|
|
430
|
-
mcpServerNames:v=[]}={}){let y={features:Object.fromEntries(r.map(b=>[b,!1])),hooks:{state:Object.fromEntries(
|
|
430
|
+
tory.");return{fingerprint:y,hookKeys:v.filter(w=>!w.isManaged).map(w=>w.key)}}function H({effort:u="",summary:p="",hookKeys:h=[],
|
|
431
|
+
mcpServerNames:v=[]}={}){let y={features:Object.fromEntries(r.map(b=>[b,!1])),hooks:{state:Object.fromEntries(h.map(b=>[
|
|
431
432
|
b,{enabled:!1}]))},include_apps_instructions:!1,include_collaboration_mode_instructions:!1,include_environment_context:!1,
|
|
432
433
|
include_permissions_instructions:!1,...u?{model_reasoning_effort:u}:{},...p?{model_reasoning_summary:p}:{},mcp_servers:Object.
|
|
433
434
|
fromEntries(v.map(b=>[b,{enabled:!1}])),memories:{dedicated_tools:!1,generate_memories:!1,use_memories:!1},notify:[],orchestrator:{
|
|
434
435
|
mcp:{enabled:!1},skills:{enabled:!1}},project_doc_max_bytes:0,shell_environment_policy:{inherit:"none",set:{}},skills:{include_instructions:!1},
|
|
435
|
-
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},w=
|
|
436
|
-
w),w}function
|
|
437
|
-
summary:y,hookKeys:b.hookKeys,mcpServerNames:w})}}async function ne(u,{effort:p="",summary:
|
|
436
|
+
tools:{experimental_request_user_input:{enabled:!1},update_plan:{enabled:!1}},web_search:"disabled"},w=mo(y);return g.add(
|
|
437
|
+
w),w}function q(u,p,h,{effort:v="",summary:y=""}={}){let w=z(u),b=K(p,h);return{mcpServerNames:w,hookState:b,config:H({effort:v,
|
|
438
|
+
summary:y,hookKeys:b.hookKeys,mcpServerNames:w})}}async function ne(u,{effort:p="",summary:h=""}={}){if(j(u),typeof u?.readConfig!=
|
|
438
439
|
"function"||typeof u?.listHooks!="function")throw f("Codex helper execution cannot inventory configuration and hooks.");
|
|
439
440
|
let v=await A(u),y=S(u),w=await u.readConfig({cwd:v.cwd,includeLayers:!1});if(S(u)!==y)throw f("Codex app-server reconne\
|
|
440
441
|
cted during helper policy verification.");let b=await u.listHooks([v.cwd]);if(S(u)!==y)throw f("Codex app-server reconne\
|
|
441
|
-
cted during helper policy verification.");let{mcpServerNames:
|
|
442
|
-
freeze({accountIdentitySignature:v.accountIdentitySignature,config:
|
|
443
|
-
fingerprint,hookKeys:Object.freeze([...R.hookKeys]),mcpServerNames:Object.freeze([...
|
|
442
|
+
cted during helper policy verification.");let{mcpServerNames:_,hookState:R,config:C}=q(w,b,v.cwd,{effort:p,summary:h});return Object.
|
|
443
|
+
freeze({accountIdentitySignature:v.accountIdentitySignature,config:C,connectionGeneration:y,executionCwd:v.cwd,hookFingerprint:R.
|
|
444
|
+
fingerprint,hookKeys:Object.freeze([...R.hookKeys]),mcpServerNames:Object.freeze([..._])})}function le(u=null,p=null){return u?.
|
|
444
445
|
accountIdentitySignature===p?.accountIdentitySignature&&u?.connectionGeneration===p?.connectionGeneration&&u?.executionCwd===
|
|
445
446
|
p?.executionCwd&&u?.hookFingerprint===p?.hookFingerprint&&JSON.stringify(u?.mcpServerNames||[])===JSON.stringify(p?.mcpServerNames||
|
|
446
|
-
[])}function
|
|
447
|
+
[])}function Ue(u,p,h=""){let v=T(h);if(!p)return u.codexAppServerHelperThreadId=v,u.codexAppServerHelperThreadRetired=!0,
|
|
447
448
|
u;let y=f("Codex could not retire a helper thread after policy verification failed.",{cleanupFailed:!0,threadId:v});return y.
|
|
448
449
|
codexAppServerHelperThreadCleanupRequired=!0,y.codexAppServerHelperThreadId=v,y}async function nt({error:u=null,provider:p=null,
|
|
449
|
-
threadId:
|
|
450
|
+
threadId:h=""}={}){let v=null;try{await p.deleteThread(h)}catch(y){v=y}throw Ue(u,v,h)}async function ot(u,p,h,v,y){try{
|
|
450
451
|
let w=await ne(u,{effort:p.config.model_reasoning_effort,summary:p.config.model_reasoning_summary});if(!le(p,w))throw f(
|
|
451
|
-
`Codex execution surfaces changed while the helper thread was ${y}.`);return Object.freeze({enforcement:w,thread:
|
|
452
|
+
`Codex execution surfaces changed while the helper thread was ${y}.`);return Object.freeze({enforcement:w,thread:h,threadId:v})}catch(w){
|
|
452
453
|
await nt({error:w,provider:u,threadId:v})}}async function pe(u,p){if(typeof u?.startThread!="function"||typeof u?.deleteThread!=
|
|
453
|
-
"function")throw f("Codex helper execution cannot own and clean up its app-server thread.");let
|
|
454
|
-
|
|
455
|
-
y,"starting")}async function st(u,p,
|
|
454
|
+
"function")throw f("Codex helper execution cannot own and clean up its app-server thread.");let h=await p(),v=await u.startThread(
|
|
455
|
+
h.settings),y=T(v?.id);if(!y)throw f("Codex app-server did not return a helper thread id.");return ot(u,h.enforcement,v,
|
|
456
|
+
y,"starting")}async function st(u,p,h){if(typeof u?.resumeThread!="function"||typeof u?.deleteThread!="function")throw f(
|
|
456
457
|
"Codex helper execution cannot safely resume and clean up its app-server thread.");let v=T(p);if(!v)throw f("Codex helpe\
|
|
457
|
-
r resume requires a controller-owned thread id.");let y=await
|
|
458
|
-
u,w,b,v,"resuming")}function xe({configResult:u,hookResult:p,workdir:
|
|
459
|
-
summary:y}).config}function it({approvalPolicy:u,baseInstructions:p,config:
|
|
460
|
-
return{allowProviderModelFallback:!1,approvalPolicy:u,baseInstructions:p,config:
|
|
461
|
-
environments:[],model:y.model,runtimeWorkspaceRoots:[],sandbox:w,selectedCapabilityRoots:[]}}function
|
|
462
|
-
sessionStartSource:"startup",threadSource:p}}function
|
|
458
|
+
r resume requires a controller-owned thread id.");let y=await h(),w=y.enforcement,b=await u.resumeThread(v,y.settings);return ot(
|
|
459
|
+
u,w,b,v,"resuming")}function xe({configResult:u,hookResult:p,workdir:h,effort:v="",summary:y=""}){return q(u,p,h,{effort:v,
|
|
460
|
+
summary:y}).config}function it({approvalPolicy:u,baseInstructions:p,config:h,cwd:v,effectiveSettings:y,sandbox:w,systemPrompt:b}){
|
|
461
|
+
return{allowProviderModelFallback:!1,approvalPolicy:u,baseInstructions:p,config:h,cwd:v,systemPrompt:b||null,dynamicTools:[],
|
|
462
|
+
environments:[],model:y.model,runtimeWorkspaceRoots:[],sandbox:w,selectedCapabilityRoots:[]}}function $t(u,p){return{...u,
|
|
463
|
+
sessionStartSource:"startup",threadSource:p}}function Bt(u){return{approvalPolicy:u.approvalPolicy,baseInstructions:u.baseInstructions,
|
|
463
464
|
config:u.config,cwd:u.cwd,systemPrompt:u.systemPrompt,model:u.model,runtimeWorkspaceRoots:u.runtimeWorkspaceRoots,sandbox:u.
|
|
464
|
-
sandbox}}function
|
|
465
|
-
model:
|
|
466
|
-
request.reasoning&&(y.effort=
|
|
467
|
-
hasConfiguration:u=>g.has(u),threadSettings:it,threadStartSettings
|
|
468
|
-
var
|
|
469
|
-
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",l=""){let
|
|
470
|
-
n is unavailable. Reconnect Codex and retry.");return
|
|
471
|
-
Codex authentication value",maxLength:
|
|
465
|
+
sandbox}}function Ht({approvalPolicy:u,cwd:p,effectiveSettings:h,outputSchema:v}){let y={approvalPolicy:u,cwd:p,environments:[],
|
|
466
|
+
model:h.model,outputSchema:v,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"none"};return h.
|
|
467
|
+
request.reasoning&&(y.effort=h.thinking),y}return Object.freeze({assertCompatibility:j,executionContext:A,inspect:ne,configuration:xe,
|
|
468
|
+
hasConfiguration:u=>g.has(u),threadSettings:it,threadStartSettings:$t,threadResumeSettings:Bt,turnSettings:Ht,start:pe,resume:st})}
|
|
469
|
+
var ip=Ma();var fr=1024*1024,Na=256*1024,ho=512,ja=128,Da=16*1024;function vo({errorPrefix:t="",identityNamespace:e="codex-account-v\
|
|
470
|
+
1",secretNamespace:r="codex-auth-secret-v1"}={}){function n(d="",l=""){let m=new Error(T(l)||"Codex helper authenticatio\
|
|
471
|
+
n is unavailable. Reconnect Codex and retry.");return m.code=T(d)||`${t}codex_helper_auth_unavailable`,m}function o(d,{label:l="\
|
|
472
|
+
Codex authentication value",maxLength:m=0}={}){if(typeof d!="string"||d.length===0||d.length>m)throw n(`${t}codex_helper\
|
|
472
473
|
_auth_invalid`,`${l} is missing or invalid. Reconnect Codex and retry.`);return d}function s(d="",l=""){return`sha256:${po(
|
|
473
474
|
"sha256").update(`${e}\0`,"utf8").update(T(d),"utf8").update("\0","utf8").update(String(l||""),"utf8").digest("hex")}`}function i(d=""){
|
|
474
475
|
return po("sha256").update(`${r}\0`,"utf8").update(String(d||""),"utf8").digest("hex")}async function a(d=""){let l=null;
|
|
475
|
-
try{l=await Oa(d,"r");let
|
|
476
|
+
try{l=await Oa(d,"r");let m=await l.stat();if(!m.isFile()||m.size>fr)throw n(`${t}codex_helper_auth_invalid`,"The select\
|
|
476
477
|
ed Codex authentication record is invalid. Reconnect Codex and retry.");let f=Buffer.alloc(fr+1),g=0;for(;g<f.length;){let{
|
|
477
478
|
bytesRead:S}=await l.read(f,g,f.length-g,null);if(S===0)break;g+=S}if(g>fr)throw n(`${t}codex_helper_auth_invalid`,"The \
|
|
478
479
|
selected Codex authentication record is too large. Reconnect Codex and retry.");let I=JSON.parse(f.subarray(0,g).toString(
|
|
479
|
-
"utf8"));if(!E(I))throw new Error("invalid authentication record");return I}catch(
|
|
480
|
-
dex_helper_auth_`)?
|
|
480
|
+
"utf8"));if(!E(I))throw new Error("invalid authentication record");return I}catch(m){throw m?.code?.startsWith?.(`${t}co\
|
|
481
|
+
dex_helper_auth_`)?m:n(`${t}codex_helper_auth_unavailable`,"The selected Codex authentication record could not be read. \
|
|
481
482
|
Reconnect Codex and retry.")}finally{await l?.close?.().catch(()=>null)}}async function c(d={}){let l=T(d.toolHomeSource);
|
|
482
|
-
if(!l||!
|
|
483
|
-
ct Codex and retry.");let
|
|
484
|
-
|
|
483
|
+
if(!l||!mr.isAbsolute(l))throw n(`${t}codex_helper_auth_unavailable`,"The selected Codex account is unavailable. Reconne\
|
|
484
|
+
ct Codex and retry.");let m=await a(mr.join(l,".codex","auth.json")),f=T(m.auth_mode).toLowerCase();if(f==="chatgpt"){let g=E(
|
|
485
|
+
m.tokens)?m.tokens:{},I=o(g.account_id,{label:"Codex account identity",maxLength:ho}),S=o(g.access_token,{label:"Codex a\
|
|
485
486
|
ccess token",maxLength:Na}),A=g.chatgpt_plan_type??g.plan_type,O=A==null||A===""?"":o(A,{label:"Codex plan type",maxLength:ja});
|
|
486
487
|
return Object.freeze({accessToken:S,accountId:I,authMode:"chatgpt",identitySignature:s("chatgpt",I),planType:O,secretSignature:i(
|
|
487
|
-
S)})}if(["apikey","api_key"].includes(f)){let g=o(
|
|
488
|
+
S)})}if(["apikey","api_key"].includes(f)){let g=o(m.OPENAI_API_KEY,{label:"Codex API key",maxLength:Da});return Object.freeze(
|
|
488
489
|
{apiKey:g,authMode:"apiKey",identitySignature:s("apiKey",g),secretSignature:i(g)})}throw n(`${t}codex_helper_auth_invali\
|
|
489
490
|
d`,"The selected Codex authentication mode is unsupported. Reconnect Codex and retry.")}return{error:n,identitySignature:s,
|
|
490
|
-
readRecord:a,readSelected:c}}import{execFile as za,spawn as
|
|
491
|
-
let{stdout:e}=await
|
|
492
|
-
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable",platform:o=process.platform,ps:s=
|
|
493
|
-
let a=o==="darwin"?100:25,c=1,d=Object.freeze({linux:"linux-proc",darwin:"darwin"}),l=d[o]||"",
|
|
491
|
+
readRecord:a,readSelected:c}}import{execFile as za,spawn as dp}from"node:child_process";import{mkdtemp as lp,open as pp,readFile as hr,readdir as La,rm as fp}from"node:fs/promises";import{setTimeout as go}from"node:timers/promises";import{promisify as Fa}from"node:util";var Ua=Fa(za);async function qa(t){
|
|
492
|
+
let{stdout:e}=await Ua("ps",t,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return e}function vr({runtimeTokenEnvironmentName:t="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:e="JSKIT_EXECUTION\
|
|
493
|
+
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable",platform:o=process.platform,ps:s=qa}={}){
|
|
494
|
+
let a=o==="darwin"?100:25,c=1,d=Object.freeze({linux:"linux-proc",darwin:"darwin"}),l=d[o]||"",m=Object.freeze({RUNNING:"\
|
|
494
495
|
running",STOPPED:"stopped"}),f=Object.freeze({ABSENT:"absent",AMBIGUOUS:"ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"\
|
|
495
|
-
mismatch"});function g(u={}){return!!(Number.isSafeInteger(Number(u.pid))&&Number(u.pid)>0&&j(u.processIdentity)&&[
|
|
496
|
-
|
|
496
|
+
mismatch"});function g(u={}){return!!(Number.isSafeInteger(Number(u.pid))&&Number(u.pid)>0&&j(u.processIdentity)&&[m.RUNNING,
|
|
497
|
+
m.STOPPED].includes(u.processState))}function I(u){let p=Number(u);if(!Number.isSafeInteger(p)||p<=0)return!1;try{return process.
|
|
497
498
|
kill(p,0),!0}catch{return!1}}function S(u){let p=Number(u);if(!Number.isSafeInteger(p)||p<=0)return!1;if(process.platform===
|
|
498
|
-
"win32")return I(p);try{return process.kill(-p,0),!0}catch{return!1}}function A(u,p){let
|
|
499
|
-
"win32"?
|
|
500
|
-
function O(u=""){let p=String(u||""),
|
|
501
|
-
v[0]||""),w=Number(v[1]),b=Number(v[2]),
|
|
502
|
-
isSafeInteger(b)||b<=0||!/^\d+$/u.test(
|
|
499
|
+
"win32")return I(p);try{return process.kill(-p,0),!0}catch{return!1}}function A(u,p){let h=Number(u),v=process.platform===
|
|
500
|
+
"win32"?h:-h;try{return process.kill(v,p),!0}catch(y){if(!["ESRCH","EPERM"].includes(String(y?.code||"")))throw y;return!1}}
|
|
501
|
+
function O(u=""){let p=String(u||""),h=p.lastIndexOf(")");if(h<0)return null;let v=p.slice(h+1).trim().split(/\s+/u),y=String(
|
|
502
|
+
v[0]||""),w=Number(v[1]),b=Number(v[2]),_=String(v[19]||"");return!/^[A-Z]$/u.test(y)||!Number.isSafeInteger(w)||w<0||!Number.
|
|
503
|
+
isSafeInteger(b)||b<=0||!/^\d+$/u.test(_)?null:{parentPid:w,processGroupId:b,startTimeTicks:_,state:y}}function N(u={}){
|
|
503
504
|
let p=E(u)?u:{};return{commandHash:T(p.commandHash),platform:T(p.platform),runtimeToken:T(p.runtimeToken),startTimeTicks:T(
|
|
504
505
|
p.startTimeTicks),version:Number(p.version||0)}}function j(u={}){let p=N(u);return!!(p.version===c&&Object.values(d).includes(
|
|
505
506
|
p.platform)&&/^[a-f0-9]{12}$/u.test(p.commandHash)&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu.
|
|
506
|
-
test(p.runtimeToken)&&/^\d+$/u.test(p.startTimeTicks))}function z(u=[],p=""){let
|
|
507
|
-
|
|
508
|
-
if(!
|
|
509
|
-
()=>""),w=O(y);if(!w||w.state==="Z")continue;let b=null,
|
|
510
|
-
|
|
511
|
-
pid:v,runtimeToken:z(R,t)})}return u}let
|
|
512
|
-
let p=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.exec(String(u).trim()),
|
|
513
|
-
if(
|
|
514
|
-
for(let
|
|
515
|
-
`)){let v=/^\s*(\d+) (.*)$/u.exec(
|
|
516
|
-
u))return null;let
|
|
517
|
-
let u=process.getuid(),p=["-x","-U",String(u),"-ww","-o","pid=,command="],[
|
|
518
|
-
,pgid=,uid=,stat=,lstart="]),s(p),s(["-E",...p])]),w=ne(v),b=ne(y),
|
|
519
|
-
`)){let
|
|
520
|
-
"Z"))continue;let Y=Number(
|
|
521
|
-
pid:Y,processGroupId:Number(
|
|
507
|
+
test(p.runtimeToken)&&/^\d+$/u.test(p.startTimeTicks))}function z(u=[],p=""){let h=u.find(v=>v.startsWith(`${p}=`));return h?
|
|
508
|
+
h.slice(p.length+1):""}async function K(){let u=[],p=await La("/proc",{withFileTypes:!0}).catch(()=>[]);for(let h of p){
|
|
509
|
+
if(!h.isDirectory()||!/^\d+$/u.test(h.name))continue;let v=Number(h.name),y=await hr(`/proc/${h.name}/stat`,"utf8").catch(
|
|
510
|
+
()=>""),w=O(y);if(!w||w.state==="Z")continue;let b=null,_=!0;try{b=await hr(`/proc/${h.name}/environ`)}catch(C){if(String(
|
|
511
|
+
C?.code||"")==="ENOENT")continue;_=!1}let R=_?b.toString("utf8").split("\0"):[];u.push({...w,commandHash:z(R,e),environmentReadable:_,
|
|
512
|
+
pid:v,runtimeToken:z(R,t)})}return u}let H=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function q(u=""){
|
|
513
|
+
let p=/^\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d{2}):(\d{2}):(\d{2})\s+(\d{4})$/u.exec(String(u).trim()),h=p?H.indexOf(p[1]):-1;
|
|
514
|
+
if(h<0)return"";let[,,v,y,w,b,_]=p.map(Number);return String(Date.UTC(_,h,v,y,w,b)/1e3)}function ne(u=""){let p=new Map;
|
|
515
|
+
for(let h of String(u).split(`
|
|
516
|
+
`)){let v=/^\s*(\d+) (.*)$/u.exec(h);v&&p.set(Number(v[1]),v[2])}return p}function le(u,p){if(u===void 0||!p?.startsWith(
|
|
517
|
+
u))return null;let h=p.slice(u.length).split(/\s+/u).filter(v=>/^[^=\s]+=/u.test(v));return h.length?h:null}async function Ue(){
|
|
518
|
+
let u=process.getuid(),p=["-x","-U",String(u),"-ww","-o","pid=,command="],[h,v,y]=await Promise.all([s(["-ax","-o","pid=\
|
|
519
|
+
,pgid=,uid=,stat=,lstart="]),s(p),s(["-E",...p])]),w=ne(v),b=ne(y),_=[];for(let R of String(h).split(`
|
|
520
|
+
`)){let C=/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\w{3}\s+\w{3}\s+\d{1,2}\s+[\d:]{8}\s+\d{4})\s*$/u.exec(R);if(!C||C[4].startsWith(
|
|
521
|
+
"Z"))continue;let Y=Number(C[1]),oe=Number(C[3])===u?le(w.get(Y),b.get(Y)):null;_.push({commandHash:z(oe||[],e),environmentReadable:!!oe,
|
|
522
|
+
pid:Y,processGroupId:Number(C[2]),runtimeToken:z(oe||[],t),startTimeTicks:q(C[5])})}return _}function nt(u={}){let p=Object.
|
|
522
523
|
values(f).includes(u?.status)?u.status:f.AMBIGUOUS;return{processGroupIds:[...new Set((Array.isArray(u?.processGroupIds)?
|
|
523
|
-
u.processGroupIds:[]).map(Number).filter(
|
|
524
|
-
processGroupIds:[],status:f.INVALID};if(u.processState===
|
|
525
|
-
|
|
526
|
-
let v=Number(u.pid),y=
|
|
527
|
-
|
|
528
|
-
v);if(
|
|
529
|
-
status:f.AMBIGUOUS}:{processGroupIds:[],status:y.length>0||S(v)?f.MISMATCH:f.ABSENT};let R=[...new Set(w.map(({processGroupId:
|
|
530
|
-
for(let
|
|
531
|
-
return{processGroupIds:[],status:f.AMBIGUOUS};return y.some(
|
|
532
|
-
AMBIGUOUS}:{processGroupIds:R,status:f.EXACT}}async function pe(u={},p={}){let
|
|
533
|
-
ction"?p.processIdentityInspector:ot;return nt(await
|
|
534
|
-
u,p);for(;Date.now()<v&&y.status===f.EXACT;)await go(100),y=await pe(u,p);return y}async function xe(u={},p={}){let
|
|
535
|
-
p.processIdentitySettleTimeoutMs,{fallback:1e3}),v=V(p.processIdentitySettlePollMs,{fallback:a}),y=Date.now()+
|
|
524
|
+
u.processGroupIds:[]).map(Number).filter(h=>Number.isSafeInteger(h)&&h>0))],status:p}}async function ot(u={}){if(!g(u))return{
|
|
525
|
+
processGroupIds:[],status:f.INVALID};if(u.processState===m.STOPPED)return{processGroupIds:[],status:f.ABSENT};let p=u.processIdentity,
|
|
526
|
+
h=p.platform!==l?null:o==="darwin"?await Ue().catch(()=>null):await K();if(!h)return{processGroupIds:[],status:f.AMBIGUOUS};
|
|
527
|
+
let v=Number(u.pid),y=h.filter(({processGroupId:C})=>C===v),w=[],b=y.some(({environmentReadable:C})=>!C);for(let C of h)
|
|
528
|
+
C.environmentReadable&&C.runtimeToken===p.runtimeToken&&C.commandHash===p.commandHash&&w.push(C);let _=w.find(({pid:C})=>C===
|
|
529
|
+
v);if(_&&_.startTimeTicks!==p.startTimeTicks)return{processGroupIds:[],status:f.AMBIGUOUS};if(w.length===0)return b?{processGroupIds:[],
|
|
530
|
+
status:f.AMBIGUOUS}:{processGroupIds:[],status:y.length>0||S(v)?f.MISMATCH:f.ABSENT};let R=[...new Set(w.map(({processGroupId:C})=>C))];
|
|
531
|
+
for(let C of R)if(h.filter(oe=>oe.processGroupId===C).some(oe=>!oe.environmentReadable||!w.some(({pid:Gs})=>Gs===oe.pid)))
|
|
532
|
+
return{processGroupIds:[],status:f.AMBIGUOUS};return y.some(C=>!w.some(({pid:Y})=>Y===C.pid))?{processGroupIds:[],status:f.
|
|
533
|
+
AMBIGUOUS}:{processGroupIds:R,status:f.EXACT}}async function pe(u={},p={}){let h=typeof p.processIdentityInspector=="fun\
|
|
534
|
+
ction"?p.processIdentityInspector:ot;return nt(await h(u))}async function st(u={},p={},h=0){let v=Date.now()+h,y=await pe(
|
|
535
|
+
u,p);for(;Date.now()<v&&y.status===f.EXACT;)await go(100),y=await pe(u,p);return y}async function xe(u={},p={}){let h=V(
|
|
536
|
+
p.processIdentitySettleTimeoutMs,{fallback:1e3}),v=V(p.processIdentitySettlePollMs,{fallback:a}),y=Date.now()+h,w=await pe(
|
|
536
537
|
u,p);for(;w.status===f.AMBIGUOUS&&Date.now()<y;)await go(Math.min(v,Math.max(1,y-Date.now()))),w=await pe(u,p);return w}
|
|
537
|
-
async function it(u={},p="SIGTERM",
|
|
538
|
-
u,
|
|
539
|
-
R=>R!==w),...y.processGroupIds.filter(R=>R===w)],
|
|
540
|
-
f.MISMATCH)return{inspection:
|
|
541
|
-
|
|
542
|
-
if(!g(u))return{identityStatus:f.INVALID,processExitVerified:!1,stopped:!1};if(u.processState===
|
|
543
|
-
return{alreadyStopped:!0,identityStatus:f.ABSENT,processExitVerified:!0,stopped:!1};let
|
|
544
|
-
ABSENT||
|
|
545
|
-
identityStatus:
|
|
538
|
+
async function it(u={},p="SIGTERM",h={}){let v=typeof h.signalProcessGroup=="function"?h.signalProcessGroup:A,y=await xe(
|
|
539
|
+
u,h);if(y.status!==f.EXACT)return{inspection:y,signaledProcessGroups:[]};let w=Number(u.pid),b=[...y.processGroupIds.filter(
|
|
540
|
+
R=>R!==w),...y.processGroupIds.filter(R=>R===w)],_=[];for(let R of b){let C=await xe(u,h);if(C.status===f.ABSENT||C.status===
|
|
541
|
+
f.MISMATCH)return{inspection:C,signaledProcessGroups:_};if(C.status!==f.EXACT)return{inspection:C,signaledProcessGroups:_};
|
|
542
|
+
C.processGroupIds.includes(R)&&(v(R,p),_.push(R))}return{inspection:await xe(u,h),signaledProcessGroups:_}}async function $t(u={},p={}){
|
|
543
|
+
if(!g(u))return{identityStatus:f.INVALID,processExitVerified:!1,stopped:!1};if(u.processState===m.STOPPED&&u.processExitVerifiedAt)
|
|
544
|
+
return{alreadyStopped:!0,identityStatus:f.ABSENT,processExitVerified:!0,stopped:!1};let h=await xe(u,p);if(h.status===f.
|
|
545
|
+
ABSENT||h.status===f.MISMATCH)return{identityStatus:h.status,processExitVerified:!0,stopped:!1};if(h.status!==f.EXACT)return{
|
|
546
|
+
identityStatus:h.status,processExitVerified:!1,stopped:!1};let v=await it(u,"SIGTERM",p);if(v.inspection.status===f.AMBIGUOUS)
|
|
546
547
|
return{identityStatus:v.inspection.status,processExitVerified:!1,signaledProcessGroups:v.signaledProcessGroups,stopped:!1};
|
|
547
|
-
let y=await st(u,p,V(p.termTimeoutMs,{fallback:3e3})),w=[...v.signaledProcessGroups];if(y.status===f.EXACT){let
|
|
548
|
-
u,"SIGKILL",p);if(w=[...new Set([...w,...
|
|
548
|
+
let y=await st(u,p,V(p.termTimeoutMs,{fallback:3e3})),w=[...v.signaledProcessGroups];if(y.status===f.EXACT){let _=await it(
|
|
549
|
+
u,"SIGKILL",p);if(w=[...new Set([...w,..._.signaledProcessGroups])],_.inspection.status===f.AMBIGUOUS)return{identityStatus:_.
|
|
549
550
|
inspection.status,processExitVerified:!1,signaledProcessGroups:w,stopped:!1};y=await st(u,p,V(p.killTimeoutMs,{fallback:1e3}))}
|
|
550
|
-
let b=[f.ABSENT,f.MISMATCH].includes(y.status);return{descendantProcessGroups:w.filter(
|
|
551
|
-
status,pid:Number(u.pid),processExitVerified:b,signaledProcessGroups:w,stopped:b&&w.length>0}}async function
|
|
552
|
-
"darwin")return O(await
|
|
553
|
-
u)]).catch(()=>"")),
|
|
554
|
-
async function
|
|
555
|
-
b)&&b.commandHash===y&&b.runtimeToken===w)return b;let
|
|
556
|
-
startTimeTicks||R.processGroupId!==
|
|
551
|
+
let b=[f.ABSENT,f.MISMATCH].includes(y.status);return{descendantProcessGroups:w.filter(_=>_!==Number(u.pid)),identityStatus:y.
|
|
552
|
+
status,pid:Number(u.pid),processExitVerified:b,signaledProcessGroups:w,stopped:b&&w.length>0}}async function Bt(u){if(o!==
|
|
553
|
+
"darwin")return O(await hr(`/proc/${u}/stat`,"utf8").catch(()=>""));let p=String(await s(["-o","pgid=,lstart=","-p",String(
|
|
554
|
+
u)]).catch(()=>"")),h=/^\s*(\d+)\s+(.+?)\s*$/u.exec(p);return h?{processGroupId:Number(h[1]),startTimeTicks:q(h[2])}:null}
|
|
555
|
+
async function Ht({commandHash:u="",pid:p=null,reportedIdentity:h=null,runtimeToken:v=""}={}){let y=T(u),w=T(v),b=N(h);if(j(
|
|
556
|
+
b)&&b.commandHash===y&&b.runtimeToken===w)return b;let _=Number(p),R=l&&Number.isSafeInteger(_)&&_>0?await Bt(_):null;if(!R?.
|
|
557
|
+
startTimeTicks||R.processGroupId!==_){let C=new Error(`${r} process identity could not be captured.`);throw C.code=n,C}return{
|
|
557
558
|
commandHash:y,platform:l,runtimeToken:w,startTimeTicks:R.startTimeTicks,version:c}}return Object.freeze({normalize:N,isValid:j,
|
|
558
|
-
normalizeInspection:nt,capture:
|
|
559
|
+
normalizeInspection:nt,capture:Ht,inspect:pe,stop:$t,isProcessAlive:I})}var xt=(t,e,r,n={})=>Object.freeze({id:t,contextWindow:e,variants:Object.freeze(r),...n}),$a=Object.freeze([Object.freeze(
|
|
559
560
|
{id:"deepseek",baseUrl:"https://api.deepseek.com/",claudeBaseUrl:"https://api.deepseek.com/anthropic",claudeAutoCompactWindow:786432,
|
|
560
561
|
webSearch:!1,models:Object.freeze([xt("deepseek-flash",1048576,["low","high","max"],{images:!0,freeformPatch:!0,codexHistoryRouting:!0}),
|
|
561
562
|
xt("deepseek-v4-pro",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),Object.freeze({id:"zai-\
|
|
@@ -563,44 +564,44 @@ coding-plan",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/a
|
|
|
563
564
|
webSearch:!1,models:Object.freeze([xt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])}),
|
|
564
565
|
Object.freeze({id:"zai",baseUrl:"https://api.z.ai/api/v1",claudeBaseUrl:"https://api.z.ai/api/anthropic",claudeAutoCompactWindow:1e6,
|
|
565
566
|
webSearch:!1,models:Object.freeze([xt("glm-5.3",1048576,["low","high","max"],{freeformPatch:!0,codexHistoryRouting:!0})])})]);
|
|
566
|
-
function we(t){return
|
|
567
|
-
deepseek:we("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":we("zai-coding-plan").baseUrl,zai:we("zai").baseUrl});var
|
|
568
|
-
UNREACHABLE:"unreachable"}),
|
|
569
|
-
SUSPECT:"suspect"}),Va=Object.freeze({RUNNING:"running",STOPPED:"stopped"})
|
|
570
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
571
|
-
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var
|
|
572
|
-
in",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
573
|
-
versionName:"1.0.0"});var
|
|
574
|
-
"metadata","migrations","runtime","vite"]);var
|
|
575
|
-
|
|
567
|
+
function we(t){return $a.find(e=>e.id===t)||null}var Sp=32*1024*1024,xp=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
568
|
+
deepseek:we("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":we("zai-coding-plan").baseUrl,zai:we("zai").baseUrl});var Ep=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var Dp=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),zp=vr();var Ha=Object.freeze({UNIX:"unix"});var Lp=process.platform==="linux"?107:103,Fp=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
569
|
+
UNREACHABLE:"unreachable"}),Up=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
570
|
+
SUSPECT:"suspect"}),Va=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),qp=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
571
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var $p=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
|
|
572
|
+
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});var Ff=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),Uf=vo().error;var qf=32*1024,$f=2*1024*1024;var Bf=64*1024,Hf=2*1024*1024,Vf=4*1024*1024;import{createRequire as gc}from"node:module";var vc=new URL("./../../../@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var rh=gc(vc);var dh=Object.freeze(["bundled","dev_server"]),uh=Object.freeze(["capacitor"]),lh=Object.freeze({callbackPath:"/auth/log\
|
|
573
|
+
in",customScheme:"",appLinkDomains:Object.freeze([])}),ph=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
574
|
+
versionName:"1.0.0"});var kh=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Mh=Object.freeze(["capabilities","kind",
|
|
575
|
+
"metadata","migrations","runtime","vite"]);var av=64*1024;var Rt=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
576
|
+
cv=new Set(Object.values(Rt)),dv=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","pro\
|
|
576
577
|
jectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
577
|
-
|
|
578
|
+
uv=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),lv=Object.freeze(["accountIde\
|
|
578
579
|
ntitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtimes\
|
|
579
|
-
Hash","terminalEnvHash","toolHomeSource","transport"]),
|
|
580
|
+
Hash","terminalEnvHash","toolHomeSource","transport"]),pv=Object.freeze(["userAgent"]);var xw=Object.freeze([/^(?:let me|i(?:'|’)ll|i will|i(?:'|’)m going to|i am going to)\s+(?:(?:first|now|quickly)\s+)*(?:analy[sz]e|call|check|confirm|do|execute|fetch|find|inspect|investigate|load|look up|open|prepare|query|read|retrieve|review|run|search|summarize|test|try|use|verify)\b/iu,
|
|
580
581
|
/^(?:analy[sz]ing|calling|checking|confirming|executing|fetching|finding|inspecting|investigating|loading|looking up|opening|preparing|querying|reading|retrieving|reviewing|running|searching|summarizing|testing|trying|using|verifying)\b/iu,
|
|
581
|
-
/^(?:one moment|please wait)\b/iu]);var
|
|
582
|
-
attachments:!1,tools:!1,nativeTools:!1});var
|
|
582
|
+
/^(?:one moment|please wait)\b/iu]);var Dw=16*1024*1024;var Fw=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).href;var Jw=5*6e4;var Fc=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
|
|
583
|
+
attachments:!1,tools:!1,nativeTools:!1});var Uy=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
583
584
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
584
|
-
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var
|
|
585
|
+
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});var hI=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
585
586
|
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
586
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var
|
|
587
|
-
if(!
|
|
587
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});var II=2*1024*1024,SI=32*1024*1024,xI=2*1024*1024;var Ho=/^[a-z][a-z0-9_.-]*$/u,Bc=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function Vo(t,e){let r=String(t||"").trim().toLowerCase();
|
|
588
|
+
if(!Ho.test(r))throw new TypeError(`${e} must match ${Ho.toString()}.`);return r}function Rr(t,e){if(t==null)return Object.
|
|
588
589
|
freeze({});if(!E(t))throw new TypeError(`${e} must be an object mapping local names to capability ids.`);let r={},n=new Set;
|
|
589
|
-
for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!
|
|
590
|
+
for(let[o,s]of Object.entries(t)){let i=String(o||"").trim();if(!Bc.test(i))throw new TypeError(`${e} local name "${i}" \
|
|
590
591
|
must be a JavaScript identifier.`);let a=Vo(s,`${e}.${i}`);if(n.has(a))throw new TypeError(`${e} declares capability "${a}\
|
|
591
|
-
" more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function
|
|
592
|
+
" more than once.`);n.add(a),r[i]=a}return Object.freeze(r)}function Hc(t){let e=new Map;for(let[r,n]of Object.entries(t))
|
|
592
593
|
for(let o of Object.keys(n)){if(e.has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${e.get(o)}\
|
|
593
594
|
and ${r}.`);e.set(o,r)}}function Pr(t,e){if(t==null)return null;if(typeof t!="function")throw new TypeError(`${e} must \
|
|
594
595
|
be a function when provided.`);return t}function kt({id:t,requires:e={},optional:r={},provides:n={},setup:o,boot:s=null,
|
|
595
|
-
shutdown:i=null}={}){let a=Vo(t,"Provider id"),c=Rr(e,`${a}.requires`),d=Rr(r,`${a}.optional`),l=Rr(n,`${a}.provides`);
|
|
596
|
-
{requires:c,optional:d,provides:l});let
|
|
597
|
-
freeze({id:a,requires:c,optional:d,provides:l,setup:
|
|
596
|
+
shutdown:i=null}={}){let a=Vo(t,"Provider id"),c=Rr(e,`${a}.requires`),d=Rr(r,`${a}.optional`),l=Rr(n,`${a}.provides`);Hc(
|
|
597
|
+
{requires:c,optional:d,provides:l});let m=Pr(o,`${a}.setup`);if(!m)throw new TypeError(`${a}.setup is required.`);return Object.
|
|
598
|
+
freeze({id:a,requires:c,optional:d,provides:l,setup:m,boot:Pr(s,`${a}.boot`),shutdown:Pr(i,`${a}.shutdown`)})}var Go="public";function Wo(){let t=[],e=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
|
|
598
599
|
tration is closed after the first payload is resolved.");let l=L(a);if(!l)throw new TypeError("Bootstrap contributor id \
|
|
599
600
|
is required.");if(typeof d!="function")throw new TypeError(`Bootstrap contributor "${l}" requires contribute().`);if(e.has(
|
|
600
601
|
l))throw new Error(`Bootstrap contributor "${l}" is duplicated.`);return e.add(l),t.push(Object.freeze({id:l,order:Number.
|
|
601
|
-
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((l,
|
|
602
|
-
(l,
|
|
603
|
-
freeze({...E(a)?a:{},payload:Object.freeze({...c})}));c={...c,...E(
|
|
602
|
+
isFinite(c)?Number(c):0,contribute:d})),i}async function o(a={}){r=!0;let c={},d=t.map((l,m)=>({entry:l,index:m})).sort(
|
|
603
|
+
(l,m)=>l.entry.order-m.entry.order||l.index-m.index).map(({entry:l})=>l);for(let l of d){let m=await l.contribute(Object.
|
|
604
|
+
freeze({...E(a)?a:{},payload:Object.freeze({...c})}));c={...c,...E(m)?m:{}}}return Object.freeze(c)}function s(){return Object.
|
|
604
605
|
freeze({sealed:r,contributorIds:Object.freeze(t.map(a=>a.id).sort())})}let i=Object.freeze({register:n,resolve:o,diagnostics:s});
|
|
605
606
|
return i}var Vc=kt({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
|
|
606
607
|
http:t}){let e=Wo();return t.router.register("GET","/api/bootstrap",{auth:Go,meta:{tags:["bootstrap"],summary:"Resolve a\
|
|
@@ -614,12 +615,12 @@ uired.");return Object.freeze({...t,type:e})}function Ko(){let t=[],e=new Set;fu
|
|
|
614
615
|
`Event listener "${a.id}" is duplicated.`);return e.add(a.id),t.push(a),s}async function n(i){let a=Wc(i);for(let c of t)
|
|
615
616
|
c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.freeze(t.
|
|
616
617
|
map(i=>i.id))})}let s=Object.freeze({register:r,publish:n,diagnostics:o});return s}var Kc=kt({id:"runtime.events",provides:{
|
|
617
|
-
events:"runtime.events"},setup(){return{events:Ko()}}});function
|
|
618
|
-
Xc(e)}function Xc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function kr(t){return t!==null&&typeof t=="object"
|
|
618
|
+
events:"runtime.events"},setup(){return{events:Ko()}}});function U(t){if(t===null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null||
|
|
619
|
+
Xc(e)}function Xc(t){return t!==null&&typeof t=="object"&&Object.getPrototypeOf(t)===null&&Reflect.ownKeys(t).length===0}function kr(t){return t!==null&&typeof t=="object"&&U(t.structure)&&U(t.operations)&&typeof t.validateWith=="function"&&
|
|
619
620
|
typeof t.toJsonSchema=="function"&&typeof t.cleanup=="function"}function Mt(t,e){if(!Object.hasOwn(e,"items"))return null;
|
|
620
|
-
let{items:r}=e;if(kr(r))return{kind:"schema",schema:r};if(
|
|
621
|
+
let{items:r}=e;if(kr(r))return{kind:"schema",schema:r};if(!U(r)||typeof r.type!="string")throw new Error(`Array field "${t}\
|
|
621
622
|
" must define items as either a Schema instance or a field definition object.`);return{kind:"definition",definition:r}}function Ze(t,e){
|
|
622
|
-
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(kr(r))return{kind:"schema",schema:r};if(
|
|
623
|
+
if(!Object.hasOwn(e,"values"))return null;let{values:r}=e;if(kr(r))return{kind:"schema",schema:r};if(!U(r)||typeof r.type!=
|
|
623
624
|
"string")throw new Error(`Object field "${t}" must define values as either a Schema instance or a field definition objec\
|
|
624
625
|
t.`);return{kind:"definition",definition:r}}function Nt(t,e){let r=Object.hasOwn(e,"schema"),n=Object.hasOwn(e,"values"),
|
|
625
626
|
o=Object.hasOwn(e,"additionalProperties");if(r&&n)throw new Error(`Object field "${t}" cannot define both schema and val\
|
|
@@ -663,14 +664,14 @@ ye("transforms",{uppercase:!0}):null,lowercase:({parameterValue:t})=>t?ye("trans
|
|
|
663
664
|
"transforms",{length:t}),unsigned:({parameterValue:t})=>t?ye("metadata",{unsigned:!0}):null,precision:({parameterValue:t})=>ye(
|
|
664
665
|
"metadata",{precision:t}),scale:({parameterValue:t})=>ye("metadata",{scale:t}),temporalPrecision:({parameterValue:t})=>ye(
|
|
665
666
|
"metadata",{temporalPrecision:t}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null};
|
|
666
|
-
function
|
|
667
|
-
isArray(n)&&!Array.isArray(o)){
|
|
667
|
+
function qr(t,e){for(let r of Object.keys(e)){let n=e[r],o=t[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
|
|
668
|
+
isArray(n)&&!Array.isArray(o)){qr(o,n);continue}t[r]=n}}function pd(t,e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(
|
|
668
669
|
"JSON Schema export hooks must return an object or null.");for(let r of Object.keys(e)){if(r===ue&&t[r]&&typeof t[r]=="o\
|
|
669
|
-
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){
|
|
670
|
-
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function
|
|
670
|
+
bject"&&typeof e[r]=="object"&&!Array.isArray(t[r])&&!Array.isArray(e[r])){qr(t[r],e[r]);continue}t[r]=e[r]}}function fd(t,e){
|
|
671
|
+
let n=[...Array.isArray(t.anyOf)&&Object.keys(t).length===1?t.anyOf:[t],...e];return n.length===1?t:{anyOf:n}}function md(t,e){
|
|
671
672
|
if(!Object.hasOwn(t.types,e.type))throw new Error(`No casting function for type: ${e.type}`);let r=t.types[e.type];if(typeof r.
|
|
672
673
|
toJsonSchema=="function")return r.toJsonSchema;let n=ud[e.type];if(!n)throw new Error(`Type '${e.type}' cannot be export\
|
|
673
|
-
ed to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
674
|
+
ed to JSON Schema without a toJsonSchema hook.`);return n}function hd(t,e,r){if(!Object.hasOwn(t.validators,e))return null;
|
|
674
675
|
let n=t.validators[e];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=ld[e];if(o)return o;throw new Error(
|
|
675
676
|
`Validator '${e}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function ps(t){if(t===
|
|
676
677
|
void 0)return"create";if(["create","replace","patch"].includes(t))return t;throw new Error(`Unsupported JSON Schema expo\
|
|
@@ -682,62 +683,62 @@ void 0&&e.operationDescriptor!==void 0)return{operationName:e.operationName,oper
|
|
|
682
683
|
e);return{operationName:r,operation:t.operations[r]}}function wd(t={}){let e={...t};return Object.defineProperty(e,zr,{value:{
|
|
683
684
|
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),e}function zt(t={}){return t[zr]?t[zr]:{definitions:{},
|
|
684
685
|
nodes:[],nextDefinitionId:1,rootNode:null}}function yd(t){return String(t).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
|
|
685
|
-
"")||"operation"}function Lr(t){return
|
|
686
|
+
"")||"operation"}function Lr(t){return U(t)&&Object.keys(t).length===1&&typeof t.$ref=="string"}function Dt(t){return Lr(
|
|
686
687
|
t)?{allOf:[t]}:t}function Id(t,e,r,n,o){return t.nodes.find(s=>s.schema===e&&s.operationName===r&&s.operation===n&&s.additionalProperties===
|
|
687
688
|
o)||null}function Sd(t,e){let r=yd(e),n=`SchemaNode_${t.nextDefinitionId}_${r}`;return t.nextDefinitionId+=1,n}function fs(t,e,r,n,o,{
|
|
688
689
|
root:s=!1}={}){let i=zt(e),a=Id(i,t,r,n,o);if(a)return s&&(a.pointer="#",i.rootNode=a),a;let c={schema:t,operationName:r,
|
|
689
690
|
operation:n,additionalProperties:o,status:"new",definitionName:s?null:Sd(i,r),pointer:s?"#":null};return s?i.rootNode=c:
|
|
690
|
-
c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function
|
|
691
|
+
c.pointer=`#/definitions/${c.definitionName}`,i.nodes.push(c),c}function ms(t,e){if(t.status==="built")return{$ref:t.pointer};
|
|
691
692
|
if(t.status==="building")return{$ref:t.pointer};let r=zt(e);t.status="building",t.pointer!=="#"&&(r.definitions[t.definitionName]=
|
|
692
693
|
{});let n=xd(t.schema,e,t.operationName,t.operation,t.additionalProperties);return t.status="built",t.pointer==="#"?n:(r.
|
|
693
|
-
definitions[t.definitionName]=n,{$ref:t.pointer})}function
|
|
694
|
-
i?{$ref:"#"}:
|
|
695
|
-
let s={},i=[];for(let[c,d]of Object.entries(t.structure))x(s,c,
|
|
694
|
+
definitions[t.definitionName]=n,{$ref:t.pointer})}function $r(t,e,r,n,o=!1){let s=zt(e),i=fs(t,e,r,n,o);return s.rootNode===
|
|
695
|
+
i?{$ref:"#"}:ms(i,e)}function tt(t,{referenceBacked:e=!1}={}){return{schema:t,referenceBacked:e}}function xd(t,e,r,n,o=!1){
|
|
696
|
+
let s={},i=[];for(let[c,d]of Object.entries(t.structure))x(s,c,Br(t,c,d,e,r,n)),n.enforceRequired&&d.required===!0&&i.push(
|
|
696
697
|
c);let a={type:"object",properties:s,additionalProperties:o};return i.length>0&&(a.required=i),a}function Td(t,e,r,n,o,s){
|
|
697
|
-
let i=Mt(e,r);if(!i)return null;if(i.kind==="schema")return{...Dt(
|
|
698
|
+
let i=Mt(e,r);if(!i)return null;if(i.kind==="schema")return{...Dt($r(i.schema,n,"replace",i.schema.operations.replace,!1)),
|
|
698
699
|
[ue]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,"schema")?"replace":o,c=a==="replace"?t.operations.
|
|
699
|
-
replace:s;return
|
|
700
|
-
ma")return{...Dt(
|
|
701
|
-
"object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return
|
|
702
|
-
definition,n,a,c)}function
|
|
700
|
+
replace:s;return Br(t,`${e}[]`,r.items,n,a,c)}function bd(t,e,r,n,o,s){let i=Ze(e,r);if(!i)return null;if(i.kind==="sche\
|
|
701
|
+
ma")return{...Dt($r(i.schema,n,"replace",i.schema.operations.replace,!1)),[ue]:{castType:"object"}};let a=i.definition.type===
|
|
702
|
+
"object"&&Object.hasOwn(i.definition,"schema")?"replace":o,c=a==="replace"?t.operations.replace:s;return Br(t,`${e}.*`,i.
|
|
703
|
+
definition,n,a,c)}function Cd(t,e,r,n,o,s){if(r.type==="object"){let a=Nt(e,r);if(a.kind==="nested")return tt($r(a.schema,
|
|
703
704
|
n,o,s,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return tt({type:"object",additionalProperties:!0});
|
|
704
|
-
if(a.kind==="map")return tt({type:"object",additionalProperties:bd(t,e,r,n,o,s)})}let i=
|
|
705
|
+
if(a.kind==="map")return tt({type:"object",additionalProperties:bd(t,e,r,n,o,s)})}let i=md(t,r)({schema:t,fieldName:e,definition:r,
|
|
705
706
|
operation:o,mode:o,options:n});if(!i||typeof i!="object"||Array.isArray(i))throw new Error(`Type '${r.type}' on field '${e}\
|
|
706
707
|
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=Td(t,e,r,n,o,s);if(a)return tt({...i,items:a},{
|
|
707
|
-
referenceBacked:Lr(i)})}return tt(i,{referenceBacked:Lr(i)})}function
|
|
708
|
-
operation:o,mode:o,options:n},a=
|
|
709
|
-
keys(r)){if(f==="type"||!Object.hasOwn(t.validators,f))continue;let g=
|
|
710
|
-
parameterValue:r[f],fieldSchema:{...c}});I&&pd(c,I)}c[ue]&&(
|
|
711
|
-
type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});let
|
|
708
|
+
referenceBacked:Lr(i)})}return tt(i,{referenceBacked:Lr(i)})}function Br(t,e,r,n,o,s){let i={schema:t,fieldName:e,definition:r,
|
|
709
|
+
operation:o,mode:o,options:n},a=Cd(t,e,r,n,o,s),c=a.referenceBacked?Dt(a.schema):{...a.schema},d={castType:r.type};for(let f of Object.
|
|
710
|
+
keys(r)){if(f==="type"||!Object.hasOwn(t.validators,f))continue;let g=hd(t,f,e);if(!g)continue;let I=g({...i,parameterName:f,
|
|
711
|
+
parameterValue:r[f],fieldSchema:{...c}});I&&pd(c,I)}c[ue]&&(qr(d,c[ue]),delete c[ue]);let l=[];r.nullable===!0&&l.push({
|
|
712
|
+
type:"null"}),r.nullOnEmpty===!0&&l.push({const:""});let m=Dt(fd(c,l));if(r.defaultTo!==void 0&&s.applyDefaults)if(typeof r.
|
|
712
713
|
defaultTo!="function"){let f=t._normalizeDefault(r,r.defaultTo,{fieldPath:e,currentObject:{},containerKey:e,objectBeforeCast:{},
|
|
713
714
|
options:{},settings:t._buildOperationSettings(o,s,{})});if(Object.keys(f.errors).length>0){let g=Object.values(f.errors)[0];
|
|
714
|
-
throw new Error(`defaultTo for "${e}" is invalid (${g.code}).`)}
|
|
715
|
-
return
|
|
716
|
-
!1:r.additionalProperties,i=zt(r),a=fs(t,r,n,o,s,{root:!0}),c={$schema:ad,...
|
|
715
|
+
throw new Error(`defaultTo for "${e}" is invalid (${g.code}).`)}m.default=f.value}else d.defaults={providedByFunction:!0};
|
|
716
|
+
return m[ue]=d,m}function hs(t,e={}){let r=wd(e),{operationName:n,operation:o}=gd(t,r),s=r.additionalProperties===void 0?
|
|
717
|
+
!1:r.additionalProperties,i=zt(r),a=fs(t,r,n,o,s,{root:!0}),c={$schema:ad,...ms(a,r)};return Object.keys(i.definitions).
|
|
717
718
|
length>0&&(c.definitions=i.definitions),c}function vs(t){return t!==null&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function Kr(t){return t instanceof
|
|
718
|
-
Le}function
|
|
719
|
+
Le}function _d(){return{self:!1,children:{}}}function gs(t){return Object.keys(t.children).length>0}function Ie(t,e){return`${t}\
|
|
719
720
|
.${String(e)}`}function Ts(t,e){return t===""?String(e):Ie(t,e)}function ws(t,e){if(t===e)return"";let r=`${e}.`;return t.
|
|
720
721
|
startsWith(r)?t.slice(r.length):null}function De(t,e){let r={};for(let n of Object.values(t)){let o=Ie(e,n.field);x(r,o,
|
|
721
722
|
{...n,field:o})}return r}function Gr(t){return jr(t,"validatePath")}function ys(t){let e={};for(let r of t){let n=Gr(r),
|
|
722
|
-
o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||x(o,i,
|
|
723
|
+
o=e;for(let s=0;s<n.length;s++){let i=n[s];Object.hasOwn(o,i)||x(o,i,_d()),s===n.length-1&&(o[i].self=!0),o=o[i].children}}
|
|
723
724
|
return e}function Ad(t,e){let r=t;for(let n of e){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
724
|
-
function Lt(t){return t===null?!0:Array.isArray(t)
|
|
725
|
+
function Lt(t){return t===null?!0:Array.isArray(t)||U(t)?Object.keys(t).length>0:t!==void 0}function Is(t){return[...t].
|
|
725
726
|
sort((e,r)=>{let n=/^[0-9]+$/.test(e),o=/^[0-9]+$/.test(r);return n&&o?Number(e)-Number(r):n?-1:o?1:e.localeCompare(r)})}
|
|
726
727
|
function Ed(t){return/^[0-9]+$/.test(t)}function Od(t,e=new WeakMap){if(e.has(t))return e.get(t);let r=Object.create(Le.
|
|
727
728
|
prototype);return e.set(t,r),r.structure=null,r.types=t.types,r.validators=t.validators,r.operations=t.operations,r.structure=
|
|
728
|
-
|
|
729
|
+
Ut(Ft(t.structure,e)),r._installOperationMethods(),Object.freeze(r)}function Ft(t,e=new WeakMap){if(t===null||typeof t!=
|
|
729
730
|
"object")return t;if(Kr(t))return Od(t,e);if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){let n=new RegExp(
|
|
730
731
|
t.source,t.flags);return n.lastIndex=t.lastIndex,n}if(e.has(t))return e.get(t);if(Array.isArray(t)){let n=[];e.set(t,n);
|
|
731
|
-
for(let o of t)n.push(Ft(o,e));return n}if(
|
|
732
|
-
o,e));return r}function
|
|
733
|
-
isArray(t))for(let r of t)
|
|
734
|
-
return
|
|
732
|
+
for(let o of t)n.push(Ft(o,e));return n}if(!U(t))return t;let r={};e.set(t,r);for(let[n,o]of Object.entries(t))x(r,n,Ft(
|
|
733
|
+
o,e));return r}function Ut(t,e=new WeakSet){if(t===null||typeof t!="object"||e.has(t)||Kr(t))return t;if(e.add(t),Array.
|
|
734
|
+
isArray(t))for(let r of t)Ut(r,e);else for(let r of Reflect.ownKeys(t))Ut(t[r],e);return Object.freeze(t)}function Hr(t){
|
|
735
|
+
return Ut(Ft(t))}function Wr(t,e,r=""){if(!Kr(t)||!Array.isArray(e)||e.length<1)return null;let[n,...o]=e;if(!Object.hasOwn(
|
|
735
736
|
t.structure,n))return null;let s=t.structure[n];if(o.length<1)return s;let i=Ts(r,n);return bs(t,s,o,i)}function bs(t,e,r,n){
|
|
736
737
|
if(e?.type==="object"){let o=t._resolveObjectFieldMode(n,e);return o.kind!=="nested"?null:Wr(o.schema,r,n)}if(e?.type===
|
|
737
738
|
"array"){let o=t._resolveArrayItemsConfig(n,e);if(!o||r.length<1)return null;let[s,...i]=r;if(!Ed(s))return null;let a=Ie(
|
|
738
739
|
n,s);return o.kind==="schema"?i.length<1?null:Wr(o.schema,i,a):i.length<1?o.definition:bs(t,o.definition,i,a)}return null}
|
|
739
740
|
function ze(t,e){let r={...t};if(Array.isArray(t.skipFields)){let n=t.skipFields.map(o=>ws(o,e)).filter(o=>o!==null&&o!==
|
|
740
|
-
"");n.length>0?r.skipFields=n:delete r.skipFields}if(
|
|
741
|
+
"");n.length>0?r.skipFields=n:delete r.skipFields}if(U(t.skipParams)){let n={};for(let[o,s]of Object.entries(t.skipParams)){
|
|
741
742
|
let i=ws(o,e);i===null||i===""||x(n,i,s)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var Rd=Object.
|
|
742
743
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
743
744
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
@@ -764,7 +765,7 @@ tion"))throw new Error("Unsupported validation option `operation`. Call `validat
|
|
|
764
765
|
.")}_buildOperationSettings(e,r,n){return{operationName:e,operation:r,targetFieldNames:r.targetFields==="input"?Object.keys(
|
|
765
766
|
n):Object.keys(this.structure),outputFieldNames:r.outputFields==="input"?Object.keys(n):Object.keys(this.structure),enforceRequired:r.
|
|
766
767
|
enforceRequired,applyDefaults:r.applyDefaults,rejectExplicitUndefined:r.rejectExplicitUndefined,defaultedFields:new Set,
|
|
767
|
-
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(
|
|
768
|
+
isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(e,r){if(!U(r))throw new Error(`${e}() expects a plain obje\
|
|
768
769
|
ct input.`)}_resolvePathValidationRequest(e={}){let r=e.operation??e.mode??"patch";if(Object.hasOwn(e,"operation")&&Object.
|
|
769
770
|
hasOwn(e,"mode")&&e.operation!==e.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
770
771
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
@@ -774,19 +775,19 @@ has(s))&&(!i&&!n.defaultedFields.has(s)||x(o,s,r[s]))}return o}_resolveObjectFie
|
|
|
774
775
|
return Mt(e,r)}_resolveObjectValuesConfig(e,r){return Ze(e,r)}_buildArrayItemSettings(e,r){return e.type==="object"&&Object.
|
|
775
776
|
hasOwn(e,"schema")?{...r,operationName:"replace",operation:this.operations.replace}:r}_castValue(e,r,n,o,s,i,a,c){let d=e.
|
|
776
777
|
nullable===!0||a.nullable===!0,l=e.nullOnEmpty===!0||a.nullOnEmpty===!0;if(!Object.hasOwn(this.types,e.type))throw new Error(
|
|
777
|
-
`No casting function for type: ${e.type}`);let
|
|
778
|
+
`No casting function for type: ${e.type}`);let m=this.types[e.type];if(r===null)return d?(x(o,s,null),{errors:{},shouldContinue:!1}):
|
|
778
779
|
{errors:this._singleErrorMap({field:n,code:"NOT_NULLABLE",message:"Field cannot be null",params:{}}),shouldContinue:!1};
|
|
779
780
|
if(r===""&&l)return x(o,s,null),{errors:{},shouldContinue:!1};let f={schema:this,definition:e,value:r,fieldName:n,object:o,
|
|
780
781
|
objectBeforeCast:i,valueBeforeCast:r,options:a,mode:c.operationName,operation:c.operationName,fieldPresent:!0,computedOptions:{
|
|
781
782
|
nullable:d||l,nullOnEmpty:l},throwTypeError:()=>{throw this._typeError(n)},throwParamError:(g,I,S)=>{throw this._paramError(
|
|
782
|
-
n,g,I,S)}};try{let g=
|
|
783
|
+
n,g,I,S)}};try{let g=m(f);if(vs(g))throw new Error(`Type handler for "${e.type}" must be synchronous.`);g!==void 0&&(x(o,
|
|
783
784
|
s,g),f.value=g)}catch(g){if(g.errorObject)return{errors:this._singleErrorMap(g.errorObject),shouldContinue:!1};throw g}return{
|
|
784
785
|
errors:{},context:f,shouldContinue:!0}}_runFieldValidators(e,r,n,o,s,i){for(let a of Object.keys(e)){if(a==="type"||this.
|
|
785
786
|
_paramToBeSkipped(a,i.skipParams,r)||!Object.hasOwn(this.validators,a))continue;let c=this.validators[a];try{s.parameterName=
|
|
786
787
|
a,s.parameterValue=e[a];let d=c(s);if(vs(d))throw new Error(`Validator handler for "${a}" must be synchronous.`);d!==void 0&&
|
|
787
788
|
(x(n,o,d),s.value=d)}catch(d){if(d.errorObject)return this._singleErrorMap(d.errorObject);throw d}}return{}}_normalizeAndValidateValue(e,r,n,o,s,i,a,c){
|
|
788
789
|
let d=this._castValue(e,r,n,o,s,i,a,c);if(Object.keys(d.errors).length>0)return d.errors;if(!d.shouldContinue)return{};let{
|
|
789
|
-
context:l}=d,
|
|
790
|
+
context:l}=d,m=this._validateNestedValue(e,n,o,s,a,c);return Object.keys(m).length>0?m:(l.value=o[s],this._runFieldValidators(
|
|
790
791
|
e,n,o,s,l,a))}_normalizeDefault(e,r,{fieldPath:n,currentObject:o,containerKey:s,objectBeforeCast:i,options:a,settings:c}){
|
|
791
792
|
let d={...o};return x(d,s,r),{errors:this._normalizeAndValidateValue(e,r,n,d,s,i,a,c),value:d[s]}}_validateNestedValue(e,r,n,o,s,i){
|
|
792
793
|
if(e.type==="object"){let c=this._resolveObjectFieldMode(r,e);return c.kind==="nested"?this._validateNestedObjectSchema(
|
|
@@ -798,15 +799,15 @@ a,e.schema,d.validatedObject):d.validatedObject),De(d.errors,r)}_extractKnownObj
|
|
|
798
799
|
entries(e))Object.hasOwn(r.structure,o)&&x(n,o,s);return n}_mergeKnownAndPassthroughObjectFields(e,r,n){let o={};for(let s of Object.
|
|
799
800
|
keys(e)){if(!Object.hasOwn(r.structure,s)){x(o,s,e[s]);continue}Object.hasOwn(n,s)&&x(o,s,n[s])}for(let[s,i]of Object.entries(
|
|
800
801
|
n))Object.hasOwn(o,s)||x(o,s,i);return o}_validateObjectValues(e,r,n,o,s,i){let a=r[n],c={...a},d={};x(r,n,c);for(let l of Object.
|
|
801
|
-
keys(a)){let
|
|
802
|
-
_mergeErrors(d,this._singleErrorMap(this._typeError(
|
|
803
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,f,ze(s,
|
|
804
|
-
d,De(I.errors,
|
|
802
|
+
keys(a)){let m=Ie(e,l);if(this._fieldToBeSkipped(m,s))continue;let f=c[l];if(f===void 0){i.rejectExplicitUndefined?this.
|
|
803
|
+
_mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let I=o.
|
|
804
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,f,ze(s,m));x(c,l,I.validatedObject),this._mergeErrors(
|
|
805
|
+
d,De(I.errors,m));continue}let g=this._normalizeAndValidateValue(o.definition,f,m,c,l,a,s,this._buildArrayItemSettings(o.
|
|
805
806
|
definition,i));this._mergeErrors(d,g)}return d}_validateArrayItems(e,r,n,o,s,i){let a=r[n],c=a.slice(),d={};x(r,n,c);for(let l=0;l<
|
|
806
|
-
c.length;l++){let
|
|
807
|
-
this._mergeErrors(d,this._singleErrorMap(this._typeError(
|
|
808
|
-
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],ze(s,
|
|
809
|
-
d,De(g.errors,
|
|
807
|
+
c.length;l++){let m=Ie(e,l);if(this._fieldToBeSkipped(m,s))continue;if(!Object.hasOwn(a,l)||c[l]===void 0){i.rejectExplicitUndefined?
|
|
808
|
+
this._mergeErrors(d,this._singleErrorMap(this._typeError(m).errorObject)):delete c[l];continue}if(o.kind==="schema"){let g=o.
|
|
809
|
+
schema._validateWithOperation("replace",o.schema.operations.replace,c[l],ze(s,m));x(c,l,g.validatedObject),this._mergeErrors(
|
|
810
|
+
d,De(g.errors,m));continue}let f=this._normalizeAndValidateValue(o.definition,c[l],m,c,l,a,s,this._buildArrayItemSettings(
|
|
810
811
|
o.definition,i));this._mergeErrors(d,f)}return d}_validateField(e,r,n,o,s){if(!Object.hasOwn(this.structure,e))return{};
|
|
811
812
|
let i=this.structure[e];if(this._fieldToBeSkipped(e,o))return{};let a=s.isFieldPresent(e),c=r[e],d=c===void 0;return s.enforceRequired&&
|
|
812
813
|
i.required&&(!a||d)&&!this._paramToBeSkipped("required",o.skipParams,e)?this._singleErrorMap({field:e,code:"REQUIRED",message:"\
|
|
@@ -816,13 +817,13 @@ i={...n},a=this._buildOperationSettings(e,r,n);for(let c of Object.keys(n))Objec
|
|
|
816
817
|
code:"FIELD_NOT_ALLOWED",message:"Field not allowed",params:{}});for(let c of a.targetFieldNames){let d=this._validateField(
|
|
817
818
|
c,n,i,o,a);this._mergeErrors(s,d)}if(a.applyDefaults){for(let c of Object.keys(this.structure))if(!a.isFieldPresent(c)&&
|
|
818
819
|
this.structure[c].defaultTo!==void 0){let d=this.structure[c],l=typeof d.defaultTo=="function"?d.defaultTo():d.defaultTo,
|
|
819
|
-
|
|
820
|
-
_mergeErrors(s,
|
|
820
|
+
m=this._normalizeDefault(d,l,{fieldPath:c,currentObject:i,containerKey:c,objectBeforeCast:n,options:o,settings:a});if(this.
|
|
821
|
+
_mergeErrors(s,m.errors),Object.keys(m.errors).length>0)continue;x(i,c,m.value),a.defaultedFields.add(c)}}return{validatedObject:this.
|
|
821
822
|
_buildOperationResult(n,i,a),errors:s}}_validateSelectedTree(e,r,n,o,s=""){let i={},a={};for(let c of Is(Object.keys(e))){
|
|
822
823
|
let d=Ts(s,c);if(!Object.hasOwn(this.structure,c))throw new Error(`Unknown schema path "${d}".`);let l=this._validateSelectedField(
|
|
823
824
|
c,e[c],r,a,n,o,d);this._mergeErrors(i,l)}return{validatedObject:a,errors:i}}_validateSelectedField(e,r,n,o,s,i,a){if(!Object.
|
|
824
825
|
hasOwn(this.structure,e))return{};let c=this.structure[e],d=r.self===!0,l=gs(r);if(this._fieldToBeSkipped(a,s))return{};
|
|
825
|
-
let
|
|
826
|
+
let m=Object.hasOwn(n,e),f=n[e],g={};if(!m){if(d&&i.enforceRequired&&c.required&&!this._paramToBeSkipped("required",s.skipParams,
|
|
826
827
|
a)&&this._mergeErrors(g,this._singleErrorMap({field:a,code:"REQUIRED",message:"Field is required",params:{}})),d&&i.applyDefaults&&
|
|
827
828
|
c.defaultTo!==void 0){let O=typeof c.defaultTo=="function"?c.defaultTo():c.defaultTo,N=this._normalizeDefault(c,O,{fieldPath:a,
|
|
828
829
|
currentObject:o,containerKey:e,objectBeforeCast:n,options:s,settings:i});this._mergeErrors(g,N.errors),Object.keys(N.errors).
|
|
@@ -831,20 +832,20 @@ a).errorObject):{};let I={[e]:f};if(d){let O=this._normalizeAndValidateValue(c,f
|
|
|
831
832
|
I[e]!==void 0?x(o,e,I[e]):I[e]===null&&x(o,e,null),O}if(!l)return{};let S=this._castValue(c,f,a,I,e,n,s,i);if(Object.keys(
|
|
832
833
|
S.errors).length>0)return S.errors;if(!S.shouldContinue)return{};let A=this._validateSelectedDescendants(c,r.children,a,
|
|
833
834
|
I,e,s,i);return Lt(I[e])&&x(o,e,I[e]),A}_validateSelectedDescendants(e,r,n,o,s,i,a){if(e.type==="object"){let c=this._resolveObjectFieldMode(
|
|
834
|
-
n,e);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let d=o[s];if(
|
|
835
|
+
n,e);if(c.kind!=="nested")throw new Error(`Schema path "${n}" does not support nested field selection.`);let d=o[s];if(!U(
|
|
835
836
|
d))return{};let l=c.schema._validateSelectedTree(r,d,ze(i,n),{...a,defaultedFields:new Set});return x(o,s,l.validatedObject),
|
|
836
837
|
De(l.errors,n)}if(e.type==="array"){let c=this._resolveArrayItemsConfig(n,e);if(!c)throw new Error(`Schema path "${n}" d\
|
|
837
838
|
oes not define array items for nested selection.`);return this._validateSelectedArrayItems(n,o,s,c,r,i,a)}throw new Error(
|
|
838
839
|
`Schema path "${n}" does not support nested field selection.`)}_validateSelectedArrayItems(e,r,n,o,s,i,a){let c=[],d=r[n],
|
|
839
|
-
l={};x(r,n,c);for(let
|
|
840
|
-
id because array segments must use numeric indexes.`);let f=Number(
|
|
840
|
+
l={};x(r,n,c);for(let m of Is(Object.keys(s))){if(!/^[0-9]+$/.test(m))throw new Error(`Schema path "${Ie(e,m)}" is inval\
|
|
841
|
+
id because array segments must use numeric indexes.`);let f=Number(m),g=Ie(e,f),I=s[m],S=I.self===!0,A=gs(I);if(this._fieldToBeSkipped(
|
|
841
842
|
g,i))continue;if(!Object.hasOwn(d,f)){S&&a.rejectExplicitUndefined&&x(l,g,this._typeError(g).errorObject);continue}let O=d[f];
|
|
842
843
|
if(O===void 0){S&&a.rejectExplicitUndefined&&x(l,g,this._typeError(g).errorObject);continue}if(o.kind==="schema"){if(S){
|
|
843
|
-
let
|
|
844
|
-
this._mergeErrors(l,De(
|
|
845
|
-
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Lt(
|
|
846
|
-
this._mergeErrors(l,De(
|
|
847
|
-
o.definition,O,g,j,0,d,i,N);Object.hasOwn(j,0)&&j[0]!==void 0?x(c,f,j[0]):j[0]===null&&x(c,f,null),this._mergeErrors(l,
|
|
844
|
+
let q=o.schema._validateWithOperation("replace",o.schema.operations.replace,O,ze(i,g));Lt(q.validatedObject)&&x(c,f,q.validatedObject),
|
|
845
|
+
this._mergeErrors(l,De(q.errors,g));continue}if(!A)continue;let H=o.schema._validateSelectedTree(I.children,O,ze(i,g),{...a,
|
|
846
|
+
operationName:"replace",operation:o.schema.operations.replace,defaultedFields:new Set});Lt(H.validatedObject)&&x(c,f,H.validatedObject),
|
|
847
|
+
this._mergeErrors(l,De(H.errors,g));continue}let N=this._buildArrayItemSettings(o.definition,a),j=[O];if(S){let H=this._normalizeAndValidateValue(
|
|
848
|
+
o.definition,O,g,j,0,d,i,N);Object.hasOwn(j,0)&&j[0]!==void 0?x(c,f,j[0]):j[0]===null&&x(c,f,null),this._mergeErrors(l,H);
|
|
848
849
|
continue}if(!A)continue;let z=this._castValue(o.definition,O,g,j,0,d,i,N);if(Object.keys(z.errors).length>0){this._mergeErrors(
|
|
849
850
|
l,z.errors);continue}if(!z.shouldContinue)continue;let K=this._validateSelectedDescendants(o.definition,I.children,g,j,0,
|
|
850
851
|
i,N);Lt(j[0])&&x(c,f,j[0]),this._mergeErrors(l,K)}return l}validateWith(e,r,n={}){if(!Object.hasOwn(this.operations,e))throw new Error(
|
|
@@ -856,12 +857,12 @@ isArray(e)||e.length===0)throw new Error("validatePaths() expects a non-empty ar
|
|
|
856
857
|
operation:s,validationOptions:i}=this._resolvePathValidationRequest(n);return this._validateSelectedTree(ys(e),r,i,this.
|
|
857
858
|
_buildOperationSettings(o,s,r))}_installOperationMethods(){for(let e of Object.keys(this.operations)){if(e in this)throw new Error(
|
|
858
859
|
`Operation name "${e}" is reserved and cannot be used as a schema method.`);this[e]=(r,n={})=>this.validateWith(e,r,n)}}toJsonSchema(e={}){
|
|
859
|
-
return
|
|
860
|
-
"")throw new Error("Field path must be a non-empty string.");let r=Wr(this,Gr(e.trim()));return r===null?null:
|
|
861
|
-
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):
|
|
862
|
-
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&x(n,o,e[o]);return n}};var{parse:
|
|
863
|
-
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=Nd(s[a++],d,r);return"["+i.join(",")+"]";function d(l,
|
|
864
|
-
|
|
860
|
+
return hs(this,e)}getFieldDefinitions(){return Hr(this.structure)}getFieldDefinition(e){if(typeof e!="string"||e.trim()===
|
|
861
|
+
"")throw new Error("Field path must be a non-empty string.");let r=Wr(this,Gr(e.trim()));return r===null?null:Hr(r)}getFieldMessages(e){
|
|
862
|
+
let r=this.getFieldDefinition(e);return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):Hr(r.messages)}cleanup(e,r){
|
|
863
|
+
let n={};for(let o of Object.keys(e))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&x(n,o,e[o]);return n}};var{parse:vS,stringify:Nd}=JSON,{keys:gS}=Object,jd=String,Dd="string";var Cs="object",zd=(t,e)=>e;var _s=(t,e,r)=>{let n=jd(e.push(r)-1);return t.set(r,n),n};var As=(t,e,r)=>{let n=e&&typeof e===Cs?(l,m)=>l===""||-1<e.indexOf(l)?m:void 0:e||zd,o=new Map,s=[],i=[],a=+_s(o,s,n.call(
|
|
864
|
+
{"":t},"",t)),c=!a;for(;a<s.length;)c=!0,i[a]=Nd(s[a++],d,r);return"["+i.join(",")+"]";function d(l,m){if(c)return c=!c,
|
|
865
|
+
m;let f=n.call(this,l,m);switch(typeof f){case Cs:if(f===null)return f;case Dd:return o.get(f)||_s(o,s,f)}return f}};var Fd=new Set(["true","1","yes","y","on"]),Ud=new Set(["false","0","no","n","off"]);function qd(t){return t!==null&&(typeof t==
|
|
865
866
|
"object"||typeof t=="function")&&typeof t.then=="function"}function Es(t){if(typeof t=="number")return Number.isFinite(t)?
|
|
866
867
|
t:null;if(typeof t=="bigint"){let e=Number(t);return Number.isSafeInteger(e)?e:null}if(typeof t=="string"){let e=t.trim();
|
|
867
868
|
if(e==="")return null;let r=Number(e);return Number.isFinite(r)?r:null}return null}function Jr(t,e){if(Object.is(t,e))return!0;
|
|
@@ -869,7 +870,7 @@ if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t in
|
|
|
869
870
|
source===e.source&&t.flags===e.flags;if(Array.isArray(t)||Array.isArray(e)){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==
|
|
870
871
|
e.length)return!1;for(let o=0;o<t.length;o++)if(!Jr(t[o],e[o]))return!1;return!0}if(t===null||e===null||typeof t!="objec\
|
|
871
872
|
t"||typeof e!="object"||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;let r=Object.keys(t),n=Object.keys(
|
|
872
|
-
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!Jr(t[o],e[o]))return!1;return!0}var
|
|
873
|
+
e);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(e,o)||!Jr(t[o],e[o]))return!1;return!0}var $d={install(t){
|
|
873
874
|
let{addType:e,addValidator:r}=t;e("none",n=>n.value),e("file",n=>{let o=n.value;o==null&&n.throwTypeError();let s=typeof o;
|
|
874
875
|
if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();return n.definition.noTrim?i:i.trim()}n.throwTypeError()}),
|
|
875
876
|
e("string",n=>{let o=n.value;if(o==null)return"";let s=typeof o;if(s==="string"||s==="number"||s==="boolean"){let i=o.toString();
|
|
@@ -879,12 +880,12 @@ o}),e("epochMilliseconds",n=>{let o=Nr(n.value,864e13);return o===null&&n.throwT
|
|
|
879
880
|
n.value,864e10);return o===null&&n.throwTypeError(),o}),e("dateTime",n=>{let o=et(n.definition,n.fieldName);return as(n.
|
|
880
881
|
value,o)||n.throwTypeError(),n.value}),e("date",n=>(ss(n.value)||n.throwTypeError(),n.value)),e("time",n=>{let o=et(n.definition,
|
|
881
882
|
n.fieldName);return is(n.value,o)||n.throwTypeError(),n.value}),e("array",n=>n.definition.type==="array"&&!Array.isArray(
|
|
882
|
-
n.value)?[n.value]:n.value),e("object",n=>(
|
|
883
|
+
n.value)?[n.value]:n.value),e("object",n=>(U(n.value)||n.throwTypeError(),n.value)),e("serialize",n=>{try{return JSON.stringify(
|
|
883
884
|
n.value)}catch{try{return As(n.value)}catch{n.throwTypeError()}}}),e("boolean",n=>{if(typeof n.value=="boolean")return n.
|
|
884
885
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
885
886
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
886
887
|
n.definition.stringFalseWhen||"false").trim().toLowerCase(),s=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
887
|
-
i=n.value.trim().toLowerCase(),a=new Set([
|
|
888
|
+
i=n.value.trim().toLowerCase(),a=new Set([...Ud,o]),c=new Set([...Fd,s]);if(a.has(i))return!1;if(c.has(i))return!0}n.throwTypeError()}),
|
|
888
889
|
e("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
889
890
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
890
891
|
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let s=Number(o);return Number.isSafeInteger(
|
|
@@ -905,7 +906,7 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
905
906
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
906
907
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
907
908
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
908
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
909
|
+
let o=n.parameterValue(n.value,n.object,n);if(qd(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
909
910
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
910
911
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
911
912
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
@@ -914,9 +915,9 @@ ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).leng
|
|
|
914
915
|
typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r(
|
|
915
916
|
"unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.
|
|
916
917
|
type!=="dateTime")throw new Error(`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r(
|
|
917
|
-
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},Os
|
|
918
|
-
unction")throw new Error(`Type handler for '${e}' must be a function.`);x(t,e,r)}function
|
|
919
|
-
on")throw new Error(`Validator handler for '${e}' must be a function.`);x(t,e,r)}function
|
|
918
|
+
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},Os=$d;var ks=new WeakMap,Ms=new WeakMap,Ns=Symbol.for("json-rest-schema.registry-metadata");function Bd(t,e,r){if(typeof r!="f\
|
|
919
|
+
unction")throw new Error(`Type handler for '${e}' must be a function.`);x(t,e,r)}function Hd(t,e,r){if(typeof r!="functi\
|
|
920
|
+
on")throw new Error(`Validator handler for '${e}' must be a function.`);x(t,e,r)}function qt(t={}){let e=Object.create(null);
|
|
920
921
|
for(let[r,n]of Object.entries(t))x(e,r,n);return e}function Vd(t,e){if(typeof t.install!="function")throw new Error("Plu\
|
|
921
922
|
gin must have an install method.");t.install(e)}function Rs(t,e,r){ks.set(t,e),Ms.set(t,r),Object.defineProperty(t,Ns,{value:Object.
|
|
922
923
|
freeze({getTypes:()=>e,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function Gd(t){if(!t||typeof t!=
|
|
@@ -926,19 +927,39 @@ typeof t=="object"&&t.types&&typeof t.types=="object"&&t.validators&&typeof t.va
|
|
|
926
927
|
nction"&&typeof t.replace=="function"&&typeof t.patch=="function"&&typeof t.toJsonSchema=="function"?{types:t.types,validators:t.
|
|
927
928
|
validators}:null}function Wd(t){return t.length===1&&Array.isArray(t[0])?t[0]:t}function Kd(t,e){return t===e}function Ps(t,e,r){
|
|
928
929
|
for(let[n,o]of Object.entries(e)){if(Object.hasOwn(t,n)&&!Kd(t[n],o))throw new Error(`Cannot merge schema factories with\
|
|
929
|
-
conflicting ${r} "${n}".`);x(t,n,o)}}function Jd(t,e,r){let n=Wd(r).filter(Boolean);if(n.length<1)return{types:
|
|
930
|
+
conflicting ${r} "${n}".`);x(t,n,o)}}function Jd(t,e,r){let n=Wd(r).filter(Boolean);if(n.length<1)return{types:qt(t),validators:qt(
|
|
930
931
|
e)};let o=Object.create(null),s=Object.create(null);for(let i of n){let a=Gd(i);if(!a)throw new Error("Factory sources m\
|
|
931
932
|
ust be schema instances or schema factories created by json-rest-schema.");Ps(o,a.types,"type"),Ps(s,a.validators,"valid\
|
|
932
|
-
ator")}return{types:o,validators:s}}function js({types:t={},validators:e={},installCore:r=!0}={}){let n=
|
|
933
|
-
let c=new Le(i,n,o,a.operations);return Rs(c,n,o),c};return Rs(s,n,o),s.addType=(i,a)=>{
|
|
934
|
-
|
|
933
|
+
ator")}return{types:o,validators:s}}function js({types:t={},validators:e={},installCore:r=!0}={}){let n=qt(t),o=qt(e),s=(i,a={})=>{
|
|
934
|
+
let c=new Le(i,n,o,a.operations);return Rs(c,n,o),c};return Rs(s,n,o),s.addType=(i,a)=>{Bd(n,i,a)},s.addValidator=(i,a)=>{
|
|
935
|
+
Hd(o,i,a)},s.use=i=>{Vd(i,{addType:s.addType,addValidator:s.addValidator})},s.createFactory=(...i)=>{let a=Jd(n,o,i);return js(
|
|
935
936
|
{types:a.types,validators:a.validators,installCore:!1})},r&&s.use(Os),s}var re=js({installCore:!0});function Se(t,e=new WeakSet){if(!t||typeof t!="object"||e.has(t))return t;e.add(t);for(let r of Object.getOwnPropertyNames(
|
|
936
|
-
t))Se(t[r],e);return Object.freeze(t)}var
|
|
937
|
-
|
|
938
|
-
|
|
937
|
+
t))Se(t[r],e);return Object.freeze(t)}var FS=Object.freeze({REQUIRED:{messageKey:"required",code:"kernel.validation.field.required"},TYPE_CAST_FAILED:{messageKey:"\
|
|
938
|
+
default",code:"kernel.validation.field.typeCastFailed"},NOT_NULLABLE:{messageKey:"default",code:"kernel.validation.field\
|
|
939
|
+
.notNullable"},MIN_LENGTH:{messageKey:"minLength",code:"kernel.validation.field.minLength"},MAX_LENGTH:{messageKey:"maxL\
|
|
940
|
+
ength",code:"kernel.validation.field.maxLength"},MIN_VALUE:{messageKey:"min",code:"kernel.validation.field.minValue"},MAX_VALUE:{
|
|
941
|
+
messageKey:"max",code:"kernel.validation.field.maxValue"},PATTERN:{messageKey:"pattern",code:"kernel.validation.field.pa\
|
|
942
|
+
ttern"},ENUM_VALUE:{messageKey:"enum",code:"kernel.validation.field.enumValue"},FIELD_NOT_ALLOWED:{messageKey:"additiona\
|
|
943
|
+
lProperties",code:"kernel.validation.field.notAllowed"},CUSTOM_VALIDATOR_FAILED:{messageKey:"validator",code:""},STRICT_BOOLEAN:{
|
|
944
|
+
messageKey:"default",code:"kernel.validation.field.strictBoolean"},RANGE_EXCEEDED:{messageKey:"default",code:"kernel.val\
|
|
945
|
+
idation.field.rangeExceeded"},NOT_EMPTY:{messageKey:"default",code:"kernel.validation.field.notEmpty"}}),US=Object.freeze(
|
|
946
|
+
{code:"kernel.validation.invalid",message:"Invalid value."});var Qd=re({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),Zd=Object.freeze({schema:Qd,
|
|
939
947
|
mode:"patch"});var zs=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),eu=Object.freeze(
|
|
940
|
-
{...zs,nullable:!0});var
|
|
941
|
-
|
|
948
|
+
{...zs,nullable:!0});var ux=new Map([{keyword:"required",code:"kernel.validation.required"},{keyword:"type",code:"kernel.validation.type"},{keyword:"\
|
|
949
|
+
minLength",code:"kernel.validation.minLength"},{keyword:"maxLength",code:"kernel.validation.maxLength"},{keyword:"minimu\
|
|
950
|
+
m",code:"kernel.validation.minimum"},{keyword:"maximum",code:"kernel.validation.maximum"},{keyword:"exclusiveMinimum",code:"\
|
|
951
|
+
kernel.validation.exclusiveMinimum"},{keyword:"exclusiveMaximum",code:"kernel.validation.exclusiveMaximum"},{keyword:"mu\
|
|
952
|
+
ltipleOf",code:"kernel.validation.multipleOf"},{keyword:"pattern",code:"kernel.validation.pattern"},{keyword:"format",code:"\
|
|
953
|
+
kernel.validation.format"},{keyword:"enum",code:"kernel.validation.enum"},{keyword:"const",code:"kernel.validation.const"},
|
|
954
|
+
{keyword:"minItems",code:"kernel.validation.minItems"},{keyword:"maxItems",code:"kernel.validation.maxItems"},{keyword:"\
|
|
955
|
+
additionalItems",code:"kernel.validation.additionalItems"},{keyword:"uniqueItems",code:"kernel.validation.uniqueItems"},
|
|
956
|
+
{keyword:"minProperties",code:"kernel.validation.minProperties"},{keyword:"maxProperties",code:"kernel.validation.maxPro\
|
|
957
|
+
perties"},{keyword:"additionalProperties",code:"kernel.validation.additionalProperties"},{keyword:"propertyNames",code:"\
|
|
958
|
+
kernel.validation.propertyNames"},{keyword:"oneOf",code:"kernel.validation.oneOf"},{keyword:"anyOf",code:"kernel.validat\
|
|
959
|
+
ion.anyOf"},{keyword:"not",code:"kernel.validation.not"},{keyword:"if",code:"kernel.validation.if"}].map(({keyword:t,code:e})=>[
|
|
960
|
+
t,e]));var Ls="^[1-9][0-9]*$",Xr=Se({type:"string",minLength:1,pattern:Ls}),ru=Se({...Xr,nullable:!0}),nu=Se({schema:re({recordId:{
|
|
961
|
+
...Xr,required:!0,messages:{pattern:{code:"kernel.validation.recordIdInvalid",message:"Record id must be a canonical pos\
|
|
962
|
+
itive integer string."}}}}),mode:"patch"});var Fs=20,Jx=32*1024,Xx=48*1024,Yr=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
942
963
|
execute:"assistant_action_execute"}),Qr=Object.freeze({type:"object",additionalProperties:!0}),iu=Object.freeze({type:"o\
|
|
943
964
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
944
965
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
@@ -954,27 +975,46 @@ chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},
|
|
|
954
975
|
string"},inputSchema:Qr,outputSchema:Qr}}),uu=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
955
976
|
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:Qr}}),lu=Object.
|
|
956
977
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
957
|
-
g"},version:{type:"integer",minimum:1},result:{}}})
|
|
978
|
+
g"},version:{type:"integer",minimum:1},result:{}}}),Us=Object.freeze([Object.freeze({name:Yr.search,description:"Discove\
|
|
958
979
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
959
980
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
960
981
|
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:iu,
|
|
961
982
|
outputSchema:au}),Object.freeze({name:Yr.contract,description:"Load the exact input and output contract for one availabl\
|
|
962
983
|
e action before executing it.",parameters:cu,outputSchema:du}),Object.freeze({name:Yr.execute,description:"Execute one a\
|
|
963
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:uu,outputSchema:lu})]);var
|
|
964
|
-
type:"string",maxLength:Fe.toolName,required:!1},arguments:{type:"string",maxLength:Fe.arguments,required:!1}}),
|
|
984
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:uu,outputSchema:lu})]);var kT=new URL("./../../../@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).href;var zT=256*1024;var LT=2*1024*1024;var FT=Us.map(({name:t,description:e,parameters:r})=>({type:"function",function:{name:t,description:e,parameters:r}}));var Fe=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var Eb=re({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Fe.text,required:!1},toolName:{
|
|
985
|
+
type:"string",maxLength:Fe.toolName,required:!1},arguments:{type:"string",maxLength:Fe.arguments,required:!1}}),Ob={type:"\
|
|
965
986
|
object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
|
|
966
987
|
eply","tool"]},text:{type:"string",maxLength:Fe.text,description:"The final reply, or a brief progress sentence for the \
|
|
967
988
|
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Fe.toolName},arguments:{type:"\
|
|
968
|
-
string",maxLength:Fe.arguments}}};
|
|
989
|
+
string",maxLength:Fe.arguments}}};var xC=Object.freeze([{message:"This conversation exceeds the configured API history limit. Start another conversation o\
|
|
990
|
+
r increase the limit.",messageCode:"assistant.conversation.apiHistoryLimit"},{message:"The model reached its output toke\
|
|
991
|
+
n limit before completing the answer. Increase maxOutputTokens in the conversation limits.",messageCode:"assistant.conve\
|
|
992
|
+
rsation.outputTokenLimit"},{message:"The model stream ended without confirming its application tool calls.",messageCode:"\
|
|
993
|
+
assistant.conversation.toolCallsUnconfirmed"},{message:"The model stream ended without confirming a completed answer.",messageCode:"\
|
|
994
|
+
assistant.conversation.answerUnconfirmed"},{message:"Application tool progress text exceeds the configured API limit.",messageCode:"\
|
|
995
|
+
assistant.conversation.toolProgressLimit"},{message:"The assistant exceeded the configured final reply limit.",messageCode:"\
|
|
996
|
+
assistant.conversation.finalReplyLimit"},{message:"Conversation updates exceed the configured history budget. Renew the \
|
|
997
|
+
context with a continuity briefing before continuing.",messageCode:"assistant.conversation.historyBudgetExceeded"},{message:"\
|
|
998
|
+
The continuity briefing exceeds the configured history budget.",messageCode:"assistant.conversation.briefingBudgetExceed\
|
|
999
|
+
ed"},{message:"Assistant provider is not configured.",messageCode:"assistant.provider.notConfigured"},{message:"The prev\
|
|
1000
|
+
ious submission was interrupted. Check delivery before submitting it again.",messageCode:"assistant.conversation.submiss\
|
|
1001
|
+
ionInterrupted"},{message:"The application restarted before this answer completed. The request was not replayed.",messageCode:"\
|
|
1002
|
+
assistant.conversation.restartInterrupted"},{message:"Copied into a stopped development environment. This request was no\
|
|
1003
|
+
t replayed.",messageCode:"assistant.conversation.copiedInterrupted"},{message:"The application operation result could no\
|
|
1004
|
+
t be saved. Restore storage access and retry saving.",messageCode:"assistant.conversation.operationResultUnsaved"},{message:"\
|
|
1005
|
+
Conversation progress could not be saved. Restore access to its storage before continuing.",messageCode:"assistant.conve\
|
|
1006
|
+
rsation.progressUnsaved"},{message:"The conversation request exceeded its time limit.",messageCode:"assistant.conversati\
|
|
1007
|
+
on.requestTimedOut"},{message:"Work stopped.",messageCode:"assistant.conversation.workStopped"},{message:"Stopped by use\
|
|
1008
|
+
r.",messageCode:"assistant.conversation.stoppedByUser"}]);function Zr({resolveConversation:t,readInstructions:e}={}){if(typeof t!="function")throw new TypeError("Conversation hoo\
|
|
969
1009
|
k delivery requires a binding resolver.");return async function(n){if(n.scope!=="session")return{kind:"unclaimed"};let o=await t(
|
|
970
1010
|
n);if(!o)return{kind:"unclaimed"};if(o.delivery==="native")return{kind:"delivery",text:""};if(o.delivery!=="hook")throw new TypeError(
|
|
971
1011
|
"Unknown conversation instruction delivery mode.");if(typeof e!="function")throw new TypeError("Hook delivery requires a\
|
|
972
1012
|
n instruction resolver.");let s=await e(o,n);if(typeof s!="string"||!s.trim())throw new TypeError("Managed conversation \
|
|
973
|
-
instructions are unavailable.");return{kind:"delivery",text:s}}}var
|
|
1013
|
+
instructions are unavailable.");return{kind:"delivery",text:s}}}var CC=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
974
1014
|
allowsManagedServer:!1,matchesProcess:({executable:t,commandLine:e})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
975
1015
|
test(`${t||""}\0${e}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:t,
|
|
976
|
-
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Du}from"node:fs/promises";import en from"node:path";var zu=Object.freeze(["main","temporary"]),
|
|
977
|
-
freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),Lu=64*1024,
|
|
1016
|
+
commandLine:e})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${t||""}\0${e}`)})});import{readFile as Du}from"node:fs/promises";import en from"node:path";var zu=Object.freeze(["main","temporary"]),Bs=Object.
|
|
1017
|
+
freeze(["managedDatabaseRefresh","managedEnvironment","managedGit","managedPreview"]),Lu=64*1024,t_=Object.freeze(["When\
|
|
978
1018
|
user input is necessary, ask no more than three concise, high-impact questions at once.","Put multiple questions on sep\
|
|
979
1019
|
arate lines as `[1] Question`, `[2] Question`, and so on.","For a small fixed set of useful choices, put `Possible answe\
|
|
980
1020
|
rs:` and a short bullet list directly beneath its own question, before the next one; never collect several questions' an\
|
|
@@ -988,7 +1028,7 @@ Possible answers:
|
|
|
988
1028
|
[2] Tell the main agent before changes?
|
|
989
1029
|
Possible answers:
|
|
990
1030
|
- Yes, tell main first
|
|
991
|
-
- No, proceed independently`]),
|
|
1031
|
+
- No, proceed independently`]),r_=Object.freeze(["The Vibe64-managed preview is the canonical application server; never \
|
|
992
1032
|
start a duplicate or replacement server. If it is unavailable, report that blocker. Describe only rendered browser evide\
|
|
993
1033
|
nce.","When adopting an authenticated app, or when its login blocks Preview inspection, inspect identity support/names w\
|
|
994
1034
|
ith `vibe64-helper preview status`; prefer `vibe64-helper preview browser identity <configured-name>` to requesting pass\
|
|
@@ -1011,64 +1051,64 @@ oice.","For interactive navigation, use the proxy URL from `vibe64-helper previe
|
|
|
1011
1051
|
l` / `endpoints.browser.url`. Inside browser eval, use `await page.goto(new URL('/your-path', preview.url).href)`. The d\
|
|
1012
1052
|
irect application endpoint under diagnostics bypasses Preview identity and is not a browser-navigation URL.","Use the ma\
|
|
1013
1053
|
naged preview browser for interactive browsing and `vibe64-helper playwright` only for an existing configured project su\
|
|
1014
|
-
ite;
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
permits, keep required viewport, identity and security checks, and use existing automated
|
|
1018
|
-
"For browser tests that write or reset data, inspect `vibe64-helper preview targets --json
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
and restores the previous Preview when the command finishes or is cancelled; report
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
and never invent a database name. Never spoof safety checks by changing only the test
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
starting another server. If test resources or external-effect controls are missing, report
|
|
1030
|
-
preview ensure --target <id> --wait --json` deliberately selects an interactive target
|
|
1031
|
-
is slow, measure migrations, fixtures and server startup before retrying or extending
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
or reread unchanged logs.","Batch related browser tests in one managed suite (one Preview
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
confirm `vibe64-helper playwright status` shows no active run and `vibe64-helper preview
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
never put values in arguments, logs, or repository files. Use empty stdin only when the
|
|
1051
|
-
"When the person refers to a saved key, account or accounts hub, run `vibe64-helper env
|
|
1052
|
-
fields, never values) and link the matching field to the variable the application reads
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
session storage.","After an Env mutation, report only the affected scope and key names,
|
|
1056
|
-
|
|
1057
|
-
generating it with the framework's own generator and piping it to `vibe64-helper env set <
|
|
1058
|
-
write it into a generated `.env` file: Vibe64 regenerates that file from Env."]);function tn(t=""){
|
|
1059
|
-
trim()}function rn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must
|
|
1060
|
-
function rt(t,e,r){let n=new Set(e),o=Object.keys(t).filter(s=>!n.has(s));if(o.length>0)throw new TypeError(
|
|
1061
|
-
|
|
1062
|
-
Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,
|
|
1063
|
-
|
|
1054
|
+
ite; never install another browser. Pin `@playwright/test` exactly to the `platformVersion` that `vibe64-helper playwrig\
|
|
1055
|
+
ht readiness` reports.","For browser evidence, batch related actions and assertions, return only needed values and inspe\
|
|
1056
|
+
ct relevant locators or regions; screenshot at meaningful checkpoints or failures, not after every click. Reuse the mana\
|
|
1057
|
+
ged browser when isolation permits, keep required viewport, identity and security checks, and use existing automated cas\
|
|
1058
|
+
es for repeat verification.","For browser tests that write or reset data, inspect `vibe64-helper preview targets --json`\
|
|
1059
|
+
and the project's `genesis/stack.md` Outputs. Run `vibe64-helper playwright --target <declared-test-target> test <suite\
|
|
1060
|
+
arguments>` (or `npm-run <script>` in place of `test`). Vibe64 starts that web target, waits for readiness, uses its de\
|
|
1061
|
+
clared application identity, and restores the previous Preview when the command finishes or is cancelled; report restora\
|
|
1062
|
+
tion failures.","A target name is not proof of test isolation. Before running a destructive suite, the application must \
|
|
1063
|
+
verify the server's actual test database and suppress real email, invoices, payments, and other external effects. Keep m\
|
|
1064
|
+
anaged Env unchanged. The test launcher and its preview-identity command must use the same database. Follow the applicat\
|
|
1065
|
+
ion's declared test resources and never invent a database name. Never spoof safety checks by changing only the test runn\
|
|
1066
|
+
er's environment.","If no suitable test target exists, add one through the project's existing Outputs contract and appli\
|
|
1067
|
+
cation-owned test scripts within authorized scope; normal Preview stays the default. Validate the exact disposable datab\
|
|
1068
|
+
ase before resetting it, prepare fixtures before reporting readiness, and make Playwright use PLAYWRIGHT_BASE_URL (the s\
|
|
1069
|
+
tarted target's URL) without starting another server. If test resources or external-effect controls are missing, report \
|
|
1070
|
+
that blocker. `vibe64-helper preview ensure --target <id> --wait --json` deliberately selects an interactive target unti\
|
|
1071
|
+
l changed. If browser startup is slow, measure migrations, fixtures and server startup before retrying or extending dead\
|
|
1072
|
+
lines.","Keep test output small: run relevant files/cases, save stdout/stderr to local artifacts and keep exit status. R\
|
|
1073
|
+
eport counts, duration, failed cases, actionable errors and artifact paths, reading only needed failure excerpts. Retain\
|
|
1074
|
+
startup, resource and Preview-restoration errors even if tests pass, and trailing wrapper diagnostics separately from J\
|
|
1075
|
+
SON. Do not rerun for output or reread unchanged logs.","Batch related browser tests in one managed suite (one Preview s\
|
|
1076
|
+
witch and restore). Suites and live Preview actions are sequential: no browser actions, ensure/restart or target changes\
|
|
1077
|
+
during a suite or restoration. Wait on the original execution, including background runs, through cleanup/restoration (\
|
|
1078
|
+
empty polls: yield_time_ms: 30000 where supported; shorter only for interactive input); read-only status/logs stay avail\
|
|
1079
|
+
able. Before live inspection, confirm `vibe64-helper playwright status` shows no active run and `vibe64-helper preview s\
|
|
1080
|
+
tatus` is ready on the restored target. To stop, run `vibe64-helper playwright cancel <run-id>`, which waits for cleanup\
|
|
1081
|
+
/restoration; retry if cleanup needs attention. Never kill test/Preview PIDs or change locks; launcher exit alone does n\
|
|
1082
|
+
ot prove tests stopped. Recheck status before reporting a busy blocker.","If a managed command reports kernel task denia\
|
|
1083
|
+
ls or a resource incident, report the blocker with its diagnostic and incident ID and ask the platform operator to inspe\
|
|
1084
|
+
ct that evidence before retrying; never raise test timeouts or weaken assertions to work around a process/thread limit. \
|
|
1085
|
+
A generic browser timeout without resource evidence does not establish a platform cause."]),n_=Object.freeze(["Each mana\
|
|
1086
|
+
ged shell command receives current development Env from Vibe64, including declared resource bindings; use them in ordina\
|
|
1087
|
+
ry commands. Do not build environment injection or copy managed credentials into source. Resource provisioning and appli\
|
|
1088
|
+
cation migrations remain separate preparation steps.","Use `vibe64-helper env status [development|production|all]` to in\
|
|
1089
|
+
spect configured key names without revealing values.","Pipe an available value to `vibe64-helper env set <development|pr\
|
|
1090
|
+
oduction> <KEY> [--secret]`; never put values in arguments, logs, or repository files. Use empty stdin only when the use\
|
|
1091
|
+
r requested an empty value.","When the person refers to a saved key, account or accounts hub, run `vibe64-helper env sav\
|
|
1092
|
+
ed` (names, descriptions and fields, never values) and link the matching field to the variable the application reads wit\
|
|
1093
|
+
h `vibe64-helper env link <development|production> <KEY> <saved-id> <field-id>` instead of asking for the value.","Keep \
|
|
1094
|
+
development and production values separate. Never invent credentials, copy a value between scopes without explicit direc\
|
|
1095
|
+
tion, or edit Vibe64 runtime/session storage.","After an Env mutation, report only the affected scope and key names, nev\
|
|
1096
|
+
er their values, and claim success only when the command succeeded.","Store a secret the application needs generated (su\
|
|
1097
|
+
ch as an application key) by generating it with the framework's own generator and piping it to `vibe64-helper env set <s\
|
|
1098
|
+
cope> <KEY> --secret`. Never write it into a generated `.env` file: Vibe64 regenerates that file from Env."]);function tn(t=""){
|
|
1099
|
+
return String(t??"").trim()}function rn(t,e){if(!t||typeof t!="object"||Array.isArray(t))throw new TypeError(`${e} must \
|
|
1100
|
+
be an object.`);return t}function rt(t,e,r){let n=new Set(e),o=Object.keys(t).filter(s=>!n.has(s));if(o.length>0)throw new TypeError(
|
|
1101
|
+
`${r} contains unsupported fields: ${o.join(", ")}.`)}function Fu(t){if(rt(t,["conversationKind","scope","session","host\
|
|
1102
|
+
Guidance"],"Vibe64 session context"),t.hostGuidance!==void 0&&(typeof t.hostGuidance!="string"||Buffer.byteLength(t.hostGuidance,
|
|
1103
|
+
"utf8")>1024))throw new TypeError("Vibe64 host guidance must be bounded text supplied by the host.");if(!zu.includes(t.conversationKind))
|
|
1064
1104
|
throw new TypeError("Vibe64 session context has an unknown conversationKind.");let e=rn(t.session,"Vibe64 session capabi\
|
|
1065
|
-
lities");rt(e,
|
|
1105
|
+
lities");rt(e,Bs,"Vibe64 session capabilities");let r=Object.fromEntries(Bs.map(n=>{if(typeof e[n]!="boolean")throw new TypeError(
|
|
1066
1106
|
`Vibe64 session capability ${n} must be boolean.`);return[n,e[n]]}));return{conversationKind:t.conversationKind,scope:"s\
|
|
1067
|
-
ession",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:r}}function
|
|
1107
|
+
ession",...t.hostGuidance?{hostGuidance:t.hostGuidance}:{},session:r}}function Uu(t){rt(t,["scope","stableContext"],"Vib\
|
|
1068
1108
|
e64 ephemeral context");let e=String(t.stableContext||"").trim();if(!e||e.length>Lu)throw new TypeError("Vibe64 ephemera\
|
|
1069
|
-
l context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function
|
|
1070
|
-
on")return Fu(t);if(t.scope==="ephemeral")return
|
|
1071
|
-
eral scopes only.")}async function
|
|
1109
|
+
l context requires bounded stableContext.");return{scope:"ephemeral",stableContext:e}}function qu(t){if(t.scope==="sessi\
|
|
1110
|
+
on")return Fu(t);if(t.scope==="ephemeral")return Uu(t);throw new TypeError("The Vibe64 driver supports session and ephem\
|
|
1111
|
+
eral scopes only.")}async function Hs(t={},{readRegistry:e=Du,workdir:r=""}={}){let n=rn(t,"Vibe64 host resolver request");if(rt(n,["data","\
|
|
1072
1112
|
providerSessionId","parentSessionIds","scope"],"Vibe64 host resolver request"),!["session","turn"].includes(n.scope))throw new TypeError(
|
|
1073
1113
|
"The Vibe64 host resolver scope must be session or turn.");if(n.scope==="turn")return null;let o=rn(n.data,"Vibe64 host \
|
|
1074
1114
|
resolver data");rt(o,["registryPath"],"Vibe64 host resolver data");let s=tn(o.registryPath);if(!en.isAbsolute(s))throw new TypeError(
|
|
@@ -1076,9 +1116,9 @@ resolver data");rt(o,["registryPath"],"Vibe64 host resolver data");let s=tn(o.re
|
|
|
1076
1116
|
sessions))throw new TypeError("The conversation ownership registry is invalid.");let a=i.sessions,c=tn(n.providerSessionId);
|
|
1077
1117
|
if(n.parentSessionIds!==void 0&&(!Array.isArray(n.parentSessionIds)||n.parentSessionIds.length>32||n.parentSessionIds.some(
|
|
1078
1118
|
f=>typeof f!="string"||!f.trim())))throw new TypeError("Invalid native conversation ancestry.");let l=[c,...n.parentSessionIds||
|
|
1079
|
-
[]].filter(Boolean).map(f=>a.find(g=>tn(g?.upstreamSessionId)===f)).find(Boolean),
|
|
1119
|
+
[]].filter(Boolean).map(f=>a.find(g=>tn(g?.upstreamSessionId)===f)).find(Boolean),m=l?.promptContext;if(!m)return null;if(r&&
|
|
1080
1120
|
l.workdir&&en.resolve(r)!==en.resolve(l.workdir))throw new Error("The managed conversation belongs to a different projec\
|
|
1081
|
-
t directory.");return
|
|
1121
|
+
t directory.");return qu(m)}var nn="";for await(let t of process.stdin)if(nn+=t,Buffer.byteLength(nn)>256*1024)throw new Error("Conversation instruc\
|
|
1082
1122
|
tion input exceeds 256 KiB.");var Vs=JSON.parse(nn);if(process.argv[2]==="--instructions"){let{vibe64ConversationInstructions:t}=await import("@local/vibe64-genesis/server");
|
|
1083
|
-
process.stdout.write(await t(Vs))}else{let t=Zr({resolveConversation:async e=>await
|
|
1123
|
+
process.stdout.write(await t(Vs))}else{let t=Zr({resolveConversation:async e=>await Hs(e,{workdir:process.cwd()})?{delivery:"\
|
|
1084
1124
|
native"}:null});process.stdout.write(JSON.stringify(await t(Vs)))}
|