vibe64 0.1.46 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/upgrade-state.js +694 -693
- package/docs/colleague-usage/coding-agents.md +4 -7
- package/node_modules/@jskit-ai/assistant-core/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-runtime/package.json +1 -1
- package/node_modules/@jskit-ai/assistant-voice/package.json +1 -1
- package/node_modules/@jskit-ai/realtime/package.json +1 -1
- package/node_modules/@local/vibe64-genesis/src/server/index.js +64 -63
- package/package.json +5 -5
- package/server.bundle.mjs +31000 -31036
package/bin/upgrade-state.js
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import { createRequire as __vibe64CreateRequire } from 'node:module';const require=__vibe64CreateRequire(import.meta.url);
|
|
3
3
|
var $U=Object.create;var IS=Object.defineProperty;var DU=Object.getOwnPropertyDescriptor;var UU=Object.getOwnPropertyNames;var zU=Object.getPrototypeOf,FU=Object.prototype.hasOwnProperty;var rt=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){
|
|
4
4
|
if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var BU=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var lt=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}};var qU=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of UU(t))!FU.call(e,o)&&o!==r&&IS(e,o,{get:()=>t[o],
|
|
5
|
-
enumerable:!(n=DU(t,o))||n.enumerable});return e};var Bn=(e,t,r)=>(r=e!=null?$U(zU(e)):{},qU(t||!e||!e.__esModule?IS(r,"default",{value:e,enumerable:!0}):r,e));var VE=lt((
|
|
5
|
+
enumerable:!(n=DU(t,o))||n.enumerable});return e};var Bn=(e,t,r)=>(r=e!=null?$U(zU(e)):{},qU(t||!e||!e.__esModule?IS(r,"default",{value:e,enumerable:!0}):r,e));var VE=lt(($ae,qE)=>{qE.exports=BE;BE.sync=S4;var zE=rt("fs");function I4(e,t){var r=t.pathExt!==void 0?t.pathExt:process.
|
|
6
6
|
env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var o=r[n].toLowerCase();if(o&&
|
|
7
7
|
e.substr(-o.length).toLowerCase()===o)return!0}return!1}function FE(e,t,r){return!e.isSymbolicLink()&&!e.isFile()?!1:I4(
|
|
8
|
-
t,r)}function BE(e,t,r){zE.stat(e,function(n,o){r(n,n?!1:FE(o,e,t))})}function S4(e,t){return FE(zE.statSync(e),e,t)}});var JE=lt((
|
|
8
|
+
t,r)}function BE(e,t,r){zE.stat(e,function(n,o){r(n,n?!1:FE(o,e,t))})}function S4(e,t){return FE(zE.statSync(e),e,t)}});var JE=lt((Dae,KE)=>{KE.exports=GE;GE.sync=A4;var HE=rt("fs");function GE(e,t,r){HE.stat(e,function(n,o){r(n,n?!1:WE(o,t))})}
|
|
9
9
|
function A4(e,t){return WE(HE.statSync(e),t)}function WE(e,t){return e.isFile()&&E4(e,t)}function E4(e,t){var r=e.mode,n=e.
|
|
10
10
|
uid,o=e.gid,i=t.uid!==void 0?t.uid:process.getuid&&process.getuid(),s=t.gid!==void 0?t.gid:process.getgid&&process.getgid(),
|
|
11
|
-
a=parseInt("100",8),c=parseInt("010",8),d=parseInt("001",8),u=a|c,l=r&d||r&c&&o===s||r&a&&n===i||r&u&&i===0;return l}});var YE=lt((
|
|
11
|
+
a=parseInt("100",8),c=parseInt("010",8),d=parseInt("001",8),u=a|c,l=r&d||r&c&&o===s||r&a&&n===i||r&u&&i===0;return l}});var YE=lt((zae,XE)=>{var Uae=rt("fs"),Ip;process.platform==="win32"||global.TESTING_WINDOWS?Ip=VE():Ip=JE();XE.exports=ew;
|
|
12
12
|
ew.sync=x4;function ew(e,t,r){if(typeof t=="function"&&(r=t,t={}),!r){if(typeof Promise!="function")throw new TypeError(
|
|
13
13
|
"callback not provided");return new Promise(function(n,o){ew(e,t||{},function(i,s){i?o(i):n(s)})})}Ip(e,t||{},function(n,o){
|
|
14
14
|
n&&(n.code==="EACCES"||t&&t.ignoreErrors)&&(n=null,o=!1),r(n,o)})}function x4(e,t){try{return Ip.sync(e,t||{})}catch(r){
|
|
15
|
-
if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var ox=lt((
|
|
15
|
+
if(t&&t.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var ox=lt((Fae,nx)=>{var oa=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",ZE=rt("path"),
|
|
16
16
|
T4=oa?";":":",QE=YE(),ex=e=>Object.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),tx=(e,t)=>{let r=t.colon||T4,n=e.
|
|
17
17
|
match(/\//)||oa&&e.match(/\\/)?[""]:[...oa?[process.cwd()]:[],...(t.path||process.env.PATH||"").split(r)],o=oa?t.pathExt||
|
|
18
18
|
process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=oa?o.split(r):[""];return oa&&e.indexOf(".")!==-1&&i[0]!==""&&i.unshift(
|
|
@@ -23,31 +23,31 @@ if(l===o.length)return p(a(u+1));let y=o[l];QE(d+y,{pathExt:i},(h,v)=>{if(!h&&v)
|
|
|
23
23
|
return p(c(d,u,l+1))})});return r?a(0).then(d=>r(null,d),r):a(0)},C4=(e,t)=>{t=t||{};let{pathEnv:r,pathExt:n,pathExtExe:o}=tx(
|
|
24
24
|
e,t),i=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,d=ZE.join(c,e),u=!c&&/^\.[\\\/]/.test(
|
|
25
25
|
e)?e.slice(0,2)+d:d;for(let l=0;l<n.length;l++){let p=u+n[l];try{if(QE.sync(p,{pathExt:o}))if(t.all)i.push(p);else return p}catch{}}}
|
|
26
|
-
if(t.all&&i.length)return i;if(t.nothrow)return null;throw ex(e)};nx.exports=rx;rx.sync=C4});var sx=lt((
|
|
27
|
-
"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};tw.exports=ix;tw.exports.default=ix});var ux=lt((
|
|
26
|
+
if(t.all&&i.length)return i;if(t.nothrow)return null;throw ex(e)};nx.exports=rx;rx.sync=C4});var sx=lt((Bae,tw)=>{"use strict";var ix=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)!=="win32"?
|
|
27
|
+
"PATH":Object.keys(t).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};tw.exports=ix;tw.exports.default=ix});var ux=lt((qae,dx)=>{"use strict";var ax=rt("path"),R4=ox(),O4=sx();function cx(e,t){let r=e.options.env||process.env,n=process.
|
|
28
28
|
cwd(),o=e.options.cwd!=null,i=o&&process.chdir!==void 0&&!process.chdir.disabled;if(i)try{process.chdir(e.options.cwd)}catch{}
|
|
29
29
|
let s;try{s=R4.sync(e.command,{path:r[O4({env:r})],pathExt:t?ax.delimiter:void 0})}catch{}finally{i&&process.chdir(n)}return s&&
|
|
30
|
-
(s=ax.resolve(o?e.options.cwd:"",s)),s}function P4(e){return cx(e)||cx(e,!0)}dx.exports=P4});var lx=lt((
|
|
30
|
+
(s=ax.resolve(o?e.options.cwd:"",s)),s}function P4(e){return cx(e)||cx(e,!0)}dx.exports=P4});var lx=lt((Vae,nw)=>{"use strict";var rw=/([()\][%!^"`<>&|;, *?])/g;function k4(e){return e=e.replace(rw,"^$1"),e}function N4(e,t){
|
|
31
31
|
return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),e=e.replace(/(?=(\\+?)?)\1$/,"$1$1"),e=`"${e}"`,e=e.replace(rw,
|
|
32
|
-
"^$1"),t&&(e=e.replace(rw,"^$1")),e}nw.exports.command=k4;nw.exports.argument=N4});var fx=lt((
|
|
33
|
-
/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var wx=lt((
|
|
34
|
-
r"),ow.readSync(n,r,0,150,0),ow.closeSync(n)}catch{}return M4(r.toString())}gx.exports=L4});var bx=lt((
|
|
32
|
+
"^$1"),t&&(e=e.replace(rw,"^$1")),e}nw.exports.command=k4;nw.exports.argument=N4});var fx=lt((Hae,px)=>{"use strict";px.exports=/^#!(.*)/});var hx=lt((Gae,mx)=>{"use strict";var j4=fx();mx.exports=(e="")=>{let t=e.match(j4);if(!t)return null;let[r,n]=t[0].replace(
|
|
33
|
+
/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?n:n?`${o} ${n}`:o}});var wx=lt((Wae,gx)=>{"use strict";var ow=rt("fs"),M4=hx();function L4(e){let r=Buffer.alloc(150),n;try{n=ow.openSync(e,"\
|
|
34
|
+
r"),ow.readSync(n,r,0,150,0),ow.closeSync(n)}catch{}return M4(r.toString())}gx.exports=L4});var bx=lt((Kae,_x)=>{"use strict";var $4=rt("path"),vx=ux(),yx=lx(),D4=wx(),U4=process.platform==="win32",z4=/\.(?:com|exe)$/i,
|
|
35
35
|
F4=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function B4(e){e.file=vx(e);let t=e.file&&D4(e.file);return t?(e.args.unshift(
|
|
36
36
|
e.file),e.command=t,vx(e)):e.file}function q4(e){if(!U4)return e;let t=B4(e),r=!z4.test(t);if(e.options.forceShell||r){let n=F4.
|
|
37
37
|
test(t);e.command=$4.normalize(e.command),e.command=yx.command(e.command),e.args=e.args.map(i=>yx.argument(i,n));let o=[
|
|
38
38
|
e.command].concat(e.args).join(" ");e.args=["/d","/s","/c",`"${o}"`],e.command=process.env.comspec||"cmd.exe",e.options.
|
|
39
39
|
windowsVerbatimArguments=!0}return e}function V4(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null),t=t?t.slice(0):[],r=Object.assign(
|
|
40
|
-
{},r);let n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:q4(n)}_x.exports=V4});var Ax=lt((
|
|
40
|
+
{},r);let n={command:e,args:t,options:r,file:void 0,original:{command:e,args:t}};return r.shell?n:q4(n)}_x.exports=V4});var Ax=lt((Jae,Sx)=>{"use strict";var iw=process.platform==="win32";function sw(e,t){return Object.assign(new Error(`${t}\
|
|
41
41
|
${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function H4(e,t){
|
|
42
42
|
if(!iw)return;let r=e.emit;e.emit=function(n,o){if(n==="exit"){let i=Ix(o,t);if(i)return r.call(e,"error",i)}return r.apply(
|
|
43
43
|
e,arguments)}}function Ix(e,t){return iw&&e===1&&!t.file?sw(t.original,"spawn"):null}function G4(e,t){return iw&&e===1&&
|
|
44
|
-
!t.file?sw(t.original,"spawnSync"):null}Sx.exports={hookChildProcess:H4,verifyENOENT:Ix,verifyENOENTSync:G4,notFoundError:sw}});var Tx=lt((
|
|
44
|
+
!t.file?sw(t.original,"spawnSync"):null}Sx.exports={hookChildProcess:H4,verifyENOENT:Ix,verifyENOENTSync:G4,notFoundError:sw}});var Tx=lt((Xae,ia)=>{"use strict";var Ex=rt("child_process"),aw=bx(),cw=Ax();function xx(e,t,r){let n=aw(e,t,r),o=Ex.spawn(
|
|
45
45
|
n.command,n.args,n.options);return cw.hookChildProcess(o,n),o}function W4(e,t,r){let n=aw(e,t,r),o=Ex.spawnSync(n.command,
|
|
46
46
|
n.args,n.options);return o.error=o.error||cw.verifyENOENTSync(o.status,n),o}ia.exports=xx;ia.exports.spawn=xx;ia.exports.
|
|
47
|
-
sync=W4;ia.exports._parse=aw;ia.exports._enoent=cw});var to=lt((
|
|
47
|
+
sync=W4;ia.exports._parse=aw;ia.exports._enoent=cw});var to=lt((GAe,qP)=>{"use strict";var FP=["nodebuffer","arraybuffer","fragments"],BP=typeof Blob<"u";BP&&FP.push("blob");
|
|
48
48
|
qP.exports={BINARY_TYPES:FP,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:BP,
|
|
49
49
|
kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol(
|
|
50
|
-
"websocket"),NOOP:()=>{}}});var xu=lt((
|
|
50
|
+
"websocket"),NOOP:()=>{}}});var xu=lt((WAe,Bf)=>{"use strict";var{EMPTY_BUFFER:DW}=to(),ey=Buffer[Symbol.species];function UW(e,t){if(e.length===0)return DW;
|
|
51
51
|
if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let o=0;o<e.length;o++){let i=e[o];r.set(i,n),n+=i.length}
|
|
52
52
|
return n<t?new ey(r.buffer,r.byteOffset,n):r}function VP(e,t,r,n,o){for(let i=0;i<o;i++)r[n+i]=e[i]^t[i&3]}function HP(e,t){
|
|
53
53
|
for(let r=0;r<e.length;r++)e[r]^=t[r&3]}function zW(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,
|
|
@@ -55,9 +55,9 @@ e.byteOffset+e.length)}function ty(e){if(ty.readOnly=!0,Buffer.isBuffer(e))retur
|
|
|
55
55
|
t=new ey(e):ArrayBuffer.isView(e)?t=new ey(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),ty.readOnly=!1),t}Bf.exports=
|
|
56
56
|
{concat:UW,mask:VP,toArrayBuffer:zW,toBuffer:ty,unmask:HP};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=rt("bufferutil");
|
|
57
57
|
Bf.exports.mask=function(t,r,n,o,i){i<48?VP(t,r,n,o,i):e.mask(t,r,n,o,i)},Bf.exports.unmask=function(t,r){t.length<32?HP(
|
|
58
|
-
t,r):e.unmask(t,r)}}catch{}});var KP=lt((
|
|
58
|
+
t,r):e.unmask(t,r)}}catch{}});var KP=lt((KAe,WP)=>{"use strict";var GP=Symbol("kDone"),ry=Symbol("kRun"),ny=class{constructor(t){this[GP]=()=>{this.pending--,
|
|
59
59
|
this[ry]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[ry]()}[ry](){if(this.pending!==
|
|
60
|
-
this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[GP])}}};WP.exports=ny});var La=lt((
|
|
60
|
+
this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[GP])}}};WP.exports=ny});var La=lt((JAe,ZP)=>{"use strict";var Tu=rt("zlib"),JP=xu(),FW=KP(),{kStatusCode:XP}=to(),BW=Buffer[Symbol.species],qW=Buffer.
|
|
61
61
|
from([0,0,255,255]),Vf=Symbol("permessage-deflate"),ro=Symbol("total-length"),ja=Symbol("callback"),zo=Symbol("buffers"),
|
|
62
62
|
Ma=Symbol("error"),qf,oy=class{constructor(t){if(this._options=t||{},this._threshold=this._options.threshold!==void 0?this.
|
|
63
63
|
_options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=
|
|
@@ -103,7 +103,7 @@ _context_takeover`]&&this._deflate.reset(),n(null,i)})}};ZP.exports=oy;function
|
|
|
103
103
|
function YP(e){if(this[ro]+=e.length,this[Vf]._maxPayload<1||this[ro]<=this[Vf]._maxPayload){this[zo].push(e);return}this[Ma]=
|
|
104
104
|
new RangeError("Max payload size exceeded"),this[Ma].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ma][XP]=1009,this.removeListener(
|
|
105
105
|
"data",YP),this.reset()}function HW(e){if(this[Vf]._inflate=null,this[Ma]){this[ja](this[Ma]);return}e[XP]=1007,this[ja](
|
|
106
|
-
e)}});var $a=lt((
|
|
106
|
+
e)}});var $a=lt((XAe,Hf)=>{"use strict";var{isUtf8:QP}=rt("buffer"),{hasBlob:GW}=to(),WW=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
|
107
107
|
0,0,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,
|
|
108
108
|
1,1,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 KW(e){return e>=
|
|
109
109
|
1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function iy(e){let t=e.length,r=0;for(;r<t;)if((e[r]&128)===
|
|
@@ -114,7 +114,7 @@ r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128
|
|
|
114
114
|
bject"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]===
|
|
115
115
|
"Blob"||e[Symbol.toStringTag]==="File")}Hf.exports={isBlob:JW,isValidStatusCode:KW,isValidUTF8:iy,tokenChars:WW};if(QP)Hf.
|
|
116
116
|
exports.isValidUTF8=function(e){return e.length<24?iy(e):QP(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=rt("utf-8-validate");
|
|
117
|
-
Hf.exports.isValidUTF8=function(t){return t.length<32?iy(t):e(t)}}catch{}});var uy=lt((
|
|
117
|
+
Hf.exports.isValidUTF8=function(t){return t.length<32?iy(t):e(t)}}catch{}});var uy=lt((YAe,sk)=>{"use strict";var{Writable:XW}=rt("stream"),ek=La(),{BINARY_TYPES:YW,EMPTY_BUFFER:tk,kStatusCode:ZW,
|
|
118
118
|
kWebSocket:QW}=to(),{concat:sy,toArrayBuffer:eK,unmask:tK}=xu(),{isValidStatusCode:rK,isValidUTF8:rk}=$a(),Gf=Buffer[Symbol.
|
|
119
119
|
species],Fr=0,nk=1,ok=2,ik=3,ay=4,cy=5,Wf=6,dy=class extends XW{constructor(t={}){super(),this._allowSynchronousEvents=t.
|
|
120
120
|
allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||YW[0],this._extensions=t.extensions||
|
|
@@ -177,7 +177,7 @@ TF8");r(i);return}this._loop=!1,this.emit("conclude",n,o),this.end()}this._state
|
|
|
177
177
|
(this.emit(this._opcode===9?"ping":"pong",t),this._state=Fr):(this._state=Wf,setImmediate(()=>{this.emit(this._opcode===
|
|
178
178
|
9?"ping":"pong",t),this._state=Fr,this.startLoop(r)}))}createError(t,r,n,o,i){this._loop=!1,this._errored=!0;let s=new t(
|
|
179
179
|
n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(s,this.createError),s.code=i,s[ZW]=o,s}};sk.exports=
|
|
180
|
-
dy});var fy=lt((
|
|
180
|
+
dy});var fy=lt((QAe,dk)=>{"use strict";var{Duplex:ZAe}=rt("stream"),{randomFillSync:nK}=rt("crypto"),{types:{isUint8Array:oK}}=rt("util"),
|
|
181
181
|
ak=La(),{EMPTY_BUFFER:iK,kWebSocket:sK,NOOP:aK}=to(),{isBlob:Da,isValidStatusCode:cK}=$a(),{mask:ck,toBuffer:qi}=xu(),Br=Symbol(
|
|
182
182
|
"kByteLength"),dK=Buffer.alloc(4),Kf=8*1024,Vi,Ua=Kf,cn=0,uK=1,lK=2,ly=class e{constructor(t,r,n){this._extensions=r||{},
|
|
183
183
|
n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this.
|
|
@@ -219,7 +219,7 @@ shift();this._bufferedBytes-=t[3][Br],Reflect.apply(t[0],this,t.slice(1))}}enque
|
|
|
219
219
|
_queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this.
|
|
220
220
|
_socket.uncork()):this._socket.write(t[0],r)}};dk.exports=ly;function py(e,t,r){typeof r=="function"&&r(t);for(let n=0;n<
|
|
221
221
|
e._queue.length;n++){let o=e._queue[n],i=o[o.length-1];typeof i=="function"&&i(t)}}function pK(e,t,r){py(e,t,r),e.onerror(
|
|
222
|
-
t)}});var vk=lt((
|
|
222
|
+
t)}});var vk=lt((eEe,wk)=>{"use strict";var{kForOnEventAttribute:Cu,kListener:my}=to(),uk=Symbol("kCode"),lk=Symbol("kData"),pk=Symbol(
|
|
223
223
|
"kError"),fk=Symbol("kMessage"),mk=Symbol("kReason"),za=Symbol("kTarget"),hk=Symbol("kType"),gk=Symbol("kWasClean"),no=class{constructor(t){
|
|
224
224
|
this[za]=null,this[hk]=t}get target(){return this[za]}get type(){return this[hk]}};Object.defineProperty(no.prototype,"t\
|
|
225
225
|
arget",{enumerable:!0});Object.defineProperty(no.prototype,"type",{enumerable:!0});var Hi=class extends no{constructor(t,r={}){
|
|
@@ -237,7 +237,7 @@ t,this,a)};else if(e==="error")n=function(i){let s=new Fa("error",{error:i,messa
|
|
|
237
237
|
"open")n=function(){let i=new no("open");i[za]=this,Jf(t,this,i)};else return;n[Cu]=!!r[Cu],n[my]=t,r.once?this.once(e,n):
|
|
238
238
|
this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[my]===t&&!r[Cu]){this.removeListener(e,r);break}}};
|
|
239
239
|
wk.exports={CloseEvent:Hi,ErrorEvent:Fa,Event:no,EventTarget:fK,MessageEvent:Ru};function Jf(e,t,r){typeof e=="object"&&
|
|
240
|
-
e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}});var Xf=lt((
|
|
240
|
+
e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}});var Xf=lt((tEe,yk)=>{"use strict";var{tokenChars:Ou}=$a();function Tn(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}function mK(e){
|
|
241
241
|
let t=Object.create(null),r=Object.create(null),n=!1,o=!1,i=!1,s,a,c=-1,d=-1,u=-1,l=0;for(;l<e.length;l++)if(d=e.charCodeAt(
|
|
242
242
|
l),s===void 0)if(u===-1&&Ou[d]===1)c===-1&&(c=l);else if(l!==0&&(d===32||d===9))u===-1&&c!==-1&&(u=l);else if(d===59||d===
|
|
243
243
|
44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);u===-1&&(u=l);let f=e.slice(c,u);d===44?(Tn(t,
|
|
@@ -254,8 +254,8 @@ void 0,c=u=-1}else throw new SyntaxError(`Unexpected character at index ${l}`);i
|
|
|
254
254
|
"Unexpected end of input");u===-1&&(u=l);let p=e.slice(c,u);return s===void 0?Tn(t,p,r):(a===void 0?Tn(r,p,!0):n?Tn(r,a,
|
|
255
255
|
p.replace(/\\/g,"")):Tn(r,a,p),Tn(t,s,r)),t}function hK(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(
|
|
256
256
|
r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(o=>{let i=n[o];return Array.isArray(i)||(i=[i]),i.map(s=>s===!0?o:`${o}\
|
|
257
|
-
=${s}`).join("; ")})).join("; ")).join(", ")}).join(", ")}yk.exports={format:hK,parse:mK}});var em=lt((
|
|
258
|
-
createHash:bK}=rt("crypto"),{Duplex:
|
|
257
|
+
=${s}`).join("; ")})).join("; ")).join(", ")}).join(", ")}yk.exports={format:hK,parse:mK}});var em=lt((oEe,Pk)=>{"use strict";var gK=rt("events"),wK=rt("https"),vK=rt("http"),Ik=rt("net"),yK=rt("tls"),{randomBytes:_K,
|
|
258
|
+
createHash:bK}=rt("crypto"),{Duplex:rEe,Readable:nEe}=rt("stream"),{URL:hy}=rt("url"),Fo=La(),IK=uy(),SK=fy(),{isBlob:AK}=$a(),
|
|
259
259
|
{BINARY_TYPES:_k,CLOSE_TIMEOUT:EK,EMPTY_BUFFER:Yf,GUID:xK,kForOnEventAttribute:gy,kListener:TK,kStatusCode:CK,kWebSocket:qt,
|
|
260
260
|
NOOP:Sk}=to(),{EventTarget:{addEventListener:RK,removeEventListener:OK}}=vk(),{format:PK,parse:kK}=Xf(),{toBuffer:NK}=xu(),
|
|
261
261
|
Ak=Symbol("kAborted"),wy=[8,13],oo=["CONNECTING","OPEN","CLOSING","CLOSED"],jK=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ht=class e extends gK{constructor(t,r,n){
|
|
@@ -362,7 +362,7 @@ this._readableState.length!==0){let t=this.read(this._readableState.length);e._r
|
|
|
362
362
|
void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():
|
|
363
363
|
(e._receiver.on("error",bk),e._receiver.on("finish",bk))}function Qf(e){this[qt]._receiver.write(e)||this.pause()}function Rk(){
|
|
364
364
|
let e=this[qt];e._readyState=ht.CLOSING,e._receiver.end(),this.end()}function Ok(){let e=this[qt];this.removeListener("e\
|
|
365
|
-
rror",Ok),this.on("error",Sk),e&&(e._readyState=ht.CLOSING,this.destroy())}});var Mk=lt((
|
|
365
|
+
rror",Ok),this.on("error",Sk),e&&(e._readyState=ht.CLOSING,this.destroy())}});var Mk=lt((sEe,jk)=>{"use strict";var iEe=em(),{Duplex:VK}=rt("stream");function kk(e){e.emit("close")}function HK(){!this.
|
|
366
366
|
destroyed&&this._writableState.finished&&this.destroy()}function Nk(e){this.removeListener("error",Nk),this.destroy(),this.
|
|
367
367
|
listenerCount("error")===0&&this.emit("error",e)}function GK(e,t){let r=!0,n=new VK({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,
|
|
368
368
|
writableObjectMode:!1});return e.on("message",function(i,s){let a=!s&&n._readableState.objectMode?i.toString():i;n.push(
|
|
@@ -372,12 +372,12 @@ function(c){s=!0,i(c)}),e.once("close",function(){s||i(o),process.nextTick(kk,n)
|
|
|
372
372
|
if(e.readyState===e.CONNECTING){e.once("open",function(){n._final(o)});return}e._socket!==null&&(e._socket._writableState.
|
|
373
373
|
finished?(o(),n._readableState.endEmitted&&n.destroy()):(e._socket.once("finish",function(){o()}),e.close()))},n._read=function(){
|
|
374
374
|
e.isPaused&&e.resume()},n._write=function(o,i,s){if(e.readyState===e.CONNECTING){e.once("open",function(){n._write(o,i,s)});
|
|
375
|
-
return}e.send(o,s)},n.on("end",HK),n.on("error",Nk),n}jk.exports=GK});var yy=lt((
|
|
375
|
+
return}e.send(o,s)},n.on("end",HK),n.on("error",Nk),n}jk.exports=GK});var yy=lt((aEe,Lk)=>{"use strict";var{tokenChars:WK}=$a();function KK(e){let t=new Set,r=-1,n=-1,o=0;for(o;o<e.length;o++){
|
|
376
376
|
let s=e.charCodeAt(o);if(n===-1&&WK[s]===1)r===-1&&(r=o);else if(o!==0&&(s===32||s===9))n===-1&&r!==-1&&(n=o);else if(s===
|
|
377
377
|
44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);n===-1&&(n=o);let a=e.slice(r,n);if(t.has(a))throw new SyntaxError(
|
|
378
378
|
`The "${a}" subprotocol is duplicated`);t.add(a),r=n=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}
|
|
379
379
|
if(r===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=e.slice(r,o);if(t.has(i))throw new SyntaxError(
|
|
380
|
-
`The "${i}" subprotocol is duplicated`);return t.add(i),t}Lk.exports={parse:KK}});var qk=lt((
|
|
380
|
+
`The "${i}" subprotocol is duplicated`);return t.add(i),t}Lk.exports={parse:KK}});var qk=lt((dEe,Bk)=>{"use strict";var JK=rt("events"),tm=rt("http"),{Duplex:cEe}=rt("stream"),{createHash:XK}=rt("crypto"),
|
|
381
381
|
$k=Xf(),Gi=La(),YK=yy(),ZK=em(),{CLOSE_TIMEOUT:QK,GUID:eJ,kWebSocket:tJ}=to(),rJ=/^[+/0-9A-Za-z]{22}==$/,Dk=0,Uk=1,Fk=2,
|
|
382
382
|
_y=class extends JK{constructor(t,r){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxBufferedChunks:256*1024,maxFragments:16*
|
|
383
383
|
1024,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:QK,
|
|
@@ -426,15 +426,15 @@ l","Content-Length":Buffer.byteLength(r),...n},e.once("finish",e.destroy),e.end(
|
|
|
426
426
|
`)+`\r
|
|
427
427
|
\r
|
|
428
428
|
`+r)}function Wi(e,t,r,n,o,i){if(e.listenerCount("wsClientError")){let s=new Error(o);Error.captureStackTrace(s,Wi),e.emit(
|
|
429
|
-
"wsClientError",s,r,t)}else ku(r,n,o,i)}});var uI=BU(()=>{});import{parseArgs as
|
|
429
|
+
"wsClientError",s,r,t)}else ku(r,n,o,i)}});var uI=BU(()=>{});import{parseArgs as gte}from"node:util";import{lstat as qz,mkdir as $A,open as Vz,readdir as Hz,readFile as Gz,realpath as jne,rm as Wz}from"node:fs/promises";import bn from"node:path";import{randomUUID as VU}from"node:crypto";import{chmod as HU,mkdir as GU,rename as WU,rm as KU,writeFile as JU}from"node:fs/promises";
|
|
430
430
|
import hg from"node:path";async function Fd(e,t,{directoryMode:r,fileMode:n}={}){let o=hg.dirname(e);await GU(o,{recursive:!0,
|
|
431
431
|
mode:r});let i=hg.join(o,`.${hg.basename(e)}.${process.pid}.${VU()}.tmp`);try{await JU(i,t,{encoding:"utf8",flag:"wx",mode:n}),
|
|
432
432
|
n!==void 0&&await HU(i,n),await WU(i,e)}finally{await KU(i,{force:!0})}}async function Gs(e,t,r={}){await Fd(e,`${JSON.stringify(
|
|
433
433
|
t,null,2)}
|
|
434
434
|
`,r)}async function Gl(e,t,r){let n=(e.get(t)||Promise.resolve()).catch(()=>{}).then(r);e.set(t,n);try{return await n}finally{
|
|
435
|
-
e.get(t)===n&&e.delete(t)}}import{randomUUID as wz}from"node:crypto";import{mkdir as vz,readFile as Ig,writeFile as yz}from"node:fs/promises";import _z from"node:path";import{createHash as SS}from"node:crypto";import{execFile as YU}from"node:child_process";import{open as ZU,readFile as
|
|
436
|
-
rename as
|
|
437
|
-
update(JSON.stringify(e)).digest("hex")}var
|
|
435
|
+
e.get(t)===n&&e.delete(t)}}import{randomUUID as wz}from"node:crypto";import{mkdir as vz,readFile as Ig,writeFile as yz}from"node:fs/promises";import _z from"node:path";import{createHash as SS}from"node:crypto";import{execFile as YU}from"node:child_process";import{open as ZU,readFile as Rte,
|
|
436
|
+
rename as Ote,rm as Pte,writeFile as kte}from"node:fs/promises";import Wl from"node:path";import{promisify as QU}from"node:util";var Ite=Object.freeze(["none","pending","committed","rolledBack","unknown"]);function nt(e,{fallback:t=""}={}){return String(e||"").trim()||t}function fr(e,{fallback:t={}}={}){return!e||typeof e!="object"||Array.isArray(e)?{...t}:e}function ot(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Mr(e,{fallback:t=0}={}){let r=Number(e);return!Number.isInteger(r)||r<1?t:r}import{createHash as XU}from"node:crypto";function fe(e){return String(e??"").trim()}function Bd(e){return XU("sha256").
|
|
437
|
+
update(JSON.stringify(e)).digest("hex")}var $te=QU(YU);var ez=Object.freeze(["apps","artifact","browser_use","browser_use_external","browser_use_full_cdp_access","code_mode","\
|
|
438
438
|
code_mode_host","computer_use","default_mode_request_user_input","deferred_executor","goals","hooks","image_generation",
|
|
439
439
|
"in_app_browser","memories","multi_agent","multi_agent_v2","plugins","psp","recommended_plugins","request_permissions_to\
|
|
440
440
|
ol","shell_tool","skill_mcp_dependency_install","skill_search","tool_call_mcp_elicitation","tool_suggest","unified_exec",
|
|
@@ -516,7 +516,7 @@ approvalPolicy:U,cwd:F,effectiveSettings:H,outputSchema:Y}){let te={approvalPoli
|
|
|
516
516
|
outputSchema:Y,runtimeWorkspaceRoots:[],sandboxPolicy:{networkAccess:!1,type:"readOnly"},summary:"none"};return H.request.
|
|
517
517
|
reasoning&&(te.effort=H.thinking),te}return Object.freeze({assertCompatibility:_,executionContext:v,inspect:M,configuration:ae,
|
|
518
518
|
hasConfiguration:U=>f.has(U),threadSettings:qe,threadStartSettings:st,threadResumeSettings:Ve,turnSettings:bt,start:Z,resume:ye})}
|
|
519
|
-
var
|
|
519
|
+
var Dte=xS();function wg({models:e}){return{models:e.map((t,r)=>({slug:t.id,display_name:t.label,description:t.label,default_reasoning_level:t.
|
|
520
520
|
defaultThinking,supported_reasoning_levels:t.variants.map(n=>({effort:n,description:n})),shell_type:"shell_command",visibility:"\
|
|
521
521
|
list",supported_in_api:!0,priority:r,base_instructions:"You are a coding assistant. Complete the user's task in the work\
|
|
522
522
|
space, use the available tools, preserve unrelated work, and verify your changes.",supports_reasoning_summaries:!1,default_reasoning_summary:"\
|
|
@@ -559,7 +559,7 @@ f.plan_type,w=v==null||v===""?"":o(v,{label:"Codex plan type",maxLength:oz});ret
|
|
|
559
559
|
authMode:"chatgpt",identitySignature:i("chatgpt",y),planType:w,secretSignature:s(h)})}if(["apikey","api_key"].includes(p)){
|
|
560
560
|
let f=o(l.OPENAI_API_KEY,{label:"Codex API key",maxLength:iz});return Object.freeze({apiKey:f,authMode:"apiKey",identitySignature:i(
|
|
561
561
|
"apiKey",f),secretSignature:s(f)})}throw n(`${e}codex_helper_auth_invalid`,"The selected Codex authentication mode is un\
|
|
562
|
-
supported. Reconnect Codex and retry.")}return{error:n,identitySignature:i,readRecord:a,readSelected:c}}import{createHash as
|
|
562
|
+
supported. Reconnect Codex and retry.")}return{error:n,identitySignature:i,readRecord:a,readSelected:c}}import{createHash as nre,randomUUID as az}from"node:crypto";import{readFile as cz,rm as dz}from"node:fs/promises";import bg from"node:path";var uz=Object.freeze(["auth","codex","status.json"]),lz=Object.freeze(["auth","codex","auth-status.json"]);var pz="vibe64_codex_reconnecting",fz="Codex is reconnecting with the current account.";function mz(e=""){let t=String(e||
|
|
563
563
|
"").trim();if(!t||!bg.isAbsolute(t))throw new Error("A Vibe64 system root is required for Codex auth state.");return bg.
|
|
564
564
|
resolve(t)}function RS(e="",{relativePath:t=[]}={}){return bg.join(mz(e),...t)}function _n(e=""){return RS(e,{relativePath:uz})}
|
|
565
565
|
function Hd(e=""){return RS(e,{relativePath:lz})}async function hz(e=""){try{return await cz(e,"utf8")}catch(t){if(t?.code==="ENOENT")return"";throw t}}async function Ws(e=""){
|
|
@@ -764,7 +764,7 @@ e.");return s("warning","Explicit Colleague repair only; the ordered upgrade led
|
|
|
764
764
|
e apply, then run ordinary candidate check/apply."),await y(i?Eg:Ag,n,"before-continuity-bootstrap"),{pending:f.map(v=>v.
|
|
765
765
|
id),applied:[]}}for(let v of f)await y(v,!1);if(!n)return{pending:f.map(v=>v.id),applied:[]};let h=[];for(let v of f)await y(
|
|
766
766
|
v,!0),p.applied.push({id:v.id,completedAt:new Date().toISOString()}),await zA(d,p),h.push(v.id),s("info",`${v.id}: compl\
|
|
767
|
-
eted and recorded.`);return{pending:[],applied:h}};return n?(await $A(c,{recursive:!0,mode:448}),UA(c,u)):u()}import{createHash as
|
|
767
|
+
eted and recorded.`);return{pending:[],applied:h}};return n?(await $A(c,{recursive:!0,mode:448}),UA(c,u)):u()}import{createHash as P5}from"node:crypto";import ih from"node:path";var HA=["plan","code","economy","router","sharedBackup"],GA=/[\x00-\x1f\x7f]/u,Ys=e=>e&&typeof e=="object"&&!Array.isArray(
|
|
768
768
|
e);function Ri(e,{legacy:t=!1}={}){let r=()=>{throw new Error("Saved model routing has an unsupported shape. Restore or \
|
|
769
769
|
repair the settings before changing them.")};(!Ys(e)||!Number.isSafeInteger(e.revision)||e.revision<0||!Ys(e.orchestrators)||
|
|
770
770
|
!(t?[1,2]:[2]).includes(e.schemaVersion))&&r();let n=o=>{(!Ys(o)||o.schema!=="vibe64.assistant-selection.v1"||Object.keys(
|
|
@@ -830,7 +830,7 @@ if(!d||typeof d!="object"||Array.isArray(d)||typeof d.type!="string")throw Jd("C
|
|
|
830
830
|
vent type.");return d}for await(let c of e){let d=Buffer.isBuffer(c)?c:Buffer.from(c),u=0;for(let l=d.indexOf(10,u);l!==
|
|
831
831
|
-1;l=d.indexOf(10,u)){let p=d.subarray(u,l);if(i+p.length>t)throw Jd("Claude JSON frame exceeded its size limit.");i&&s(
|
|
832
832
|
p);let f=i?o.subarray(0,i):p;i=0;let y=a(f);y&&(yield y),u=l+1}s(d.subarray(u))}if(i&&!r)throw Jd("Claude JSON stream en\
|
|
833
|
-
ded in an incomplete frame.")}import{execFile as Qz,spawn as
|
|
833
|
+
ded in an incomplete frame.")}import{execFile as Qz,spawn as $oe}from"node:child_process";import{mkdtemp as Uoe,open as zoe,readFile as Pg,readdir as eF,rm as Foe}from"node:fs/promises";import{setTimeout as QA}from"node:timers/promises";import{promisify as tF}from"node:util";var rF=tF(Qz);async function nF(e){
|
|
834
834
|
let{stdout:t}=await rF("ps",e,{env:{...process.env,LC_ALL:"C",TZ:"UTC"},maxBuffer:67108864});return t}function kg({runtimeTokenEnvironmentName:e="JSKIT_EXECUTION_RUNTIME_TOKEN",commandHashEnvironmentName:t="JSKIT_EXECUTION\
|
|
835
835
|
_COMMAND_HASH",label:r="Native",unavailableCode:n="native_process_identity_unavailable",platform:o=process.platform,ps:i=nF}={}){
|
|
836
836
|
let a=o==="darwin"?100:25,c=1,d=Object.freeze({linux:"linux-proc",darwin:"darwin"}),u=d[o]||"",l=Object.freeze({RUNNING:"\
|
|
@@ -899,7 +899,7 @@ async function bt({commandHash:U="",pid:F=null,reportedIdentity:H=null,runtimeTo
|
|
|
899
899
|
H);if(_(_e)&&_e.commandHash===te&&_e.runtimeToken===ie)return _e;let Se=Number(F),Ze=u&&Number.isSafeInteger(Se)&&Se>0?await Ve(
|
|
900
900
|
Se):null;if(!Ze?.startTimeTicks||Ze.processGroupId!==Se){let Pe=new Error(`${r} process identity could not be captured.`);
|
|
901
901
|
throw Pe.code=n,Pe}return{commandHash:te,platform:u,runtimeToken:ie,startTimeTicks:Ze.startTimeTicks,version:c}}return Object.
|
|
902
|
-
freeze({normalize:m,isValid:_,normalizeInspection:X,capture:bt,inspect:Z,stop:st,isProcessAlive:y})}var
|
|
902
|
+
freeze({normalize:m,isValid:_,normalizeInspection:X,capture:bt,inspect:Z,stop:st,isProcessAlive:y})}var Koe=new URL("./../node_modules/@jskit-ai/assistant-core/src/server/conversation/commandWrapper.js",import.meta.url).
|
|
903
903
|
href;function op(e,t,r,n){return Bd([e,t,r,n])}async function Ng(e,t,r){let n;try{n=await r(`${e.claudeBaseUrl}/v1/messages`,{method:"POST",redirect:"error",signal:AbortSignal.
|
|
904
904
|
timeout(3e4),headers:{Authorization:`Bearer ${t}`,"anthropic-version":"2023-06-01","Content-Type":"application/json"},body:JSON.
|
|
905
905
|
stringify({model:e.models[0].id,max_tokens:64,messages:[{role:"user",content:"Reply with OK."}]})})}catch{throw new Error(
|
|
@@ -1083,17 +1083,17 @@ oneNinth:"\u2151",oneTenth:"\u2152"},r4={tick:"\u221A",info:"i",warning:"\u203C"
|
|
|
1083
1083
|
circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"\
|
|
1084
1084
|
( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\
|
|
1085
1085
|
\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"\
|
|
1086
|
-
1/7",oneNinth:"1/9",oneTenth:"1/10"},n4={...CE,...RE},o4={...CE,...r4},i4=Zg(),s4=i4?n4:o4,gp=s4,
|
|
1086
|
+
1/7",oneNinth:"1/9",oneTenth:"1/10"},n4={...CE,...RE},o4={...CE,...r4},i4=Zg(),s4=i4?n4:o4,gp=s4,ase=Object.entries(RE);import a4 from"node:tty";var c4=a4?.WriteStream?.prototype?.hasColors?.()??!1,we=(e,t)=>{if(!c4)return o=>o;let r=`\x1B[${e}\
|
|
1087
1087
|
m`,n=`\x1B[${t}m`;return o=>{let i=o+"",s=i.indexOf(n);if(s===-1)return r+i+n;let a=r,c=0,u=(t===22?n:"")+r;for(;s!==-1;)
|
|
1088
|
-
a+=i.slice(c,s)+u,c=s+n.length,s=i.indexOf(n,c);return a+=i.slice(c)+n,a}},
|
|
1089
|
-
23),
|
|
1090
|
-
28),
|
|
1091
|
-
37,39),wp=we(90,39),
|
|
1092
|
-
47,49)
|
|
1093
|
-
101,49),
|
|
1094
|
-
"58;5;1",59),
|
|
1095
|
-
"58;5;7",59),
|
|
1096
|
-
"58;5;13",59),
|
|
1088
|
+
a+=i.slice(c,s)+u,c=s+n.length,s=i.indexOf(n,c);return a+=i.slice(c)+n,a}},use=we(0,0),OE=we(1,22),lse=we(2,22),pse=we(3,
|
|
1089
|
+
23),fse=we(4,24),mse=we("4:2",24),hse=we("4:3",24),gse=we("4:4",24),wse=we("4:5",24),vse=we(53,55),yse=we(7,27),_se=we(8,
|
|
1090
|
+
28),bse=we(9,29),Ise=we(30,39),Sse=we(31,39),Ase=we(32,39),Ese=we(33,39),xse=we(34,39),Tse=we(35,39),Cse=we(36,39),Rse=we(
|
|
1091
|
+
37,39),wp=we(90,39),Ose=we(40,49),Pse=we(41,49),kse=we(42,49),Nse=we(43,49),jse=we(44,49),Mse=we(45,49),Lse=we(46,49),$se=we(
|
|
1092
|
+
47,49),Dse=we(100,49),PE=we(91,39),Use=we(92,39),kE=we(93,39),zse=we(94,39),Fse=we(95,39),Bse=we(96,39),qse=we(97,39),Vse=we(
|
|
1093
|
+
101,49),Hse=we(102,49),Gse=we(103,49),Wse=we(104,49),Kse=we(105,49),Jse=we(106,49),Xse=we(107,49),Yse=we("58;5;0",59),Zse=we(
|
|
1094
|
+
"58;5;1",59),Qse=we("58;5;2",59),eae=we("58;5;3",59),tae=we("58;5;4",59),rae=we("58;5;5",59),nae=we("58;5;6",59),oae=we(
|
|
1095
|
+
"58;5;7",59),iae=we("58;5;8",59),sae=we("58;5;9",59),aae=we("58;5;10",59),cae=we("58;5;11",59),dae=we("58;5;12",59),uae=we(
|
|
1096
|
+
"58;5;13",59),lae=we("58;5;14",59),pae=we("58;5;15",59);var ME=({type:e,message:t,timestamp:r,piped:n,commandId:o,result:{failed:i=!1}={},options:{reject:s=!0}})=>{let a=d4(r),
|
|
1097
1097
|
c=u4[e]({failed:i,reject:s,piped:n}),d=l4[e]({reject:s});return`${wp(`[${a}]`)} ${wp(`[${o}]`)} ${d(c)} ${d(t)}`},d4=e=>`${vp(
|
|
1098
1098
|
e.getHours(),2)}:${vp(e.getMinutes(),2)}:${vp(e.getSeconds(),2)}.${vp(e.getMilliseconds(),3)}`,vp=(e,t)=>String(e).padStart(
|
|
1099
1099
|
t,"0"),NE=({failed:e,reject:t})=>e?t?gp.cross:gp.warning:gp.tick,u4={command:({piped:e})=>e?"|":"$",output:()=>" ",ipc:()=>"\
|
|
@@ -1111,8 +1111,8 @@ void 0,_4=0n,b4=e=>{for(let t of e){if(t===!1)throw new TypeError(`The "verbose:
|
|
|
1111
1111
|
t)&&!mp(t)){let r=hp.map(n=>`'${n}'`).join(", ");throw new TypeError(`The "verbose" option must not be ${t}. Allowed val\
|
|
1112
1112
|
ues are: ${r} or a function.`)}}};import{hrtime as UE}from"node:process";var _p=()=>UE.bigint(),Qg=e=>Number(UE.bigint()-e)/1e6;var bp=(e,t,r)=>{let n=_p(),{command:o,escapedCommand:i}=EE(e,t),s=Kg(r,"verbose"),a=DE(s,i,{...r});return $E(i,a),{command:o,
|
|
1113
1113
|
escapedCommand:i,startTime:n,verboseInfo:a}};var DT=Bn(Tx(),1);import o1 from"node:path";import $T from"node:process";import Ep from"node:process";import Pi from"node:path";function Sp(e={}){let{env:t=process.env,platform:r=process.platform}=e;return r!=="win32"?"PATH":Object.keys(t).reverse().
|
|
1114
|
-
find(n=>n.toUpperCase()==="PATH")||"Path"}import{promisify as K4}from"node:util";import{execFile as J4,execFileSync as
|
|
1115
|
-
import{fileURLToPath as X4}from"node:url";var
|
|
1114
|
+
find(n=>n.toUpperCase()==="PATH")||"Path"}import{promisify as K4}from"node:util";import{execFile as J4,execFileSync as ece}from"node:child_process";import Cx from"node:path";
|
|
1115
|
+
import{fileURLToPath as X4}from"node:url";var nce=K4(J4);function Ap(e){return e instanceof URL?X4(e):e}function Rx(e){return{*[Symbol.iterator](){let t=Cx.resolve(Ap(e)),r;for(;r!==t;)yield t,r=t,t=Cx.resolve(t,"..")}}}var oce=10*
|
|
1116
1116
|
1024*1024;var Y4=({cwd:e=Ep.cwd(),path:t=Ep.env[Sp()],preferLocal:r=!0,execPath:n=Ep.execPath,addExecPath:o=!0}={})=>{let i=Pi.resolve(
|
|
1117
1117
|
Ap(e)),s=[],a=t.split(Pi.delimiter);return r&&Z4(s,a,i),o&&Q4(s,a,n,i),t===""||t===Pi.delimiter?`${s.join(Pi.delimiter)}${t}`:
|
|
1118
1118
|
[...s,t].join(Pi.delimiter)},Z4=(e,t,r)=>{for(let n of Rx(r)){let o=Pi.join(n,"node_modules/.bin");t.includes(o)||e.push(
|
|
@@ -1158,7 +1158,7 @@ standard:s})=>[e,{name:e,number:t,description:r,supported:n,action:o,forced:i,st
|
|
|
1158
1158
|
r=Array.from({length:t},(n,o)=>aB(o,e));return Object.assign({},...r)},aB=(e,t)=>{let r=cB(e,t);if(r===void 0)return{};let{
|
|
1159
1159
|
name:n,description:o,supported:i,action:s,forced:a,standard:c}=r;return{[e]:{name:n,number:e,description:o,supported:i,action:s,
|
|
1160
1160
|
forced:a,standard:c}}},cB=(e,t)=>{let r=t.find(({name:n})=>nB.signals[n]===e);return r!==void 0?r:t.find(n=>n.number===e)},
|
|
1161
|
-
|
|
1161
|
+
bce=sB();var Fx=e=>{let t="option `killSignal`";if(e===0)throw new TypeError(`Invalid ${t}: 0 cannot be used.`);return qx(e,t)},Bx=e=>e===
|
|
1162
1162
|
0?e:qx(e,"`subprocess.kill()`'s argument"),qx=(e,t)=>{if(Number.isInteger(e))return dB(e,t);if(typeof e=="string")return lB(
|
|
1163
1163
|
e,t);throw new TypeError(`Invalid ${t} ${String(e)}: it must be a string or an integer.
|
|
1164
1164
|
${uw()}`)},dB=(e,t)=>{if(zx.has(e))return zx.get(e);throw new TypeError(`Invalid ${t} ${e}: this signal integer does not\
|
|
@@ -1651,7 +1651,7 @@ t,...r),this.#e.reallyExit=t=>this.#a(t)}}unload(){this.#s&&(this.#s=!1,$i.forEa
|
|
|
1651
1651
|
this.#i,this.#r.count-=1)}#a(t){return lf(this.#e)?(this.#e.exitCode=t||0,this.#r.emit("exit",this.#e.exitCode,null),this.#i.
|
|
1652
1652
|
call(this.#e,this.#e.exitCode)):0}#c(t,...r){let n=this.#n;if(t==="exit"&&lf(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=
|
|
1653
1653
|
r[0]);let o=n.call(this.#e,t,...r);return this.#r.emit("exit",this.#e.exitCode,null),o}else return n.call(this.#e,t,...r)}},
|
|
1654
|
-
tv=globalThis.process,{onExit:OR,load:
|
|
1654
|
+
tv=globalThis.process,{onExit:OR,load:ome,unload:ime}=$V(lf(tv)?new ev(tv):new Qw);var PR=(e,{cleanup:t,detached:r},{signal:n})=>{if(!t||r)return;let o=OR(()=>{e.kill()});DV(n,()=>{o()})};var NR=({source:e,sourcePromise:t,boundOptions:r,createNested:n},...o)=>{let i=_p(),{destination:s,destinationStream:a,destinationError:c,
|
|
1655
1655
|
from:d,unpipeSignal:u}=UV(r,n,o),{sourceStream:l,sourceError:p}=FV(e,d),{options:f,fileDescriptors:y}=An.get(e);return{sourcePromise:t,
|
|
1656
1656
|
sourceStream:l,sourceOptions:f,sourceError:p,destination:s,destinationStream:a,destinationError:c,unpipeSignal:u,fileDescriptors:y,
|
|
1657
1657
|
startTime:i}},UV=(e,t,r)=>{try{let{destination:n,pipeOptions:{from:o,to:i,unpipeSignal:s}={}}=zV(e,t,...r),a=Pp(n,i);return{
|
|
@@ -1796,8 +1796,8 @@ length>0)throw new TypeError(`The command and its arguments must be passed as a
|
|
|
1796
1796
|
e);return{file:r,commandArguments:n}},VH=e=>{if(typeof e!="string")throw new TypeError(`The command must be a string: ${String(
|
|
1797
1797
|
e)}.`);let t=e.trim();if(t==="")return[];let r=[];for(let n of t.split(HH)){let o=r.at(-1);o&&o.endsWith("\\")?r[r.length-
|
|
1798
1798
|
1]=`${o.slice(0,-1)} ${n}`:r.push(n)}return r},HH=/ +/g;var fO=(e,t,r)=>{e.sync=t(GH,r),e.s=e.sync},mO=({options:e})=>hO(e),GH=({options:e})=>({...hO(e),isSync:!0}),hO=e=>({options:{
|
|
1799
|
-
...WH(e),...e}}),WH=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},gO={preferLocal:!0};var wO=jo(()=>({})),
|
|
1800
|
-
getEachMessage:
|
|
1799
|
+
...WH(e),...e}}),WH=({input:e,inputFile:t,stdio:r})=>e===void 0&&t===void 0&&r===void 0?{stdin:"inherit"}:{},gO={preferLocal:!0};var wO=jo(()=>({})),Kge=jo(()=>({isSync:!0})),Jge=jo(uO),Xge=jo(lO),Yge=jo(CT),Zge=jo(mO,{},gO,fO),{sendMessage:Qge,getOneMessage:ewe,
|
|
1800
|
+
getEachMessage:twe,getCancelSignal:rwe}=mR();function KH(e=0){let t=Number(e);return Number.isSafeInteger(t)?t:1}function mu({code:e="",error:t="",exitCode:r=0,ok:n=null,
|
|
1801
1801
|
output:o="",outputEncoding:i="utf8",pid:s=null,signal:a="",stderr:c="",stdout:d="",timedOut:u=!1,execution:l=null,retryable:p=null}={}){
|
|
1802
1802
|
let f=KH(r),y=String(d||""),h=String(c||""),v=String(o||[y,h].filter(Boolean).join(`
|
|
1803
1803
|
`)).trim();return{code:Oe(e),error:Oe(t),exitCode:f,ok:n===null?f===0:n===!0,output:v,pid:Number.isSafeInteger(Number(s))?
|
|
@@ -1848,9 +1848,9 @@ ub-workflow-command":e.purpose==="github-api"?"github-api-command":e.purpose==="
|
|
|
1848
1848
|
d":e.purpose==="health"?"health-status":"vibe64-command"}async function Iv(e={},{env:t=process.env,helperPath:r="",maxBuffer:n=void 0,
|
|
1849
1849
|
outputEncoding:o="utf8",runCapture:i=hu,signal:s=null,timeout:a=15e3}={}){let c={env:t,input:`${JSON.stringify(e)}
|
|
1850
1850
|
`,outputEncoding:o,signal:s,timeout:a};return Number.isSafeInteger(Number(n))&&Number(n)>0&&(c.maxBuffer=Number(n)),i("s\
|
|
1851
|
-
udo",["-n",bv(r),"execute"],c)}import{createRequire as aG}from"node:module";var sG=new URL("./../node_modules/@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var
|
|
1852
|
-
login",customScheme:"",appLinkDomains:Object.freeze([])}),
|
|
1853
|
-
versionName:"1.0.0"});var
|
|
1851
|
+
udo",["-n",bv(r),"execute"],c)}import{createRequire as aG}from"node:module";var sG=new URL("./../node_modules/@jskit-ai/kernel/server/support/symlinkSafeRequire.js",import.meta.url).href;var _we=aG(sG);var Twe=Object.freeze(["bundled","dev_server"]),Cwe=Object.freeze(["capacitor"]),Rwe=Object.freeze({callbackPath:"/auth/\
|
|
1852
|
+
login",customScheme:"",appLinkDomains:Object.freeze([])}),Owe=Object.freeze({packageName:"",minSdk:26,targetSdk:35,versionCode:1,
|
|
1853
|
+
versionName:"1.0.0"});var Xwe=Object.freeze(["dependencies","optionalDependencies","peerDependencies"]),Ywe=Object.freeze(["capabilities","kin\
|
|
1854
1854
|
d","metadata","migrations","runtime","vite"]);function lG(e={}){return Wn(e.userKey,e.project?.ownerUserKey,e.project?.ownerUsername,e.project?.ownerUser?.username,e.
|
|
1855
1855
|
session?.metadata?.session_git_command_actor_user_key)}async function AO(e={}){let t=Oe(e.actor)||"daemon";if(t==="daemo\
|
|
1856
1856
|
n"||t==="app")return{actor:t,credentialScope:t,requiresRealUser:!1,user:qg()};let r=lG(e);if(!r){let n=new Error("A user\
|
|
@@ -1976,7 +1976,7 @@ n),...GO({actor:e,request:n}),...s,...$O({actor:e,request:n}),...i},d={...c,...j
|
|
|
1976
1976
|
{env:d,existingPath:[...Mv({env:d}),d.PATH].filter(Boolean).join(":"),inheritedPath:r,runtimes:n.runtimes,shimDirs:n.shimDirs||
|
|
1977
1977
|
[]}),l={...d,PATH:u,...Xt()?{}:{VIBE64_TOOL_PATH:u}};return{...l,...Ev({actor:e,env:t,gitConfig:{cwd:n.cwd,env:l},personGitIdentity:n.
|
|
1978
1978
|
personGitIdentity,project:n.project,session:n.session,userKey:n.userKey})}}import{randomUUID as w2}from"node:crypto";import{mkdirSync as v2,writeFileSync as y2}from"node:fs";import Bv from"node:path";import{Buffer as VG}from"node:buffer";import HG from"node:crypto";import{createRequire as GG}from"node:module";var qG=new URL("./../node_modules/@local/vibe64-execution/src/server/engines/terminalSessions.js",import.meta.url).href,
|
|
1979
|
-
ZO=256*1024,WG=300,$v=100,Dv=28;var
|
|
1979
|
+
ZO=256*1024,WG=300,$v=100,Dv=28;var zye=600*1e3,KG=1440*60*1e3,Fye=Object.freeze({"ctrl-c":"",enter:"\r",escape:"\x1B",tab:" "}),Of=new Map,JG=GG(qG),XG=new Map;function YG(){return{code:"terminal_session_not_found",error:"Terminal session not found.",ok:!1}}function zv(e=""){return String(
|
|
1980
1980
|
e||"default").trim()||"default"}function kf(e){let t=zv(e);return Of.has(t)||Of.set(t,new Map),Of.get(t)}function ZG(e="\
|
|
1981
1981
|
default"){return XG.get(zv(e))||null}function QG(e="default"){let t=ZG(e);return t?{code:t.code,error:t.error,ok:!1}:null}function e2(e=""){let t=String(e||"");return[...Of.keys()].filter(r=>r.startsWith(t))}function eP(e){let t=String(e||""),
|
|
1982
1982
|
r=t.length;for(let n=0;n<WG&&(r=t.lastIndexOf(`
|
|
@@ -2143,7 +2143,7 @@ env:u,requiresHelper:a,resolveEnv:f,...v});return i?await i.runCommand(t,{actor:
|
|
|
2143
2143
|
runLocal:y}):t.releaseEnvironmentFile?Jt("Release environment execution requires a managed host.","vibe64_release_enviro\
|
|
2144
2144
|
nment_unavailable",{execution:t.execution}):s?Jt("Managed execution safety is unavailable. Vibe64 did not start this wor\
|
|
2145
2145
|
k.","vibe64_managed_execution_provider_unavailable",{execution:t.execution,retryable:!1}):y()}catch(r){return Jt(r?.message||
|
|
2146
|
-
"Vibe64 command failed.",r?.code||"vibe64_command_failed",{execution:t?.execution})}}var
|
|
2146
|
+
"Vibe64 command failed.",r?.code||"vibe64_command_failed",{execution:t?.execution})}}var C_e=512*1024*1024,R_e=1024*1024*1024;var q2=Object.freeze(["LANG","LC_ALL","NO_PROXY","PATH","SSL_CERT_DIR","SSL_CERT_FILE","TZ"]);var M_e=Object.freeze({linux:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-linux.m\
|
|
2147
2147
|
d",darwin:"https://github.com/mobily-enterprises/vibe64/blob/main/docs/colleague-usage/set-up-macos.md"}),jf=Object.freeze(
|
|
2148
2148
|
{claude:{name:"Claude Code",run:[["claude"]],guideUrl:"https://code.claude.com/docs/en/setup",any:"curl -fsSL https://cl\
|
|
2149
2149
|
aude.ai/install.sh | bash"},codex:{name:"Codex",run:[["codex"]],guideUrl:"https://github.com/openai/codex",any:"curl -fs\
|
|
@@ -2168,7 +2168,7 @@ h -c "$(curl -fsSL https://php.new/install/linux)"',brew:'/bin/bash -c "$(curl -
|
|
|
2168
2168
|
name:"Build tools",setup:"build-tools",run:[["cc","gcc","clang"],["make"]],guideUrl:"https://guides.rubyonrails.org/inst\
|
|
2169
2169
|
all_ruby_on_rails.html",detail:"Some packages compile native code, so they need a compiler and a few libraries.",apt:"su\
|
|
2170
2170
|
do apt install build-essential pkg-config libyaml-dev libssl-dev zlib1g-dev libpq-dev default-libmysqlclient-dev libgmp-\
|
|
2171
|
-
dev",brew:"brew install pkg-config libyaml openssl@3 gmp"}}),
|
|
2171
|
+
dev",brew:"brew install pkg-config libyaml openssl@3 gmp"}}),L_e=Object.freeze({composer:"php"});var AP="backups.git",EP="vibe64-atomic",V2=`backup_canonical_ref() {
|
|
2172
2172
|
vibe64_backup_repository="$1"
|
|
2173
2173
|
vibe64_source_repository="$2"
|
|
2174
2174
|
vibe64_source_ref="$3"
|
|
@@ -2186,7 +2186,7 @@ r "$vibe64_backup_repository" rev-parse --verify "$vibe64_backup_ref"
|
|
|
2186
2186
|
' "$vibe64_source_ref" >&2
|
|
2187
2187
|
return 1
|
|
2188
2188
|
fi
|
|
2189
|
-
}`,
|
|
2189
|
+
}`,B_e=`#!/bin/sh
|
|
2190
2190
|
set -eu
|
|
2191
2191
|
|
|
2192
2192
|
zero_object=0000000000000000000000000000000000000000
|
|
@@ -2260,7 +2260,7 @@ while read -r old_object _new_object ref_name; do
|
|
|
2260
2260
|
backup_canonical_ref "$backup_repository" "$git_dir" "$ref_name" "$old_object" "$backup_ref"
|
|
2261
2261
|
fi
|
|
2262
2262
|
done <"$updates_file"
|
|
2263
|
-
`;var
|
|
2263
|
+
`;var J_e=new URL("./../node_modules/@local/vibe64-execution/src/server/runtime/agentPreviewBrowserWorkerSource.js",import.meta.
|
|
2264
2264
|
url).href;var G2=["Usage:"," vibe64-helper preview ensure [--target <target-id>] [--wait] [--json] [--timeout-ms <ms>]"," vibe64\
|
|
2265
2265
|
-helper preview targets [--json]"," vibe64-helper preview status [--json]"," vibe64-helper preview stop [--json]"," v\
|
|
2266
2266
|
ibe64-helper preview inspect-url"," vibe64-helper preview screenshot [--output <path>]"," vibe64-helper preview browse\
|
|
@@ -2295,12 +2295,12 @@ for the configured primary application.","Do not start a duplicate copy of that
|
|
|
2295
2295
|
t secondary application explicitly requested by the user, such as a reference app, may run separately without replacing \
|
|
2296
2296
|
this preview."].join(`
|
|
2297
2297
|
`)+`
|
|
2298
|
-
`;import{fileURLToPath as Y2}from"node:url";var X2=new URL("./../node_modules/@local/vibe64-execution/src/server/conversationExecution.js",import.meta.url).href,
|
|
2299
|
-
new URL("./engines/stdioBridge.js",X2));var
|
|
2298
|
+
`;import{fileURLToPath as Y2}from"node:url";var X2=new URL("./../node_modules/@local/vibe64-execution/src/server/conversationExecution.js",import.meta.url).href,obe=Y2(
|
|
2299
|
+
new URL("./engines/stdioBridge.js",X2));var ube=["skip=$1; version=$2; shift 2",'for name in "$@"; do',' found=$(command -v -- "$name" 2>/dev/null) || continue',
|
|
2300
2300
|
" case $found in /*) ;; *) continue ;; esac",' if [ -n "$skip" ]; then case $found in /usr/bin/*) continue ;; esac; fi',
|
|
2301
2301
|
` printf '%s\\n' "$found"`,' exec "$found" $version 2>&1',"done","exit 127"].join(`
|
|
2302
2302
|
`);var Q2=Object.freeze(Object.fromEntries(["claude","codex","opencode"].map(e=>{let{name:t,guideUrl:r,any:n}=jf[e];return[
|
|
2303
|
-
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as eW}from"node:child_process";import{readFile as tW,readdir as
|
|
2303
|
+
e,Object.freeze({name:t,guideUrl:r,install:n})]})));import{execFile as eW}from"node:child_process";import{readFile as tW,readdir as wbe}from"node:fs/promises";import Gv from"node:process";
|
|
2304
2304
|
import{promisify as rW}from"node:util";var nW=rW(eW);function oW(e=""){let t=String(e||"").trim(),r=t.lastIndexOf(")");if(r<
|
|
2305
2305
|
0)return null;let n=t.slice(r+1).trim().split(/\s+/u),o=String(n[0]||""),i=String(n[19]||"");return!/^[A-Za-z]$/u.test(o)||
|
|
2306
2306
|
!/^\d+$/u.test(i)?null:{groupId:Number(n[2]),startTimeTicks:i,state:o}}function iW(e=""){let t=/^\s*(\d+)\s+(\S+)\s+(\S.*\S)\s*$/u.
|
|
@@ -2319,7 +2319,7 @@ Library","Application Support","Vibe64"));let n=String(Do.env.XDG_STATE_HOME||""
|
|
|
2319
2319
|
return eo($o.join(e||Do.cwd(),fW))}function TP({explicitRoot:e="",home:t=Ca.homedir()}={}){return eo(e,wW({home:t}))}function vW({env:e=Do.env,explicitRoot:t="",home:r=Ca.homedir(),projectsRoot:n="",runtimeProfile:o=null}={}){let i=t||e[Wv];
|
|
2320
2320
|
return String(i||"").trim()?eo(i):hW(o)?gW(r):eo($o.join(n||xP(r),pW))}function CP({env:e=Do.env,explicitRoot:t="",home:r=Ca.
|
|
2321
2321
|
homedir(),runtimeProfile:n=null,systemRoot:o=""}={}){let i=t||e[lW];if(String(i||"").trim())return eo(i);let s=String(o||
|
|
2322
|
-
"").trim()?eo(o):vW({env:e,home:r,runtimeProfile:n});return $o.join(s,"services")}import{mkdir as
|
|
2322
|
+
"").trim()?eo(o):vW({env:e,home:r,runtimeProfile:n});return $o.join(s,"services")}import{mkdir as _Se,readFile as yW,rm as bSe,writeFile as ISe}from"node:fs/promises";import RP from"node:path";var _W="runtime",bW="open.json";function IW(e=""){let t=N(e);return t?RP.join(RP.resolve(t),_W,bW):""}async function Jv({
|
|
2323
2323
|
projectRuntimeRoot:e=""}={}){let t=IW(e);if(!t)return Kv("");try{let r=JSON.parse(await yW(t,"utf8"));return!Ne(r)||r.open!==
|
|
2324
2324
|
!0?Kv(t):OP({...r,filePath:t,open:!0})}catch(r){if(Rt(r)||r instanceof SyntaxError)return Kv(t);throw r}}function OP(e={}){let t=e?.open===!0;return{open:t,...t&&N(e.openedAt)?{openedAt:N(e.openedAt)}:{},...t&&N(e.projectSlug)?
|
|
2325
2325
|
{projectSlug:N(e.projectSlug)}:{},...t&&N(e.reason)?{reason:N(e.reason)}:{},...t&&N(e.updatedAt)?{updatedAt:N(e.updatedAt)}:
|
|
@@ -2343,7 +2343,7 @@ test(o.topic.commit)||typeof o.topic.topicHash!="string"||!/^[a-f0-9]{64}$/u.tes
|
|
|
2343
2343
|
"string"||!s.test(o.lesson.code)||typeof o.lesson.hash!="string"||!/^[a-f0-9]{64}$/u.test(o.lesson.hash)||i.kind!=="bund\
|
|
2344
2344
|
led")throw Yv();let c=i.sourcePath;if(typeof c!="string"||!c||c.length>512||c.includes("\\")||c.includes("\0")||AW.posix.
|
|
2345
2345
|
isAbsolute(c)||/^[a-zA-Z][a-zA-Z0-9+.-]*:/u.test(c)||c!=="."&&c.split("/").some(d=>!d||d==="."||d===".."))throw Yv();return{
|
|
2346
|
-
schemaVersion:2,learnerKey:r,practiceId:n,pin:{course:{...o.course},topic:{...o.topic},lesson:{...o.lesson}},exercise:{...i}}}var NP="github",jP="managed_git",MP="local_source";var
|
|
2346
|
+
schemaVersion:2,learnerKey:r,practiceId:n,pin:{course:{...o.course},topic:{...o.topic},lesson:{...o.lesson}},exercise:{...i}}}var NP="github",jP="managed_git",MP="local_source";var BSe=Object.freeze({GITHUB:NP,MANAGED_GIT:jP,LOCAL_SOURCE:MP});function LP(e){return e.messages||[e.system,e.user,...e.thinking||[],...e.commentary||[],e.assistant].filter(Boolean)}var zr=["system","user","assistant"];function $P(e,{beforeTurnId:t="",limit:r=0}={}){let n=e.flatMap((v,w)=>zr.filter(m=>v[m]).map(m=>({index:w,role:m,turnId:v.
|
|
2347
2347
|
turnId}))),o=e.findIndex(v=>v.turnId===t),i="";if(o<0&&t.startsWith("message:"))try{let[v,w]=JSON.parse(t.slice(8));zr.includes(
|
|
2348
2348
|
w)&&(o=e.findIndex(m=>m.turnId===v),i=w)}catch{}let s=i?zr.indexOf(i):0,a=o<0?-1:n.findIndex(v=>v.index>o||v.index===o&&
|
|
2349
2349
|
zr.indexOf(v.role)>=s),c=a<0?n.length:a,d=r>0?Math.max(0,c-r):0,u=n[d],l=d>0?zr.indexOf(u.role):0,p=d>0?u.index:0,f=o<0?
|
|
@@ -2420,7 +2420,7 @@ push(M),M.messageId&&f.set(M.messageId,I)}}}}async function d(u,l,p=!1){let f=s(
|
|
|
2420
2420
|
async()=>{let w=c(await a(f)),m=await l(w.view);if(i.delete(f),p)await r(f);else{let _=w.record();await t(f,_,w.view);let I=typeof n==
|
|
2421
2421
|
"function"?await n(f):null;I!=null&&i.set(f,{version:I,record:_})}return m}),v=h.then(()=>{},()=>{});o.set(f,v);try{return await h}finally{
|
|
2422
2422
|
o.get(f)===v&&o.delete(f)}}return Object.freeze({write:d,async read(u,l){let p=s(u);return await o.get(p),l(c(await a(p)).
|
|
2423
|
-
view)},async deleteConversation(u){await d(u,async()=>{},!0)}})}var
|
|
2423
|
+
view)},async deleteConversation(u){await d(u,async()=>{},!0)}})}var NAe=new Set(["contextcompaction",...["context","thread","conversation"].flatMap(e=>["compact","compacted","compactio\
|
|
2424
2424
|
n","truncate","truncated","truncation"].flatMap(t=>[`${e}_${t}`,`${t}_${e}`]))]);var Bt=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"finalizing",
|
|
2425
2425
|
INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),MW=new Set(Object.values(Bt)),LW=new Set([Bt.CANCELLED,
|
|
2426
2426
|
Bt.COMPLETED,Bt.FAILED,Bt.INTERRUPTED,Bt.TIMED_OUT]),$W=new Set([Bt.ACTIVE,Bt.FINALIZING,Bt.STARTING]);function We(e){return String(
|
|
@@ -2430,17 +2430,17 @@ has(Bi(e))}function Uo(e={},t=Bi){let r=t(e.state),n=Eu(r),o=r===Bt.FINALIZING?"
|
|
|
2430
2430
|
idle";return{active:n,completedAt:We(e.finishedAt),error:We(e.error),goalStatus:We(e.providerGoalStatus),goalThreadId:We(
|
|
2431
2431
|
e.providerGoalThreadId),inputSource:We(e.inputSource),outerTurnId:We(e.outerTurnId),phase:n&&e.providerStatus!=="observa\
|
|
2432
2432
|
tion_lost"?We(e.providerPhase):"",runId:We(e.id),runState:r,startedAt:We(e.startedAt),state:o,status:We(e.providerStatus||
|
|
2433
|
-
e.status||r),threadId:We(e.providerThreadId),turnId:We(e.providerTurnId),updatedAt:We(e.updatedAt)}}import kJ from"node:path";var oJ=Bn(Mk(),1),iJ=Bn(Xf(),1),sJ=Bn(La(),1),aJ=Bn(uy(),1),cJ=Bn(fy(),1),dJ=Bn(yy(),1),uJ=Bn(em(),1),lJ=Bn(qk(),1);import{isUtf8 as fJ}from"node:buffer";var mJ=32*1024*1024,
|
|
2433
|
+
e.status||r),threadId:We(e.providerThreadId),turnId:We(e.providerTurnId),updatedAt:We(e.updatedAt)}}import kJ from"node:path";var oJ=Bn(Mk(),1),iJ=Bn(Xf(),1),sJ=Bn(La(),1),aJ=Bn(uy(),1),cJ=Bn(fy(),1),dJ=Bn(yy(),1),uJ=Bn(em(),1),lJ=Bn(qk(),1);import{isUtf8 as fJ}from"node:buffer";var mJ=32*1024*1024,wEe=Object.freeze({chatgpt:"https://chatgpt.com/backend-api/codex",apiKey:"https://api.openai.com/v1",
|
|
2434
2434
|
deepseek:tn("deepseek").baseUrl.replace(/\/$/u,""),"zai-coding-plan":tn("zai-coding-plan").baseUrl,zai:tn("zai").baseUrl});function rm(e,t=422){return Object.assign(new Error(`Codex cannot safely send this compacted conversation to the selecte\
|
|
2435
2435
|
d model: ${e} Continue with the previous model or start a new conversation. Saved history has not been changed.`),{statusCode:t})}async function*by(e,t,r,n,{strictComplete:o=!1}={}){let i=Buffer.alloc(65536),s=[],a=0,c=t;for(let d=t;d<r;){n.throwIfAborted();
|
|
2436
2436
|
let{bytesRead:u}=await e.read(i,0,Math.min(i.length,r-d),d);if(!u)throw rm("the saved history changed during recovery. R\
|
|
2437
2437
|
etry the turn.");let l=i.subarray(0,u),p=0;for(;p<u;){let f=l.indexOf(10,p),y=f>=0,h=y?f:u;if(a+=h-p,a>mJ)throw rm("a sa\
|
|
2438
2438
|
ved history record exceeds the recovery size limit.",413);if(s.push(Buffer.from(i.subarray(p,h))),y){if(n.throwIfAborted(),
|
|
2439
2439
|
a){let v=Buffer.concat(s,a);if(o&&!fJ(v))throw rm("the saved history contains invalid UTF-8.");yield{row:JSON.parse(v.toString(
|
|
2440
|
-
"utf8")),offset:c}}s=[],a=0,c=d+f+1}p=h+(y?1:0)}d+=u}if(o&&a)throw rm("the saved history has an incomplete final record.")}var
|
|
2441
|
-
UNREACHABLE:"unreachable"}),
|
|
2442
|
-
SUSPECT:"suspect"}),wJ=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),
|
|
2443
|
-
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var
|
|
2440
|
+
"utf8")),offset:c}}s=[],a=0,c=d+f+1}p=h+(y?1:0)}d+=u}if(o&&a)throw rm("the saved history has an incomplete final record.")}var SEe=new URL("./../node_modules/@jskit-ai/assistant-core/src/server/conversation/codexProcess.js",import.meta.url).href;var PEe=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),kEe=kg();var gJ=Object.freeze({UNIX:"unix"});var NEe=process.platform==="linux"?107:103,jEe=Object.freeze({MISSING:"missing",RESPONSIVE:"responsive",TIMEOUT:"timeout",
|
|
2441
|
+
UNREACHABLE:"unreachable"}),MEe=Object.freeze({EXITED:"exited",INCOMPATIBLE:"incompatible",LIVE:"live",MISSING:"missing",
|
|
2442
|
+
SUSPECT:"suspect"}),wJ=Object.freeze({RUNNING:"running",STOPPED:"stopped"}),LEe=Object.freeze({ABSENT:"absent",AMBIGUOUS:"\
|
|
2443
|
+
ambiguous",EXACT:"exact",INVALID:"invalid",MISMATCH:"mismatch"});var $Ee=Object.freeze({runtimeToken:"JSKIT_EXECUTION_RUNTIME_TOKEN",modelCatalogSource:"JSKIT_CODEX_MODEL_CATALOG_SOURCE",
|
|
2444
2444
|
commandHash:"JSKIT_EXECUTION_COMMAND_HASH"});import Iy from"node:path";import{chmod as yJ,copyFile as _J,lstat as bJ,mkdtemp as IJ,open as SJ,realpath as AJ,rm as EJ}from"node:fs/promises";
|
|
2445
2445
|
import{createReadStream as xJ}from"node:fs";import{tmpdir as TJ}from"node:os";import{pathToFileURL as Vk}from"node:url";
|
|
2446
2446
|
import{createHash as Hk}from"node:crypto";async function Ki(e,t,{signal:r}={}){if(!Iy.isAbsolute(e||"")||typeof t!="func\
|
|
@@ -2469,7 +2469,7 @@ keys(r).sort().map(n=>[n,r[n]])):r)}function nm(e,{signal:t,maxBytes:r=2*1024**3
|
|
|
2469
2469
|
s)}
|
|
2470
2470
|
`;if(o+=Buffer.byteLength(a),o>r)throw new Error("Native export exceeded its byte limit; history was not retired.");n.update(
|
|
2471
2471
|
a),i++,await e(s),t?.throwIfAborted()},complete(s={}){return t?.throwIfAborted(),{revision:n.digest("hex"),bytes:o,recordCount:i,
|
|
2472
|
-
...s}}}}var
|
|
2472
|
+
...s}}}}var Dxe=Object.freeze({HELPER:"helper",INTERACTIVE:"interactive"}),Uxe=_g().error;var zxe=32*1024,Fxe=2*1024*1024;var Bxe=64*1024,qxe=2*1024*1024,Vxe=4*1024*1024;async function om(e,{threadId:t,signal:r}={}){if(!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u.test(t||"")||kJ.basename(
|
|
2473
2473
|
e||"")!=="goals_1.sqlite")throw new TypeError("Codex goal inspection requires its exact thread ID and supported goals_1.\
|
|
2474
2474
|
sqlite path.");return Ki(e,n=>{let o=n.prepare("PRAGMA table_info(thread_goals)").all(),i=["thread_id","goal_id","object\
|
|
2475
2475
|
ive","status"],s=["token_budget","tokens_used","time_used_seconds","created_at_ms","updated_at_ms"];if(!o.some(d=>d.name===
|
|
@@ -2482,12 +2482,12 @@ t||!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/u.test(c.goal_id||"")||typeof
|
|
|
2482
2482
|
ed","blocked","usage_limited","budget_limited","complete"].includes(c.status)||c.token_budget!==null&&(!Number.isSafeInteger(
|
|
2483
2483
|
c.token_budget)||c.token_budget<0)||["tokens_used","time_used_seconds","created_at_ms","updated_at_ms"].some(d=>!Number.
|
|
2484
2484
|
isSafeInteger(c[d])||c[d]<0))throw new Error("Codex's saved native goal is unsupported or ambiguous; no history was chan\
|
|
2485
|
-
ged.");return c},{signal:r})}var
|
|
2486
|
-
|
|
2485
|
+
ged.");return c},{signal:r})}var tCe=64*1024;var $u=Object.freeze({ACTIVE:"active",CLEANUP_REQUIRED:"cleanup_required",READY:"ready",STARTING_TURN:"starting_turn"}),
|
|
2486
|
+
rCe=new Set(Object.values($u)),nCe=Object.freeze(["createdAt","executionProfile","identity","lifecycle","ownershipId","p\
|
|
2487
2487
|
rojectContextRoot","projectRuntimeRoot","revision","schemaVersion","sessionId","threadId","turnId","updatedAt","workdir"]),
|
|
2488
|
-
|
|
2488
|
+
oCe=Object.freeze(["providerId","providerKeyFingerprint","runtime","server","transportId"]),iCe=Object.freeze(["accountI\
|
|
2489
2489
|
dentitySignature","authStateSignature","endpoint","executionMode","executionContextHash","provider","runtimeDir","runtim\
|
|
2490
|
-
esHash","terminalEnvHash","toolHomeSource","transport"]),
|
|
2490
|
+
esHash","terminalEnvHash","toolHomeSource","transport"]),sCe=Object.freeze(["userAgent"]);var mN=e=>Bi(fe(e)),t3=e=>Eu(fe(e)),r3=e=>Qv(fe(e));function pm(e,t,{normalizeState:r=mN,isActive:n=t3}={}){return ot(e)?
|
|
2491
2491
|
{...e,active:n(e.state),events:Array.isArray(e.events)?e.events.filter(ot):[],id:t,state:r(e.state)}:null}function fm(e,t,{
|
|
2492
2492
|
event:r={},patch:n={}}={},{now:o=()=>new Date,normalizeState:i=mN,isTerminal:s=r3}={}){let a=fe(r.at||n.updatedAt)||o().
|
|
2493
2493
|
toISOString(),c=i(n.state||r.state||e.state),d=s(c),u={...r,at:a,kind:fe(r.kind||c||"updated"),message:fe(r.message||n.message),
|
|
@@ -2509,9 +2509,9 @@ get(c),h=y?.messageId===l?.messageId&&y?.origin===l?.origin&&!y?.turnId?{...y,..
|
|
|
2509
2509
|
add(c),p.messages.delete(c),p.authorship.delete(c),r+=1;let v=n(a);return f&&typeof d=="string"&&h?.turnId&&["user","app\
|
|
2510
2510
|
lication"].includes(h.origin)&&(v.completedMessages=[{...f,turnId:h.turnId,origin:h.origin,...h.origin==="application"&&
|
|
2511
2511
|
h.completedEnvelope===!0?{completedEnvelope:!0}:{},...["assistant","commentary","thinking"].includes(u)?{role:u}:{},text:d,
|
|
2512
|
-
status:"complete"}]),v}function s(a){return t.delete(a),r+=1,n(a)}return{read:n,update:o,complete:i,clear:s}}var
|
|
2512
|
+
status:"complete"}]),v}function s(a){return t.delete(a),r+=1,n(a)}return{read:n,update:o,complete:i,clear:s}}var fOe=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,
|
|
2513
2513
|
/^(?: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,
|
|
2514
|
-
/^(?:one moment|please wait)\b/iu]);import{createReadStream as a3}from"node:fs";import{lstat as
|
|
2514
|
+
/^(?:one moment|please wait)\b/iu]);import{createReadStream as a3}from"node:fs";import{lstat as TOe,open as c3,readdir as Uy,realpath as wN,rm as COe,stat as d3}from"node:fs/promises";
|
|
2515
2515
|
import qa from"node:path";var vN=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/iu,u3=/\.jsonl(?:\.(?:superseded|orphaned)-.*)?$/u;function zy(e){
|
|
2516
2516
|
if(!vN.test(e))throw new TypeError("Invalid Claude conversation id.");return e}function yN(e){return e.normalize("NFC").
|
|
2517
2517
|
replace(/[^a-zA-Z0-9]/gu,"-")}function l3(e){return typeof e=="string"?e:(Array.isArray(e)?e:[]).filter(t=>t.type==="tex\
|
|
@@ -2539,27 +2539,28 @@ last-prompt"].includes(e.type))return{type:e.type,uuid:e.uuid,parentUuid:e.paren
|
|
|
2539
2539
|
isArray(t)||!["user","assistant"].includes(e.type)){if(e.type!=="user"||e.toolUseResult===void 0)return e;let{toolUseResult:i,
|
|
2540
2540
|
...s}=e;return s}let r=e.type==="user"?t.filter(i=>i?.type==="text"):t.map(i=>i?.type==="tool_use"&&i.name!=="Structured\
|
|
2541
2541
|
Output"?{type:"tool_use",id:i.id,name:i.name}:i),{toolUseResult:n,...o}=e;return{...o,message:{...e.message,content:r}}}
|
|
2542
|
-
function g3(e){let t=ao.get(e.path),r=Promise.resolve(t?.reading).catch(()=>{}).then(()=>
|
|
2543
|
-
set(e.path,{...t?.value&&{value:t.value},reading:r});ao.size>f3;)ao.delete(ao.keys().next().value);return r}async function w3(e){
|
|
2544
|
-
let
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
c="",d=[],u=new Map,l="",p=!1;if(e.allowIncompleteTail
|
|
2554
|
-
1})))h.isSidechain||d.push(h);for(let h of d)h.uuid&&u.
|
|
2555
|
-
uuid),h.type==="last-prompt"&&h.leafUuid&&(l=h.leafUuid,
|
|
2556
|
-
l),l=u.get(l)?.parentUuid;let y=new Set;for(let h of d)p&&
|
|
2557
|
-
h.message?.id&&h.message.content?.some(v=>v.type===
|
|
2558
|
-
h.uuid))continue;if(h.type==="system"&&h.subtype===
|
|
2559
|
-
"goal"&&h.commandRun.args==="clear"&&typeof h.
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2542
|
+
function g3(e){let t=ao.get(e.path),r=Promise.resolve(t?.reading).catch(()=>{}).then(()=>v3(e));for(ao.delete(e.path),ao.
|
|
2543
|
+
set(e.path,{...t?.value&&{value:t.value},reading:r});ao.size>f3;)ao.delete(ao.keys().next().value);return r}async function w3(e,t,r){
|
|
2544
|
+
let n=Buffer.alloc(65536);for(let o=r;o>t;){let i=Math.max(t,o-n.length);await e.read(n,0,o-i,i);let s=n.subarray(0,o-i).
|
|
2545
|
+
lastIndexOf(10);if(s!==-1)return i+s+1;o=i}return t}async function v3(e){let t=ao.get(e.path)?.value,r=await c3(e.path,"\
|
|
2546
|
+
r");try{let n=t&&t.dev===e.dev&&t.ino===e.ino&&t.offset<=e.size;if(n){let u=Buffer.alloc(t.check.length);await r.read(u,
|
|
2547
|
+
0,u.length,t.offset-u.length),n=u.equals(t.check)}let o=n?t.offset:0,i=await w3(r,o,e.size),s=[];if(i>o)for await(let u of Og(
|
|
2548
|
+
r.createReadStream({start:o,end:i-1,autoClose:!1})))u.isSidechain||s.push(h3(u));let a=Buffer.alloc(Math.min(m3,i));await r.
|
|
2549
|
+
read(a,0,a.length,i-a.length);let c={dev:e.dev,ino:e.ino,offset:i,check:a,frames:n?t.frames.concat(s):s},d=ao.get(e.path);
|
|
2550
|
+
return d&&(d.value=c),c.frames}catch(n){let o=ao.get(e.path);throw o&&delete o.value,n}finally{await r.close()}}async function Bo(e){
|
|
2551
|
+
let t=await gm(e),r={...e.includeUserMessages?{userMessages:[]}:{},...e.includeCommandMessages?{commandMessages:[]}:{},...e.
|
|
2552
|
+
includeFinalCarriers?{completedResults:[],failedResults:[],structuredOutputs:[]}:{}};if(!t||t.size===0)return{exists:!1,
|
|
2553
|
+
messages:[],userIds:[],text:"",...r};let n=new Map,o=[],i="",s=null,a="",c="",d=[],u=new Map,l="",p=!1;if(e.allowIncompleteTail??
|
|
2554
|
+
!0)d=await g3(t);else for await(let h of Og(a3(t.path,{end:t.size-1})))h.isSidechain||d.push(h);for(let h of d)h.uuid&&u.
|
|
2555
|
+
set(h.uuid,h),["user","assistant"].includes(h.type)&&h.uuid&&(l=h.uuid),h.type==="last-prompt"&&h.leafUuid&&(l=h.leafUuid,
|
|
2556
|
+
p||=h.rewound===!0);let f=new Set;if(p)for(;l&&!f.has(l);)f.add(l),l=u.get(l)?.parentUuid;let y=new Set;for(let h of d)p&&
|
|
2557
|
+
h.uuid&&!f.has(h.uuid)||h.type==="assistant"&&!h.parent_tool_use_id&&h.message?.id&&h.message.content?.some(v=>v.type===
|
|
2558
|
+
"tool_use")&&y.add(h.message.id);for(let h of d){if(p&&h.uuid&&!f.has(h.uuid))continue;if(h.type==="system"&&h.subtype===
|
|
2559
|
+
"local_command"&&!h.parent_tool_use_id&&!h.isMeta&&h.commandRun?.command==="goal"&&h.commandRun.args==="clear"&&typeof h.
|
|
2560
|
+
content=="string"&&/^<local-command-stdout>(?:No goal set|Goal cleared: [\s\S]+)<\/local-command-stdout>$/u.test(h.content)){
|
|
2561
|
+
s=null,a="";let w=u.get(h.parentUuid);c=w?.type==="user"&&!w.isMeta&&!w.parent_tool_use_id?w.uuid:""}if(e.includeCommandMessages&&
|
|
2562
|
+
h.type==="system"&&h.subtype==="local_command"&&h.uuid&&!h.parent_tool_use_id&&!h.isMeta&&typeof h.commandRun?.command==
|
|
2563
|
+
"string"&&h.commandRun.command){let w=typeof h.content=="string"?/^<local-command-(stdout|stderr)>([\s\S]*)<\/local-command-\1>$/u.
|
|
2563
2564
|
exec(h.content):null;w&&r.commandMessages.push({id:`claude_${h.uuid}_0`,text:w[2],data:{native:{engineId:"claude",type:"\
|
|
2564
2565
|
system",subtype:"local_command",command:h.commandRun.command,output:w[1]}}})}let v=h.attachment;if(h.type==="attachment"&&
|
|
2565
2566
|
!h.parent_tool_use_id&&v?.type==="goal_status"&&typeof v.condition=="string"){if((v.sentinel===!0||s?.objective!==v.condition)&&
|
|
@@ -2583,9 +2584,9 @@ id,text:JSON.stringify(w.input)})}for(let w of bN(h,{commentary:y.has(h.message?
|
|
|
2583
2584
|
content.length===1&&typeof h.message.id=="string"&&h.message.id&&Number.isSafeInteger(h.apiBlockIndex)&&h.apiBlockIndex>=
|
|
2584
2585
|
0?{outputId:`claude_${h.message.id}_${h.apiBlockIndex}`}:{}})}return{exists:!0,messages:[...n.values()],userIds:o,goal:s,
|
|
2585
2586
|
goalCommandId:c,...r,text:[...n.values()].filter(h=>h.role==="assistant"&&h.userId===i).map(h=>h.text).join(`
|
|
2586
|
-
`)}}import{createHash as
|
|
2587
|
-
16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}var
|
|
2588
|
-
attachments:!1,tools:!1,nativeTools:!1});var
|
|
2587
|
+
`)}}import{createHash as b3,randomUUID as zOe}from"node:crypto";function wm(e){let t=b3("sha256").update(String(e)).digest("hex");return`${t.slice(0,8)}-${t.slice(8,12)}-4${t.slice(13,
|
|
2588
|
+
16)}-8${t.slice(17,20)}-${t.slice(20,32)}`}var I3=Object.freeze({streaming:!1,instructions:!1,configuration:!1,goals:!1,goalBudgets:!1,goalCommands:Object.freeze({}),
|
|
2589
|
+
attachments:!1,tools:!1,nativeTools:!1});var aPe=Object.freeze({goals:!0,goalBudgets:!1,goalCommands:Object.freeze({set:Object.freeze({delivery:"message",interruptsTurn:!1}),
|
|
2589
2590
|
resume:Object.freeze({delivery:"message",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
2590
2591
|
cancel:Object.freeze({delivery:"message",interruptsTurn:!0})})});import{isAbsolute as SN}from"node:path";var vm=new Set(["api","claude","codex","opencode"]),Sr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Mt(e){
|
|
2591
2592
|
throw Object.assign(new Error(e),{code:"conversation_runtime_upgrade_unavailable"})}function xN(e){let t=e?.replacement;
|
|
@@ -2596,8 +2597,8 @@ e,"preparedAt")&&typeof e.preparedAt!="string")&&Mt("Conversation runtime has an
|
|
|
2596
2597
|
state before upgrading."),e.engine!=="api"&&!Sr(e.binding)&&Mt("A native conversation has no saved binding. Restore its \
|
|
2597
2598
|
exact identity before upgrading."),e.engine==="opencode"&&e.binding.sessionId&&(typeof e.binding.databasePath!="string"||
|
|
2598
2599
|
!e.binding.databasePath)&&Mt("This OpenCode conversation uses an older private database binding. A complete offline nati\
|
|
2599
|
-
ve-history upgrade is required before this metadata upgrade; its database was not changed.")}var
|
|
2600
|
-
adId":e==="claude"?"conversationId":"sessionId";function TN(e){return e.binding?.[
|
|
2600
|
+
ve-history upgrade is required before this metadata upgrade; its database was not changed.")}var E3=e=>e==="codex"?"thre\
|
|
2601
|
+
adId":e==="claude"?"conversationId":"sessionId";function TN(e){return e.binding?.[E3(e.engine)]}function EN(e,t,r,n){if(e===void 0||((!Sr(e)||typeof e.messageId!="string"||!e.messageId||typeof e.text!="string"||!Array.
|
|
2601
2602
|
isArray(e.attachments)||typeof e.at!="string")&&Mt("Conversation runtime has an unsupported pending request. Inspect it \
|
|
2602
2603
|
before upgrading."),t.engine==="api"))return;let o=TN(t);if(r===3&&!Object.hasOwn(e,"inspectionOnly")){(typeof e.attempted!=
|
|
2603
2604
|
"boolean"||e.attempted&&(typeof o!="string"||!o||e.threadId!==o||typeof e.message!="string")||Object.hasOwn(e,"message")&&
|
|
@@ -2621,7 +2622,7 @@ binding:t.binding,segmentId:t.segmentId,continuity:t.continuity,continuityAttach
|
|
|
2621
2622
|
t.submission?e.request=t.submission:delete e.request}function ON(e,{engine:t,selection:r,retireNative:n,pending:o,value:i}){
|
|
2622
2623
|
i?(t!=="api"&&(e.seen=i.engines[t].seen),e.lastEngine=i.lastEngine):t!=="api"&&(!r||n===!0||t==="opencode"&&!o.binding.sessionId)&&
|
|
2623
2624
|
(e.lastEngine=""),delete e.replacement}function PN({workdir:e,configRoot:t}){return{threadId:"",workdir:e,configRoot:t,executionId:""}}
|
|
2624
|
-
function
|
|
2625
|
+
function x3(e,t){let r=["operationId","successorSegmentId","expectedSegmentId","expectedThreadId","expectedToolSchemaIde\
|
|
2625
2626
|
ntity","workdir","configRoot"];(!Sr(t)||Object.keys(t).some(i=>!r.includes(i))||typeof t.operationId!="string"||typeof t.
|
|
2626
2627
|
successorSegmentId!="string"||!/^[\w-]{1,128}$/u.test(t.operationId||"")||!/^[\w-]{1,128}$/u.test(t.successorSegmentId||
|
|
2627
2628
|
"")||typeof t.expectedSegmentId!="string"||!t.expectedSegmentId||typeof t.expectedThreadId!="string"||!t.expectedThreadId||
|
|
@@ -2636,7 +2637,7 @@ ding delivery, paths or retained replacement IDs.");let n={operationId:t.operati
|
|
|
2636
2637
|
codex",configuration:structuredClone(e.configuration),retireNative:!0,operation:"select"},o=CN({request:n,engine:"codex",
|
|
2637
2638
|
configuration:structuredClone(e.configuration),reason:"model-change",segmentId:t.successorSegmentId,continuity:{text:void 0,
|
|
2638
2639
|
attachments:[]},seen:{}});o.binding=PN(t),RN(e,o,n,"codex"),ON(e,{engine:"codex",selection:!0,retireNative:!0,pending:o})}
|
|
2639
|
-
function
|
|
2640
|
+
function T3(e,t){(!Sr(e)||![2,3].includes(e.version)||!Array.isArray(e.predecessors))&&Mt("This conversation has an unsu\
|
|
2640
2641
|
pported runtime version. Inspect its original format and provide an offline conversion before opening it."),xN(e)&&Mt("T\
|
|
2641
2642
|
his conversation has an unfinished Undo operation from an earlier runtime. Inspect its saved native and local history of\
|
|
2642
2643
|
fline before upgrading; no history was changed."),e.version===3&&(typeof e.lastEngine!="string"||e.lastEngine&&!vm.has(e.
|
|
@@ -2648,15 +2649,15 @@ r.binding?(AN(r),EN(r.submission,r,e.version,t)):r.submission!==void 0&&Mt("An u
|
|
|
2648
2649
|
out its exact saved binding. Inspect it before upgrading.")}}function qr({metadata:e,conversationLog:t,retirement:r}){if((!Sr(
|
|
2649
2650
|
e)||!Array.isArray(t))&&Mt("Conversation runtime upgrade requires metadata and the complete stored transcript."),e.runtime===
|
|
2650
2651
|
void 0)return r!==void 0&&Mt("Offline native retirement requires the exact saved runtime; it cannot create a historical \
|
|
2651
|
-
binding."),{metadata:e,changed:!1,warnings:[]};let n=e.runtime,o=structuredClone(n),i=[];if(
|
|
2652
|
+
binding."),{metadata:e,changed:!1,warnings:[]};let n=e.runtime,o=structuredClone(n),i=[];if(T3(o,i),r!==void 0)return x3(
|
|
2652
2653
|
o,r),{metadata:{...e,runtime:o},changed:!0,warnings:i};if(n.version===3)return{metadata:e,changed:!1,warnings:[]};let s="";
|
|
2653
2654
|
for(let a of t){(!Sr(a)||!Array.isArray(a.messages))&&Mt("Conversation history has an unsupported turn. Inspect it befor\
|
|
2654
2655
|
e upgrading.");let c=a.metadata?.runtime;!c||c.supersededBy||!a.messages.some(d=>["user","system"].includes(d.role))||(vm.
|
|
2655
2656
|
has(c.engine)||Mt("An accepted conversation turn has an unknown engine. Inspect its attribution before upgrading."),s=c.
|
|
2656
|
-
engine)}return o.version=3,o.lastEngine=s,{metadata:{...e,runtime:o},changed:!0,warnings:i}}var
|
|
2657
|
+
engine)}return o.version=3,o.lastEngine=s,{metadata:{...e,runtime:o},changed:!0,warnings:i}}var kPe=Object.freeze({goals:!0,goalBudgets:!0,goalCommands:Object.freeze({set:Object.freeze({delivery:"control",interruptsTurn:!1}),
|
|
2657
2658
|
resume:Object.freeze({delivery:"control",interruptsTurn:!1}),pause:Object.freeze({delivery:"control",interruptsTurn:!0}),
|
|
2658
|
-
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});import{Buffer as kN}from"node:buffer";import NN from"node:path";var
|
|
2659
|
-
"object"||Array.isArray(n)?r:{...n,content:Array.isArray(r.parts)?r.parts:[],type:
|
|
2659
|
+
cancel:Object.freeze({delivery:"control",interruptsTurn:!1})})});import{Buffer as kN}from"node:buffer";import NN from"node:path";var k3=2*1024*1024,UPe=32*1024*1024,zPe=2*1024*1024,N3=fe;function j3(e=null){return(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]).map(r=>{let n=r?.info;return!n||typeof n!=
|
|
2660
|
+
"object"||Array.isArray(n)?r:{...n,content:Array.isArray(r.parts)?r.parts:[],type:N3(n.role)}})}async function Fy({databasePath:e,
|
|
2660
2661
|
conversationId:t,onMessage:r,signal:n}={}){if(!NN.isAbsolute(e||"")||!/^ses_[a-zA-Z0-9_]{1,256}$/u.test(t||"")||typeof r!=
|
|
2661
2662
|
"function")throw new TypeError("OpenCode inspection requires its exact database, conversation and message reader.");let o=()=>new Error(
|
|
2662
2663
|
"OpenCode native storage could not be inspected completely. Keep its writers stopped and inspect its original database b\
|
|
@@ -2664,7 +2665,7 @@ efore retrying.");try{return await Ki(e,async i=>{let s=i.prepare("SELECT * FROM
|
|
|
2664
2665
|
id!==t||!NN.isAbsolute(s.directory||""))throw o();if(i.prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND nam\
|
|
2665
2666
|
e = 'session_input'").get()&&i.prepare("SELECT 1 FROM session_input WHERE session_id = ? AND promoted_seq IS NULL LIMIT \
|
|
2666
2667
|
1").get(t))throw new Error("OpenCode has an unpromoted native request. Inspect it before restoring continuity; no reques\
|
|
2667
|
-
t was repeated.");let a=nm(async({message:d})=>r(
|
|
2668
|
+
t was repeated.");let a=nm(async({message:d})=>r(j3([d])[0]),{signal:n}),c=i.prepare("SELECT id, message_id, session_id,\
|
|
2668
2669
|
data FROM part WHERE message_id = ? ORDER BY id");for(let d of i.prepare("SELECT id, session_id, data FROM message WHER\
|
|
2669
2670
|
E session_id = ? ORDER BY time_created, id").iterate(t)){if(n?.throwIfAborted(),!/^msg_[a-zA-Z0-9_]{1,256}$/u.test(d.id))
|
|
2670
2671
|
throw o();let u=kN.byteLength(d.data);if(u>64*1024*1024)throw o();let l=JSON.parse(d.data);if(!l||typeof l!="object"||Array.
|
|
@@ -2676,16 +2677,16 @@ text:[]})}return{session:s,...a.complete()}},{signal:n})}catch(i){throw n?.abort
|
|
|
2676
2677
|
"OpenCode ")||String(i?.message||"").startsWith("Native storage ")?i:o()}}function Du(e={}){let t=[e.text,...(e.content||[]).filter(r=>r?.type==="text").map(r=>r.text)].filter(r=>typeof r=="stri\
|
|
2677
2678
|
ng"&&r.trim());return[...new Set(t)].join(`
|
|
2678
2679
|
|
|
2679
|
-
`)}var MN=/^[a-z][a-z0-9_.-]*$/u,
|
|
2680
|
+
`)}var MN=/^[a-z][a-z0-9_.-]*$/u,M3=/^[A-Za-z_$][A-Za-z0-9_$]*$/u;function LN(e,t){let r=String(e||"").trim().toLowerCase();
|
|
2680
2681
|
if(!MN.test(r))throw new TypeError(`${t} must match ${MN.toString()}.`);return r}function By(e,t){if(e==null)return Object.
|
|
2681
2682
|
freeze({});if(!ot(e))throw new TypeError(`${t} must be an object mapping local names to capability ids.`);let r={},n=new Set;
|
|
2682
|
-
for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!
|
|
2683
|
+
for(let[o,i]of Object.entries(e)){let s=String(o||"").trim();if(!M3.test(s))throw new TypeError(`${t} local name "${s}" \
|
|
2683
2684
|
must be a JavaScript identifier.`);let a=LN(i,`${t}.${s}`);if(n.has(a))throw new TypeError(`${t} declares capability "${a}\
|
|
2684
|
-
" more than once.`);n.add(a),r[s]=a}return Object.freeze(r)}function
|
|
2685
|
+
" more than once.`);n.add(a),r[s]=a}return Object.freeze(r)}function L3(e){let t=new Map;for(let[r,n]of Object.entries(e))
|
|
2685
2686
|
for(let o of Object.keys(n)){if(t.has(o))throw new TypeError(`Provider local name "${o}" is declared by both ${t.get(o)}\
|
|
2686
2687
|
and ${r}.`);t.set(o,r)}}function qy(e,t){if(e==null)return null;if(typeof e!="function")throw new TypeError(`${t} must \
|
|
2687
2688
|
be a function when provided.`);return e}function ym({id:e,requires:t={},optional:r={},provides:n={},setup:o,boot:i=null,
|
|
2688
|
-
shutdown:s=null}={}){let a=LN(e,"Provider id"),c=By(t,`${a}.requires`),d=By(r,`${a}.optional`),u=By(n,`${a}.provides`);
|
|
2689
|
+
shutdown:s=null}={}){let a=LN(e,"Provider id"),c=By(t,`${a}.requires`),d=By(r,`${a}.optional`),u=By(n,`${a}.provides`);L3(
|
|
2689
2690
|
{requires:c,optional:d,provides:u});let l=qy(o,`${a}.setup`);if(!l)throw new TypeError(`${a}.setup is required.`);return Object.
|
|
2690
2691
|
freeze({id:a,requires:c,optional:d,provides:u,setup:l,boot:qy(i,`${a}.boot`),shutdown:qy(s,`${a}.shutdown`)})}var $N="public";function DN(){let e=[],t=new Set,r=!1;function n({id:a,order:c=0,contribute:d}={}){if(r)throw new Error("Bootstrap regis\
|
|
2691
2692
|
tration is closed after the first payload is resolved.");let u=nt(a);if(!u)throw new TypeError("Bootstrap contributor id\
|
|
@@ -2695,20 +2696,20 @@ isFinite(c)?Number(c):0,contribute:d})),s}async function o(a={}){r=!0;let c={},d
|
|
|
2695
2696
|
(u,l)=>u.entry.order-l.entry.order||u.index-l.index).map(({entry:u})=>u);for(let u of d){let l=await u.contribute(Object.
|
|
2696
2697
|
freeze({...ot(a)?a:{},payload:Object.freeze({...c})}));c={...c,...ot(l)?l:{}}}return Object.freeze(c)}function i(){return Object.
|
|
2697
2698
|
freeze({sealed:r,contributorIds:Object.freeze(e.map(a=>a.id).sort())})}let s=Object.freeze({register:n,resolve:o,diagnostics:i});
|
|
2698
|
-
return s}var
|
|
2699
|
+
return s}var $3=ym({id:"runtime.bootstrap",requires:{http:"runtime.http"},provides:{bootstrap:"runtime.bootstrap"},setup({
|
|
2699
2700
|
http:e}){let t=DN();return e.router.register("GET","/api/bootstrap",{auth:$N,meta:{tags:["bootstrap"],summary:"Resolve a\
|
|
2700
|
-
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function
|
|
2701
|
+
pp bootstrap payload"}},async(r,n)=>{n.code(200).send(await t.resolve({request:r,reply:n,query:r.query||{}}))}),{bootstrap:t}}});function D3(e){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Event listener must be an object.");let t=String(
|
|
2701
2702
|
e.id||"").trim();if(!t)throw new TypeError("Event listener id is required.");if(typeof e.handle!="function")throw new TypeError(
|
|
2702
2703
|
`Event listener "${t}" requires handle().`);if(e.matches!=null&&typeof e.matches!="function")throw new TypeError(`Event \
|
|
2703
2704
|
listener "${t}" matches must be a function when provided.`);return Object.freeze({id:t,handle:e.handle,matches:typeof e.
|
|
2704
|
-
matches=="function"?e.matches:null})}function
|
|
2705
|
+
matches=="function"?e.matches:null})}function U3(e){if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("Pub\
|
|
2705
2706
|
lished event must be an object.");let t=String(e.type||"").trim();if(!t)throw new TypeError("Published event type is req\
|
|
2706
|
-
uired.");return Object.freeze({...e,type:t})}function UN(){let e=[],t=new Set;function r(s){let a
|
|
2707
|
-
`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=
|
|
2707
|
+
uired.");return Object.freeze({...e,type:t})}function UN(){let e=[],t=new Set;function r(s){let a=D3(s);if(t.has(a.id))throw new Error(
|
|
2708
|
+
`Event listener "${a.id}" is duplicated.`);return t.add(a.id),e.push(a),i}async function n(s){let a=U3(s);for(let c of e)
|
|
2708
2709
|
c.matches&&c.matches(a)!==!0||await c.handle(a);return a}function o(){return Object.freeze({listenerIds:Object.freeze(e.
|
|
2709
|
-
map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var
|
|
2710
|
+
map(s=>s.id))})}let i=Object.freeze({register:r,publish:n,diagnostics:o});return i}var z3=ym({id:"runtime.events",provides:{
|
|
2710
2711
|
events:"runtime.events"},setup(){return{events:UN()}}});function ar(e){if(e===null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===
|
|
2711
|
-
null||
|
|
2712
|
+
null||B3(t)}function B3(e){return e!==null&&typeof e=="object"&&Object.getPrototypeOf(e)===null&&Reflect.ownKeys(e).length===
|
|
2712
2713
|
0}function Vy(e){return e!==null&&typeof e=="object"&&ar(e.structure)&&ar(e.operations)&&typeof e.validateWith=="function"&&
|
|
2713
2714
|
typeof e.toJsonSchema=="function"&&typeof e.cleanup=="function"}function _m(e,t){if(!Object.hasOwn(t,"items"))return null;
|
|
2714
2715
|
let{items:r}=t;if(Vy(r))return{kind:"schema",schema:r};if(!ar(r)||typeof r.type!="string")throw new Error(`Array field "${e}\
|
|
@@ -2723,32 +2724,32 @@ s: true.`);if(r){if(!Vy(t.schema))throw new Error(`Object field "${e}" must defi
|
|
|
2723
2724
|
kind:"nested",schema:t.schema,allowAdditionalProperties:t.additionalProperties===!0}}return n?{kind:"map",valuesConfig:Uu(
|
|
2724
2725
|
e,t)}:t.additionalProperties===!0?{kind:"opaque"}:{kind:"plain"}}function Va(e){return e?.type==="number"||e?.type==="integer"||e?.type==="epochMilliseconds"||e?.type==="epochSeconds"}var Hy="^(?:0|-?[1-9]\\d*)$",zN="\\d{4}",FN="0[1-9]|1[0-2]",BN="0[1-9]|[12]\\d|3[01]",qN="[01]\\d|2[0-3]",Ha="[0-5]\\d",
|
|
2725
2726
|
Im=`(?:${qN}):${Ha}`,VN=`(?:Z|[+-](?:${qN}):${Ha})`,HN=`(${zN})-(${FN})-(${BN})`,GN=`${zN}-(?:${FN})-(?:${BN})`,WN=`^${GN}\
|
|
2726
|
-
$`,
|
|
2727
|
-
))?${VN}$`),
|
|
2728
|
-
0)}function
|
|
2729
|
-
1&&o<=12&&i>=1&&i<=
|
|
2727
|
+
$`,q3=new RegExp(`^${HN}$`),V3=new RegExp(`^${Im}(?::${Ha}(?:\\.(\\d+))?)?$`),H3=new RegExp(`^${HN}T${Im}:${Ha}(?:\\.(\\d+\
|
|
2728
|
+
))?${VN}$`),G3=new RegExp(Hy),W3=[31,28,31,30,31,30,31,31,30,31,30,31];function K3(e){return e%4===0&&(e%100!==0||e%400===
|
|
2729
|
+
0)}function J3(e,t){return t===2?K3(e)?29:28:W3[t-1]}function KN(e,t,r){let n=Number(e),o=Number(t),i=Number(r);return o>=
|
|
2730
|
+
1&&o<=12&&i>=1&&i<=J3(n,o)}function zu(e,t){let r=e.temporalPrecision;if(r!==void 0){if(!Number.isInteger(r)||r<0)throw new Error(
|
|
2730
2731
|
`temporalPrecision for "${t}" must be a non-negative integer.`);return r}}function JN(e,t){return e===void 0?!0:t===void 0||
|
|
2731
|
-
e.length<=t}function XN(e){if(typeof e!="string")return!1;let t=
|
|
2732
|
-
if(typeof e!="string")return!1;let r=
|
|
2733
|
-
let r=
|
|
2732
|
+
e.length<=t}function XN(e){if(typeof e!="string")return!1;let t=q3.exec(e);return t!==null&&KN(t[1],t[2],t[3])}function YN(e,t){
|
|
2733
|
+
if(typeof e!="string")return!1;let r=V3.exec(e);return r!==null&&JN(r[1],t)}function ZN(e,t){if(typeof e!="string")return!1;
|
|
2734
|
+
let r=H3.exec(e);return r===null?!1:KN(r[1],r[2],r[3])&&JN(r[4],t)}function QN(e){return e===void 0?"(?:\\.\\d+)?":e===0?
|
|
2734
2735
|
"":`(?:\\.\\d{1,${e}})?`}function e0(e,t){let r=zu(e,t);return`^${Im}(?::${Ha}${QN(r)})?$`}function t0(e,t){let r=zu(e,t);
|
|
2735
|
-
return`^${GN}T${Im}:${Ha}${QN(r)}${VN}$`}function Gy(e,t){let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&
|
|
2736
|
-
test(e))r=Number(e);else return null;return!Number.isSafeInteger(r)||r<-t||r>t?null:r===0?0:r}var
|
|
2737
|
-
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function
|
|
2736
|
+
return`^${GN}T${Im}:${Ha}${QN(r)}${VN}$`}function Gy(e,t){let r;if(typeof e=="number")r=e;else if(typeof e=="string"&&G3.
|
|
2737
|
+
test(e))r=Number(e);else return null;return!Number.isSafeInteger(r)||r<-t||r>t?null:r===0?0:r}var X3=new Set(["__proto__","prototype","constructor"]);function Te(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Y3(e,t){if(X3.
|
|
2738
|
+
has(e))throw new Error(`${t}() received unsafe path segment "${e}".`)}function Z3(e){return typeof e!="string"?e:e.replace(
|
|
2738
2739
|
/\[(.+?)\]/g,".$1").replace(/^\.+/,"").replace(/\.+/g,".").replace(/\.$/,"")}function Wy(e,t,{normalize:r=!1,allowEmpty:n=!1}={}){
|
|
2739
|
-
let o=r?
|
|
2740
|
+
let o=r?Z3(e):e;if(typeof o!="string"||o.trim()===""){if(n&&o==="")return[];throw new Error(`${t}() expects a non-empty \
|
|
2740
2741
|
dotted path string.`)}let i=o.split(".");if(i.some(s=>s===""))throw new Error(`${t}() received an invalid path "${o}".`);
|
|
2741
|
-
for(let s of i)
|
|
2742
|
-
Jy=Symbol("json-rest-schema.exportContext"),
|
|
2743
|
-
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Hy}]}}function Xi(e,t){return{[qo]:{[e]:t}}}var
|
|
2742
|
+
for(let s of i)Y3(s,t);return i}var Q3="http://json-schema.org/draft-07/schema#",qo="x-json-rest-schema",Ky=["object","array","string","number","boolean"],
|
|
2743
|
+
Jy=Symbol("json-rest-schema.exportContext"),e8=["true","1","yes","y","on"],t8=["false","0","no","n","off"];function r0(e){
|
|
2744
|
+
return{anyOf:[{type:"integer",minimum:-e,maximum:e},{type:"string",pattern:Hy}]}}function Xi(e,t){return{[qo]:{[e]:t}}}var r8={
|
|
2744
2745
|
none:()=>({type:Ky}),blob:()=>({type:Ky}),serialize:()=>({type:Ky}),object:()=>({type:"object"}),array:()=>({type:"array"}),
|
|
2745
2746
|
file:()=>({type:"string"}),string:()=>({type:"string"}),number:()=>({type:["number","string"]}),integer:()=>({type:["int\
|
|
2746
2747
|
eger","string"]}),epochMilliseconds:()=>r0(864e13),epochSeconds:()=>r0(864e10),dateTime:({definition:e,fieldName:t})=>({
|
|
2747
2748
|
type:"string",format:"date-time",pattern:t0(e,t)}),date:()=>({type:"string",format:"date",pattern:WN}),time:({definition:e,
|
|
2748
2749
|
fieldName:t})=>({type:"string",pattern:e0(e,t)}),boolean:({definition:e})=>{if(e.strictBoolean===!0)return{type:"boolean"};
|
|
2749
|
-
let t=new Set([...
|
|
2750
|
+
let t=new Set([...e8,String(e.stringTrueWhen||"true").trim().toLowerCase()]),r=new Set([...t8,String(e.stringFalseWhen||
|
|
2750
2751
|
"false").trim().toLowerCase()]);return{anyOf:[{type:"boolean"},{type:"number",enum:[0,1]},{type:"string",enum:[...r,...t]}]}},
|
|
2751
|
-
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},
|
|
2752
|
+
id:()=>({type:["integer","string"],minimum:1,pattern:"^[1-9][0-9]*$"})},n8={minLength:({definition:e,parameterValue:t})=>e.
|
|
2752
2753
|
type==="string"?{minLength:t}:null,maxLength:({definition:e,parameterValue:t})=>e.type==="string"?{maxLength:t}:null,min:({
|
|
2753
2754
|
definition:e,parameterValue:t})=>Va(e)?{minimum:t}:null,max:({definition:e,parameterValue:t})=>Va(e)?{maximum:t}:null,pattern:({
|
|
2754
2755
|
definition:e,parameterValue:t})=>e.type==="string"?{pattern:t instanceof RegExp?t.source:t}:null,enum:({parameterValue:e})=>({
|
|
@@ -2758,69 +2759,69 @@ Xi("transforms",{uppercase:!0}):null,lowercase:({parameterValue:e})=>e?Xi("trans
|
|
|
2758
2759
|
"metadata",{precision:e}),scale:({parameterValue:e})=>Xi("metadata",{scale:e}),temporalPrecision:({parameterValue:e})=>Xi(
|
|
2759
2760
|
"metadata",{temporalPrecision:e}),strictBoolean:()=>null,required:()=>null,nullable:()=>null,nullOnEmpty:()=>null,defaultTo:()=>null};
|
|
2760
2761
|
function Qy(e,t){for(let r of Object.keys(t)){let n=t[r],o=e[r];if(n&&o&&typeof n=="object"&&typeof o=="object"&&!Array.
|
|
2761
|
-
isArray(n)&&!Array.isArray(o)){Qy(o,n);continue}e[r]=n}}function
|
|
2762
|
+
isArray(n)&&!Array.isArray(o)){Qy(o,n);continue}e[r]=n}}function o8(e,t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error(
|
|
2762
2763
|
"JSON Schema export hooks must return an object or null.");for(let r of Object.keys(t)){if(r===qo&&e[r]&&typeof e[r]=="o\
|
|
2763
|
-
bject"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Qy(e[r],t[r]);continue}e[r]=t[r]}}function
|
|
2764
|
-
let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===1?e:{anyOf:n}}function
|
|
2764
|
+
bject"&&typeof t[r]=="object"&&!Array.isArray(e[r])&&!Array.isArray(t[r])){Qy(e[r],t[r]);continue}e[r]=t[r]}}function i8(e,t){
|
|
2765
|
+
let n=[...Array.isArray(e.anyOf)&&Object.keys(e).length===1?e.anyOf:[e],...t];return n.length===1?e:{anyOf:n}}function s8(e,t){
|
|
2765
2766
|
if(!Object.hasOwn(e.types,t.type))throw new Error(`No casting function for type: ${t.type}`);let r=e.types[t.type];if(typeof r.
|
|
2766
|
-
toJsonSchema=="function")return r.toJsonSchema;let n=
|
|
2767
|
-
ed to JSON Schema without a toJsonSchema hook.`);return n}function
|
|
2768
|
-
let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=
|
|
2767
|
+
toJsonSchema=="function")return r.toJsonSchema;let n=r8[t.type];if(!n)throw new Error(`Type '${t.type}' cannot be export\
|
|
2768
|
+
ed to JSON Schema without a toJsonSchema hook.`);return n}function a8(e,t,r){if(!Object.hasOwn(e.validators,t))return null;
|
|
2769
|
+
let n=e.validators[t];if(typeof n.toJsonSchema=="function")return n.toJsonSchema;let o=n8[t];if(o)return o;throw new Error(
|
|
2769
2770
|
`Validator '${t}' on field '${r}' cannot be exported to JSON Schema without a toJsonSchema hook.`)}function n0(e){if(e===
|
|
2770
2771
|
void 0)return"create";if(["create","replace","patch"].includes(e))return e;throw new Error(`Unsupported JSON Schema expo\
|
|
2771
|
-
rt mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function
|
|
2772
|
+
rt mode '${e}'. Expected 'create', 'replace', or 'patch'.`)}function c8(e,t={}){if(t.mode!==void 0&&t.operation!==void 0){
|
|
2772
2773
|
let r=n0(t.mode);if(r!==t.operation)throw new Error(`Conflicting JSON Schema export options: mode '${r}' does not match \
|
|
2773
2774
|
operation '${t.operation}'.`)}if(t.operation!==void 0){if(!Object.hasOwn(e.operations,t.operation))throw new Error(`Unkn\
|
|
2774
|
-
own JSON Schema export operation '${t.operation}'.`);return t.operation}return n0(t.mode)}function
|
|
2775
|
-
void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};let r=
|
|
2776
|
-
t);return{operationName:r,operation:e.operations[r]}}function
|
|
2775
|
+
own JSON Schema export operation '${t.operation}'.`);return t.operation}return n0(t.mode)}function d8(e,t={}){if(t.operationName!==
|
|
2776
|
+
void 0&&t.operationDescriptor!==void 0)return{operationName:t.operationName,operation:t.operationDescriptor};let r=c8(e,
|
|
2777
|
+
t);return{operationName:r,operation:e.operations[r]}}function u8(e={}){let t={...e};return Object.defineProperty(t,Jy,{value:{
|
|
2777
2778
|
definitions:{},nodes:[],nextDefinitionId:1,rootNode:null},enumerable:!1}),t}function Am(e={}){return e[Jy]?e[Jy]:{definitions:{},
|
|
2778
|
-
nodes:[],nextDefinitionId:1,rootNode:null}}function
|
|
2779
|
+
nodes:[],nextDefinitionId:1,rootNode:null}}function l8(e){return String(e).replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,
|
|
2779
2780
|
"")||"operation"}function Xy(e){return ar(e)&&Object.keys(e).length===1&&typeof e.$ref=="string"}function Sm(e){return Xy(
|
|
2780
|
-
e)?{allOf:[e]}:e}function
|
|
2781
|
-
o)||null}function
|
|
2782
|
-
root:i=!1}={}){let s=Am(t),a=
|
|
2783
|
-
operation:n,additionalProperties:o,status:"new",definitionName:i?null:
|
|
2781
|
+
e)?{allOf:[e]}:e}function p8(e,t,r,n,o){return e.nodes.find(i=>i.schema===t&&i.operationName===r&&i.operation===n&&i.additionalProperties===
|
|
2782
|
+
o)||null}function f8(e,t){let r=l8(t),n=`SchemaNode_${e.nextDefinitionId}_${r}`;return e.nextDefinitionId+=1,n}function o0(e,t,r,n,o,{
|
|
2783
|
+
root:i=!1}={}){let s=Am(t),a=p8(s,e,r,n,o);if(a)return i&&(a.pointer="#",s.rootNode=a),a;let c={schema:e,operationName:r,
|
|
2784
|
+
operation:n,additionalProperties:o,status:"new",definitionName:i?null:f8(s,r),pointer:i?"#":null};return i?s.rootNode=c:
|
|
2784
2785
|
c.pointer=`#/definitions/${c.definitionName}`,s.nodes.push(c),c}function i0(e,t){if(e.status==="built")return{$ref:e.pointer};
|
|
2785
2786
|
if(e.status==="building")return{$ref:e.pointer};let r=Am(t);e.status="building",e.pointer!=="#"&&(r.definitions[e.definitionName]=
|
|
2786
|
-
{});let n=
|
|
2787
|
+
{});let n=m8(e.schema,t,e.operationName,e.operation,e.additionalProperties);return e.status="built",e.pointer==="#"?n:(r.
|
|
2787
2788
|
definitions[e.definitionName]=n,{$ref:e.pointer})}function e_(e,t,r,n,o=!1){let i=Am(t),s=o0(e,t,r,n,o);return i.rootNode===
|
|
2788
|
-
s?{$ref:"#"}:i0(s,t)}function Fu(e,{referenceBacked:t=!1}={}){return{schema:e,referenceBacked:t}}function
|
|
2789
|
+
s?{$ref:"#"}:i0(s,t)}function Fu(e,{referenceBacked:t=!1}={}){return{schema:e,referenceBacked:t}}function m8(e,t,r,n,o=!1){
|
|
2789
2790
|
let i={},s=[];for(let[c,d]of Object.entries(e.structure))Te(i,c,t_(e,c,d,t,r,n)),n.enforceRequired&&d.required===!0&&s.push(
|
|
2790
|
-
c);let a={type:"object",properties:i,additionalProperties:o};return s.length>0&&(a.required=s),a}function
|
|
2791
|
+
c);let a={type:"object",properties:i,additionalProperties:o};return s.length>0&&(a.required=s),a}function h8(e,t,r,n,o,i){
|
|
2791
2792
|
let s=_m(t,r);if(!s)return null;if(s.kind==="schema")return{...Sm(e_(s.schema,n,"replace",s.schema.operations.replace,!1)),
|
|
2792
2793
|
[qo]:{castType:"object"}};let a=r.items.type==="object"&&Object.hasOwn(r.items,"schema")?"replace":o,c=a==="replace"?e.operations.
|
|
2793
|
-
replace:i;return t_(e,`${t}[]`,r.items,n,a,c)}function
|
|
2794
|
+
replace:i;return t_(e,`${t}[]`,r.items,n,a,c)}function g8(e,t,r,n,o,i){let s=Uu(t,r);if(!s)return null;if(s.kind==="sche\
|
|
2794
2795
|
ma")return{...Sm(e_(s.schema,n,"replace",s.schema.operations.replace,!1)),[qo]:{castType:"object"}};let a=s.definition.type===
|
|
2795
2796
|
"object"&&Object.hasOwn(s.definition,"schema")?"replace":o,c=a==="replace"?e.operations.replace:i;return t_(e,`${t}.*`,s.
|
|
2796
|
-
definition,n,a,c)}function
|
|
2797
|
+
definition,n,a,c)}function w8(e,t,r,n,o,i){if(r.type==="object"){let a=bm(t,r);if(a.kind==="nested")return Fu(e_(a.schema,
|
|
2797
2798
|
n,o,i,a.allowAdditionalProperties===!0),{referenceBacked:!0});if(a.kind==="opaque")return Fu({type:"object",additionalProperties:!0});
|
|
2798
|
-
if(a.kind==="map")return Fu({type:"object",additionalProperties:
|
|
2799
|
+
if(a.kind==="map")return Fu({type:"object",additionalProperties:g8(e,t,r,n,o,i)})}let s=s8(e,r)({schema:e,fieldName:t,definition:r,
|
|
2799
2800
|
operation:o,mode:o,options:n});if(!s||typeof s!="object"||Array.isArray(s))throw new Error(`Type '${r.type}' on field '${t}\
|
|
2800
|
-
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=
|
|
2801
|
+
' returned an invalid JSON Schema fragment.`);if(r.type==="array"){let a=h8(e,t,r,n,o,i);if(a)return Fu({...s,items:a},{
|
|
2801
2802
|
referenceBacked:Xy(s)})}return Fu(s,{referenceBacked:Xy(s)})}function t_(e,t,r,n,o,i){let s={schema:e,fieldName:t,definition:r,
|
|
2802
|
-
operation:o,mode:o,options:n},a=
|
|
2803
|
-
keys(r)){if(p==="type"||!Object.hasOwn(e.validators,p))continue;let f=
|
|
2804
|
-
parameterValue:r[p],fieldSchema:{...c}});y&&
|
|
2805
|
-
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let l=Sm(
|
|
2803
|
+
operation:o,mode:o,options:n},a=w8(e,t,r,n,o,i),c=a.referenceBacked?Sm(a.schema):{...a.schema},d={castType:r.type};for(let p of Object.
|
|
2804
|
+
keys(r)){if(p==="type"||!Object.hasOwn(e.validators,p))continue;let f=a8(e,p,t);if(!f)continue;let y=f({...s,parameterName:p,
|
|
2805
|
+
parameterValue:r[p],fieldSchema:{...c}});y&&o8(c,y)}c[qo]&&(Qy(d,c[qo]),delete c[qo]);let u=[];r.nullable===!0&&u.push({
|
|
2806
|
+
type:"null"}),r.nullOnEmpty===!0&&u.push({const:""});let l=Sm(i8(c,u));if(r.defaultTo!==void 0&&i.applyDefaults)if(typeof r.
|
|
2806
2807
|
defaultTo!="function"){let p=e._normalizeDefault(r,r.defaultTo,{fieldPath:t,currentObject:{},containerKey:t,objectBeforeCast:{},
|
|
2807
2808
|
options:{},settings:e._buildOperationSettings(o,i,{})});if(Object.keys(p.errors).length>0){let f=Object.values(p.errors)[0];
|
|
2808
2809
|
throw new Error(`defaultTo for "${t}" is invalid (${f.code}).`)}l.default=p.value}else d.defaults={providedByFunction:!0};
|
|
2809
|
-
return l[qo]=d,l}function s0(e,t={}){let r=
|
|
2810
|
-
!1:r.additionalProperties,s=Am(r),a=o0(e,r,n,o,i,{root:!0}),c={$schema:
|
|
2810
|
+
return l[qo]=d,l}function s0(e,t={}){let r=u8(t),{operationName:n,operation:o}=d8(e,r),i=r.additionalProperties===void 0?
|
|
2811
|
+
!1:r.additionalProperties,s=Am(r),a=o0(e,r,n,o,i,{root:!0}),c={$schema:Q3,...i0(a,r)};return Object.keys(s.definitions).
|
|
2811
2812
|
length>0&&(c.definitions=s.definitions),c}function a0(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function s_(e){return e instanceof
|
|
2812
|
-
Ka}function
|
|
2813
|
+
Ka}function v8(){return{self:!1,children:{}}}function c0(e){return Object.keys(e.children).length>0}function Yi(e,t){return`${e}\
|
|
2813
2814
|
.${String(t)}`}function m0(e,t){return e===""?String(t):Yi(e,t)}function d0(e,t){if(e===t)return"";let r=`${t}.`;return e.
|
|
2814
2815
|
startsWith(r)?e.slice(r.length):null}function Ga(e,t){let r={};for(let n of Object.values(e)){let o=Yi(t,n.field);Te(r,o,
|
|
2815
2816
|
{...n,field:o})}return r}function o_(e){return Wy(e,"validatePath")}function u0(e){let t={};for(let r of e){let n=o_(r),
|
|
2816
|
-
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||Te(o,s,
|
|
2817
|
-
return t}function
|
|
2817
|
+
o=t;for(let i=0;i<n.length;i++){let s=n[i];Object.hasOwn(o,s)||Te(o,s,v8()),i===n.length-1&&(o[s].self=!0),o=o[s].children}}
|
|
2818
|
+
return t}function y8(e,t){let r=e;for(let n of t){if(r==null||typeof r!="object"||!Object.hasOwn(r,n))return;r=r[n]}return r}
|
|
2818
2819
|
function Em(e){return e===null?!0:Array.isArray(e)||ar(e)?Object.keys(e).length>0:e!==void 0}function l0(e){return[...e].
|
|
2819
2820
|
sort((t,r)=>{let n=/^[0-9]+$/.test(t),o=/^[0-9]+$/.test(r);return n&&o?Number(t)-Number(r):n?-1:o?1:t.localeCompare(r)})}
|
|
2820
|
-
function
|
|
2821
|
+
function _8(e){return/^[0-9]+$/.test(e)}function b8(e,t=new WeakMap){if(t.has(e))return t.get(e);let r=Object.create(Ka.
|
|
2821
2822
|
prototype);return t.set(e,r),r.structure=null,r.types=e.types,r.validators=e.validators,r.operations=e.operations,r.structure=
|
|
2822
2823
|
Tm(xm(e.structure,t)),r._installOperationMethods(),Object.freeze(r)}function xm(e,t=new WeakMap){if(e===null||typeof e!=
|
|
2823
|
-
"object")return e;if(s_(e))return
|
|
2824
|
+
"object")return e;if(s_(e))return b8(e,t);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){let n=new RegExp(
|
|
2824
2825
|
e.source,e.flags);return n.lastIndex=e.lastIndex,n}if(t.has(e))return t.get(e);if(Array.isArray(e)){let n=[];t.set(e,n);
|
|
2825
2826
|
for(let o of e)n.push(xm(o,t));return n}if(!ar(e))return e;let r={};t.set(e,r);for(let[n,o]of Object.entries(e))Te(r,n,xm(
|
|
2826
2827
|
o,t));return r}function Tm(e,t=new WeakSet){if(e===null||typeof e!="object"||t.has(e)||s_(e))return e;if(t.add(e),Array.
|
|
@@ -2828,26 +2829,26 @@ isArray(e))for(let r of e)Tm(r,t);else for(let r of Reflect.ownKeys(e))Tm(e[r],t
|
|
|
2828
2829
|
return Tm(xm(e))}function i_(e,t,r=""){if(!s_(e)||!Array.isArray(t)||t.length<1)return null;let[n,...o]=t;if(!Object.hasOwn(
|
|
2829
2830
|
e.structure,n))return null;let i=e.structure[n];if(o.length<1)return i;let s=m0(r,n);return h0(e,i,o,s)}function h0(e,t,r,n){
|
|
2830
2831
|
if(t?.type==="object"){let o=e._resolveObjectFieldMode(n,t);return o.kind!=="nested"?null:i_(o.schema,r,n)}if(t?.type===
|
|
2831
|
-
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!
|
|
2832
|
+
"array"){let o=e._resolveArrayItemsConfig(n,t);if(!o||r.length<1)return null;let[i,...s]=r;if(!_8(i))return null;let a=Yi(
|
|
2832
2833
|
n,i);return o.kind==="schema"?s.length<1?null:i_(o.schema,s,a):s.length<1?o.definition:h0(e,o.definition,s,a)}return null}
|
|
2833
2834
|
function Wa(e,t){let r={...e};if(Array.isArray(e.skipFields)){let n=e.skipFields.map(o=>d0(o,t)).filter(o=>o!==null&&o!==
|
|
2834
2835
|
"");n.length>0?r.skipFields=n:delete r.skipFields}if(ar(e.skipParams)){let n={};for(let[o,i]of Object.entries(e.skipParams)){
|
|
2835
|
-
let s=d0(o,t);s===null||s===""||Te(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var
|
|
2836
|
+
let s=d0(o,t);s===null||s===""||Te(n,s,i)}Object.keys(n).length>0?r.skipParams=n:delete r.skipParams}return r}var I8=Object.
|
|
2836
2837
|
freeze({create:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
2837
2838
|
replace:Object.freeze({targetFields:"schema",enforceRequired:!0,applyDefaults:!0,outputFields:"validated",rejectExplicitUndefined:!0}),
|
|
2838
2839
|
patch:Object.freeze({targetFields:"input",enforceRequired:!1,applyDefaults:!1,outputFields:"input",rejectExplicitUndefined:!0})});
|
|
2839
2840
|
function p0(e,t,r,n){let o=t[r];if(!n.includes(o))throw new Error(`Operation "${e}" must define ${r} as one of: ${n.join(
|
|
2840
2841
|
", ")}.`)}function n_(e,t,r,n=!0){let o=t[r];if(!(o===void 0&&!n)&&typeof o!="boolean")throw new Error(`Operation "${e}"\
|
|
2841
|
-
must define ${r} as a boolean.`)}function
|
|
2842
|
+
must define ${r} as a boolean.`)}function S8(e,t){if(typeof t!="object"||t===null||Array.isArray(t))throw new Error(`Op\
|
|
2842
2843
|
eration "${e}" must be an object.`);return p0(e,t,"targetFields",["schema","input"]),n_(e,t,"enforceRequired"),n_(e,t,"a\
|
|
2843
2844
|
pplyDefaults"),p0(e,t,"outputFields",["validated","input"]),n_(e,t,"rejectExplicitUndefined",!1),Object.freeze({targetFields:t.
|
|
2844
2845
|
targetFields,enforceRequired:t.enforceRequired,applyDefaults:t.applyDefaults,outputFields:t.outputFields,rejectExplicitUndefined:t.
|
|
2845
|
-
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function
|
|
2846
|
+
rejectExplicitUndefined===void 0?!0:t.rejectExplicitUndefined})}function A8(e={}){if(typeof e!="object"||e===null||Array.
|
|
2846
2847
|
isArray(e))throw new Error("Schema operations must be an object.");let t=Object.create(null);for(let[r,n]of Object.entries(
|
|
2847
|
-
|
|
2848
|
-
null);for(let[r,n]of Object.entries(e))Te(t,r,n);return Object.freeze(t)}function
|
|
2848
|
+
I8))Te(t,r,n);for(let[r,n]of Object.entries(e))Te(t,r,S8(r,n));return Object.freeze(t)}function f0(e){let t=Object.create(
|
|
2849
|
+
null);for(let[r,n]of Object.entries(e))Te(t,r,n);return Object.freeze(t)}function E8(e){let t={...e};return delete t.operation,
|
|
2849
2850
|
delete t.mode,t}var Ka=class{constructor(t,r,n,o={}){this.structure=t,this.types=f0(r),this.validators=f0(n),this.operations=
|
|
2850
|
-
|
|
2851
|
+
A8(o),this._installOperationMethods()}_typeError(t){return this._paramError(t,"TYPE_CAST_FAILED","Value could not be cas\
|
|
2851
2852
|
t to the required type.")}_paramError(t,r,n,o={}){let i=new Error(n);return i.errorObject={field:t,code:r,message:n,params:o},
|
|
2852
2853
|
i}_paramToBeSkipped(t,r,n){return typeof r!="object"||r===null?!1:!!(Array.isArray(r[n])&&r[n].includes(t))}_fieldToBeSkipped(t,r){
|
|
2853
2854
|
return Array.isArray(r.skipFields)&&r.skipFields.includes(t)}_mergeErrors(t,r){for(let[n,o]of Object.entries(r))Te(t,n,o)}_singleErrorMap(t){
|
|
@@ -2862,7 +2863,7 @@ isFieldPresent:o=>Object.hasOwn(n,o)}}_assertPlainObjectInput(t,r){if(!ar(r))thr
|
|
|
2862
2863
|
ect input.`)}_resolvePathValidationRequest(t={}){let r=t.operation??t.mode??"patch";if(Object.hasOwn(t,"operation")&&Object.
|
|
2863
2864
|
hasOwn(t,"mode")&&t.operation!==t.mode)throw new Error("Path validation options `operation` and `mode` must match when b\
|
|
2864
2865
|
oth are provided.");if(!Object.hasOwn(this.operations,r))throw new Error(`Unknown operation "${r}".`);let n=this.operations[r];
|
|
2865
|
-
return{operationName:r,operation:n,validationOptions:
|
|
2866
|
+
return{operationName:r,operation:n,validationOptions:E8(t)}}_buildOperationResult(t,r,n){let o={};for(let i of n.outputFieldNames){
|
|
2866
2867
|
if(!Object.hasOwn(this.structure,i))continue;let s=n.isFieldPresent(i);(r[i]!==void 0||s&&t[i]===null||n.defaultedFields.
|
|
2867
2868
|
has(i))&&(!s&&!n.defaultedFields.has(i)||Te(o,i,r[i]))}return o}_resolveObjectFieldMode(t,r){return bm(t,r)}_resolveArrayItemsConfig(t,r){
|
|
2868
2869
|
return _m(t,r)}_resolveObjectValuesConfig(t,r){return Uu(t,r)}_buildArrayItemSettings(t,r){return t.type==="object"&&Object.
|
|
@@ -2945,7 +2946,7 @@ o.definition,y.children,f,_,0,s,m);Em(_[0])&&Te(c,p,_[0]),this._mergeErrors(u,x)
|
|
|
2945
2946
|
hasOwn(this.operations,t))throw new Error(`Unknown operation "${t}".`);let o=this.operations[t];return this._assertPlainObjectInput(
|
|
2946
2947
|
t,r),this._validateWithOperation(t,o,r,n)}validateAt(t,r,n={}){this._assertPlainObjectInput("validateAt",r);let o=o_(t),
|
|
2947
2948
|
{operationName:i,operation:s,validationOptions:a}=this._resolvePathValidationRequest(n),c=this._validateSelectedTree(u0(
|
|
2948
|
-
[t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:
|
|
2949
|
+
[t]),r,a,this._buildOperationSettings(i,s,r));return{validatedValue:y8(c.validatedObject,o),errors:c.errors}}validatePaths(t,r,n={}){
|
|
2949
2950
|
if(this._assertPlainObjectInput("validatePaths",r),!Array.isArray(t)||t.length===0)throw new Error("validatePaths() expe\
|
|
2950
2951
|
cts a non-empty array of schema paths.");let{operationName:o,operation:i,validationOptions:s}=this._resolvePathValidationRequest(
|
|
2951
2952
|
n);return this._validateSelectedTree(u0(t),r,s,this._buildOperationSettings(o,i,r))}_installOperationMethods(){for(let t of Object.
|
|
@@ -2954,9 +2955,9 @@ thod.`);this[t]=(r,n={})=>this.validateWith(t,r,n)}}toJsonSchema(t={}){return s0
|
|
|
2954
2955
|
this.structure)}getFieldDefinition(t){if(typeof t!="string"||t.trim()==="")throw new Error("Field path must be a non-emp\
|
|
2955
2956
|
ty string.");let r=i_(this,o_(t.trim()));return r===null?null:r_(r)}getFieldMessages(t){let r=this.getFieldDefinition(t);
|
|
2956
2957
|
return!r||typeof r.messages!="object"||r.messages===null?Object.freeze({}):r_(r.messages)}cleanup(t,r){let n={};for(let o of Object.
|
|
2957
|
-
keys(t))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&Te(n,o,t[o]);return n}};var{parse:
|
|
2958
|
-
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=
|
|
2959
|
-
l;let p=n.call(this,u,l);switch(typeof p){case g0:if(p===null)return p;case
|
|
2958
|
+
keys(t))Object.hasOwn(this.structure,o)&&this.structure[o][r]&&Te(n,o,t[o]);return n}};var{parse:jke,stringify:x8}=JSON,{keys:Mke}=Object,T8=String,C8="string";var g0="object",R8=(e,t)=>t;var w0=(e,t,r)=>{let n=T8(t.push(r)-1);return e.set(r,n),n};var v0=(e,t,r)=>{let n=t&&typeof t===g0?(u,l)=>u===""||-1<t.indexOf(u)?l:void 0:t||R8,o=new Map,i=[],s=[],a=+w0(o,i,n.call(
|
|
2959
|
+
{"":e},"",e)),c=!a;for(;a<i.length;)c=!0,s[a]=x8(i[a++],d,r);return"["+s.join(",")+"]";function d(u,l){if(c)return c=!c,
|
|
2960
|
+
l;let p=n.call(this,u,l);switch(typeof p){case g0:if(p===null)return p;case C8:return o.get(p)||w0(o,i,p)}return p}};var P8=new Set(["true","1","yes","y","on"]),k8=new Set(["false","0","no","n","off"]);function N8(e){return e!==null&&(typeof e==
|
|
2960
2961
|
"object"||typeof e=="function")&&typeof e.then=="function"}function y0(e){if(typeof e=="number")return Number.isFinite(e)?
|
|
2961
2962
|
e:null;if(typeof e=="bigint"){let t=Number(e);return Number.isSafeInteger(t)?t:null}if(typeof e=="string"){let t=e.trim();
|
|
2962
2963
|
if(t==="")return null;let r=Number(t);return Number.isFinite(r)?r:null}return null}function a_(e,t){if(Object.is(e,t))return!0;
|
|
@@ -2964,7 +2965,7 @@ if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(e in
|
|
|
2964
2965
|
source===t.source&&e.flags===t.flags;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==
|
|
2965
2966
|
t.length)return!1;for(let o=0;o<e.length;o++)if(!a_(e[o],t[o]))return!1;return!0}if(e===null||t===null||typeof e!="objec\
|
|
2966
2967
|
t"||typeof t!="object"||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;let r=Object.keys(e),n=Object.keys(
|
|
2967
|
-
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!a_(e[o],t[o]))return!1;return!0}var
|
|
2968
|
+
t);if(r.length!==n.length)return!1;for(let o of r)if(!Object.hasOwn(t,o)||!a_(e[o],t[o]))return!1;return!0}var j8={install(e){
|
|
2968
2969
|
let{addType:t,addValidator:r}=e;t("none",n=>n.value),t("file",n=>{let o=n.value;o==null&&n.throwTypeError();let i=typeof o;
|
|
2969
2970
|
if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();return n.definition.noTrim?s:s.trim()}n.throwTypeError()}),
|
|
2970
2971
|
t("string",n=>{let o=n.value;if(o==null)return"";let i=typeof o;if(i==="string"||i==="number"||i==="boolean"){let s=o.toString();
|
|
@@ -2979,7 +2980,7 @@ n.value)}catch{try{return v0(n.value)}catch{n.throwTypeError()}}}),t("boolean",n
|
|
|
2979
2980
|
value;if(typeof n.value=="number"){if(n.value===1)return!0;if(n.value===0)return!1;n.throwTypeError()}if(typeof n.value==
|
|
2980
2981
|
"bigint"){if(n.value===1n)return!0;if(n.value===0n)return!1;n.throwTypeError()}if(typeof n.value=="string"){let o=String(
|
|
2981
2982
|
n.definition.stringFalseWhen||"false").trim().toLowerCase(),i=String(n.definition.stringTrueWhen||"true").trim().toLowerCase(),
|
|
2982
|
-
s=n.value.trim().toLowerCase(),a=new Set([...
|
|
2983
|
+
s=n.value.trim().toLowerCase(),a=new Set([...k8,o]),c=new Set([...P8,i]);if(a.has(s))return!1;if(c.has(s))return!0}n.throwTypeError()}),
|
|
2983
2984
|
t("id",n=>{if(typeof n.value=="number"){if(Number.isSafeInteger(n.value)&&n.value>0)return n.value;n.throwTypeError()}if(typeof n.
|
|
2984
2985
|
value=="bigint"){if(n.value>0n&&n.value<=BigInt(Number.MAX_SAFE_INTEGER))return Number(n.value);n.throwTypeError()}if(typeof n.
|
|
2985
2986
|
value=="string"){let o=n.value.trim();/^[1-9][0-9]*$/.test(o)||n.throwTypeError();let i=Number(o);return Number.isSafeInteger(
|
|
@@ -3000,7 +3001,7 @@ n.throwParamError("PATTERN","Value does not match the required pattern.",{patter
|
|
|
3000
3001
|
parameterValue){if(n.definition.type!=="boolean")throw new Error(`strictBoolean can only be used on boolean fields (${n.
|
|
3001
3002
|
fieldName}).`);typeof n.valueBeforeCast!="boolean"&&n.throwParamError("STRICT_BOOLEAN","Value must be a boolean.")}}),r(
|
|
3002
3003
|
"validator",n=>{if(typeof n.parameterValue!="function")throw new Error(`Validator for ${n.fieldName} must be a function.`);
|
|
3003
|
-
let o=n.parameterValue(n.value,n.object,n);if(
|
|
3004
|
+
let o=n.parameterValue(n.value,n.object,n);if(N8(o))throw new Error(`Custom validator for "${n.fieldName}" must be synch\
|
|
3004
3005
|
ronous.`);typeof o=="string"&&n.throwParamError("CUSTOM_VALIDATOR_FAILED",o)}),r("uppercase",n=>{if(typeof n.value=="str\
|
|
3005
3006
|
ing")return n.value.toUpperCase()}),r("lowercase",n=>{if(typeof n.value=="string")return n.value.toLowerCase()}),r("leng\
|
|
3006
3007
|
th",n=>{if(typeof n.value=="string")return n.value.substr(0,n.parameterValue);Number.isInteger(Number(n.valueBeforeCast))&&
|
|
@@ -3009,93 +3010,93 @@ ed character range.",{max:n.parameterValue,actual:String(n.valueBeforeCast).leng
|
|
|
3009
3010
|
typeof n.value=="string"&&n.value===""&&n.throwParamError("NOT_EMPTY","Field cannot be empty.")}),r("required",()=>{}),r(
|
|
3010
3011
|
"unsigned",()=>{}),r("precision",()=>{}),r("scale",()=>{}),r("temporalPrecision",n=>{if(n.definition.type!=="time"&&n.definition.
|
|
3011
3012
|
type!=="dateTime")throw new Error(`temporalPrecision can only be used on time or dateTime fields (${n.fieldName}).`)}),r(
|
|
3012
|
-
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},_0=
|
|
3013
|
-
unction")throw new Error(`Type handler for '${t}' must be a function.`);Te(e,t,r)}function
|
|
3013
|
+
"nullable",()=>{}),r("nullOnEmpty",()=>{}),r("defaultTo",()=>{})}},_0=j8;var S0=new WeakMap,A0=new WeakMap,E0=Symbol.for("json-rest-schema.registry-metadata");function M8(e,t,r){if(typeof r!="f\
|
|
3014
|
+
unction")throw new Error(`Type handler for '${t}' must be a function.`);Te(e,t,r)}function L8(e,t,r){if(typeof r!="funct\
|
|
3014
3015
|
ion")throw new Error(`Validator handler for '${t}' must be a function.`);Te(e,t,r)}function Cm(e={}){let t=Object.create(
|
|
3015
|
-
null);for(let[r,n]of Object.entries(e))Te(t,r,n);return t}function
|
|
3016
|
+
null);for(let[r,n]of Object.entries(e))Te(t,r,n);return t}function $8(e,t){if(typeof e.install!="function")throw new Error(
|
|
3016
3017
|
"Plugin must have an install method.");e.install(t)}function b0(e,t,r){S0.set(e,t),A0.set(e,r),Object.defineProperty(e,E0,
|
|
3017
|
-
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function
|
|
3018
|
+
{value:Object.freeze({getTypes:()=>t,getValidators:()=>r}),enumerable:!1,configurable:!1,writable:!1})}function D8(e){if(!e||
|
|
3018
3019
|
typeof e!="object"&&typeof e!="function")return null;let t=S0.get(e),r=A0.get(e);if(t&&r)return{types:t,validators:r};let n=e[E0];
|
|
3019
3020
|
return n&&typeof n.getTypes=="function"&&typeof n.getValidators=="function"?{types:n.getTypes(),validators:n.getValidators()}:
|
|
3020
3021
|
typeof e=="object"&&e.types&&typeof e.types=="object"&&e.validators&&typeof e.validators=="object"&&typeof e.create=="fu\
|
|
3021
3022
|
nction"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="function"?{types:e.types,validators:e.
|
|
3022
|
-
validators}:null}function
|
|
3023
|
-
for(let[n,o]of Object.entries(t)){if(Object.hasOwn(e,n)&&!
|
|
3024
|
-
conflicting ${r} "${n}".`);Te(e,n,o)}}function
|
|
3025
|
-
t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a
|
|
3023
|
+
validators}:null}function U8(e){return e.length===1&&Array.isArray(e[0])?e[0]:e}function z8(e,t){return e===t}function I0(e,t,r){
|
|
3024
|
+
for(let[n,o]of Object.entries(t)){if(Object.hasOwn(e,n)&&!z8(e[n],o))throw new Error(`Cannot merge schema factories with\
|
|
3025
|
+
conflicting ${r} "${n}".`);Te(e,n,o)}}function F8(e,t,r){let n=U8(r).filter(Boolean);if(n.length<1)return{types:Cm(e),validators:Cm(
|
|
3026
|
+
t)};let o=Object.create(null),i=Object.create(null);for(let s of n){let a=D8(s);if(!a)throw new Error("Factory sources m\
|
|
3026
3027
|
ust be schema instances or schema factories created by json-rest-schema.");I0(o,a.types,"type"),I0(i,a.validators,"valid\
|
|
3027
3028
|
ator")}return{types:o,validators:i}}function x0({types:e={},validators:t={},installCore:r=!0}={}){let n=Cm(e),o=Cm(t),i=(s,a={})=>{
|
|
3028
|
-
let c=new Ka(s,n,o,a.operations);return b0(c,n,o),c};return b0(i,n,o),i.addType=(s,a)=>{
|
|
3029
|
-
|
|
3029
|
+
let c=new Ka(s,n,o,a.operations);return b0(c,n,o),c};return b0(i,n,o),i.addType=(s,a)=>{M8(n,s,a)},i.addValidator=(s,a)=>{
|
|
3030
|
+
L8(o,s,a)},i.use=s=>{$8(s,{addType:i.addType,addValidator:i.addValidator})},i.createFactory=(...s)=>{let a=F8(n,o,s);return x0(
|
|
3030
3031
|
{types:a.types,validators:a.validators,installCore:!1})},r&&i.use(_0),i}var oe=x0({installCore:!0});function Zi(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e);for(let r of Object.getOwnPropertyNames(
|
|
3031
|
-
e))Zi(e[r],t);return Object.freeze(e)}var
|
|
3032
|
+
e))Zi(e[r],t);return Object.freeze(e)}var B8=new Set(["create","replace","patch"]),q8=Object.freeze({REQUIRED:"required",TYPE_CAST_FAILED:"default",NOT_NULLABLE:"\
|
|
3032
3033
|
default",MIN_LENGTH:"minLength",MAX_LENGTH:"maxLength",MIN_VALUE:"min",MAX_VALUE:"max",PATTERN:"pattern",ENUM_VALUE:"enu\
|
|
3033
3034
|
m",FIELD_NOT_ALLOWED:"additionalProperties",CUSTOM_VALIDATOR_FAILED:"default"});function Rm(e){return!!e&&typeof e=="obj\
|
|
3034
3035
|
ect"&&typeof e.create=="function"&&typeof e.replace=="function"&&typeof e.patch=="function"&&typeof e.toJsonSchema=="fun\
|
|
3035
3036
|
ction"}function T0(e=null,{defaultMode:t="create",context:r="schema definition.mode"}={}){let n=fr(e),o=nt(t).toLowerCase()||"c\
|
|
3036
|
-
reate",i=Object.prototype.hasOwnProperty.call(n,"mode")?nt(n.mode).toLowerCase():"";if(!i)return o;if(!
|
|
3037
|
+
reate",i=Object.prototype.hasOwnProperty.call(n,"mode")?nt(n.mode).toLowerCase():"";if(!i)return o;if(!B8.has(i))throw new TypeError(
|
|
3037
3038
|
`${r} must be one of: create, replace, patch.`);return i}function C0(e=null,t=""){let r=nt(t);if(!r)return{};let n=fr(e);return Rm(n.schema)?fr(n.schema.getFieldMessages(r)):{}}
|
|
3038
|
-
function
|
|
3039
|
-
let n=nt(t?.code).toUpperCase(),o=C0(r,e),i=n==="FIELD_NOT_ALLOWED"&&Object.keys(o).length<1?
|
|
3039
|
+
function V8(e=null,t=""){let r=nt(t).split(".").filter(Boolean);return r.length<2?{}:(r.pop(),C0(e,r.join(".")))}function H8(e,t,r=null){
|
|
3040
|
+
let n=nt(t?.code).toUpperCase(),o=C0(r,e),i=n==="FIELD_NOT_ALLOWED"&&Object.keys(o).length<1?V8(r,e):o,s=q8[n];if(s&&typeof i[s]==
|
|
3040
3041
|
"string"){let a=nt(i[s]);if(a)return a}if(typeof i.default=="string"){let a=nt(i.default);if(a)return a}return nt(t?.message||
|
|
3041
3042
|
t?.code||"Invalid value.")}function c_(e={},t=null){let r=fr(e),n={};for(let[o,i]of Object.entries(r)){let s=nt(o);if(!s)
|
|
3042
|
-
continue;if(typeof i=="string"){n[s]=i;continue}let a=
|
|
3043
|
+
continue;if(typeof i=="string"){n[s]=i;continue}let a=H8(s,i,t);n[s]=a||"Invalid value."}return n}function G8(e){return!!e&&typeof e=="object"&&!Array.isArray(e)&&(Object.prototype.hasOwnProperty.call(e,"schema")||Object.
|
|
3043
3044
|
prototype.hasOwnProperty.call(e,"mode"))}function Om(e,{context:t="schema definition",defaultMode:r=""}={}){if(e==null)return null;
|
|
3044
|
-
if(!
|
|
3045
|
+
if(!G8(e))throw new TypeError(`${t} must be a schema definition object.`);let n=fr(e);if(!Object.prototype.hasOwnProperty.
|
|
3045
3046
|
call(n,"schema"))throw new TypeError(`${t}.schema is required.`);if(!Rm(n.schema))throw new TypeError(`${t}.schema must \
|
|
3046
3047
|
be a json-rest-schema schema instance.`);let o={schema:n.schema},i=nt(r).toLowerCase();return o.mode=T0(n,{defaultMode:i||
|
|
3047
3048
|
"patch",context:`${t}.mode`}),Object.freeze(o)}function d_(e,t,{context:r="schema definition",defaultMode:n=""}={}){let o=Om(e,{context:r,defaultMode:n});return o?o.schema[o.
|
|
3048
|
-
mode](t):null}var
|
|
3049
|
-
mode:"patch"});var R0=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),
|
|
3049
|
+
mode](t):null}var W8=oe({cursor:{type:"id",required:!1},limit:{type:"number",required:!1,min:1,unsigned:!0}}),K8=Object.freeze({schema:W8,
|
|
3050
|
+
mode:"patch"});var R0=Object.freeze({type:"string",pattern:"^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d)?$",minLength:5}),J8=Object.freeze(
|
|
3050
3051
|
{...R0,nullable:!0});function O0({message:e="Schema validation failed.",fieldErrors:t=null,errors:r=null,cause:n,statusCode:o=null}={}){let i=new Error(
|
|
3051
3052
|
e,n?{cause:n}:void 0);return Number.isInteger(o)&&o>=400&&o<=599&&(i.statusCode=o),t&&typeof t=="object"?(i.fieldErrors=
|
|
3052
3053
|
t,i.details={...i.details||{},fieldErrors:t}):r!=null&&(i.details={...i.details||{},errors:r}),i}function Pm(e,t,{phase:r="\
|
|
3053
3054
|
input",context:n="schema definition",statusCode:o=null}={}){if(e==null)return t;let i=d_(e,t,{defaultMode:r==="output"?"\
|
|
3054
3055
|
replace":"patch",context:n}),s=c_(i.errors,e);if(Object.keys(s).length>0)throw O0({fieldErrors:s,statusCode:o});return i.
|
|
3055
|
-
validatedObject??t}var P0="^[1-9][0-9]*$",u_=Zi({type:"string",minLength:1,pattern:P0}),
|
|
3056
|
-
...u_,required:!0,messages:{pattern:"Record id must be a canonical positive integer string."}}}),mode:"patch"});var k0=20,
|
|
3057
|
-
execute:"assistant_action_execute"}),p_=Object.freeze({type:"object",additionalProperties:!0}),
|
|
3056
|
+
validatedObject??t}var P0="^[1-9][0-9]*$",u_=Zi({type:"string",minLength:1,pattern:P0}),X8=Zi({...u_,nullable:!0}),Y8=Zi({schema:oe({recordId:{
|
|
3057
|
+
...u_,required:!0,messages:{pattern:"Record id must be a canonical positive integer string."}}}),mode:"patch"});var k0=20,t0e=32*1024,r0e=48*1024,l_=Object.freeze({search:"assistant_action_search",contract:"assistant_action_contract",
|
|
3058
|
+
execute:"assistant_action_execute"}),p_=Object.freeze({type:"object",additionalProperties:!0}),e9=Object.freeze({type:"o\
|
|
3058
3059
|
bject",additionalProperties:!1,properties:{query:{type:"string",maxLength:200,description:"Optional literal words or act\
|
|
3059
3060
|
ion-id fragments; every word must match. Use short resource or operation terms such as list. Omit query to browse all av\
|
|
3060
3061
|
ailable actions."},cursor:{type:"string",maxLength:1e3,description:"Opaque cursor returned by the previous search page."},
|
|
3061
|
-
limit:{type:"integer",minimum:1,maximum:k0,description:"Maximum compact matches to return."}}}),
|
|
3062
|
+
limit:{type:"integer",minimum:1,maximum:k0,description:"Maximum compact matches to return."}}}),t9=Object.freeze({type:"\
|
|
3062
3063
|
object",additionalProperties:!1,required:["items","nextCursor","total"],properties:{items:{type:"array",maxItems:k0,items:{
|
|
3063
3064
|
type:"object",additionalProperties:!1,required:["actionId","version","kind","description"],properties:{actionId:{type:"s\
|
|
3064
3065
|
tring"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"string"}}}},nextCursor:{anyOf:[{type:"\
|
|
3065
|
-
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),
|
|
3066
|
-
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),
|
|
3066
|
+
string"},{type:"null"}]},total:{type:"integer",minimum:0}}}),r9=Object.freeze({type:"object",additionalProperties:!1,required:[
|
|
3067
|
+
"actionId"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1}}}),n9=Object.
|
|
3067
3068
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","kind","description","inputSchema","outputS\
|
|
3068
3069
|
chema"],properties:{actionId:{type:"string"},version:{type:"integer",minimum:1},kind:{type:"string"},description:{type:"\
|
|
3069
|
-
string"},inputSchema:p_,outputSchema:p_}}),
|
|
3070
|
-
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:p_}}),
|
|
3070
|
+
string"},inputSchema:p_,outputSchema:p_}}),o9=Object.freeze({type:"object",additionalProperties:!1,required:["actionId",
|
|
3071
|
+
"input"],properties:{actionId:{type:"string",minLength:1,maxLength:300},version:{type:"integer",minimum:1},input:p_}}),i9=Object.
|
|
3071
3072
|
freeze({type:"object",additionalProperties:!1,required:["actionId","version","result"],properties:{actionId:{type:"strin\
|
|
3072
3073
|
g"},version:{type:"integer",minimum:1},result:{}}}),N0=Object.freeze([Object.freeze({name:l_.search,description:"Discove\
|
|
3073
3074
|
r application actions available to the current user and surface, including list, search, and query operations for multip\
|
|
3074
3075
|
le records. Search before claiming a capability is unavailable. If terminology does not match, use broader terms or omit\
|
|
3075
|
-
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:
|
|
3076
|
-
outputSchema:
|
|
3077
|
-
e action before executing it.",parameters:
|
|
3078
|
-
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:
|
|
3076
|
+
query to browse. Returns compact paged matches without schemas; follow nextCursor when more discovery is needed.",parameters:e9,
|
|
3077
|
+
outputSchema:t9}),Object.freeze({name:l_.contract,description:"Load the exact input and output contract for one availabl\
|
|
3078
|
+
e action before executing it.",parameters:r9,outputSchema:n9}),Object.freeze({name:l_.execute,description:"Execute one a\
|
|
3079
|
+
vailable action after loading its exact contract in this turn. The action result is returned in result.",parameters:o9,outputSchema:i9})]);var km=fe;function Nm(e={}){let t=km(e.prompt||e.message);return e.outputSchema?[t,"","Return only one JSON value matching this JS\
|
|
3079
3080
|
ON Schema. Do not wrap it in Markdown code fences:",JSON.stringify(e.outputSchema)].join(`
|
|
3080
3081
|
`):t}function Bu(e=""){let t=String(e??""),r=/^```(?:json)?[\t ]*\r?\n([\s\S]*?)\r?\n```$/iu.exec(t.trim());return r?r[1].
|
|
3081
3082
|
trim():t}function j0(e={}){return km(e?.error?.message||e?.error?.data?.message||e?.error?.name||e?.error)}function f_(e=null){return(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]).map((r,n)=>({index:n,message:r})).sort((r,n)=>(Number(
|
|
3082
3083
|
r.message?.time?.created)||0)-(Number(n.message?.time?.created)||0)||r.index-n.index).map(({message:r})=>r)}function qu(e=null,t=""){let r=f_(e),n=r.findIndex(s=>km(s?.id)===km(t));if(n<0)return[];let o=[],i=!1;for(let s of r.slice(
|
|
3083
3084
|
n+1)){if(s?.type==="user")if(s.content?.some(a=>a.type==="compaction"&&a.auto===!0))i=!0;else{if(!i)break;i=!1}o.push(s)}
|
|
3084
3085
|
return o}function jm(e=null,{readError:t=j0}={}){let r=[...f_(e)].reverse().find(n=>n?.type==="assistant");return{error:t(r),message:r,
|
|
3085
|
-
text:r?.summary?"":Du(r)}}var
|
|
3086
|
-
href;var
|
|
3087
|
-
type:"string",maxLength:Vo.toolName,required:!1},arguments:{type:"string",maxLength:Vo.arguments,required:!1}}),
|
|
3086
|
+
text:r?.summary?"":Du(r)}}var N0e=new URL("./../node_modules/@jskit-ai/assistant-core/src/server/conversation/openCodeProcess.js",import.meta.url).
|
|
3087
|
+
href;var D0e=256*1024;var U0e=2*1024*1024;var z0e=N0.map(({name:e,description:t,parameters:r})=>({type:"function",function:{name:e,description:t,parameters:r}}));var Vo=Object.freeze({text:16e3,toolName:256,arguments:256*1024,toolProgress:280});var I9=oe({kind:{type:"string",enum:["reply","tool"],required:!0},text:{type:"string",maxLength:Vo.text,required:!1},toolName:{
|
|
3088
|
+
type:"string",maxLength:Vo.toolName,required:!1},arguments:{type:"string",maxLength:Vo.arguments,required:!1}}),Tje={type:"\
|
|
3088
3089
|
object",additionalProperties:!1,required:["kind","text","toolName","arguments"],properties:{kind:{type:"string",enum:["r\
|
|
3089
3090
|
eply","tool"]},text:{type:"string",maxLength:Vo.text,description:"The final reply, or a brief progress sentence for the \
|
|
3090
3091
|
first tool request; empty for subsequent tool requests."},toolName:{type:"string",maxLength:Vo.toolName},arguments:{type:"\
|
|
3091
|
-
string",maxLength:Vo.arguments}}};function Ja(e){let t=JSON.parse(e),r=
|
|
3092
|
+
string",maxLength:Vo.arguments}}};function Ja(e){let t=JSON.parse(e),r=I9.create(t);if(Object.keys(r.errors).length||!t||
|
|
3092
3093
|
Array.isArray(t))throw new Error("Invalid assistant response envelope.");let n=r.validatedObject;if(n.kind==="reply"&&(!n.
|
|
3093
3094
|
text||n.toolName||n.arguments))throw new Error("A reply needs text and no tool call.");if(n.kind==="tool"&&(!n.toolName||
|
|
3094
3095
|
!n.arguments||(n.text||"").length>Vo.toolProgress))throw new Error(`A tool call needs its name and JSON arguments, with \
|
|
3095
|
-
at most ${Vo.toolProgress} characters of progress text.`);return n}var
|
|
3096
|
+
at most ${Vo.toolProgress} characters of progress text.`);return n}var hMe=Object.freeze({codex:Object.freeze({requiresWriterExclusion:!1}),claude:Object.freeze({requiresWriterExclusion:!0,
|
|
3096
3097
|
allowsManagedServer:!1,matchesProcess:({executable:e,commandLine:t})=>/(?:^|[\0/])claude(?:\0|$)|@anthropic-ai\/claude-code\//u.
|
|
3097
3098
|
test(`${e||""}\0${t}`)}),opencode:Object.freeze({requiresWriterExclusion:!0,allowsManagedServer:!0,matchesProcess:({executable:e,
|
|
3098
|
-
commandLine:t})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${e||""}\0${t}`)})});import{AsyncLocalStorage as Ij}from"node:async_hooks";import{createHash as
|
|
3099
|
+
commandLine:t})=>/(?:^|[\0/])opencode(?:\0|$)/u.test(`${e||""}\0${t}`)})});import{AsyncLocalStorage as Ij}from"node:async_hooks";import{createHash as uX,randomUUID as es}from"node:crypto";import{
|
|
3099
3100
|
isDeepStrictEqual as X_}from"node:util";function L0(e){if(e?.role!=="assistant"||typeof e.text!="string")return null;let t=e.text.replace(/\r\n/gu,`
|
|
3100
3101
|
`).split(`
|
|
3101
3102
|
`),r=null;for(let n=0;n<t.length;n+=1){let o=t[n];if(r){let s=/^ {0,3}(`{3,}|~{3,})\s*$/u.exec(o);if(!s||s[1][0]!==r.character||
|
|
@@ -3109,45 +3110,45 @@ request:i[1]==="```"&&i[2]==="vibe64-integration"})}return null}var m_=/^[A-Za-z
|
|
|
3109
3110
|
n renewal id: ${t||"(empty)"}`,"vibe64_invalid_session_renewal_id");return t}async function h_(e,t=[],{allowedRoots:r=[],cwd:n="",gitSafeDirectories:o,maxBuffer:i,runtimes:s,timeout:a}={}){let c=await Ui(
|
|
3110
3111
|
{actor:"daemon",allowedRoots:[n,...r].filter(Boolean),args:t,command:e,cwd:n,envPolicy:"session",gitSafeDirectories:o,maxBuffer:i,
|
|
3111
3112
|
mode:"capture",purpose:"source",...s?{runtimes:s}:{},timeout:a});return{ok:c.ok===!0,output:N(`${c.stdout||""}
|
|
3112
|
-
${c.stderr||""}`)||N(c.output||c.error),stdout:String(c.stdout||""),stderr:String(c.stderr||"")}}import{randomUUID as
|
|
3113
|
-
import g_ from"node:path";import
|
|
3114
|
-
e)}.${
|
|
3115
|
-
return await
|
|
3113
|
+
${c.stderr||""}`)||N(c.output||c.error),stdout:String(c.stdout||""),stderr:String(c.stderr||"")}}import{randomUUID as C9}from"node:crypto";import{mkdir as R9,rename as O9,rm as P9,stat as k9,writeFile as N9}from"node:fs/promises";
|
|
3114
|
+
import g_ from"node:path";import j9 from"node:process";async function ct(e,t){let r=g_.dirname(e),n=g_.join(r,`.${g_.basename(
|
|
3115
|
+
e)}.${j9.pid}.${C9()}.tmp`);await R9(r,{recursive:!0});try{await N9(n,String(t),"utf8");let o=w_(await k9(n,{bigint:!0}));
|
|
3116
|
+
return await O9(n,e),o}catch(o){throw await P9(n,{force:!0}),o}}async function cr(e,t){await ct(e,`${JSON.stringify(t,null,
|
|
3116
3117
|
2)}
|
|
3117
|
-
`)}function w_(e){return`${e.dev}:${e.ino}:${e.size}:${e.mtimeNs}`}import{randomUUID as b_}from"node:crypto";import{mkdir as z0,readFile as
|
|
3118
|
-
import $m from"node:path";import Ho from"node:process";var
|
|
3119
|
-
warn:40,error:50,fatal:60,silent:1/0});var
|
|
3118
|
+
`)}function w_(e){return`${e.dev}:${e.ino}:${e.size}:${e.mtimeNs}`}import{randomUUID as b_}from"node:crypto";import{mkdir as z0,readFile as F9,rename as B0,rm as I_,stat as B9}from"node:fs/promises";
|
|
3119
|
+
import $m from"node:path";import Ho from"node:process";var XMe=Object.freeze(["fatal","error","warn","info","debug","trace","silent"]),YMe=Object.freeze({trace:10,debug:20,info:30,
|
|
3120
|
+
warn:40,error:50,fatal:60,silent:1/0});var rLe=Object.freeze(["req.headers.authorization","req.headers.cookie","req.headers['set-cookie']","res.headers['set-co\
|
|
3120
3121
|
okie']","*.authorization","*.cookie","*.credential","*.credentials","*.databaseUrl","*.database_url","*.dsn","*.password",
|
|
3121
3122
|
"*.secret","*.token","*.apiToken","*.api_token","*.apiKey","*.api_key","*.accessToken","*.access_token","*.refreshToken",
|
|
3122
|
-
"*.refresh_token"]),Vu="[redacted]",
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
"")||t}function U0(e=""){return
|
|
3127
|
-
|
|
3123
|
+
"*.refresh_token"]),Vu="[redacted]",M9=/(?:authorization|password|passphrase|token|secret|credential|api[_-]?key|api[_-]?token|access[_-]?token|refresh[_-]?token|database[_-]?url|dsn)/iu,
|
|
3124
|
+
L9=/\b((?:DATABASE[_-]?URL|DSN)|(?:[A-Za-z_][A-Za-z0-9_-]*?)?(?:PASSWORD|PASS|PASSPHRASE|TOKEN|SECRET|CREDENTIAL|API[_-]?KEY|API[_-]?TOKEN|ACCESS[_-]?TOKEN|REFRESH[_-]?TOKEN|DSN)[A-Za-z0-9_-]*)\b(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\s,;]+)/giu,
|
|
3125
|
+
$9=/\b(authorization|proxy-authorization)\b(\s*[:=]\s*)(?:"[^"]*"|'[^']*'|(?:Bearer|Basic)\s+[^\s,;]+|[^\s,;]+)/giu,D9=/\b(Bearer|Basic)\s+[A-Za-z0-9._~+/=-]+/giu,
|
|
3126
|
+
U9=/\b([a-z][a-z0-9+.-]*:\/\/)([^/@\s:]+):([^/@\s]+)@/giu;function $0(e="",t="vibe64.operational_event"){return String(e||"").trim().replace(/[^a-zA-Z0-9_.:-]+/gu,"_").replace(/^_+|_+$/gu,
|
|
3127
|
+
"")||t}function U0(e=""){return M9.test(String(e||""))}function D0(e=""){return String(e||"").replace($9,`$1$2${Vu}`).replace(
|
|
3128
|
+
D9,`$1 ${Vu}`).replace(L9,`$1$2${Vu}`).replace(U9,`$1${Vu}@`)}function v_(e,{field:t="",seen:r=new WeakSet}={}){return U0(t)?Vu:typeof e=="string"?D0(e):!e||typeof e!="object"?e:e instanceof
|
|
3128
3129
|
Error?{code:String(e.code||""),message:D0(e.message),name:String(e.name||"Error")}:r.has(e)?"[circular]":(r.add(e),Array.
|
|
3129
|
-
isArray(e)?e.map(n=>v_(n,{seen:r})):Object.fromEntries(Object.entries(e).map(([n,o])=>[n,v_(o,{field:n,seen:r})])))}function
|
|
3130
|
+
isArray(e)?e.map(n=>v_(n,{seen:r})):Object.fromEntries(Object.entries(e).map(([n,o])=>[n,v_(o,{field:n,seen:r})])))}function z9(e={}){
|
|
3130
3131
|
let t=e&&typeof e=="object"&&!Array.isArray(e)?e:{};return v_({...t,component:$0(t.component,"vibe64"),event:$0(t.event,
|
|
3131
|
-
"vibe64.operational_event")})}function y_(e,t="info",r={},n=""){let o=e?.[t];return typeof o!="function"?!1:(o.call(e,
|
|
3132
|
-
r),n),!0)}var
|
|
3133
|
-
t=>{setTimeout(t,e)})}function
|
|
3134
|
-
!0}catch(r){return r?.code==="EPERM"}}var V0=/^[A-Z]$/u,F0=250,Mm=new Map,Lm=new Map;function
|
|
3135
|
-
e);if(!t)return Promise.resolve({platform:
|
|
3132
|
+
"vibe64.operational_event")})}function y_(e,t="info",r={},n=""){let o=e?.[t];return typeof o!="function"?!1:(o.call(e,z9(
|
|
3133
|
+
r),n),!0)}var q9=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/u,V9=2e3,q0=1,H9=20,G9="pid-only",__=new Map;function W9(e=0){return new Promise(
|
|
3134
|
+
t=>{setTimeout(t,e)})}function K9(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<=0)return!1;try{return Ho.kill(t,0),
|
|
3135
|
+
!0}catch(r){return r?.code==="EPERM"}}var V0=/^[A-Z]$/u,F0=250,Mm=new Map,Lm=new Map;function J9(e=Ho.platform){let t=Au(
|
|
3136
|
+
e);if(!t)return Promise.resolve({platform:G9,startTimeTicks:""});if(!Lm.has(t)){let r=Mf(Ho.pid,{platform:e}).then(n=>{if(n.
|
|
3136
3137
|
status!=="exact"||!V0.test(n.state))throw B("Vibe64 could not establish the session-lock owner process identity.","vibe6\
|
|
3137
3138
|
4_session_lock_process_identity_unavailable");return{platform:t,startTimeTicks:n.startTimeTicks}});r.catch(()=>Lm.delete(
|
|
3138
|
-
t)),Lm.set(t,r)}return Lm.get(t)}async function
|
|
3139
|
+
t)),Lm.set(t,r)}return Lm.get(t)}async function X9(e,t={}){let r=Au()==="darwin-ps",n=`${e}:${N(t.startTimeTicks)}`,o=r?
|
|
3139
3140
|
Mm.get(n):null;if(o&&Date.now()-o.atMs<F0)return o.observed;let i=await Mf(e);if(r){for(let[s,a]of Mm)Date.now()-a.atMs>=
|
|
3140
3141
|
F0&&Mm.delete(s);i.status==="exact"&&Mm.set(n,{atMs:Date.now(),observed:i})}return i}async function H0(e={}){let t=Number(
|
|
3141
|
-
e?.pid);if(!Number.isSafeInteger(t)||t<=0)return"ambiguous";let r=Ne(e?.processIdentity)?e.processIdentity:{},n=await
|
|
3142
|
+
e?.pid);if(!Number.isSafeInteger(t)||t<=0)return"ambiguous";let r=Ne(e?.processIdentity)?e.processIdentity:{},n=await X9(
|
|
3142
3143
|
t,r);return n.status==="absent"?"absent":Number(e?.schemaVersion)!==q0||N(r.platform)!==Au()||!/^\d+$/u.test(N(r.startTimeTicks))||
|
|
3143
|
-
n.status!=="exact"||!V0.test(n.state)?
|
|
3144
|
-
function Xa(e,t=""){let r=N(t);if(!
|
|
3144
|
+
n.status!=="exact"||!V0.test(n.state)?K9(t)?"ambiguous":"absent":n.startTimeTicks===N(r.startTimeTicks)?"exact":"reused"}
|
|
3145
|
+
function Xa(e,t=""){let r=N(t);if(!q9.test(r))throw B(`Invalid vibe64 session lock name: ${r||"(empty)"}`,"vibe64_sessio\
|
|
3145
3146
|
n_lock_name_invalid");return $m.join(e.sessionsRoot,".locks",e.sessionId,`${r}.lock`)}async function S_(e=""){try{return JSON.
|
|
3146
|
-
parse(await
|
|
3147
|
-
"absent","reused"].includes(await H0(t));try{let r=await
|
|
3147
|
+
parse(await F9($m.join(e,"owner.json"),"utf8"))}catch{return null}}async function A_(e=""){let t=await S_(e);if(t?.pid)return[
|
|
3148
|
+
"absent","reused"].includes(await H0(t));try{let r=await B9(e);return Date.now()-r.mtimeMs>=V9}catch(r){return Rt(r)}}async function Y9(e=""){
|
|
3148
3149
|
if(!await A_(e))return!1;let t=`${e}.abandoned.${Ho.pid}.${b_()}`;try{await B0(e,t)}catch(r){return!!Rt(r)}return await I_(
|
|
3149
3150
|
t,{force:!0,recursive:!0}),!0}async function G0(e,t="",{logger:r=null,onRejected:n=null,operation:o="",processPlatform:i=Ho.
|
|
3150
|
-
platform,waitMs:s=0}={}){let a=Xa(e,t),c=$m.dirname(a),d=await
|
|
3151
|
+
platform,waitMs:s=0}={}){let a=Xa(e,t),c=$m.dirname(a),d=await J9(i),u=b_(),l=b_(),p=Date.now(),f=!1;function y(v,w={}){
|
|
3151
3152
|
if(o)try{y_(r,["contended","rejected"].includes(v)?"warn":"info",{component:"vibe64.session_lock",event:`vibe64.session_\
|
|
3152
3153
|
lock.${v}`,projectRoot:e.projectContextRoot,sessionId:e.sessionId,lockName:t,operation:o,attemptId:l,pid:Ho.pid,waitMs:s,
|
|
3153
3154
|
...w},`Session lock ${v}.`)}catch{}}let h=__.get(a)||new Set;__.set(a,h),h.add(l);try{for(await z0(c,{recursive:!0});;){
|
|
@@ -3155,57 +3156,57 @@ if(h.values().next().value===l)try{await z0(a,{mode:448});let m=Date.now();try{a
|
|
|
3155
3156
|
m).toISOString(),operation:o||t,attemptId:l,pid:Ho.pid,processIdentity:d,schemaVersion:q0,token:u})}catch(_){throw await I_(
|
|
3156
3157
|
a,{force:!0,recursive:!0}),_}return y("acquired",{waitedMs:Date.now()-p}),async()=>{let _=await S_(a);if(N(_?.token)!==u)
|
|
3157
3158
|
return;let I=`${a}.released.${Ho.pid}.${u}`;try{await B0(a,I)}catch(x){if(Rt(x))return;throw x}await I_(I,{force:!0,recursive:!0}),
|
|
3158
|
-
y("released",{heldMs:Date.now()-m})}}catch(m){if(m?.code!=="EEXIST")throw m;if(await
|
|
3159
|
+
y("released",{heldMs:Date.now()-m})}}catch(m){if(m?.code!=="EEXIST")throw m;if(await Y9(a))continue}let v=Date.now()-p,w=v>=
|
|
3159
3160
|
s;if(w||o&&!f){let m=await S_(a);w&&n?.(N(m?.operation));let _=Date.parse(m?.createdAt);y(w?"rejected":"contended",{waitedMs:v,
|
|
3160
3161
|
owner:m?{operation:N(m.operation)||"unknown",attemptId:N(m.attemptId),pid:m.pid,createdAt:m.createdAt,heldMs:Number.isFinite(
|
|
3161
|
-
_)?Math.max(0,Date.now()-_):null,processStatus:await H0(m)}:null}),f=!0}if(w)return null;await
|
|
3162
|
+
_)?Math.max(0,Date.now()-_):null,processStatus:await H0(m)}:null}),f=!0}if(w)return null;await W9(Math.min(H9,Math.max(1,
|
|
3162
3163
|
s-(Date.now()-p))))}}finally{h.delete(l),h.size===0&&__.delete(a)}}var Vr=Object.freeze({CLAUDE:"claude",CODEX:"codex",OPENCODE:"opencode"}),K0=Object.freeze({CLAUDE_STREAM_JSON:"claude_s\
|
|
3163
|
-
tream_json",CODEX_APP_SERVER:"codex_app_server",OPENCODE_SERVER:"opencode_server"}),W0="vibe64.assistant-selection.v1";var E_="assistant_selection",
|
|
3164
|
+
tream_json",CODEX_APP_SERVER:"codex_app_server",OPENCODE_SERVER:"opencode_server"}),W0="vibe64.assistant-selection.v1";var E_="assistant_selection",Z9=/^sha256:[a-f0-9]{64}$/u,Dm=new Set(Object.values(Vr)),Qi=Object.freeze({CATALOG_STALE:"\
|
|
3164
3165
|
vibe64_assistant_catalog_stale",CONNECTION_REQUIRED:"vibe64_assistant_connection_required",ENGINE_IMMUTABLE:"vibe64_assi\
|
|
3165
3166
|
stant_engine_immutable",INVALID:"vibe64_assistant_selection_invalid",TURN_ACTIVE:"vibe64_assistant_selection_turn_active",
|
|
3166
3167
|
UNAVAILABLE:"vibe64_assistant_selection_unavailable"});function J0(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:
|
|
3167
3168
|
{}}function Um(e=""){return String(e??"").trim()}function Ya(e,t,r={}){let n=new Error(t);return n.code=e,n.details=Object.
|
|
3168
|
-
freeze({...r}),n.statusCode=409,n}function
|
|
3169
|
-
127})}function Hu(e,t,{allowEmpty:r=!1,maxLength:n=512}={}){let o=Um(e);if(!o&&!r||o.length>n||
|
|
3170
|
-
`Assistant ${t} is invalid.`,{field:t});return o}function
|
|
3169
|
+
freeze({...r}),n.statusCode=409,n}function Q9(e=""){return Array.from(e).some(t=>{let r=t.codePointAt(0);return r<=31||r===
|
|
3170
|
+
127})}function Hu(e,t,{allowEmpty:r=!1,maxLength:n=512}={}){let o=Um(e);if(!o&&!r||o.length>n||Q9(o))throw Ya(Qi.INVALID,
|
|
3171
|
+
`Assistant ${t} is invalid.`,{field:t});return o}function eX(e,t="catalogRevision"){let r=Um(e);if(!Z9.test(r))throw Ya(
|
|
3171
3172
|
Qi.INVALID,"Assistant catalog revision is invalid.",{field:t});return r}function Hr(e={}){let t=J0(e),r=Hu(t.engineId,"e\
|
|
3172
3173
|
ngineId",{maxLength:64});if(!Dm.has(r))throw Ya(Qi.INVALID,`Unknown assistant engine: ${r}.`,{engineId:r,field:"engineId"});
|
|
3173
3174
|
let n=Um(t.schema)||W0;if(n!==W0)throw Ya(Qi.INVALID,"Assistant selection schema is unsupported.",{field:"schema",schema:n});
|
|
3174
|
-
return Object.freeze({agentId:Hu(t.agentId,"agentId",{maxLength:256}),catalogRevision:
|
|
3175
|
+
return Object.freeze({agentId:Hu(t.agentId,"agentId",{maxLength:256}),catalogRevision:eX(t.catalogRevision),engineId:r,modelId:Hu(
|
|
3175
3176
|
t.modelId,"modelId"),modelProviderId:Hu(t.modelProviderId,"modelProviderId",{maxLength:256}),schema:n,variantId:Hu(t.variantId,
|
|
3176
3177
|
"variantId",{allowEmpty:!0,maxLength:256})})}function X0(e={},{required:t=!0}={}){let r=Um(J0(e)[E_]);if(!r&&t!==!0)return null;if(!r)throw Ya(Qi.INVALID,"This sessi\
|
|
3177
3178
|
on has no durable assistant selection.",{field:E_});try{return Hr(JSON.parse(r))}catch(n){throw n?.code===Qi.INVALID?n:Ya(
|
|
3178
|
-
Qi.INVALID,"This session's durable assistant selection is unreadable.",{field:E_})}}var
|
|
3179
|
-
e.engineId}import{copyFile as rj,cp as
|
|
3180
|
-
rm as Fe,writeFile as
|
|
3181
|
-
return Object.freeze(e)}import Gr from"node:path";var
|
|
3179
|
+
Qi.INVALID,"This session's durable assistant selection is unreadable.",{field:E_})}}var fLe=Object.freeze(["engineId","modelProviderId","modelId","agentId","variantId"]);function Y0(e={}){return e.engineId==="codex"&&e.modelProviderId&&e.modelProviderId!=="openai"?`codex/${e.modelProviderId}`:
|
|
3180
|
+
e.engineId}import{copyFile as rj,cp as lX,lstat as dr,mkdir as Yt,open as Ku,readdir as B_,readFile as Gm,realpath as nj,rename as co,
|
|
3181
|
+
rm as Fe,writeFile as pX}from"node:fs/promises";import{constants as N_}from"node:fs";import V from"node:path";import Ju from"node:process";function Gu(e,t=new WeakSet){if(!e||typeof e!="object"||t.has(e))return e;t.add(e);for(let r of Object.values(e))Gu(r,t);
|
|
3182
|
+
return Object.freeze(e)}import Gr from"node:path";var tX="managed_session_source";function zm(e=""){let t=N(e);return t?Gr.resolve(t):""}function Z0(e="",t=""){let r=zm(e),
|
|
3182
3183
|
n=N(t);return r&&n?Gr.join(r,"sessions","active",n,"source"):""}function x_(e={},t=""){if(N(e?.metadata?.source_path_authority)!==
|
|
3183
|
-
|
|
3184
|
+
tX||N(e?.metadata?.source_kind)!=="session_clone")return!1;let r=zm(t),n=N(e.sessionId||e.id);if(!r||!n)return!1;let o=zm(
|
|
3184
3185
|
e.sessionRoot);return o&&Js(o,r)?!1:Gr.basename(r)==="source"&&Gr.basename(Gr.dirname(r))===n&&Gr.basename(Gr.dirname(Gr.
|
|
3185
|
-
dirname(r)))==="active"&&Gr.basename(Gr.dirname(Gr.dirname(Gr.dirname(r))))==="sessions"}function
|
|
3186
|
+
dirname(r)))==="active"&&Gr.basename(Gr.dirname(Gr.dirname(Gr.dirname(r))))==="sessions"}function rX(e={}){if(N(e?.metadata?.
|
|
3186
3187
|
source_removed).toLowerCase()==="yes")return"";let t=zm(e.metadata?.source_path||e.metadata?.source||e.source||e.sourcePath);
|
|
3187
|
-
return t&&x_(e,t)?t:""}function T_(e={}){return
|
|
3188
|
-
image/bmp",gif:"image/gif",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",webp:"image/webp"});function
|
|
3188
|
+
return t&&x_(e,t)?t:""}function T_(e={}){return rX(e)}var nX=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu,yLe=Object.freeze({avif:"image/avif",bmp:"\
|
|
3189
|
+
image/bmp",gif:"image/gif",jpeg:"image/jpeg",jpg:"image/jpeg",png:"image/png",webp:"image/webp"});function oX(e=""){let t=Array.from(String(e??""),r=>{let n=r.codePointAt(0);return n<=31||n===127?" ":r}).join("").trim();
|
|
3189
3190
|
return Array.from(t).slice(0,160).join("")}function C_(e=[]){return(Array.isArray(e)?e:[]).slice(0,10).map(t=>{if(!t||typeof t!=
|
|
3190
|
-
"object"||Array.isArray(t)||typeof t.fileName!="string")return null;let r=
|
|
3191
|
+
"object"||Array.isArray(t)||typeof t.fileName!="string")return null;let r=oX(t.fileName);return r?{...nX.test(String(t.attachmentId||
|
|
3191
3192
|
""))?{attachmentId:t.attachmentId}:{},.../^\[(?:Image|File) #[1-9][0-9]{0,3}\]$/u.test(t.reference||"")?{reference:t.reference}:
|
|
3192
|
-
{},fileName:r,...Number.isSafeInteger(t.size)&&t.size>=0?{size:t.size}:{}}:null}).filter(Boolean)}import{randomUUID as
|
|
3193
|
+
{},fileName:r,...Number.isSafeInteger(t.size)&&t.size>=0?{size:t.size}:{}}:null}).filter(Boolean)}import{randomUUID as iX}from"node:crypto";import{lstat as sX,mkdir as aX,readlink as O_,rename as cX,rm as R_,symlink as dX}from"node:fs/promises";
|
|
3193
3194
|
import Wr from"node:path";var Q0="selected";function ej(e=""){let t=N(e);if(!t)throw B("Current Vibe64 session alias requires sessionsRoot.","vibe\
|
|
3194
3195
|
64_sessions_root_required");return Wr.join(Wr.resolve(t),Q0)}function P_(e=""){let t=N(e);if(!t)throw B("Current Vibe64 \
|
|
3195
3196
|
session alias requires aliasPath.","vibe64_current_session_alias_path_required");return Wr.resolve(t)}async function k_(e){
|
|
3196
|
-
try{return await
|
|
3197
|
+
try{return await sX(e)}catch(t){if(Rt(t))return null;throw t}}function tj(e=""){return Wr.join("active",e)}async function Wu({
|
|
3197
3198
|
aliasPath:e="",sessionId:t=""}={}){let r=P_(e),n=N(t),o=await k_(r);if(o&&!o.isSymbolicLink())throw B(`Cannot manage cur\
|
|
3198
3199
|
rent Vibe64 session alias because ${r} is not a symbolic link.`,"vibe64_current_session_alias_conflict");if(!n){o&&await R_(
|
|
3199
|
-
r,{force:!0});return}let i=tj(n);if(o&&await O_(r)===i)return;let s=Wr.dirname(r),a=Wr.join(s,`.${Q0}-${
|
|
3200
|
-
s,{recursive:!0}),await
|
|
3200
|
+
r,{force:!0});return}let i=tj(n);if(o&&await O_(r)===i)return;let s=Wr.dirname(r),a=Wr.join(s,`.${Q0}-${iX()}`);try{await aX(
|
|
3201
|
+
s,{recursive:!0}),await dX(i,a,"dir"),await cX(a,r)}finally{await R_(a,{force:!0})}}async function Fm({aliasPath:e="",sessionId:t=""}={}){
|
|
3201
3202
|
let r=P_(e);if(!(await k_(r))?.isSymbolicLink())return;let o=tj(N(t));await O_(r)===o&&await R_(r,{force:!0})}async function Za({
|
|
3202
3203
|
aliasPath:e=""}={}){let t=P_(e),r=await k_(t);if(!r)return"";if(!r.isSymbolicLink())throw B(`Cannot read current Vibe64 \
|
|
3203
3204
|
session because ${t} is not a symbolic link.`,"vibe64_current_session_alias_conflict");let n=await O_(t),o=Wr.normalize(
|
|
3204
3205
|
n);if(Wr.isAbsolute(n)||Wr.dirname(o)!=="active"||Wr.basename(o)!==N(Wr.basename(o)))throw B(`Cannot read invalid curren\
|
|
3205
|
-
t Vibe64 session alias target: ${n||"(empty)"}.`,"vibe64_current_session_alias_invalid");return Wr.basename(o)}var
|
|
3206
|
-
renewal_activating",RENEWAL_PENDING:"renewal_pending",RENEWAL_QUIESCED:"renewal_quiesced"}),
|
|
3206
|
+
t Vibe64 session alias target: ${n||"(empty)"}.`,"vibe64_current_session_alias_invalid");return Wr.basename(o)}var fX=2,oj=2,ij="label",er="learning_session",Sj=120,ce=Gu({ACTIVE:"active",ARCHIVED:"archived",BLOCKED:"blocked",RENEWAL_ACTIVATING:"\
|
|
3207
|
+
renewal_activating",RENEWAL_PENDING:"renewal_pending",RENEWAL_QUIESCED:"renewal_quiesced"}),mX=new Set(Object.values(ce)),
|
|
3207
3208
|
Xu=new Set([ce.ACTIVE,ce.BLOCKED,ce.RENEWAL_QUIESCED]),Yu=new Set([ce.RENEWAL_ACTIVATING,ce.RENEWAL_PENDING]),Bm=new Set(
|
|
3208
|
-
[...Yu,ce.RENEWAL_QUIESCED]),sj="vibe64.session_archive",Aj="renewal_selected_before_archive",j_="none",
|
|
3209
|
+
[...Yu,ce.RENEWAL_QUIESCED]),sj="vibe64.session_archive",Aj="renewal_selected_before_archive",j_="none",hX=Object.freeze(
|
|
3209
3210
|
[er,"repository_branch","github_pull_request","base_branch","base_commit","canonical_commit","branch","renewal_acknowled\
|
|
3210
3211
|
ged_at","renewal_activated_at","renewal_actor_display_name","renewal_actor_id","renewal_archived_at","renewal_confirmed_\
|
|
3211
3212
|
at","renewal_finalized_at","renewal_handover_delivered_at","renewal_id","renewal_quiesced_at","renewal_quiesced_id","ren\
|
|
@@ -3215,17 +3216,17 @@ newed_at","renewed_from","renewed_to","source_default_branch","source_kind","sou
|
|
|
3215
3216
|
dle_artifact","source_recovery_default_branch","source_recovery_dirty","source_recovery_head","source_recovery_kind","so\
|
|
3216
3217
|
urce_recovery_patch_artifact","source_recovery_remote_url","source_recovery_saved","source_recovery_saved_at","source_re\
|
|
3217
3218
|
covery_session_name","source_recovery_source_path","source_recovery_untracked_artifact","source_recovery_untracked_count",
|
|
3218
|
-
"source_remote_url","source_removed"]),
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
Wo=/^\d{6}$/u,cj="attachments.json",L_="metadata.json",
|
|
3219
|
+
"source_remote_url","source_removed"]),gX=6e4,wX=50*1024*1024,vX=200,yX=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,191}$/u,_X=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/u,
|
|
3220
|
+
bX=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,191}$/u,Ej=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u,aj=/^([A-Za-z0-9][A-Za-z0-9_-]{0,127})\.json$/u,
|
|
3221
|
+
IX=Gu(["assistant","commentary","system","thinking","user"]),M_=/^(user|assistant|commentary|system|thinking)\.(\d{8}T\d{9}Z)(?:\.([A-Za-z0-9][A-Za-z0-9_-]{0,127}))?\.md$/u,
|
|
3222
|
+
Wo=/^\d{6}$/u,cj="attachments.json",L_="metadata.json",SX=Object.freeze(["base_commit","canonical_commit","repository_mo\
|
|
3222
3223
|
de","source","source_kind","source_path","source_path_authority","source_removed"]),xj=/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/u,
|
|
3223
|
-
|
|
3224
|
+
AX=/^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u,rs=Object.freeze({FAILED:"failed",READY:"ready",RUNNING:"running"}),EX=new Set(Object.
|
|
3224
3225
|
values(rs)),Rn=Object.freeze({ACTIVE:"active",CANCELLED:"cancelled",COMPLETED:"completed",FAILED:"failed",FINALIZING:"fi\
|
|
3225
|
-
nalizing",INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),
|
|
3226
|
-
[Rn.CANCELLED,Rn.COMPLETED,Rn.FAILED,Rn.INTERRUPTED,Rn.TIMED_OUT]),
|
|
3227
|
-
qm=new Map,Vm=mm(),Qa=new Ij,$_=new Ij;function lo(e){let t=N(e);return
|
|
3228
|
-
return
|
|
3226
|
+
nalizing",INTERRUPTED:"interrupted",STARTING:"starting",TIMED_OUT:"timed_out"}),xX=new Set(Object.values(Rn)),TX=new Set(
|
|
3227
|
+
[Rn.CANCELLED,Rn.COMPLETED,Rn.FAILED,Rn.INTERRUPTED,Rn.TIMED_OUT]),CX=new Set([Rn.ACTIVE,Rn.FINALIZING,Rn.STARTING]),dj=6e4,
|
|
3228
|
+
qm=new Map,Vm=mm(),Qa=new Ij,$_=new Ij;function lo(e){let t=N(e);return AX.test(t)}function Tj(e){return yX.test(N(e))}function Cj(e){
|
|
3229
|
+
return bX.test(N(e))}function ts(e){return Object.assign(B(`Unknown vibe64 session: ${e}`,"vibe64_session_not_found"),{statusCode:404})}
|
|
3229
3230
|
function le(e){let t=N(e);if(!lo(t))throw B(`Invalid vibe64 session id: ${t||"(empty)"}`,"vibe64_invalid_session_id");return t}
|
|
3230
3231
|
function Rj(e){let t=N(e);if(!xj.test(t))throw B(`Invalid vibe64 metadata name: ${t||"(empty)"}`,"vibe64_invalid_metadat\
|
|
3231
3232
|
a_name");return t}function q_(e){let t=N(e);if(!Tj(t))throw B(`Invalid vibe64 agent run id: ${t||"(empty)"}`,"vibe64_inv\
|
|
@@ -3242,33 +3243,33 @@ enewal_link_mismatch")}function pj(e={}){let t=Ne(e.metadata)?e.metadata:{},r=e.
|
|
|
3242
3243
|
N(t.renewal_id);return!m_.test(r)||e.status!==ce.RENEWAL_QUIESCED&&N(t.renewal_finalized_at)?!1:[ce.RENEWAL_ACTIVATING,ce.
|
|
3243
3244
|
RENEWAL_PENDING].includes(e.status)?lo(t.renewed_from):e.status===ce.RENEWAL_QUIESCED?!!N(t.renewal_quiesced_at):e.status===
|
|
3244
3245
|
ce.ARCHIVED?lo(t.renewed_to):e.status===ce.ACTIVE&&lo(t.renewed_from)&&!N(t.renewed_to)}function Jm(e){let t=N(e)||Rn.STARTING;
|
|
3245
|
-
if(!
|
|
3246
|
-
has(Jm(e))}function
|
|
3246
|
+
if(!xX.has(t))throw B(`Invalid vibe64 agent run state: ${t}`,"vibe64_invalid_agent_run_state");return t}function RX(e){return CX.
|
|
3247
|
+
has(Jm(e))}function OX(e){return TX.has(Jm(e))}function fj(e){let t=N(e)||rs.RUNNING;if(!EX.has(t))throw B(`Invalid vibe\
|
|
3247
3248
|
64 background task status: ${t}`,"vibe64_invalid_background_task_status");return t}function Jo(e){let t=N(e)||ce.ACTIVE;
|
|
3248
|
-
if(!
|
|
3249
|
+
if(!mX.has(t))throw B(`Invalid vibe64 session status: ${t}`,"vibe64_invalid_session_status");return t}function Wm(e={}){let t=Jo(e.status);if(Yu.has(t))throw B(`Vibe64 session is reserved for an in-progress renewal: ${N(e.
|
|
3249
3250
|
sessionId)||"(unknown)"}`,"vibe64_session_renewal_private");return e}function Hm(e={}){let t=Wm(e);if(t.status===ce.RENEWAL_QUIESCED)
|
|
3250
3251
|
throw B(`Vibe64 session is read-only while its renewal is in progress: ${N(e.sessionId)||"(unknown)"}`,"vibe64_session_r\
|
|
3251
|
-
enewal_quiesced");return t}function
|
|
3252
|
-
throw B(`Invalid vibe64 session list status group: ${t}`,"vibe64_invalid_session_list_status_group")}function
|
|
3253
|
-
(Array.isArray(e)?e:[]).map(t=>N(t)).filter(Boolean).map(Jo))}function
|
|
3252
|
+
enewal_quiesced");return t}function PX(e=""){let t=N(e);if(!t)return"";if(["all","archived","open"].includes(t))return t;
|
|
3253
|
+
throw B(`Invalid vibe64 session list status group: ${t}`,"vibe64_invalid_session_list_status_group")}function kX(e=[]){return new Set(
|
|
3254
|
+
(Array.isArray(e)?e:[]).map(t=>N(t)).filter(Boolean).map(Jo))}function NX(e={}){return{statusGroup:PX(e.statusGroup),statuses:kX(
|
|
3254
3255
|
e.statuses)}}function mj(e,{statusGroup:t="",statuses:r=new Set}={}){let n=N(e)||ce.ACTIVE;return Yu.has(n)||r.size>0&&!r.
|
|
3255
3256
|
has(n)?!1:t==="open"?Xu.has(n):t==="archived"?n===ce.ARCHIVED:Xu.has(n)||n===ce.ARCHIVED}function hj({statusGroup:e="",statuses:t=new Set}={}){
|
|
3256
3257
|
return e!=="open"&&(t.size<1||t.has(ce.ARCHIVED))}async function $t(e){try{return await Gm(e,"utf8")}catch(t){if(Rt(t))return"";
|
|
3257
3258
|
throw t}}function Oj(e){let t=new Map;function r(n,o,i){return t.delete(n),t.set(n,{identity:o,value:i}),t.size>e&&t.delete(
|
|
3258
3259
|
t.keys().next().value),i}return Object.freeze({remember:r,async read(n,o){let i=await Ku(n,"r");try{let s=w_(await i.stat(
|
|
3259
3260
|
{bigint:!0})),a=t.get(n);return a?.identity===s?r(n,s,a.value):r(n,s,o(await i.readFile("utf8")))}finally{await i.close()}}})}
|
|
3260
|
-
var gj=Oj(8),
|
|
3261
|
+
var gj=Oj(8),jX=Oj(256),wj=new WeakMap;function MX(e,t){let r=wj.get(e);if(!r){r=new Set;for(let n of e.turns.values())for(let o of n.
|
|
3261
3262
|
messages)o.messageId&&r.add(o.messageId);wj.set(e,r)}return!!t&&r.has(t)}async function ec(e,t=[],{allowedRoots:r=[],cwd:n="",
|
|
3262
|
-
maxBuffer:o=
|
|
3263
|
-
e);return Number.isSafeInteger(t)&&t>=0?t:0}function Pj(e={}){return{...e,revision:Ko(e.revision)}}function
|
|
3263
|
+
maxBuffer:o=wX,timeout:i=gX}={}){return h_(e,t,{allowedRoots:r,cwd:n||Ju.cwd(),maxBuffer:o,timeout:i})}function Ko(e){let t=Number(
|
|
3264
|
+
e);return Number.isSafeInteger(t)&&t>=0?t:0}function Pj(e={}){return{...e,revision:Ko(e.revision)}}function LX(e,t={},r=""){
|
|
3264
3265
|
if(!Ne(e)||N(e.sessionId)!==r)return e;let n=Pj(t);return{...e,manifest:Ne(e.manifest)?{...e.manifest,revision:n.revision,
|
|
3265
3266
|
updatedAt:N(n.updatedAt)}:e.manifest,revision:n.revision,updatedAt:N(n.updatedAt)}}function Cn(e,t){let n=(qm.get(e)||Promise.
|
|
3266
3267
|
resolve()).catch(()=>null).then(t),o=n.catch(()=>null).finally(()=>{qm.get(e)===o&&qm.delete(e)});return qm.set(e,o),n}async function Ar(e){
|
|
3267
3268
|
try{return await B_(e,{withFileTypes:!0})}catch(t){if(Rt(t))return[];throw t}}function tc(e,t){return e.filter(r=>r.isFile()&&
|
|
3268
3269
|
t(r.name)).map(r=>r.name).sort((r,n)=>r.localeCompare(n))}function U_(e,t){return e.filter(r=>r.isDirectory()&&t(r.name)).
|
|
3269
3270
|
map(r=>r.name).sort((r,n)=>r.localeCompare(n))}function dn(e){let t=e instanceof Date?e:new Date(e);if(Number.isNaN(t.getTime()))
|
|
3270
|
-
throw B("Invalid vibe64 clock value.","vibe64_invalid_clock");return t}function
|
|
3271
|
-
/\.\d{3}Z$/u,"").replace("T","_").replaceAll(":","-")}function
|
|
3271
|
+
throw B("Invalid vibe64 clock value.","vibe64_invalid_clock");return t}function $X(e){return dn(e).toISOString().replace(
|
|
3272
|
+
/\.\d{3}Z$/u,"").replace("T","_").replaceAll(":","-")}function DX(e=""){let r=N(e).match(/^(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(\d{3})Z$/u);
|
|
3272
3273
|
return r?`${r[1]}-${r[2]}-${r[3]}T${r[4]}:${r[5]}:${r[6]}.${r[7]}Z`:""}function kj({activeSessionsRoot:e="",closingSessionsRoot:t="",
|
|
3273
3274
|
archivedSessionsRoot:r="",currentSessionAliasPath:n="",projectContextRoot:o="",sessionId:i="",sessionRoot:s="",sessionsRoot:a="",
|
|
3274
3275
|
stateRoot:c=""}={}){return{activeSessionsRoot:e,agentRunsRoot:s?V.join(s,"agent-runs"):"",artifactsRoot:s?V.join(s,"arti\
|
|
@@ -3276,23 +3277,23 @@ facts"):"",backgroundTasksRoot:s?V.join(s,"background-tasks"):"",closingSessions
|
|
|
3276
3277
|
V.join(s,"conversation-log"):"",conversationsRoot:s?V.join(s,"conversations"):"",currentSessionAliasPath:n,dropZoneRoot:s?
|
|
3277
3278
|
V.join(s,"drop-zone"):"",manifestPath:s?V.join(s,"session.json"):"",metadataRoot:s?V.join(s,"metadata"):"",projectContextRoot:o,
|
|
3278
3279
|
projectBackupsRoot:c?V.join(c,"backups"):"",sessionId:i,sessionRoot:s,sessionsRoot:a,stateRoot:c,statusPath:s?V.join(s,"\
|
|
3279
|
-
status"):""}}function
|
|
3280
|
+
status"):""}}function UX({projectContextRoot:e=Ju.cwd(),projectRuntimeRoot:t="",projectSessionSourceRoot:r="",sessionId:n=""}={}){
|
|
3280
3281
|
let o=Gd(e),i=t?V.resolve(t):"";if(!i)throw B("Vibe64 session paths require projectRuntimeRoot.","vibe64_project_runtime\
|
|
3281
3282
|
_root_required");let s=V.join(i,"sessions"),a=r?V.join(V.resolve(r),"sessions"):"",c=V.join(s,"active"),d=V.join(s,"clos\
|
|
3282
3283
|
ing"),u=V.join(s,"archived"),l=N(n),p=l?V.join(c,le(l)):"";return kj({activeSessionsRoot:c,closingSessionsRoot:d,archivedSessionsRoot:u,
|
|
3283
|
-
currentSessionAliasPath:a?ej(a):"",projectContextRoot:o,sessionId:l,sessionRoot:p,sessionsRoot:s,stateRoot:i})}function
|
|
3284
|
+
currentSessionAliasPath:a?ej(a):"",projectContextRoot:o,sessionId:l,sessionRoot:p,sessionsRoot:s,stateRoot:i})}function zX(e){return typeof e=="function"?()=>dn(e()):()=>new Date}async function FX(e,t){let r=$X(t);for(let n=0;n<1e3;n+=
|
|
3284
3285
|
1){let o=n===0?r:`${r}_${n+1}`;if(!await W_(e,o))return o}throw B("Unable to allocate an vibe64 session id.","vibe64_ses\
|
|
3285
3286
|
sion_id_exhausted")}function nc(e={},t=""){return V.join(e.archivedSessionsRoot,`${le(t)}.tar.gz`)}function oc(e={},t=""){
|
|
3286
3287
|
return V.join(e.archivedSessionsRoot,`${le(t)}.json`)}function vj(e={}){return V.join(e.archivedSessionsRoot,".staging")}
|
|
3287
3288
|
function Xm(e={}){return V.join(e.archivedSessionsRoot,".renewals")}function ic(e={},t=""){return V.join(Xm(e),le(t))}function z_(e={},t=""){
|
|
3288
|
-
return V.join(Xm(e),".building",le(t))}function F_(e={},t=""){return V.join(Xm(e),".publishing",le(t))}function
|
|
3289
|
-
let r=le(t);return V.join(ic(e,r),`${r}.tar.gz`)}function
|
|
3290
|
-
return V.join(e.closingSessionsRoot,le(t))}function G_(e={}){return V.join(e.activeSessionsRoot,".creating")}async function
|
|
3289
|
+
return V.join(Xm(e),".building",le(t))}function F_(e={},t=""){return V.join(Xm(e),".publishing",le(t))}function BX(e={},t=""){
|
|
3290
|
+
let r=le(t);return V.join(ic(e,r),`${r}.tar.gz`)}function qX(e={},t=""){let r=le(t);return V.join(ic(e,r),`${r}.json`)}function H_(e={},t=""){
|
|
3291
|
+
return V.join(e.closingSessionsRoot,le(t))}function G_(e={}){return V.join(e.activeSessionsRoot,".creating")}async function VX(e={},t=""){
|
|
3291
3292
|
let r=le(t),n=G_(e),o=await Ar(n);await Promise.all(o.filter(i=>i.isDirectory()&&i.name.startsWith(`${r}.`)).map(i=>Fe(V.
|
|
3292
3293
|
join(n,i.name),{force:!0,recursive:!0})))}async function Km(e={},t=""){let r=le(t);return await Xe(oc(e,r))||await Xe(nc(
|
|
3293
3294
|
e,r))}async function W_(e={},t=""){let r=le(t);return await Xe(V.join(e.activeSessionsRoot,r))||await Xe(H_(e,r))||await Km(
|
|
3294
|
-
e,r)}function Ye(e,t){return V.join(e.metadataRoot,Rj(t))}function
|
|
3295
|
-
e),r=t.split("/");if(!t||t.includes("\\")||r.some(n=>!
|
|
3295
|
+
e,r)}function Ye(e,t){return V.join(e.metadataRoot,Rj(t))}function HX(e=""){return N(e).slice(0,Sj)}function K_(e){let t=N(
|
|
3296
|
+
e),r=t.split("/");if(!t||t.includes("\\")||r.some(n=>!_X.test(n)))throw B(`Invalid vibe64 artifact path: ${t||"(empty)"}`,
|
|
3296
3297
|
"vibe64_invalid_artifact_path");return r.join("/")}function rc(e,t){let r=K_(t),n=V.resolve(e.artifactsRoot),o=V.resolve(
|
|
3297
3298
|
n,...r.split("/"));if(!Js(n,o))throw B(`Invalid vibe64 artifact path: ${r}`,"vibe64_invalid_artifact_path");return o}function yj(e,t){
|
|
3298
3299
|
return V.join(e.agentRunsRoot,`${q_(t)}.json`)}function _j(e,t){return V.join(e.backgroundTasksRoot,`${V_(t)}.json`)}function Go(e,t){
|
|
@@ -3312,10 +3313,10 @@ pin,noExercise:r.noExercise}),!0}catch{return!1}}function gt({clock:e=void 0,log
|
|
|
3312
3313
|
onRenewalQuiesceStep:o=null,projectContextRoot:i=Ju.cwd(),projectRuntimeRoot:s="",projectSessionSourceRoot:a="",sessionLockProcessPlatform:c=Ju.
|
|
3313
3314
|
platform}={}){let d=J_(r);if(d&&!a)throw B("A practice learning runtime requires its actual project session source root.",
|
|
3314
3315
|
"vibe64_learning_scope_invalid");let u=Gd(i),l=String(s||"").trim();if(!l)throw B("Vibe64 session store requires project\
|
|
3315
|
-
RuntimeRoot.","vibe64_project_runtime_root_required");let p=V.resolve(l),f=
|
|
3316
|
+
RuntimeRoot.","vibe64_project_runtime_root_required");let p=V.resolve(l),f=zX(e),y=typeof n=="function"?n:async()=>{},h=typeof o==
|
|
3316
3317
|
"function"?o:async()=>{};function v(g,b="",S={}){return G0(g,b,{...S,logger:t,processPlatform:c})}function w(g,b,S,{timeoutMessage:A,
|
|
3317
3318
|
timeoutCode:E},P){return Cn(g,async()=>{let O=await v(b,S,{waitMs:dj});if(!O)throw B(A,E);try{return await P()}finally{await O()}})}
|
|
3318
|
-
function m(g=""){return
|
|
3319
|
+
function m(g=""){return UX({projectContextRoot:u,projectRuntimeRoot:p,projectSessionSourceRoot:a,sessionId:g})}function _(){
|
|
3319
3320
|
return V.join(p,"session-renewals")}function I(g=""){return V.join(_(),`${le(g)}.json`)}async function x(g=""){let b=le(
|
|
3320
3321
|
g),S=m(),A=Z0(a,b),E=q=>B(`Session creation state already exists for ${b}: ${q}. Inspect and recover it before creating \
|
|
3321
3322
|
the session.`,"vibe64_session_creation_state_conflict"),P=async q=>{try{return await dr(q)}catch(de){if(de?.code==="ENOE\
|
|
@@ -3347,12 +3348,12 @@ status)!==ce.ARCHIVED)throw B(`Invalid Vibe64 session archive status: ${A}`,"vib
|
|
|
3347
3348
|
...g,archivePath:b,index:g.index,metadataPath:S,status:A}}async function qe(g,b){let S=le(b),A=oc(g,S);if(!await Xe(A))return null;
|
|
3348
3349
|
try{return ae(JSON.parse(await Gm(A,"utf8")),{archivePath:nc(g,S),metadataPath:A})}catch(E){throw E?.code?.startsWith?.(
|
|
3349
3350
|
"vibe64_")?E:B(`Invalid Vibe64 session archive metadata: ${A}`,"vibe64_invalid_session_archive_metadata")}}async function st(g){
|
|
3350
|
-
let b=m();return qe(b,g)}async function Ve(g){let b=m(),S=le(g),A=
|
|
3351
|
+
let b=m();return qe(b,g)}async function Ve(g){let b=m(),S=le(g),A=BX(b,S),E=qX(b,S),[P,O]=await Promise.all([Xe(A),Xe(E)]);
|
|
3351
3352
|
if(!P&&!O)return null;if(!P||!O)throw B(`Prepared renewal archive is incomplete for ${S}.`,"vibe64_session_renewal_archi\
|
|
3352
3353
|
ve_incomplete");let k;try{k=JSON.parse(await Gm(E,"utf8"))}catch($){throw $?.code?.startsWith?.("vibe64_")?$:B(`Invalid \
|
|
3353
3354
|
prepared renewal archive metadata: ${E}`,"vibe64_invalid_session_archive_metadata")}return ae(k,{archivePath:A,metadataPath:E})}
|
|
3354
3355
|
async function bt(){let g=m(),b=await Ar(g.archivedSessionsRoot),S=tc(b,A=>A.endsWith(".json")&&lo(A.slice(0,-5)));return(await Promise.
|
|
3355
|
-
all(S.map(A=>qe(g,A.slice(0,-5))))).filter(Boolean)}function U(g={}){if(!Ne(g))return{};let b=
|
|
3356
|
+
all(S.map(A=>qe(g,A.slice(0,-5))))).filter(Boolean)}function U(g={}){if(!Ne(g))return{};let b=hX.map(S=>[S,N(g[S])]).filter(
|
|
3356
3357
|
([,S])=>S);return Object.fromEntries(b)}function F(g={},{sessionId:b=""}={}){let S=Ne(g.manifest)?g.manifest:{},A=N(g.createdAt||
|
|
3357
3358
|
S.createdAt),E=N(g.updatedAt||S.updatedAt||A);return{createdAt:A,manifest:{createdAt:A,revision:Ko(g.revision??S.revision),
|
|
3358
3359
|
runtimeKind:N(S.runtimeKind),updatedAt:E},metadata:U(g.metadata),revision:Ko(g.revision??S.revision),sessionId:le(b||g.sessionId),
|
|
@@ -3429,7 +3430,7 @@ participant?.active===!0){let O=Oa(P.lease);try{return await Qa.run({key:E,lease
|
|
|
3429
3430
|
!0,sessionPaths:P.sessionPaths},()=>b(P.sessionPaths))}finally{Pa(P.lease,O)}}return w(E,A,"mutation",{timeoutMessage:`T\
|
|
3430
3431
|
imed out waiting to update Vibe64 session: ${A.sessionId}`,timeoutCode:"vibe64_session_mutation_lock_timeout"},async()=>{
|
|
3431
3432
|
let O=await Z(A.sessionId);await _e(O);let k=zf(),$=Oa(k),z;try{z=await Qa.run({key:E,lease:k,participant:$,renewal:S,sessionPaths:O},
|
|
3432
|
-
()=>b(O))}finally{Pa(k,$),await k.idle}let q=await Tt(O);return
|
|
3433
|
+
()=>b(O))}finally{Pa(k,$),await k.idle}let q=await Tt(O);return LX(z,q,O.sessionId)})}async function kt(g,b){let S=m(g),
|
|
3433
3434
|
A=Qa.getStore();return A?.key===S.sessionRoot&&A.participant?.active===!0&&A.renewal===!0?en(g,b,{renewal:!0}):en(g,async E=>(Hm(
|
|
3434
3435
|
{sessionId:E.sessionId,status:await Qe(E)}),b(E)))}async function Nt(g,b){return en(g,b,{renewal:!0})}async function Qt(g,b,S,{
|
|
3435
3436
|
operation:A="",renewal:E=!1,waitMs:P=0}={}){if(typeof S!="function")throw new TypeError("Exclusive Vibe64 session work r\
|
|
@@ -3455,19 +3456,19 @@ g,at)}async function at(g){let b=await Ai(g);return uo(b,d,g.sessionId),b}async
|
|
|
3455
3456
|
A=>xj.test(A)),S=await Promise.all(b.map(async A=>[A,N(await $t(Ye(g,A)))]));return Object.fromEntries(S)}async function Ud(g){
|
|
3456
3457
|
return d?et(g,async(b,S)=>{let A=await at(b),E=uo(A,d,b.sessionId),P=await Qe(b),O=await je(b);return{...O,sessionRoot:S?
|
|
3457
3458
|
"":O.sessionRoot,purpose:"learning",learning:E,status:P,archived:!!S||P===ce.ARCHIVED,nativeExecutionRoot:T_(O)}}):It(g)}
|
|
3458
|
-
async function It(g){return et(g,je)}async function je(g){d&&await at(g);let b=await Promise.all(
|
|
3459
|
+
async function It(g){return et(g,je)}async function je(g){d&&await at(g);let b=await Promise.all(SX.map(async S=>[S,N(await $t(
|
|
3459
3460
|
Ye(g,S)))]));return{metadata:Object.fromEntries(b),projectContextRoot:g.projectContextRoot,sessionId:g.sessionId,sessionRoot:g.
|
|
3460
|
-
sessionRoot}}async function xo(g,b={}){return
|
|
3461
|
+
sessionRoot}}async function xo(g,b={}){return HX(b[ij])||g.sessionId}async function Ei(g,b,S){return kt(g,async A=>{let E=rc(
|
|
3461
3462
|
A,b);return await ct(E,S),E})}async function og(g,b,S){return kt(g,async A=>{let E=rc(A,b);return await cr(E,S),E})}async function yD(g,b){
|
|
3462
3463
|
return et(g,S=>$t(rc(S,b)))}async function _D(g,b){return Se(g,S=>$t(rc(S,b)))}async function bD(g,b,S){return Nt(g,async A=>{
|
|
3463
|
-
let E=rc(A,b);return await cr(E,S),E})}async function ig(g,b){let S=q_(b),A;try{A=await
|
|
3464
|
+
let E=rc(A,b);return await cr(E,S),E})}async function ig(g,b){let S=q_(b),A;try{A=await jX.read(yj(g,S),E=>E?JSON.parse(
|
|
3464
3465
|
E):null)}catch(E){if(Rt(E))return null;if(!(E instanceof SyntaxError))throw E;A=void 0}if(A===null)return null;try{if(A===
|
|
3465
|
-
void 0)throw new SyntaxError;return pm(A,S,{normalizeState:Jm,isActive:
|
|
3466
|
+
void 0)throw new SyntaxError;return pm(A,S,{normalizeState:Jm,isActive:RX})}catch{throw B(`Invalid vibe64 agent run: ${S}`,
|
|
3466
3467
|
"vibe64_invalid_agent_run")}}async function ID(g,b){return et(g,S=>ig(S,b))}async function SD(g){return et(g,eS)}async function eS(g){
|
|
3467
3468
|
let b=tc(await Ar(g.agentRunsRoot),A=>A.endsWith(".json")&&Tj(A.slice(0,-5)));return(await Promise.all(b.map(A=>ig(g,A.slice(
|
|
3468
3469
|
0,-5))))).filter(Boolean).sort((A,E)=>N(A.updatedAt).localeCompare(N(E.updatedAt))||N(A.id).localeCompare(N(E.id)))}async function AD(g,b,{
|
|
3469
3470
|
event:S={},patch:A={}}={}){return kt(g,async E=>{let P=q_(b),O=await ig(E,P)||{events:[],id:P},k=fm(O,P,{event:S,patch:A},
|
|
3470
|
-
{now:f,normalizeState:Jm,isTerminal:
|
|
3471
|
+
{now:f,normalizeState:Jm,isTerminal:OX});return await cr(yj(E,P),k),k})}async function sg(g,b){let S=V_(b),A=await $t(_j(
|
|
3471
3472
|
g,S));if(!A)return null;try{let E=JSON.parse(A);return Ne(E)?{...E,events:Array.isArray(E.events)?E.events.filter(Ne):[],
|
|
3472
3473
|
id:S,status:fj(E.status)}:null}catch{throw B(`Invalid vibe64 background task: ${S}`,"vibe64_invalid_background_task")}}async function ED(g,b){
|
|
3473
3474
|
return et(g,S=>sg(S,b))}async function xD(g){return et(g,tS)}async function tS(g){let b=tc(await Ar(g.backgroundTasksRoot),
|
|
@@ -3476,15 +3477,15 @@ A=>A.endsWith(".json")&&Cj(A.slice(0,-5)));return(await Promise.all(b.map(A=>sg(
|
|
|
3476
3477
|
reset:E=!1,shouldWrite:P=null}={}){return kt(g,async O=>{let k=V_(b),$=E===!0?{events:[],id:k}:await sg(O,k)||{events:[],
|
|
3477
3478
|
id:k},z=N(S.at||A.updatedAt)||f().toISOString(),q=fj(A.status||S.status||$.status),de=N($.status),re={...S,at:z,kind:N(S.
|
|
3478
3479
|
kind||q||"updated"),message:N(S.message||A.message),status:q};if(typeof P=="function"&&!P({event:re,patch:A,previous:$,status:q}))
|
|
3479
|
-
return $;let pe={...$,...A,events:[...Array.isArray($.events)?$.events:[],re].slice(-
|
|
3480
|
+
return $;let pe={...$,...A,events:[...Array.isArray($.events)?$.events:[],re].slice(-vX),finishedAt:q===rs.RUNNING?"":N(
|
|
3480
3481
|
A.finishedAt||$.finishedAt)||z,id:k,kind:Object.hasOwn(A,"kind")?N(A.kind):N(re.kind||$.kind),message:Object.hasOwn(A,"m\
|
|
3481
3482
|
essage")?N(A.message):Object.hasOwn(S,"message")?N(S.message):N($.message),startedAt:q===rs.RUNNING&&de!==rs.RUNNING?z:N(
|
|
3482
3483
|
A.startedAt||$.startedAt)||z,status:q,updatedAt:z};return q!==rs.RUNNING&&!Object.hasOwn(A,"stage")&&delete pe.stage,q!==
|
|
3483
3484
|
rs.FAILED&&!Object.hasOwn(A,"error")&&(pe.error=""),await cr(_j(O,k),pe),pe})}async function CD(g,b,S){let A=N(S).match(
|
|
3484
|
-
M_);if(!A)return null;let E=N(A[3]);return{at
|
|
3485
|
+
M_);if(!A)return null;let E=N(A[3]);return{at:DX(A[2]),role:A[1],text:N(await $t(V.join(Go(g,b),S))),...E?{messageId:E}:
|
|
3485
3486
|
{}}}async function RD(g,b){let S=tc(await Ar(Go(g,b)),O=>M_.test(O)),A=(await Promise.all(S.map(O=>CD(g,b,O)))).filter(Boolean),
|
|
3486
3487
|
[E,P]=await Promise.all([LD(g,b),$D(g,b)]);return{messages:A.map(O=>O.role==="user"&&E.length?{...O,attachments:E}:O),...P?
|
|
3487
|
-
{metadata:P}:{}}}async function OD(g,b,S){let A=L0(S);if(!A)return null;let E=
|
|
3488
|
+
{metadata:P}:{}}}async function OD(g,b,S){let A=L0(S);if(!A)return null;let E=uX("sha256").update(S.text).digest("hex"),
|
|
3488
3489
|
P=await $t(V.join(Go(g,b),"integration-setup.json")),O={outcome:"pending"};if(P){let k;try{k=JSON.parse(P)}catch{throw B(
|
|
3489
3490
|
"Invalid integration setup decision.","vibe64_invalid_integration_setup_decision")}let $=k?.outcome==="completed";if(!Ne(
|
|
3490
3491
|
k)||Object.keys(k).length!==($?6:2)||typeof k.requestId!="string"||!/^[a-f0-9]{64}$/u.test(k.requestId)||($?!rS(k)||!nS(
|
|
@@ -3533,7 +3534,7 @@ rewound:g.rewound,turns:[...g.turns]}}function zd(g){let b;try{b=JSON.parse(g)}c
|
|
|
3533
3534
|
t valid JSON. Restore it before continuing.","vibe64_invalid_conversation_storage")}return aS(b)}function aS(g){let b=Array.
|
|
3534
3535
|
isArray(g?.turns)?new Set(g.turns.map(S=>S?.[0])):new Set;if(g?.version!==1||!Ne(g.metadata)||!Array.isArray(g.rewound)||
|
|
3535
3536
|
!Array.isArray(g.turns)||g.turns.some(S=>!Array.isArray(S)||S.length!==2||typeof S[0]!="string"||!Wo.test(S[0])||!Ne(S[1])||
|
|
3536
|
-
!Array.isArray(S[1].messages)||S[1].metadata!==void 0&&!Ne(S[1].metadata)||S[1].messages.some(A=>!Ne(A)||!
|
|
3537
|
+
!Array.isArray(S[1].messages)||S[1].metadata!==void 0&&!Ne(S[1].metadata)||S[1].messages.some(A=>!Ne(A)||!IX.includes(A.
|
|
3537
3538
|
role)||typeof A.text!="string"||typeof A.at!="string"||!Number.isFinite(Date.parse(A.at))||A.messageId!==void 0&&typeof A.
|
|
3538
3539
|
messageId!="string"))||b.size!==g.turns.length||g.rewound.some(S=>!b.has(S)))throw B("Conversation storage has an unsupp\
|
|
3539
3540
|
orted or damaged format. Restore it before continuing.","vibe64_invalid_conversation_storage");return{metadata:g.metadata,
|
|
@@ -3544,7 +3545,7 @@ son","message-ids.json"].includes(S.name)))throw B("This conversation needs the
|
|
|
3544
3545
|
metadata:{},rewound:[]}}function dS(g,b,S=!1,A=null){let E;return ka({async readRecord(){return E=await cS(g),E},async writeRecord(O,k){
|
|
3545
3546
|
k={metadata:k.metadata,turns:k.turns,rewound:k.rewound??E.rewound};let $=sS(k);aS($);let z=V.join(g.conversationLogRoot,
|
|
3546
3547
|
"transcript.json"),q=await ct(z,`${JSON.stringify($)}
|
|
3547
|
-
`);gj.remember(z,q,k)}})[S?"write":"read"](g.conversationLogRoot,O=>b({...O,...S?{}:{async hasMessage(k){return
|
|
3548
|
+
`);gj.remember(z,q,k)}})[S?"write":"read"](g.conversationLogRoot,O=>b({...O,...S?{}:{async hasMessage(k){return MX(E,k)}},
|
|
3548
3549
|
async listTurnIds(){return(await O.listTurnIds()).filter(k=>!E.rewound.includes(k))},...typeof O.findMessageTurnId=="fun\
|
|
3549
3550
|
ction"?{async findMessageTurnId(k){let $=await O.findMessageTurnId(k);return $&&!E.rewound.includes($)?$:""}}:{},async readTurn(k){
|
|
3550
3551
|
let $=await O.readTurn(k);if(!$||E.rewound.includes(k))return $;let z=await OD(g,k,$.assistant);return z?{...$,integrationSetup:z}:
|
|
@@ -3615,7 +3616,7 @@ let z=m(E),q=m(P),[de,re,pe,ue]=await Promise.all([Qe(z),at(z),Qe(q),at(q)]);if(
|
|
|
3615
3616
|
A||pe!==ce.RENEWAL_PENDING||N(ue.renewal_id)!==A||N(ue.renewed_from)!==E)throw B(`Renewal archive cannot be prepared fro\
|
|
3616
3617
|
m ${de} -> ${pe}.`,"vibe64_session_renewal_transition_invalid");let G=(O.currentSessionAliasPath?await Za({aliasPath:O.currentSessionAliasPath}):
|
|
3617
3618
|
"")===E?E:j_,W=ic(O,E),ee=V.join(k,E),ne=V.join(k,`${E}.tar.gz`),Ie=V.join(k,`${E}.json`),ke=nc(O,E),He=oc(O,E),mt=f().toISOString();
|
|
3618
|
-
try{await Yt(k,{recursive:!0}),await
|
|
3619
|
+
try{await Yt(k,{recursive:!0}),await lX(z.sessionRoot,ee,{recursive:!0,filter:Hs=>Hs!==z.dropZoneRoot});let zt=se(E,ee);
|
|
3619
3620
|
await Promise.all(uj.map(Hs=>Fe(Ye(zt,Hs),{force:!0}))),await Promise.all([...Object.entries(lj(ue,{archivedAt:mt,renewalId:A,
|
|
3620
3621
|
selectedBeforeArchive:G,successorSessionId:P})).map(([Hs,mg])=>ct(Ye(zt,Hs),`${mg}
|
|
3621
3622
|
`)),ct(zt.statusPath,`${ce.ARCHIVED}
|
|
@@ -3722,17 +3723,17 @@ let b=N(await $t(Ye(m(g),er)));return bj(b,g)}async function yU(){let g=m();if(!
|
|
|
3722
3723
|
S:null}async function vS({metadata:g={},runtimeKind:b="",sessionId:S="",status:A=ce.ACTIVE}={},E=null){if(Object.hasOwn(
|
|
3723
3724
|
g,er))throw B("Learning purpose is supplied only by the authorized runtime constructor, not creation metadata.","vibe64_\
|
|
3724
3725
|
learning_scope_invalid");let P=Object.fromEntries(Object.entries(g).map(([re,pe])=>[Rj(re),N(pe)])),O=Jo(A),k=m();await Yt(
|
|
3725
|
-
k.activeSessionsRoot,{recursive:!0});let $=f().toISOString(),z=S?le(S):await
|
|
3726
|
+
k.activeSessionsRoot,{recursive:!0});let $=f().toISOString(),z=S?le(S):await FX(k,$),q=m(z);d&&(P[er]=JSON.stringify({schemaVersion:1,
|
|
3726
3727
|
...d,conversationId:z}));let de=await v(q,"create",{waitMs:dj});if(!de)throw B(`Vibe64 session creation is already in pr\
|
|
3727
3728
|
ogress: ${z}`,"vibe64_session_busy");try{let re=await Cn(q.sessionRoot,async()=>{let pe=G_(k),ue=V.join(pe,`${z}.${Ju.pid}\
|
|
3728
3729
|
.${es()}`),he=se(z,ue),G=!1;try{if(await W_(k,z))throw B(`Vibe64 session already exists: ${z}`,"vibe64_session_exists");
|
|
3729
3730
|
await Yt(ue,{recursive:!0}),await Promise.all([Yt(he.dropZoneRoot,{recursive:!0}),Yt(he.agentRunsRoot,{recursive:!0}),Yt(
|
|
3730
3731
|
he.artifactsRoot,{recursive:!0}),Yt(he.backgroundTasksRoot,{recursive:!0}),Yt(he.metadataRoot,{recursive:!0})]);let W=N(
|
|
3731
|
-
b),ee={...W?{runtimeKind:W}:{},createdAt:$,product:"vibe64",revision:1,schemaVersion:
|
|
3732
|
+
b),ee={...W?{runtimeKind:W}:{},createdAt:$,product:"vibe64",revision:1,schemaVersion:fX,sessionId:z,updatedAt:$};if(await Promise.
|
|
3732
3733
|
all([cr(he.manifestPath,ee),ct(he.statusPath,`${O}
|
|
3733
3734
|
`),...Object.entries(P).map(([ne,Ie])=>ct(Ye(he,ne),`${Ie}
|
|
3734
3735
|
`))]),await W_(k,z))throw B(`Vibe64 session already exists: ${z}`,"vibe64_session_exists");return await co(ue,q.sessionRoot),
|
|
3735
|
-
G=!0,await
|
|
3736
|
+
G=!0,await VX(k,z).catch(()=>null),yn(z)}catch(W){throw["EEXIST","ENOTEMPTY"].includes(W?.code)?B(`Vibe64 session alread\
|
|
3736
3737
|
y exists: ${z}`,"vibe64_session_exists"):W}finally{G||await Fe(ue,{force:!0,recursive:!0})}});return E?await E(re):re}finally{
|
|
3737
3738
|
await de()}}async function _U(g={},b=null){if(b!==null&&typeof b!="function")throw new TypeError("Session initialization\
|
|
3738
3739
|
must be a function.");let S=Jo(g.status);if(Bm.has(S))throw B(`Renewal session status requires createRenewalPendingSess\
|
|
@@ -3822,7 +3823,7 @@ currentSessionAliasPath&&await Fm({aliasPath:$.currentSessionAliasPath,sessionId
|
|
|
3822
3823
|
Ar(g.closingSessionsRoot)]),A=U_(b,lo),E=U_(S,lo),P=[...new Set([...A,...E])].sort((k,$)=>k.localeCompare($)),O=d?[]:await Promise.
|
|
3823
3824
|
all(P.map(wS));return Promise.all(P.filter((k,$)=>!O[$]).map(async k=>({sessionId:k,status:await Ut(k)})))}async function yS(){
|
|
3824
3825
|
let g=[];for(let b of await fg())if(b.status===ce.ARCHIVED){let S=await yn(b.sessionId);if(N(S.metadata.renewal_id)&&N(S.
|
|
3825
|
-
metadata.renewed_to))continue;await mS(b.sessionId),g.push(b.sessionId)}return g}async function _S(g={}){let b=
|
|
3826
|
+
metadata.renewed_to))continue;await mS(b.sessionId),g.push(b.sessionId)}return g}async function _S(g={}){let b=NX(g),S=await fg();
|
|
3826
3827
|
hj(b)&&(await yS(),S=S.filter(O=>O.status!==ce.ARCHIVED)),S=S.filter(({status:O})=>mj(O,b));let A=await Promise.all(S.map(
|
|
3827
3828
|
async({sessionId:O})=>!await A_(Xa(m(O),"create"))));S=S.filter((O,k)=>!A[k]);let E=new Set(S.map(O=>O.sessionId));return{
|
|
3828
3829
|
archivedRecords:hj(b)?(await bt()).filter(O=>!E.has(O.sessionId)).filter(O=>mj(O.status,b)).filter(O=>d||!bj(H(O).metadata?.[er],
|
|
@@ -3892,7 +3893,7 @@ if(ne.sessionId!==he)throw new Error(`Session archive identity does not match ${
|
|
|
3892
3893
|
let ke=await z(Ie,ne),He=A?await A({record:ee,sessionPaths:Ie}):null;if(He&&ae(He,{archivePath:ue,metadataPath:G}),!ke.length){
|
|
3893
3894
|
He&&$.push({filePath:G,original:W,contents:`${JSON.stringify(He,null,2)}
|
|
3894
3895
|
`});return}for(let Kt of ke){if(Kt.contents===null){await Fe(Kt.filePath);continue}await Yt(V.dirname(Kt.filePath),{recursive:!0,
|
|
3895
|
-
mode:448}),await
|
|
3896
|
+
mode:448}),await pX(Kt.filePath,Kt.contents,{mode:384})}let mt=V.join(g,`${es()}.tar.gz`);if(!(await ec("tar",["-czf",mt,
|
|
3896
3897
|
"-C",V.dirname(Ie.sessionRoot),"."],{allowedRoots:[g],cwd:u})).ok)throw new Error(`Cannot stage upgraded archive for ${he}\
|
|
3897
3898
|
.`);await pr(mt),$.push({filePath:ue,replacementPath:mt}),He&&$.push({filePath:G,original:W,contents:`${JSON.stringify(He,
|
|
3898
3899
|
null,2)}
|
|
@@ -3987,11 +3988,11 @@ upsertConversationAssistantMessage:JD,writeConversationAssistantMessage:KD,write
|
|
|
3987
3988
|
writeConversationThinkingMessage:YD,writeConversationUserMessage:eU,writeMetadataValue:jr,writeMetadataValueForRenewal:Ld,
|
|
3988
3989
|
writeJsonArtifactForRenewal:bD,writeSessionRenewalStateRecord:T,withPublishedRenewalSession:Ze,withArchivedSession:Pe,pruneArchivedSessionAttachments:Ee,
|
|
3989
3990
|
pruneArchivedSessionArtifacts:Fs,writeSessionLabel:Je,writeStatus:wn}}var Mj=new Set(Object.values(Vr)),Zm=new Set(["plan","code","economy","auto"]),Lj=new Set(["routing","sending","uncertai\
|
|
3990
|
-
n","sent","failed","cancelled","done","review_pending","review_sending","review_uncertain","reviewing"]),
|
|
3991
|
+
n","sent","failed","cancelled","done","review_pending","review_sending","review_uncertain","reviewing"]),GX=new Set([...Lj,
|
|
3991
3992
|
"planning","planning_pending","planning_sending","planning_uncertain","implementation_pending","implementation_sending",
|
|
3992
|
-
"implementation_uncertain"]),On=e=>e&&typeof e=="object"&&!Array.isArray(e),
|
|
3993
|
+
"implementation_uncertain"]),On=e=>e&&typeof e=="object"&&!Array.isArray(e),WX=["custom","senior","junior","helper","rev\
|
|
3993
3994
|
iew","deslop","commit_title","conversation_summary","voice_turn","database_assistant","lesson_review","prompt_hint","req\
|
|
3994
|
-
uest_routing","session_title","source_explanation"];function
|
|
3995
|
+
uest_routing","session_title","source_explanation"];function KX(e={}){if(!e||typeof e!="object"||Array.isArray(e)||!["cu\
|
|
3995
3996
|
stom","senior","junior","auto"].includes(e.mode))throw Object.assign(new Error("Choose Custom, Senior, Junior, or Auto."),
|
|
3996
3997
|
{code:"vibe64_assistant_routing_invalid",statusCode:409});if(e.workflowEngineId!==void 0&&!Mj.has(e.workflowEngineId))throw Object.
|
|
3997
3998
|
assign(new Error("Choose a supported workflow orchestrator."),{code:"vibe64_assistant_routing_invalid",statusCode:409});
|
|
@@ -3999,11 +4000,11 @@ if(e.mode==="custom"&&!e.override)throw Object.assign(new Error("Choose a custom
|
|
|
3999
4000
|
routing_invalid",statusCode:409});return e.override&&e.mode!=="auto"&&Hr(e.override),e}function xr(e,{schemaVersion:t=4,
|
|
4000
4001
|
preferences:r=!1,request:n=!1}={}){if(!On(e)||![3,4].includes(t)||e.schemaVersion!==void 0&&e.schemaVersion!==t)throw new Error(
|
|
4001
4002
|
"Saved routing has an unsupported format. Use the matching release.");let o=new Set(["custom","senior","junior","auto","\
|
|
4002
|
-
router","review","deslop",t===3?"intern":"helper",...
|
|
4003
|
+
router","review","deslop",t===3?"intern":"helper",...WX.filter(s=>s!=="helper")]);for(let s of["mode","requestedMode","r\
|
|
4003
4004
|
esolvedMode","role"])if(e[s]!==void 0&&e[s]!==""&&!o.has(e[s]))throw new Error("Saved routing contains an unknown role. \
|
|
4004
|
-
Inspect it before upgrading.");r&&
|
|
4005
|
+
Inspect it before upgrading.");r&&KX(t===3&&e.mode==="intern"?{...e,mode:"junior"}:e),e.workflowEngineId!==void 0&&Qm(e.
|
|
4005
4006
|
workflowEngineId,"Saved routing");let i=e.configuration===void 0&&e.admissionRequired===!0;if(n&&(!e.mode||!On(e.configuration)&&
|
|
4006
|
-
!i||!On(e.assignments)||!Object.keys(e.assignments).length||!
|
|
4007
|
+
!i||!On(e.assignments)||!Object.keys(e.assignments).length||!GX.has(e.status)))throw new Error("Saved routing has an uns\
|
|
4007
4008
|
upported routing request. Inspect it before upgrading.");for(let s of["selection","observedSelection","effectiveSelectio\
|
|
4008
4009
|
n","configuredSelection","destination","deliverySelection"])e[s]!=null&&Er(e[s],"Saved routing");if(e.configuration&&(t===
|
|
4009
4010
|
3?Oi:_r)({...e.configuration,schemaVersion:e.configuration.schemaVersion??t}),e.assignments!==void 0){if(!On(e.assignments))
|
|
@@ -4015,7 +4016,7 @@ ed routing override has no captured model selection.");xr(e.override,{schemaVers
|
|
|
4015
4016
|
xr(e.decision,{schemaVersion:t}),e.seniorJuniorPair){if(!On(e.seniorJuniorPair)||Object.keys(e.seniorJuniorPair).some(s=>![
|
|
4016
4017
|
"senior","junior"].includes(s)))throw new Error("Saved routing has an invalid workflow pair.");for(let s of Object.values(
|
|
4017
4018
|
e.seniorJuniorPair))xr(s,{schemaVersion:t})}if(e.planCodePair)throw new Error("Saved native routing contains a legacy wo\
|
|
4018
|
-
rkflow pair.");return e}function
|
|
4019
|
+
rkflow pair.");return e}function JX(e={}){if(!e||typeof e!="object"||Array.isArray(e)||!Zm.has(e.mode))throw Object.assign(
|
|
4019
4020
|
new Error("Choose Plan, Code, Economy, or Auto."),{code:"vibe64_assistant_routing_invalid",statusCode:409});if(e.workflowEngineId!==
|
|
4020
4021
|
void 0&&!Object.values(Vr).includes(e.workflowEngineId))throw Object.assign(new Error("Choose a supported workflow orche\
|
|
4021
4022
|
strator."),{code:"vibe64_assistant_routing_invalid",statusCode:409});return{mode:e.mode,review:e.review===!0,...e.workflowEngineId?
|
|
@@ -4074,7 +4075,7 @@ e conversation identities.`);l.nativeBindings={...s.nativeBindings,[p]:{conversa
|
|
|
4074
4075
|
agentSettings:s.agentSettings||{},runId:s.runId||"",messageId:s.messageId||""}}}JSON.stringify(l)!==JSON.stringify(s)&&i.
|
|
4075
4076
|
conversations.push(l)}if(n?.successor?.assistantSelection&&!["completed","cancelled"].includes(n.status)){let s=Er(n.successor.
|
|
4076
4077
|
assistantSelection,`Renewal of ${e}`),a=n.successor.assistantRouting;if(a&&["senior","junior","custom","intern"].includes(
|
|
4077
|
-
a.mode))return xr(a,{preferences:!0,schemaVersion:a.mode==="intern"?3:4}),i;let c=
|
|
4078
|
+
a.mode))return xr(a,{preferences:!0,schemaVersion:a.mode==="intern"?3:4}),i;let c=JX(a||{mode:"code",review:!1,override:s,
|
|
4078
4079
|
workflowEngineId:s.engineId});c.workflowEngineId||(c.workflowEngineId=s.engineId),JSON.stringify(c)!==JSON.stringify(a)&&
|
|
4079
4080
|
(i.renewal={...n,successor:{...n.successor,assistantRouting:c}})}return i}var Y_={defaultScores:{plan:2,code:2,economy:2,router:2},models:[{engineId:"codex",modelProviderId:"openai",modelId:"gpt\
|
|
4080
4081
|
-6-astra",scores:{plan:10,code:8,economy:3,router:3}},{engineId:"codex",modelProviderId:"openai",modelId:"gpt-6-sol",scores:{
|
|
@@ -4092,7 +4093,7 @@ plan:6,code:6,economy:8,router:8}},{engineId:"opencode",modelProviderId:"zai",mo
|
|
|
4092
4093
|
economy:6,router:6}},{engineId:"opencode",modelProviderId:"zai-coding-plan",modelId:"glm-5.3-flash",scores:{plan:7,code:7,
|
|
4093
4094
|
economy:6,router:6}}]};var el=Object.freeze({HELPER:"helper"}),un=Object.freeze({COMMIT_TITLE:"commit_title",CONVERSATION_SUMMARY:"conversation\
|
|
4094
4095
|
_summary",VOICE_TURN:"voice_turn",DATABASE_ASSISTANT:"database_assistant",LESSON_REVIEW:"lesson_review",PROMPT_HINT:"pro\
|
|
4095
|
-
mpt_hint",REQUEST_ROUTING:"request_routing",SESSION_TITLE:"session_title",SOURCE_EXPLANATION:"source_explanation"}),
|
|
4096
|
+
mpt_hint",REQUEST_ROUTING:"request_routing",SESSION_TITLE:"session_title",SOURCE_EXPLANATION:"source_explanation"}),YX=Object.
|
|
4096
4097
|
freeze({[un.COMMIT_TITLE]:Object.freeze({maxInputCharacters:24e3,maxOutputCharacters:512,timeoutMs:12e4}),[un.VOICE_TURN]:Object.
|
|
4097
4098
|
freeze({maxInputCharacters:12e3,maxOutputCharacters:512,timeoutMs:1e4}),[un.CONVERSATION_SUMMARY]:Object.freeze({maxInputCharacters:2e5,
|
|
4098
4099
|
maxOutputCharacters:16e3,timeoutMs:12e4}),[un.DATABASE_ASSISTANT]:Object.freeze({maxInputCharacters:5e5,maxOutputCharacters:16e3,
|
|
@@ -4105,7 +4106,7 @@ MAX_TIMEOUT_MS:3e5}),hr=Object.freeze({INVALID:"vibe64_agent_execution_profile_i
|
|
|
4105
4106
|
execution_profile_model_unavailable",POLICY_UNENFORCEABLE:"vibe64_agent_execution_profile_policy_unenforceable",PROFILE_UNKNOWN:"\
|
|
4106
4107
|
vibe64_agent_execution_profile_unknown",REASONING_UNSUPPORTED:"vibe64_agent_execution_profile_reasoning_unsupported",UNBOUNDED:"\
|
|
4107
4108
|
vibe64_agent_execution_profile_unbounded",UNSAFE:"vibe64_agent_execution_profile_unsafe",WORKLOAD_UNSUPPORTED:"vibe64_ag\
|
|
4108
|
-
ent_execution_profile_workload_unsupported"}),
|
|
4109
|
+
ent_execution_profile_workload_unsupported"}),ZX=new Set(Object.values(el)),QX=new Set(Object.values(un)),rb=class extends Error{constructor(t,r,n={}){
|
|
4109
4110
|
super(r),this.name="Vibe64AgentExecutionProfileError",this.code=t,this.details=Object.freeze({...n});for(let[o,i]of Object.
|
|
4110
4111
|
entries(this.details))["code","details","message","name"].includes(o)||(this[o]=i)}};function gr(e,t,r={}){return new rb(
|
|
4111
4112
|
e,t,r)}function Uj(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.
|
|
@@ -4116,11 +4117,11 @@ hr.INVALID,`Execution profile ${t} must be text.`,{field:t});let n=e.trim();if(!
|
|
|
4116
4117
|
tion profile ${t} is invalid.`,{field:t});return n}function zj(e,t){if(typeof e!="boolean")throw gr(hr.INVALID,`Executio\
|
|
4117
4118
|
n profile ${t} must be a boolean.`,{field:t});return e}function Zu(e,t){if(zj(e,t)!==!1)throw gr(hr.UNSAFE,`Execution pr\
|
|
4118
4119
|
ofile ${t} must be disabled.`,{field:t});return!1}function tb(e,t,r){if(!Number.isSafeInteger(e)||e<=0||e>r)throw gr(hr.
|
|
4119
|
-
UNBOUNDED,`Execution profile ${t} must be a positive integer no greater than ${r}.`,{field:t,maximum:r});return e}function
|
|
4120
|
-
if(!Uj(e))throw gr(hr.UNBOUNDED,"Execution profile limits are required.",{field:"limits"});return e}function
|
|
4121
|
-
e,"profileId",64);if(!
|
|
4122
|
-
let t=Qu(e,"workloadId",64);if(!
|
|
4123
|
-
.`,{workloadId:t});return t}function
|
|
4120
|
+
UNBOUNDED,`Execution profile ${t} must be a positive integer no greater than ${r}.`,{field:t,maximum:r});return e}function e5(e){
|
|
4121
|
+
if(!Uj(e))throw gr(hr.UNBOUNDED,"Execution profile limits are required.",{field:"limits"});return e}function t5(e){let t=Qu(
|
|
4122
|
+
e,"profileId",64);if(!ZX.has(t))throw gr(hr.PROFILE_UNKNOWN,`Unknown execution profile: ${t}.`,{profileId:t});return t}function r5(e){
|
|
4123
|
+
let t=Qu(e,"workloadId",64);if(!QX.has(t))throw gr(hr.WORKLOAD_UNSUPPORTED,`Unsupported execution profile workload: ${t}\
|
|
4124
|
+
.`,{workloadId:t});return t}function n5(e){return Object.freeze({profileId:t5(e.profileId),workloadId:r5(e.workloadId)})}function o5(e){let t=Q_(e,"resolution"),r=n5(t),n=Q_(t.request,"request policy"),o=Q_(t.policy,"tool policy"),i=e5(t.limits);
|
|
4124
4125
|
eb(n,["allowProviderModelFallback","reasoning","summary"],"request"),eb(o,["environmentAccess","networkAccess","reposito\
|
|
4125
4126
|
ryWrite","tools"],"policy"),eb(i,["maxInputCharacters","maxOutputCharacters","timeoutMs"],"limits");let s=zj(n.reasoning,
|
|
4126
4127
|
"request.reasoning");if(typeof t.thinking!="string")throw gr(hr.INVALID,"Execution profile thinking must be text.",{field:"\
|
|
@@ -4134,34 +4135,34 @@ maxOutputCharacters:tb(i.maxOutputCharacters,"limits.maxOutputCharacters",Z_.MAX
|
|
|
4134
4135
|
"policy.repositoryWrite"),tools:Dj.NONE}),profileId:r.profileId,providerId:Qu(t.providerId,"providerId",64),request:Object.
|
|
4135
4136
|
freeze({allowProviderModelFallback:Zu(n.allowProviderModelFallback,"request.allowProviderModelFallback"),reasoning:s,summary:Zu(
|
|
4136
4137
|
n.summary,"request.summary")}),revision:Qu(t.revision,"revision",128),thinking:a,workloadId:r.workloadId})}function Fj(e){
|
|
4137
|
-
return
|
|
4138
|
-
gpt-5.3-codex-spark",nb=Object.freeze(["low","medium","high","xhigh"]),
|
|
4138
|
+
return o5(e)}var Bj=Object.freeze({MODEL:"model",THINKING:"thinking"}),n$e=Vr.CODEX,s5="gpt-5.6-sol",a5="gpt-5.5",qj=s5,c5="xhigh",d5="\
|
|
4139
|
+
gpt-5.3-codex-spark",nb=Object.freeze(["low","medium","high","xhigh"]),u5=Object.freeze([...nb,"max"]),l5=Object.freeze(
|
|
4139
4140
|
[Object.freeze({executionProfiles:Object.freeze([el.HELPER]),id:Vr.CODEX,implemented:!0,label:"Codex",planUsage:Object.freeze(
|
|
4140
4141
|
{label:"Codex",managementUrl:"https://chatgpt.com/codex/settings/usage"}),terminal:"codex",terminalAttachments:!1,parameters:Object.
|
|
4141
4142
|
freeze([Object.freeze({id:Bj.MODEL,defaultValue:qj,label:"Model",options:Object.freeze([Object.freeze({label:"Automatic \
|
|
4142
|
-
(GPT-5.6 Sol)",value:""}),Object.freeze({label:"GPT-5.6 Sol",supportedThinking:
|
|
4143
|
-
.5",supportedThinking:nb,value:
|
|
4144
|
-
value:
|
|
4143
|
+
(GPT-5.6 Sol)",value:""}),Object.freeze({label:"GPT-5.6 Sol",supportedThinking:u5,value:qj}),Object.freeze({label:"GPT-5\
|
|
4144
|
+
.5",supportedThinking:nb,value:a5}),Object.freeze({label:"Codex Spark",request:Object.freeze({summary:!1}),supportedThinking:nb,
|
|
4145
|
+
value:d5})])}),Object.freeze({id:Bj.THINKING,defaultValue:c5,label:"Thinking",options:Object.freeze([Object.freeze({label:"\
|
|
4145
4146
|
Automatic",value:""}),Object.freeze({label:"Low",value:"low"}),Object.freeze({label:"Medium",value:"medium"}),Object.freeze(
|
|
4146
4147
|
{label:"High",value:"high"}),Object.freeze({label:"X High",value:"xhigh"}),Object.freeze({label:"Max",value:"max"})])})])}),
|
|
4147
4148
|
Object.freeze({executionProfiles:Object.freeze([el.HELPER]),id:Vr.CLAUDE,implemented:!0,label:"Claude Code",planUsage:Object.
|
|
4148
4149
|
freeze({label:"Claude",managementUrl:"https://claude.ai/settings/usage"}),parameters:Object.freeze([]),terminal:"native",
|
|
4149
4150
|
terminalAttachments:!1}),Object.freeze({executionProfiles:Object.freeze([]),id:Vr.OPENCODE,implemented:!1,label:"OpenCod\
|
|
4150
4151
|
e",parameters:Object.freeze([]),terminal:"native",terminalAttachments:!0})]);var eh=Object.freeze({COMPLETED:"completed",RUNNING:"running",STARTING:"starting",STOPPED:"stopped",STOPPING:"stopping",
|
|
4151
|
-
WAITING:"waiting"}),
|
|
4152
|
-
continue"}),
|
|
4152
|
+
WAITING:"waiting"}),i$e=new Set([eh.RUNNING,eh.STARTING,eh.STOPPING,eh.WAITING]),p5=Object.freeze({COMPLETE:"complete",CONTINUE:"\
|
|
4153
|
+
continue"}),s$e=Object.freeze({additionalProperties:!1,properties:{kind:{enum:Object.values(p5),type:"string"},message:{
|
|
4153
4154
|
description:"Normal Markdown shown to the user for this task turn.",type:"string"},report:{description:"A concise factua\
|
|
4154
4155
|
l handoff for the main conversation when the task is complete; otherwise an empty string.",type:"string"}},required:["ki\
|
|
4155
|
-
nd","message","report"],type:"object"});var
|
|
4156
|
+
nd","message","report"],type:"object"});var f5=Object.freeze({RESTRICTED:"vibe64_assistant_owner_required",UNAVAILABLE:"vibe64_assistant_connection_unavailable"});var m$e=Object.freeze({additionalProperties:!1,properties:Object.freeze({suggestions:Object.freeze({items:Object.freeze(
|
|
4156
4157
|
{additionalProperties:!1,properties:Object.freeze({label:Object.freeze({maxLength:24,minLength:1,type:"string"}),prompt:Object.
|
|
4157
4158
|
freeze({maxLength:108,minLength:1,type:"string"})}),required:Object.freeze(["label","prompt"]),type:"object"}),maxItems:3,
|
|
4158
|
-
minItems:3,type:"array"})}),required:Object.freeze(["suggestions"]),type:"object"}),
|
|
4159
|
+
minItems:3,type:"array"})}),required:Object.freeze(["suggestions"]),type:"object"}),h$e=Object.freeze({existingProject:Object.
|
|
4159
4160
|
freeze([Object.freeze({label:"Tour this project",prompt:"Give me a quick tour of this project"}),Object.freeze({label:"F\
|
|
4160
4161
|
ind first improvement",prompt:"What should I improve first?"}),Object.freeze({label:"Plan safe change",prompt:"Help me p\
|
|
4161
4162
|
lan a small safe change"})]),greenfield:Object.freeze([Object.freeze({label:"Shape app idea",prompt:"Help me shape my ap\
|
|
4162
4163
|
p idea"}),Object.freeze({label:"Plan first version",prompt:"Show me the simplest useful first version"}),Object.freeze({
|
|
4163
|
-
label:"Decide first steps",prompt:"What should we decide first?"})])});import{createHash as
|
|
4164
|
-
writeFile as
|
|
4164
|
+
label:"Decide first steps",prompt:"What should we decide first?"})])});import{createHash as h5,randomUUID as Gj}from"node:crypto";import{chmod as Wj,mkdir as g5,readFile as w5,rename as v5,unlink as y5,
|
|
4165
|
+
writeFile as _5}from"node:fs/promises";import Kj from"node:path";var th=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u,Vj=/^sha256:[a-f0-9]{64}$/u;function wt(e,t,r=400,n=null){let o=new Error(t);return o.code=e,o.statusCode=r,n&&(o.fieldErrors=n),o}var ob="opencode-native",Hj="glm-4.7-flash",m5=Object.freeze({anthropic:Object.freeze({billingLabel:"Usage-based API bil\
|
|
4165
4166
|
ling",defaultModelId:"claude-haiku-4-5",managementUrl:"https://platform.claude.com/settings/billing",ownerOnly:!1}),deepseek:Object.
|
|
4166
4167
|
freeze({billingLabel:"Usage-based API billing",defaultModelId:"deepseek-flash",managementUrl:"https://platform.deepseek.\
|
|
4167
4168
|
com/top_up",ownerOnly:!1}),opencode:Object.freeze({billingLabel:"Usage-based Zen API billing",defaultModelId:"claude-hai\
|
|
@@ -4174,23 +4175,23 @@ ownerOnly:!1,productLabel:"GLM-4.7 Flash \xB7 Regular Z.AI API",routeLabel:"Regu
|
|
|
4174
4175
|
rsonal Coding Plan quota."}),"zai-coding-plan":Object.freeze({billingLabel:"Coding Plan quota",defaultModelId:"glm-5.3-f\
|
|
4175
4176
|
lash",managementUrl:"https://z.ai/subscribe",ownerOnly:!0,productLabel:"GLM \xB7 Personal Coding Plan",routeLabel:"Z.AI \
|
|
4176
4177
|
Personal Coding Plan"})});function ns(e=""){return String(e??"").trim()}function ib(e={}){let t=ns(e.id||e.modelProviderId);
|
|
4177
|
-
if(!t)throw wt("vibe64_ai_provider_unknown","Choose a provider from the current OpenCode catalog.");let r=
|
|
4178
|
+
if(!t)throw wt("vibe64_ai_provider_unknown","Choose a provider from the current OpenCode catalog.");let r=m5[t]||{},n=ns(
|
|
4178
4179
|
r.defaultModelId||e.defaultModelId);if(!n)throw wt("vibe64_ai_provider_default_model_missing","OpenCode did not identify\
|
|
4179
4180
|
a default model for this provider.",409);let o=r.ownerOnly!==!1;return{accessLabel:o?"Personal use":"Workspace use",billingLabel:ns(
|
|
4180
4181
|
r.billingLabel)||"Provider API key",canonicalUrl:"",defaultModelId:n,endpointCode:ob,managementUrl:ns(r.managementUrl),modelAccess:r.
|
|
4181
4182
|
modelAccess?{...r.modelAccess}:null,modelProviderId:t,ownerOnly:o,productLabel:ns(r.productLabel||e.label)||t,routeLabel:ns(
|
|
4182
|
-
r.routeLabel||r.productLabel||e.label)||t,routeNote:ns(r.routeNote)}}var
|
|
4183
|
-
elling","complete","failed","interrupted","running","starting"]),sc="zai",
|
|
4183
|
+
r.routeLabel||r.productLabel||e.label)||t,routeNote:ns(r.routeNote)}}var b5=5,kn="opencode",I5="big-pickle",S5=2e3,Jj=new Set(["all","recommended","verified"]),A5=new Set(["cancelled","canc\
|
|
4184
|
+
elling","complete","failed","interrupted","running","starting"]),sc="zai",E5=16384,x5=160;function De(e=""){return String(
|
|
4184
4185
|
e??"").trim()}function ab(e=""){return Array.from(e).some(t=>{let r=t.codePointAt(0);return r<32||r===127})}function tl(e=""){
|
|
4185
|
-
let t=De(e);if(!th.test(t))throw wt("vibe64_ai_provider_invalid","AI provider id is invalid.",400);return t}function
|
|
4186
|
+
let t=De(e);if(!th.test(t))throw wt("vibe64_ai_provider_invalid","AI provider id is invalid.",400);return t}function T5(e=""){
|
|
4186
4187
|
let t=De(e);if(!Vj.test(t))throw wt("vibe64_ai_provider_revision_invalid","Refresh the provider catalog before saving th\
|
|
4187
|
-
is API key.",409);return t}function
|
|
4188
|
-
throw wt("vibe64_ai_api_key_invalid","API key is invalid.",400);return t}function
|
|
4189
|
-
t);let r=typeof e=="string"?e.trim():"";if(!r||Array.from(r).length>
|
|
4190
|
-
"AI provider label is invalid.",400);return r}function Xj(e="",t=""){return`sha256:${
|
|
4188
|
+
is API key.",409);return t}function C5(e=""){let t=typeof e=="string"?e.trim():"";if(!t||Array.from(t).length>E5||ab(t))
|
|
4189
|
+
throw wt("vibe64_ai_api_key_invalid","API key is invalid.",400);return t}function R5(e="",t=""){if(e==null||e==="")return De(
|
|
4190
|
+
t);let r=typeof e=="string"?e.trim():"";if(!r||Array.from(r).length>x5||ab(r))throw wt("vibe64_ai_provider_label_invalid",
|
|
4191
|
+
"AI provider label is invalid.",400);return r}function Xj(e="",t=""){return`sha256:${h5("sha256").update(`${e}\0${t}`).digest(
|
|
4191
4192
|
"hex")}`}function os(e=null){return[...new Set((Array.isArray(e)?e:[]).map(De).filter(t=>t&&t.length<=256&&!ab(t)))]}function rl(e=0){
|
|
4192
4193
|
let t=Number(e);return Number.isSafeInteger(t)&&t>=0?t:0}function cb(e=null){if(!e||typeof e!="object"||Array.isArray(e))
|
|
4193
|
-
return null;let t=De(e.status);return
|
|
4194
|
+
return null;let t=De(e.status);return A5.has(t)?{checked:rl(e.checked),currentModelId:De(e.currentModelId).slice(0,256),
|
|
4194
4195
|
enabled:rl(e.enabled),finishedAt:De(e.finishedAt),id:De(e.id),message:De(e.message).slice(0,320),rejected:rl(e.rejected),
|
|
4195
4196
|
retryable:rl(e.retryable),startedAt:De(e.startedAt),status:t,total:rl(e.total),updatedAt:De(e.updatedAt)}:null}function Yo(e={},t=""){
|
|
4196
4197
|
try{let r=ib({defaultModelId:e.defaultModelId,id:t,label:e.productLabel||e.label}),n=typeof e.ownerOnly=="boolean"?e.ownerOnly:
|
|
@@ -4206,7 +4207,7 @@ modelAccessUnlocked===!0,ownerOnly:a.ownerOnly===!1?!1:d?.ownerOnly!==!1,product
|
|
|
4206
4207
|
De(a.label)||s,providerRevision:De(a.providerRevision),updatedAt:De(a.updatedAt),...s===kn?{zenEnabledModelIds:os(a.zenEnabledModelIds),
|
|
4207
4208
|
zenModelAccessMode:Jj.has(De(a.zenModelAccessMode))?De(a.zenModelAccessMode):"recommended",zenModelCheck:cb(a.zenModelCheck)}:
|
|
4208
4209
|
{}}}let o=De(t.preferredProviderId),i=th.test(o)?o:Object.hasOwn(n,sc)?sc:"";return{connections:n,preferredProviderId:i,
|
|
4209
|
-
updatedAt:De(t.updatedAt),version:
|
|
4210
|
+
updatedAt:De(t.updatedAt),version:b5}}function Yj(e={},t="",{activeZenCheck:r=!1}={}){if(t===kn){let n=Jj.has(De(e.zenModelAccessMode))?
|
|
4210
4211
|
De(e.zenModelAccessMode):"recommended",o=cb(e.zenModelCheck);return{check:o&&["starting","running","cancelling"].includes(
|
|
4211
4212
|
o.status)&&!r?{...o,currentModelId:"",message:"The previous model check stopped when Vibe64 restarted.",status:"interrup\
|
|
4212
4213
|
ted"}:o,configurable:!0,enabledModelIds:os([Yo(e,t)?.defaultModelId,...n==="verified"?e.zenEnabledModelIds:[]]),label:"Z\
|
|
@@ -4218,7 +4219,7 @@ fingerprint:De(e.fingerprint),id:t,keyHint:n.length>4?`\u2022\u2022\u2022\u2022$
|
|
|
4218
4219
|
label:De(e.label)||t,managementUrl:o?.managementUrl||"",modelProviderId:t,modelAccess:i||null,ownerOnly:o?.ownerOnly!==!1,
|
|
4219
4220
|
preferred:e.preferred===!0,productLabel:o?.productLabel||"Unconfirmed provider route",providerRevision:De(e.providerRevision),
|
|
4220
4221
|
removable:!0,updatedAt:De(e.updatedAt)}}function Pn(e={},t=""){let r=e.connections?.[t]||null;return r?{...r,preferred:e.
|
|
4221
|
-
preferredProviderId===t}:null}async function
|
|
4222
|
+
preferredProviderId===t}:null}async function O5({apiKey:e,policy:t,verifyConnection:r}={}){try{if((await r({apiKey:e,engineId:"\
|
|
4222
4223
|
opencode",modelId:t.defaultModelId,modelProviderId:t.modelProviderId}))?.ok!==!0)throw Object.assign(new Error("OpenCode\
|
|
4223
4224
|
verification did not complete."),{retryable:!0,statusCode:503})}catch(n){if(Number(n?.statusCode)===409||n?.code==="vib\
|
|
4224
4225
|
e64_assistant_catalog_stale")throw wt("vibe64_ai_provider_policy_stale",`${t.productLabel} changed in OpenCode. Refresh \
|
|
@@ -4229,13 +4230,13 @@ thing was saved; try again later.`;throw wt("vibe64_ai_key_verification_unavaila
|
|
|
4229
4230
|
Nothing was saved. Check billing and quota, then try again.`:`${t.productLabel} rejected this key or could not complete\
|
|
4230
4231
|
a test request. Check the key, billing, and quota, then try again.`;throw wt("vibe64_ai_api_key_rejected",s,422,{apiKey:s})}}
|
|
4231
4232
|
function rh({filePath:e="",onConnectionChanged:t=()=>null,withConnectionChange:r=async(s,a)=>a(),readModelIds:n=null,verifyConnection:o=null,
|
|
4232
|
-
zenModelCheckDelayMs:i=
|
|
4233
|
+
zenModelCheckDelayMs:i=S5}={}){if(!De(e))throw new TypeError("AI connections require a private store path.");if(typeof o!=
|
|
4233
4234
|
"function")throw new TypeError("AI connections require OpenCode key verification.");let s=Kj.resolve(e),a=new Map,c=Promise.
|
|
4234
|
-
resolve();async function d(){try{return sb(JSON.parse(await
|
|
4235
|
+
resolve();async function d(){try{return sb(JSON.parse(await w5(s,"utf8")))}catch(v){if(v?.code==="ENOENT")return sb({});
|
|
4235
4236
|
throw v instanceof SyntaxError?wt("vibe64_ai_connection_state_malformed","AI connection state is not valid JSON.",500):v}}
|
|
4236
|
-
async function u(v={}){let w=sb(v),m=Kj.dirname(s);await
|
|
4237
|
-
pid}.${Gj()}.tmp`;try{await
|
|
4238
|
-
`,{encoding:"utf8",mode:384}),await
|
|
4237
|
+
async function u(v={}){let w=sb(v),m=Kj.dirname(s);await g5(m,{mode:448,recursive:!0}),await Wj(m,448);let _=`${s}.${process.
|
|
4238
|
+
pid}.${Gj()}.tmp`;try{await _5(_,`${JSON.stringify(w,null,2)}
|
|
4239
|
+
`,{encoding:"utf8",mode:384}),await v5(_,s),await Wj(s,384)}catch(I){throw await y5(_).catch(()=>null),I}return w}function l(v){
|
|
4239
4240
|
let w=c.catch(()=>null).then(async()=>{let m=await d();if(Object.values(m.connections).some(_=>Object.hasOwn(_,"helperMo\
|
|
4240
4241
|
delId")))throw wt("vibe64_ai_routing_upgrade_required","Stop the services and run the application state upgrade before c\
|
|
4241
4242
|
hanging AI connections.",409);return v()});return c=w.catch(()=>null),w}function p(){let v=Math.max(0,Number(i)||0);return v?
|
|
@@ -4244,7 +4245,7 @@ connections[kn];if(!_||_.fingerprint!==v.fingerprint||_.zenModelCheck?.id!==v.id
|
|
|
4244
4245
|
toISOString();return _.zenModelCheck.updatedAt=x,m.updatedAt=x,await u(m),_})}async function y(v,w,m=""){await f(v,_=>{_.
|
|
4245
4246
|
zenModelCheck.currentModelId="",_.zenModelCheck.finishedAt=new Date().toISOString(),_.zenModelCheck.message=De(m).slice(
|
|
4246
4247
|
0,320),_.zenModelCheck.status=w}),a.get(kn)===v&&a.delete(kn)}async function h(v){try{let w=os(await n()),m=Yo({},kn)?.defaultModelId,
|
|
4247
|
-
_=w.filter(x=>x!==
|
|
4248
|
+
_=w.filter(x=>x!==I5&&x!==m).sort((x,C)=>x.localeCompare(C));if(!await f(v,x=>{x.zenModelCheck.currentModelId=_[0]||"",x.
|
|
4248
4249
|
zenModelCheck.status="running",x.zenModelCheck.total=_.length}))return;for(let[x,C]of _.entries()){if(v.cancelled){await y(
|
|
4249
4250
|
v,"cancelled","Model checking was cancelled.");return}let T=!1,M=!1;try{T=(await o({apiKey:v.apiKey,engineId:"opencode",
|
|
4250
4251
|
modelId:C,modelProviderId:kn}))?.ok===!0,M=!T}catch(X){M=X?.retryable===!0||Number(X?.statusCode)>=500}let L=_[x+1]||"";
|
|
@@ -4264,13 +4265,13 @@ removed"};return await r(x,()=>u(m)),await t(x),{id:w,ok:!0,removed:!0}})},async
|
|
|
4264
4265
|
_=Pn(m,w);if(!_)return null;let I=Yo(_,w);if(!I)throw wt("vibe64_ai_endpoint_selection_required","The owner must choose \
|
|
4265
4266
|
this provider's billing endpoint before it can be used.",409);return{apiKey:_.apiKey,canonicalUrl:"",defaultModelId:I.defaultModelId,
|
|
4266
4267
|
endpointCode:I.endpointCode,fingerprint:_.fingerprint,modelProviderId:w,providerRevision:_.providerRevision}},async upsertConnection(v={},{
|
|
4267
|
-
provider:w=null}={}){let m=tl(v.modelProviderId||v.providerId||v.id),_=
|
|
4268
|
+
provider:w=null}={}){let m=tl(v.modelProviderId||v.providerId||v.id),_=C5(v.apiKey),I=T5(v.providerRevision);if(m===kn&&
|
|
4268
4269
|
_==="public")throw wt("vibe64_ai_public_key_unsupported","Vibe64 does not use OpenCode Zen's account-free access. Paste \
|
|
4269
4270
|
your Zen API key.",400,{apiKey:"Paste your own OpenCode Zen API key."});if(De(w?.id)!==m||De(w?.definitionRevision)!==I)
|
|
4270
4271
|
throw wt("vibe64_ai_provider_revision_changed","Refresh the provider catalogue before saving this API key.",409);let x=ib(
|
|
4271
|
-
w);return l(async()=>{await
|
|
4272
|
+
w);return l(async()=>{await O5({apiKey:_,policy:x,verifyConnection:o});let C=await d(),T=C.connections[m]||null,M=new Date().
|
|
4272
4273
|
toISOString(),L=Xj(m,_),K=T?.fingerprint===L,X=a.get(m);X&&(X.cancelled=!0,a.delete(m));let se={apiKey:_,billingLabel:x.
|
|
4273
|
-
billingLabel,createdAt:De(T?.createdAt)||M,defaultModelId:x.defaultModelId,endpointCode:x.endpointCode,fingerprint:L,label:
|
|
4274
|
+
billingLabel,createdAt:De(T?.createdAt)||M,defaultModelId:x.defaultModelId,endpointCode:x.endpointCode,fingerprint:L,label:R5(
|
|
4274
4275
|
v.label,De(T?.label)||x.productLabel||m),managementUrl:x.managementUrl,modelAccessUnlocked:T?.modelAccessUnlocked===!0,ownerOnly:x.
|
|
4275
4276
|
ownerOnly,productLabel:x.productLabel,providerRevision:I,updatedAt:M,...m===kn?{zenEnabledModelIds:K?os(T.zenEnabledModelIds):
|
|
4276
4277
|
[],zenModelAccessMode:K?T.zenModelAccessMode:"recommended",zenModelCheck:K?cb(T.zenModelCheck):null}:{}};C.connections[m]=
|
|
@@ -4302,13 +4303,13 @@ all"?"all":"recommended",M=new Date().toISOString();return C.zenEnabledModelIds=
|
|
|
4302
4303
|
["starting","running","cancelling"].includes(C.zenModelCheck.status)&&(C.zenModelCheck.currentModelId="",C.zenModelCheck.
|
|
4303
4304
|
finishedAt=M,C.zenModelCheck.message=_==="enable-all"?"The check stopped because all current Zen models were enabled.":"\
|
|
4304
4305
|
The check stopped because additional Zen models were disabled.",C.zenModelCheck.status="cancelled",C.zenModelCheck.updatedAt=
|
|
4305
|
-
M),C.updatedAt=M,x.updatedAt=M,await u(x),await t({modelProviderId:m,reason:"model-access-updated"}),Xo(Pn(x,m),m,{activeZenCheck:!1})})}})}var
|
|
4306
|
-
isArray(e),Kr=e=>JSON.stringify([e.engineId,e.modelProviderId,e.modelId]),
|
|
4306
|
+
M),C.updatedAt=M,x.updatedAt=M,await u(x),await t({modelProviderId:m,reason:"model-access-updated"}),Xo(Pn(x,m),m,{activeZenCheck:!1})})}})}var k5="gpt-5.6-luna",N5="haiku",db=["plan","code","economy","router","sharedBackup"],ub=e=>e&&typeof e=="object"&&!Array.
|
|
4307
|
+
isArray(e),Kr=e=>JSON.stringify([e.engineId,e.modelProviderId,e.modelId]),j5=e=>P5("sha256").update(e).digest("hex"),Zj=e=>`${JSON.
|
|
4307
4308
|
stringify(e,null,2)}
|
|
4308
4309
|
`;function nh(e,t){return(Y_.models.find(n=>["engineId","modelProviderId","modelId"].every(o=>n[o]===e[o]))?.scores||Y_.
|
|
4309
4310
|
defaultScores)[t==="sharedBackup"?"economy":t]}function nl(e,t,r,n=""){let o={schema:"vibe64.assistant-selection.v1",engineId:e,
|
|
4310
|
-
modelProviderId:t,modelId:r,variantId:n,agentId:e==="opencode"?"build":e};return{...o,catalogRevision:`sha256:${
|
|
4311
|
-
stringify(o))}`,selectionSource:"recommended"}}function
|
|
4311
|
+
modelProviderId:t,modelId:r,variantId:n,agentId:e==="opencode"?"build":e};return{...o,catalogRevision:`sha256:${j5(JSON.
|
|
4312
|
+
stringify(o))}`,selectionSource:"recommended"}}function M5({configuration:e,nativeHelpers:t={},connections:r=[],curatedConnections:n=[],
|
|
4312
4313
|
historicalSelections:o=[]}){if([3,4].includes(e?.schemaVersion)){if((e.schemaVersion===3?Oi:_r)(e),Object.keys(t).length||
|
|
4313
4314
|
r.some(d=>d.helperModelId))throw new Error("Current model routing coexists with legacy helper settings. Inspect the reta\
|
|
4314
4315
|
ined choices before upgrading.");return e}if(e&&Ri(e,{legacy:!0}),e?.schemaVersion===2&&!Object.keys(t).length&&!r.some(
|
|
@@ -4325,7 +4326,7 @@ u=>u.connected)){let u=new Set([d.economyModelId,d.helperModelId,...d.modelAcces
|
|
|
4325
4326
|
includes(l)||c(nl("opencode",d.id,l),d.ownerOnly===!1,d.id==="opencode"&&l==="big-pickle")}for(let d of Object.values(s))
|
|
4326
4327
|
for(let u of db){let l=d[u];if(!l)continue;l.selectionSource||="explicit";let p=a.get(Kr(l));c(l,p?.shared===!0,p?.backupEligible===
|
|
4327
4328
|
!0||["plan","code"].includes(u))}for(let[d,u]of Object.entries(s)){let l=[];if(["codex","claude"].includes(d)){let y=d===
|
|
4328
|
-
"codex"?"openai":"anthropic",h=d==="codex"?
|
|
4329
|
+
"codex"?"openai":"anthropic",h=d==="codex"?k5:N5,v=t[d]?.modelId;if(t[d]||Object.values(u).some(w=>w?.modelProviderId===
|
|
4329
4330
|
y)){let w=v||h,m=[...a.values()].filter(({selection:I})=>I.engineId===d&&I.modelId===w),_=m.length===1?m[0].selection.modelProviderId:
|
|
4330
4331
|
y;l.push({engineId:d,modelProviderId:_,modelId:w,selectionSource:v?"explicit":"default"}),w===h&&c(nl(d,y,w,"low"),!1)}if(d===
|
|
4331
4332
|
"codex")for(let w of rn)n.some(m=>m.id===w.id&&m.connected)&&l.push({engineId:d,modelProviderId:w.id,modelId:w.models[0].
|
|
@@ -4340,7 +4341,7 @@ sort((v,w)=>nh(w,"sharedBackup")-nh(v,"sharedBackup")||Kr(v).localeCompare(Kr(w)
|
|
|
4340
4341
|
reason:"legacy_helpers_differ",previous:p,proposed:u.economy||null});for(let y of db)u[y]??=null}return e?.schemaVersion===
|
|
4341
4342
|
2&&JSON.stringify(e.orchestrators)===JSON.stringify(s)?e:Ri({schemaVersion:2,revision:(e?.revision||0)+1,orchestrators:s})}
|
|
4342
4343
|
function oh(e,t){if(e===null)return null;try{let r=JSON.parse(e);if(ub(r))return r}catch{}throw new Error(`${t} is inval\
|
|
4343
|
-
id. Inspect it before upgrading routing.`)}async function
|
|
4344
|
+
id. Inspect it before upgrading routing.`)}async function L5(e,t,r){let n=ih.join(e,"ai-connections/routing.json"),o=ih.
|
|
4344
4345
|
join(e,"ai-connections/connections.json");await ge(e,n);let i=await Ae(n),s=await Ae(o),a=oh(s,"AI connections");if(a&&(!Number.
|
|
4345
4346
|
isInteger(a.version)||a.version<1||a.version>5||!ub(a.connections)||Object.values(a.connections).some(v=>!ub(v)||typeof v.
|
|
4346
4347
|
apiKey!="string"||!v.apiKey||v.helperModelId!==void 0&&(typeof v.helperModelId!="string"||v.helperModelId.length>512||[...v.
|
|
@@ -4353,12 +4354,12 @@ let u=await Promise.all(rn.map(async v=>{let w=Hn(e,v.id,"codex"),m=await Ae(w.c
|
|
|
4353
4354
|
torical curated provider connection"),I=_&&typeof _.apiKey=="string"&&_.apiKey,x=I?await Ws(w.systemRoot):null;return{id:v.
|
|
4354
4355
|
id,connected:!!(I&&!_.codexDisabled&&!x),claudeReady:!!(I&&_.claudeReady&&!x)}}));if(!(i!==null||a||t.length||d.length||
|
|
4355
4356
|
u.some(v=>v.connected)||await Ae(_n(e))!==null))return[];let p=await rh({filePath:o,verifyConnection:()=>{throw new Error(
|
|
4356
|
-
"Offline routing upgrade cannot call a provider.")}}).listConnections().then(
|
|
4357
|
+
"Offline routing upgrade cannot call a provider.")}}).listConnections().then($5).then(v=>v.map(w=>({...w,economyModelId:a?.
|
|
4357
4358
|
connections[w.id]?.economyModelId||w.defaultModelId,helperModelId:a?.connections[w.id]?.helperModelId||""}))),f=oh(i,"Mo\
|
|
4358
|
-
del routing"),y=
|
|
4359
|
+
del routing"),y=M5({configuration:f,nativeHelpers:c,connections:p,curatedConnections:u,historicalSelections:r}),h=[{filePath:n,
|
|
4359
4360
|
original:i,contents:y===f?i:Zj(y)}];if(a){let v=structuredClone(a);for(let w of Object.values(v.connections))delete w.helperModelId;
|
|
4360
4361
|
JSON.stringify(v)!==JSON.stringify(a)&&d.unshift({filePath:o,original:s,contents:Zj(v)})}return{updates:h,retired:d,configuration:y}}
|
|
4361
|
-
function
|
|
4362
|
+
function $5(e){let t=e.map(o=>({...o,builtIn:!1})),r={configurable:!1,enabledModelIds:["big-pickle"],mode:"recommended",
|
|
4362
4363
|
recommendedModelId:"big-pickle"},n=t.find(({id:o})=>o==="opencode");return n?t.map(o=>o!==n?o:{...o,modelAccess:o.modelAccess&&
|
|
4363
4364
|
{...o.modelAccess,recommendedModelId:"big-pickle",enabledModelIds:["big-pickle",...o.modelAccess.mode==="verified"?o.modelAccess.
|
|
4364
4365
|
enabledModelIds.slice(1):[]]}}):[...t,{id:"opencode",modelProviderId:"opencode",builtIn:!0,connected:!0,defaultModelId:"\
|
|
@@ -4367,10 +4368,10 @@ prepareUpdates:async n=>{let o=await ut(t),i=[],s=[];for(let d of o){let l=await
|
|
|
4367
4368
|
prepareAssistantRoutingStateUpgrade({temporaryRoot:n,transform:p=>{let f=$j(p);p.renewal?.successor?.assistantSelection&&
|
|
4368
4369
|
s.push(Hr(p.renewal.successor.assistantSelection)),p.metadata.assistant_selection&&s.push(Hr(JSON.parse(p.metadata.assistant_selection)));
|
|
4369
4370
|
for(let y of p.conversations)y.assistantSelection&&s.push(Hr(y.assistantSelection));return f}});l.length&&r("info",`${ih.
|
|
4370
|
-
basename(d)}: ${l.length} routing state file(s) to upgrade.`),i.push(...l)}let a=await
|
|
4371
|
+
basename(d)}: ${l.length} routing state file(s) to upgrade.`),i.push(...l)}let a=await L5(t,o,s),c=[...a.updates||[],...i,
|
|
4371
4372
|
...a.retired||[]];for(let[d,u]of Object.entries(a.configuration?.orchestrators||{}))u.helperRoutingReview&&r("warning",`${d}\
|
|
4372
4373
|
: old helpers differ from Economy. The owner must review helper routing before those helpers run.`),u.sharedBackup||r("w\
|
|
4373
|
-
arning",`${d}: choose a shared Backup in Model routing to enable personal-access substitution.`);return c}})}import{lstat as rM,readFile as
|
|
4374
|
+
arning",`${d}: choose a shared Backup in Model routing to enable personal-access substitution.`);return c}})}import{lstat as rM,readFile as D5,readdir as eM}from"node:fs/promises";import is from"node:path";var Nn=e=>e&&typeof e=="object"&&!Array.isArray(e),lb=e=>`${JSON.stringify(e,null,2)}
|
|
4374
4375
|
`;function nM(e){if(!Nn(e))throw new Error("Saved model assignments must be an object.");let t={...e};if(Object.hasOwn(t,
|
|
4375
4376
|
"intern")){if(Object.hasOwn(t,"helper"))throw new Error("Both previous and current Helper assignments exist. Resolve the\
|
|
4376
4377
|
conflict before upgrading.");t.helper=t.intern,delete t.intern}return t}function oM(e){if(!Nn(e)||!Nn(e.orchestrators)||
|
|
@@ -4399,11 +4400,11 @@ decision.backupUsed,backupReason:a.decision.backupReason};a.decision.workflowEng
|
|
|
4399
4400
|
{senior:d,junior:d},a.assignments={...a.assignments,senior:c,junior:c}}return a}function tM(e){let t={};for(let r of["as\
|
|
4400
4401
|
sistant_routing","assistant_routing_request","assistant_routing_goal"]){if(!e[r])continue;let n=JSON.parse(e[r]);if(n===
|
|
4401
4402
|
null)continue;let o=ol(n,{preferences:r==="assistant_routing"});JSON.stringify(n)!==JSON.stringify(o)&&(t[r]=JSON.stringify(
|
|
4402
|
-
o))}return t}function
|
|
4403
|
+
o))}return t}function U5({metadata:e,conversations:t,renewal:r}){let n={metadata:tM(e),conversations:t.map(o=>{let i={...o};
|
|
4403
4404
|
return o.routingMetadata&&(i.routingMetadata={...o.routingMetadata,...tM(o.routingMetadata)}),i})};return r?.successor?.
|
|
4404
4405
|
assistantRouting&&(n.renewal={...r,successor:{...r.successor,assistantRouting:ol(r.successor.assistantRouting,{preferences:!0})}}),
|
|
4405
|
-
n}function
|
|
4406
|
-
try{if(!(await rM(e)).isFile())throw new Error(`Upgrade requires a regular file: ${e}`);return await
|
|
4406
|
+
n}function z5(e){return e.assistantRouting?{...e,assistantRouting:ol(e.assistantRouting,{history:!0})}:e}async function sh(e){
|
|
4407
|
+
try{if(!(await rM(e)).isFile())throw new Error(`Upgrade requires a regular file: ${e}`);return await D5(e,"utf8")}catch(t){
|
|
4407
4408
|
if(t.code==="ENOENT")return null;throw t}}async function iM(e){let{systemRoot:t,report:r}=e;return xe({...e,prepareUpdates:async n=>{
|
|
4408
4409
|
let o=[],i=is.join(t,"ai-connections/routing.json"),s=await sh(i);if(s!==null){let d=JSON.parse(s);if(d.schemaVersion<3){
|
|
4409
4410
|
if(e.apply)throw new Error("Run the preceding model-routing upgrades first.");return r("info","Earlier upgrades will pre\
|
|
@@ -4414,7 +4415,7 @@ e an unsupported shape.");let u=!1;for(let l of Object.values(d.connections))if(
|
|
|
4414
4415
|
defaultModelId!==void 0&&l.defaultModelId!==l.economyModelId)throw new Error("Provider defaults conflict. Review AI conn\
|
|
4415
4416
|
ections before upgrading.");l.defaultModelId=l.economyModelId,delete l.economyModelId,u=!0}u&&o.push({filePath:a,original:c,
|
|
4416
4417
|
contents:lb(d)})}for(let d of await ut(t)){let l=await gt({projectContextRoot:d,projectRuntimeRoot:d}).prepareAssistantRoutingStateUpgrade(
|
|
4417
|
-
{temporaryRoot:n,transform:
|
|
4418
|
+
{temporaryRoot:n,transform:U5,transformTurnMetadata:z5,transformHelperRecord:ac});o.push(...l);let p=is.join(d,"codex-ec\
|
|
4418
4419
|
onomy-thread-ownership"),f=[];try{if(!(await rM(p)).isDirectory())throw new Error("Helper ownership must be a regular di\
|
|
4419
4420
|
rectory.");f=await eM(p,{withFileTypes:!0})}catch(y){if(y.code!=="ENOENT")throw y}for(let y of f){if(y.isDirectory()&&y.
|
|
4420
4421
|
name===".locks"){if((await eM(is.join(p,y.name))).length)throw new Error("Stop helper writers and resolve retained owner\
|
|
@@ -4427,9 +4428,9 @@ I=await sh(w);if(I!==null&&I!==_)throw new Error("Conflicting Helper ownership r
|
|
|
4427
4428
|
ng.");o.push({filePath:w,original:I,contents:_},{filePath:h,original:v,contents:null})}(l.length||f.length)&&r("info",`${is.
|
|
4428
4429
|
basename(d)}: converting saved Helper settings and ownership.`)}return r("info","Helper keeps the saved model and thinki\
|
|
4429
4430
|
ng. Former third-role chats switch to Junior; accepted work and authored messages retain their destination and identity."),
|
|
4430
|
-
o}})}import{lstat as sM,readFile as
|
|
4431
|
+
o}})}import{lstat as sM,readFile as F5}from"node:fs/promises";import pb from"node:path";var il={plan:"senior",code:"junior",economy:"intern"},B5=new Set(["senior","junior","intern","router","auto","review","d\
|
|
4431
4432
|
eslop"]),cc=e=>e&&typeof e=="object"&&!Array.isArray(e);function aM(e){if(e==="")return e;let t=Object.hasOwn(il,e)?il[e]:
|
|
4432
|
-
e;if(!
|
|
4433
|
+
e;if(!B5.has(t))throw new Error("Routing contains an unknown model role. Inspect the saved routing before upgrading.");return t}
|
|
4433
4434
|
function fb(e){if(!cc(e))throw new Error("Routing assignments must be an object.");let t=Object.create(null);for(let[r,n]of Object.
|
|
4434
4435
|
entries(e)){let o=Object.hasOwn(il,r)?il[r]:r;if(Object.hasOwn(t,o))throw new Error("Routing contains both old and new n\
|
|
4435
4436
|
ames for one role. Resolve the conflict before upgrading.");t[o]=n}return t.helperRoutingReview?.reason==="legacy_helper\
|
|
@@ -4448,14 +4449,14 @@ fb(t.planCodePair),delete t.planCodePair}return t.continuation==="plan"&&(t.cont
|
|
|
4448
4449
|
for(let r of["assistant_routing","assistant_routing_request","assistant_routing_goal"]){if(!e[r])continue;let n;try{n=JSON.
|
|
4449
4450
|
parse(e[r])}catch{throw new Error(`Invalid ${r}. Inspect the saved routing before upgrading.`)}if(n===null)continue;let o=r===
|
|
4450
4451
|
"assistant_routing"&&["senior","junior","custom","auto"].includes(n.mode)?xr(n,{preferences:!0}):sl(n);JSON.stringify(o)!==
|
|
4451
|
-
JSON.stringify(n)&&(t[r]=JSON.stringify(o))}return t}function
|
|
4452
|
+
JSON.stringify(n)&&(t[r]=JSON.stringify(o))}return t}function q5({metadata:e,conversations:t,renewal:r}){for(let n of t)
|
|
4452
4453
|
if(n.routingMetadata!==void 0&&!cc(n.routingMetadata))throw new Error("Temporary conversation routing metadata must be a\
|
|
4453
4454
|
n object. Inspect it before upgrading.");return{metadata:cM(e),conversations:t.map(n=>({...n,...n.routingMetadata?{routingMetadata:{
|
|
4454
4455
|
...n.routingMetadata,...cM(n.routingMetadata)}}:{}})),...r?.successor?.assistantRouting?{renewal:{...r,successor:{...r.successor,
|
|
4455
|
-
assistantRouting:sl(r.successor.assistantRouting)}}}:{}}}function
|
|
4456
|
+
assistantRouting:sl(r.successor.assistantRouting)}}}:{}}}function V5(e){return e.assistantRouting?{...e,assistantRouting:sl(
|
|
4456
4457
|
e.assistantRouting)}:e}async function uM(e){let{systemRoot:t,report:r}=e;return xe({...e,prepareUpdates:async n=>{let o=[],
|
|
4457
4458
|
i=pb.join(t,"ai-connections","routing.json"),s;try{if(!(await sM(pb.dirname(i))).isDirectory()||!(await sM(i)).isFile())
|
|
4458
|
-
throw new Error("Model routing must be a regular file in a regular directory.");s=await
|
|
4459
|
+
throw new Error("Model routing must be a regular file in a regular directory.");s=await F5(i,"utf8")}catch(a){if(a.code!==
|
|
4459
4460
|
"ENOENT")throw a}if(s!==void 0){let a;try{a=JSON.parse(s)}catch{throw new Error("Model routing is invalid JSON. Repair i\
|
|
4460
4461
|
t before upgrading roles.")}if(!cc(a))throw new Error("Model routing must be an object. Repair it before upgrading roles\
|
|
4461
4462
|
.");if(a.schemaVersion===4)_r(a);else if(a.schemaVersion===3)Oi(a);else if(Ri(a,{legacy:!0}),a.schemaVersion===1){if(e.apply)
|
|
@@ -4463,10 +4464,10 @@ throw new Error("Run the preceding routing V2 upgrade before renaming roles.");r
|
|
|
4463
4464
|
e will prepare the older configuration first.")}else{let c=Oi(dM(a));o.push({filePath:i,original:s,contents:`${JSON.stringify(
|
|
4464
4465
|
c,null,2)}
|
|
4465
4466
|
`})}}for(let a of await ut(t)){let d=await gt({projectContextRoot:a,projectRuntimeRoot:a}).prepareAssistantRoutingStateUpgrade(
|
|
4466
|
-
{temporaryRoot:n,transform:
|
|
4467
|
+
{temporaryRoot:n,transform:q5,transformTurnMetadata:V5});d.length&&r("info",`${pb.basename(a)}: ${d.length} routing meta\
|
|
4467
4468
|
data/history file(s) to rename.`),o.push(...d)}return r("info","Senior, Junior and Intern preserve model selections, req\
|
|
4468
|
-
uest receipts and message contents. Native provider histories are unchanged."),o}})}import{createHash as
|
|
4469
|
-
08fc6a0650e707409bce5ef18f02f47eee69c3d570962e535ae46244a15fad63"},hb=e=>
|
|
4469
|
+
uest receipts and message contents. Native provider histories are unchanged."),o}})}import{createHash as H5}from"node:crypto";import{readFile as lM}from"node:fs/promises";import ah from"node:path";var mb={sessionId:"2026-09-26_13-48-46",messageId:"message_tab_6fd37be8-c0a2-4f0f-ad47-756fc8213580_mulardk5_2",revision:"\
|
|
4470
|
+
08fc6a0650e707409bce5ef18f02f47eee69c3d570962e535ae46244a15fad63"},hb=e=>H5("sha256").update(e).digest("hex");function G5(e,t,r){
|
|
4470
4471
|
if(t.messageId!==r.messageId||hb(e)!==r.revision)return null;if(t.mode!=="auto"||t.reason!=="discussion"||t.status!=="do\
|
|
4471
4472
|
ne"||t.workPlan?.status!=="drafting"||t.workPlan.revision!==r.revision||t.workPlan.text!==e||!e.startsWith(`Status: draf\
|
|
4472
4473
|
ting
|
|
@@ -4476,22 +4477,22 @@ ting
|
|
|
4476
4477
|
let{systemRoot:t,report:r}=e;await xe({...e,prepareUpdates:async()=>{let n=[];for(let o of await ut(t)){let s=gt({projectContextRoot:o,
|
|
4477
4478
|
projectRuntimeRoot:o}).paths(mb.sessionId),a=ah.join(s.sessionRoot,"work-plan/plan.md"),c;try{c=await lM(a,"utf8")}catch(p){
|
|
4478
4479
|
if(p.code==="ENOENT")continue;throw p}if(hb(c)!==mb.revision)continue;let d=ah.join(s.metadataRoot,"assistant_routing_re\
|
|
4479
|
-
quest"),u=await lM(d,"utf8"),l=
|
|
4480
|
+
quest"),u=await lM(d,"utf8"),l=G5(c,JSON.parse(u),mb);if(!l){r("warning",`${ah.basename(o)}: the affected plan has a new\
|
|
4480
4481
|
er request; leaving it unchanged for review.`);continue}r("warning",`${ah.basename(o)}: restoring the verified completed\
|
|
4481
4482
|
plan and its matching display snapshot; no conversation messages change.`),n.push({filePath:a,original:c,contents:l.plan},
|
|
4482
|
-
{filePath:d,original:u,contents:JSON.stringify(l.request)})}return n}})}import{createHash as
|
|
4483
|
+
{filePath:d,original:u,contents:JSON.stringify(l.request)})}return n}})}import{createHash as W5}from"node:crypto";import K5 from"node:path";function J5(e){let t=/^Status: (drafting|ready|blocked|paused|implemented|active|completed)\r?$/mu.exec(e)?.[1];if(!t)throw new Error(
|
|
4483
4484
|
"A saved plan has no recognized status. Inspect it before upgrading plans.");return e.replace(/^Status: .*\r?$/mu,`Statu\
|
|
4484
|
-
s: ${["implemented","completed"].includes(t)?"completed":"active"}`)}function
|
|
4485
|
-
let n=r.map(({conversationId:i,originalOld:s,original:a})=>{let c=
|
|
4485
|
+
s: ${["implemented","completed"].includes(t)?"completed":"active"}`)}function X5({metadata:e,conversations:t,plans:r=[]}){
|
|
4486
|
+
let n=r.map(({conversationId:i,originalOld:s,original:a})=>{let c=J5(s??a);if(s!==null&&a!==null&&a!==c)throw new Error(
|
|
4486
4487
|
"Both legacy and current plans exist with different contents. Resolve that conflict before upgrading.");return{conversationId:i,
|
|
4487
4488
|
text:c}});function o(i,s){if(!i?.assistant_routing_request)return{};let a=JSON.parse(i.assistant_routing_request);if(!a||
|
|
4488
4489
|
typeof a!="object"||Array.isArray(a))throw new Error("Invalid saved plan routing request.");let c=n.find(u=>u.conversationId===
|
|
4489
|
-
s),d={...a,workPlan:c?{text:c.text,status:/^Status: (active|completed)$/mu.exec(c.text)[1],revision:
|
|
4490
|
+
s),d={...a,workPlan:c?{text:c.text,status:/^Status: (active|completed)$/mu.exec(c.text)[1],revision:W5("sha256").update(
|
|
4490
4491
|
c.text).digest("hex")}:null};return JSON.stringify(d)===JSON.stringify(a)?{}:{assistant_routing_request:JSON.stringify(d)}}
|
|
4491
4492
|
return{plans:n,metadata:o(e,""),conversations:t.map(i=>({...i,...i.routingMetadata?{routingMetadata:{...i.routingMetadata,
|
|
4492
4493
|
...o(i.routingMetadata,i.conversationId)}}:{}}))}}async function fM(e){let{systemRoot:t,report:r}=e;return xe({...e,prepareUpdates:async n=>{
|
|
4493
4494
|
let o=[];for(let i of await ut(t)){let a=await gt({projectContextRoot:i,projectRuntimeRoot:i}).prepareAssistantRoutingStateUpgrade(
|
|
4494
|
-
{temporaryRoot:n,includePlans:!0,transform:
|
|
4495
|
+
{temporaryRoot:n,includePlans:!0,transform:X5});a.length&&r("info",`${K5.basename(i)}: preserving plans in plans/current\
|
|
4495
4496
|
.md and converting their explicit status; ${a.length} file(s).`),o.push(...a)}return r("info","Explicit implemented plan\
|
|
4496
4497
|
s become completed; other plans remain active. No completion is inferred from turn outcomes. Plan text and conversation \
|
|
4497
4498
|
history are preserved."),o}})}import{randomUUID as EI}from"node:crypto";import{lstat as Yr,mkdir as xI,readFile as bo,readdir as TI,rename as CI,rm as RI,
|
|
@@ -4508,16 +4509,16 @@ e.scopeId)||s.has(c.freshOperation.operationId)||!Array.isArray(c.unconfirmedMes
|
|
|
4508
4509
|
r(),s.add(c.freshOperation.operationId);let d=new Set;for(let u of c.unconfirmedMessages)(!u||typeof u.messageId!="strin\
|
|
4509
4510
|
g"||!u.messageId||u.messageId.length>128||typeof u.clientId!="string"||!u.clientId||u.clientId.length>128||typeof u.text!=
|
|
4510
4511
|
"string"||!u.text.trim()||u.text.length>24e3||u.source!=="client-reported"||u.status!=="unconfirmed"||d.has(u.messageId))&&
|
|
4511
|
-
r(),d.add(u.messageId)}}import{randomUUID as mI}from"node:crypto";import{glob as
|
|
4512
|
-
import{homedir as Uh}from"node:os";import Be from"node:path";import{isDeepStrictEqual as wi}from"node:util";import
|
|
4513
|
-
on"?ch[e]():null}function
|
|
4514
|
-
home:e.toolHomeSource,uid:e.uid,username:e.username}}}function
|
|
4515
|
-
function gb({env:e=ch.env,gid:t=hM("getgid"),home:r=
|
|
4516
|
-
systemRoot:s="",terminalEnv:a={},toolHomeSource:c="",uid:d=hM("getuid"),username:u=""}={}){let l=yt(n),p=
|
|
4517
|
-
f={...yt(ch.env),...yt(e),...yt(l.env)},y=
|
|
4512
|
+
r(),d.add(u.messageId)}}import{randomUUID as mI}from"node:crypto";import{glob as O7,lstat as Rd,open as P7,readdir as hI,realpath as pI}from"node:fs/promises";
|
|
4513
|
+
import{homedir as Uh}from"node:os";import Be from"node:path";import{isDeepStrictEqual as wi}from"node:util";import Y5 from"node:os";import mM from"node:path";import ch from"node:process";function Z5(e=""){let t=Oe(e);return t&&mM.isAbsolute(t)?mM.resolve(t):""}function hM(e=""){return typeof ch[e]=="functi\
|
|
4514
|
+
on"?ch[e]():null}function Q5(e={}){return{actor:"app",credentialScope:e.scope||"app",requiresRealUser:!1,user:{gid:e.gid,
|
|
4515
|
+
home:e.toolHomeSource,uid:e.uid,username:e.username}}}function eY(e=[]){let t=Array.isArray(e)?e:[];return Gn([..._u,...t])}
|
|
4516
|
+
function gb({env:e=ch.env,gid:t=hM("getgid"),home:r=Y5.homedir(),providerOptions:n={},requireSystemRoot:o=!1,shimDirs:i=[],
|
|
4517
|
+
systemRoot:s="",terminalEnv:a={},toolHomeSource:c="",uid:d=hM("getuid"),username:u=""}={}){let l=yt(n),p=eY(l.runtimes),
|
|
4518
|
+
f={...yt(ch.env),...yt(e),...yt(l.env)},y=Z5(s||l.systemRoot||f[Wv]);if(o&&!y)return{code:"vibe64_codex_system_root_requ\
|
|
4518
4519
|
ired",error:"A Vibe64 system root is required for Codex runtime operations.",errors:[{code:"vibe64_codex_system_root_req\
|
|
4519
4520
|
uired",message:"A Vibe64 system root is required for Codex runtime operations."}],ok:!1};let h=Ug({gid:t,home:c||l.toolHomeSource||
|
|
4520
|
-
r,uid:d,username:u});if(h?.ok===!1)return h;let v=
|
|
4521
|
+
r,uid:d,username:u});if(h?.ok===!1)return h;let v=Q5(h),w=mr(a),m=Sa(w,{envPolicy:"session"}),_=Di({actor:v,baseEnv:f,request:{
|
|
4521
4522
|
env:{},envPolicy:"auth",purpose:"codex",runtimes:p}}),I=Di({actor:v,baseEnv:_,request:{env:w,envPolicy:"session",project:{
|
|
4522
4523
|
databaseEnv:w},purpose:"codex",runtimes:p,shimDirs:i}});return{...h,env:_,ok:!0,providerOptions:{...l,env:_,runtimes:p,systemRoot:y,
|
|
4523
4524
|
toolHomeSource:h.toolHomeSource},runtimes:p,systemRoot:y,terminalEnv:m,terminalProcessEnv:I}}function ve(e,t,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError(
|
|
@@ -4545,22 +4546,22 @@ gc=class extends _t{},wc=class extends Q{constructor(){super("Could not parse re
|
|
|
4545
4546
|
eached")}},vc=class extends Q{constructor(){super("Could not parse response content as the request was rejected by the c\
|
|
4546
4547
|
ontent filter")}},jn=class extends Error{constructor(t){super(t)}},as=class extends _t{constructor(t,r,n){let o="OAuth2 \
|
|
4547
4548
|
authentication error",i;if(r&&typeof r=="object"){let s=r;i=s.error;let a=s.error_description;a&&typeof a=="string"?o=a:
|
|
4548
|
-
i&&(o=i)}super(t,r,o,n),this.error_code=i}},dl=class extends Q{constructor(t,r,n){super(t),this.provider=r,this.cause=n}};var
|
|
4549
|
+
i&&(o=i)}super(t,r,o,n),this.error_code=i}},dl=class extends Q{constructor(t,r,n){super(t),this.provider=r,this.cause=n}};var rY=/^[a-z][a-z0-9+.-]*:/i,gM=e=>rY.test(e),tr=e=>(tr=Array.isArray,tr(e)),wb=tr;function dh(e){return typeof e!="obj\
|
|
4549
4550
|
ect"?{}:e??{}}function vb(e){if(!e)return!0;for(let t in e)return!1;return!0}function wM(e,t){return Object.prototype.hasOwnProperty.
|
|
4550
4551
|
call(e,t)}function ul(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}var vM=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t))throw new Q(`${e} must be an integer`);if(t<0)throw new Q(`${e}\
|
|
4551
|
-
must be a positive integer`);return t};var yM=e=>{try{return JSON.parse(e)}catch{return}};var Mn=e=>new Promise(t=>setTimeout(t,e));var ei="6.49.0";var SM=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function
|
|
4552
|
+
must be a positive integer`);return t};var yM=e=>{try{return JSON.parse(e)}catch{return}};var Mn=e=>new Promise(t=>setTimeout(t,e));var ei="6.49.0";var SM=()=>typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u";function nY(){return typeof Deno<"u"&&Deno.
|
|
4552
4553
|
build!=null?"deno":typeof EdgeRuntime<"u"?"edge":Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.
|
|
4553
|
-
process:0)==="[object process]"?"node":"unknown"}var
|
|
4554
|
+
process:0)==="[object process]"?"node":"unknown"}var oY=()=>{let e=nY();if(e==="deno")return{"X-Stainless-Lang":"js","X-\
|
|
4554
4555
|
Stainless-Package-Version":ei,"X-Stainless-OS":bM(Deno.build.os),"X-Stainless-Arch":_M(Deno.build.arch),"X-Stainless-Run\
|
|
4555
4556
|
time":"deno","X-Stainless-Runtime-Version":typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<
|
|
4556
4557
|
"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ei,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other\
|
|
4557
4558
|
:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if(e==="node")return{
|
|
4558
4559
|
"X-Stainless-Lang":"js","X-Stainless-Package-Version":ei,"X-Stainless-OS":bM(globalThis.process.platform??"unknown"),"X-\
|
|
4559
4560
|
Stainless-Arch":_M(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.
|
|
4560
|
-
process.version??"unknown"};let t=
|
|
4561
|
+
process.version??"unknown"};let t=iY();return t?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ei,"X-Stainless-O\
|
|
4561
4562
|
S":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${t.browser}`,"X-Stainless-Runtime-Version":t.version}:
|
|
4562
4563
|
{"X-Stainless-Lang":"js","X-Stainless-Package-Version":ei,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Sta\
|
|
4563
|
-
inless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function
|
|
4564
|
+
inless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function iY(){if(typeof navigator>"u"||!navigator)return null;
|
|
4564
4565
|
let e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},
|
|
4565
4566
|
{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},
|
|
4566
4567
|
{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];
|
|
@@ -4568,7 +4569,7 @@ for(let{key:t,pattern:r}of e){let n=r.exec(navigator.userAgent);if(n){let o=n[1]
|
|
|
4568
4569
|
version:`${o}.${i}.${s}`}}}return null}var _M=e=>e==="x32"?"x32":e==="x86_64"||e==="x64"?"x64":e==="arm"?"arm":e==="aarc\
|
|
4569
4570
|
h64"||e==="arm64"?"arm64":e?`other:${e}`:"unknown",bM=e=>(e=e.toLowerCase(),e.includes("ios")?"iOS":e==="android"?"Andro\
|
|
4570
4571
|
id":e==="darwin"?"MacOS":e==="win32"?"Windows":e==="freebsd"?"FreeBSD":e==="openbsd"?"OpenBSD":e==="linux"?"Linux":e?`Ot\
|
|
4571
|
-
her:${e}`:"Unknown"),IM,AM=()=>IM??(IM=
|
|
4572
|
+
her:${e}`:"Unknown"),IM,AM=()=>IM??(IM=oY());function uh(){if(typeof fetch<"u")return fetch;throw new Error("`fetch` is not defined as a global; Either pass `fetch` \
|
|
4572
4573
|
to the client, `new OpenAI({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function yb(...e){let t=globalThis.
|
|
4573
4574
|
ReadableStream;if(typeof t>"u")throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill i\
|
|
4574
4575
|
t, `globalThis.ReadableStream = ReadableStream`");return new t(...e)}function ll(e){let t=Symbol.asyncIterator in e?e[Symbol.
|
|
@@ -4589,18 +4590,18 @@ return s};function RM(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.con
|
|
|
4589
4590
|
e)}},kM=function(e,t){Array.prototype.push.apply(e,tr(t)?t:[t])},OM,Dt={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,
|
|
4590
4591
|
arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:CM,encodeValuesOnly:!1,
|
|
4591
4592
|
format:bb,formatter:Ib,indices:!1,serializeDate(e){return(OM??(OM=Function.prototype.call.bind(Date.prototype.toISOString)))(
|
|
4592
|
-
e)},skipNulls:!1,strictNullHandling:!1};function
|
|
4593
|
+
e)},skipNulls:!1,strictNullHandling:!1};function aY(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||
|
|
4593
4594
|
typeof e=="symbol"||typeof e=="bigint"}var xb={};function NM(e,t,r,n,o,i,s,a,c,d,u,l,p,f,y,h,v,w){let m=e,_=w,I=0,x=!1;for(;(_=
|
|
4594
4595
|
_.get(xb))!==void 0&&!x;){let K=_.get(e);if(I+=1,typeof K<"u"){if(K===I)throw new RangeError("Cyclic object value");x=!0}
|
|
4595
4596
|
typeof _.get(xb)>"u"&&(I=0)}if(typeof d=="function"?m=d(t,m):m instanceof Date?m=p?.(m):r==="comma"&&tr(m)&&(m=Eb(m,function(K){
|
|
4596
|
-
return K instanceof Date?p?.(K):K})),m===null){if(i)return c&&!h?c(t,Dt.encoder,v,"key",f):t;m=""}if(
|
|
4597
|
+
return K instanceof Date?p?.(K):K})),m===null){if(i)return c&&!h?c(t,Dt.encoder,v,"key",f):t;m=""}if(aY(m)||RM(m)){if(c){
|
|
4597
4598
|
let K=h?t:c(t,Dt.encoder,v,"key",f);return[y?.(K)+"="+y?.(c(m,Dt.encoder,v,"value",f))]}return[y?.(t)+"="+y?.(String(m))]}
|
|
4598
4599
|
let C=[];if(typeof m>"u")return C;let T;if(r==="comma"&&tr(m))h&&c&&(m=Eb(m,c)),T=[{value:m.length>0?m.join(",")||null:void 0}];else if(tr(
|
|
4599
4600
|
d))T=d;else{let K=Object.keys(m);T=u?K.sort(u):K}let M=a?String(t).replace(/\./g,"%2E"):String(t),L=n&&tr(m)&&m.length===
|
|
4600
4601
|
1?M+"[]":M;if(o&&tr(m)&&m.length===0)return L+"[]";for(let K=0;K<T.length;++K){let X=T[K],se=typeof X=="object"&&typeof X.
|
|
4601
4602
|
value<"u"?X.value:m[X];if(s&&se===null)continue;let Z=l&&a?X.replace(/\./g,"%2E"):X,ye=tr(m)?typeof r=="function"?r(L,Z):
|
|
4602
4603
|
L:L+(l?"."+Z:"["+Z+"]");w.set(e,I);let ae=new WeakMap;ae.set(xb,w),kM(C,NM(se,ye,r,n,o,i,s,a,r==="comma"&&h&&tr(m)?null:
|
|
4603
|
-
c,d,u,l,p,f,y,h,v,ae))}return C}function
|
|
4604
|
+
c,d,u,l,p,f,y,h,v,ae))}return C}function cY(e=Dt){if(typeof e.allowEmptyArrays<"u"&&typeof e.allowEmptyArrays!="boolean")
|
|
4604
4605
|
throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys<
|
|
4605
4606
|
"u"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, wh\
|
|
4606
4607
|
en provided");if(e.encoder!==null&&typeof e.encoder<"u"&&typeof e.encoder!="function")throw new TypeError("Encoder has t\
|
|
@@ -4618,7 +4619,7 @@ Dt.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:Dt.encoder,enc
|
|
|
4618
4619
|
"boolean"?e.encodeValuesOnly:Dt.encodeValuesOnly,filter:o,format:r,formatter:n,serializeDate:typeof e.serializeDate=="fu\
|
|
4619
4620
|
nction"?e.serializeDate:Dt.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Dt.skipNulls,sort:typeof e.
|
|
4620
4621
|
sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Dt.strictNullHandling}}
|
|
4621
|
-
function jM(e,t={}){let r=e,n=
|
|
4622
|
+
function jM(e,t={}){let r=e,n=cY(t),o,i;typeof n.filter=="function"?(i=n.filter,r=i("",r)):tr(n.filter)&&(i=n.filter,o=i);
|
|
4622
4623
|
let s=[];if(typeof r!="object"||r===null)return"";let a=PM[n.arrayFormat],c=a==="comma"&&n.commaRoundTrip;o||(o=Object.keys(
|
|
4623
4624
|
r)),n.sort&&o.sort(n.sort);let d=new WeakMap;for(let p=0;p<o.length;++p){let f=o[p];n.skipNulls&&r[f]===null||kM(s,NM(r[f],
|
|
4624
4625
|
f,a,c,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,
|
|
@@ -4628,26 +4629,26 @@ u:""}function MM(e){return jM(e,{arrayFormat:"brackets"})}function DM(e){let t=0
|
|
|
4628
4629
|
var LM;function Tr(e){let t;return(LM??(t=new globalThis.TextEncoder,LM=t.encode.bind(t)))(e)}var $M;function Tb(e){let t;
|
|
4629
4630
|
return($M??(t=new globalThis.TextDecoder,$M=t.decode.bind(t)))(e)}var Cr,Rr,cs=class{constructor(){Cr.set(this,void 0),Rr.set(this,void 0),ve(this,Cr,new Uint8Array,"f"),ve(this,Rr,null,
|
|
4630
4631
|
"f")}decode(t){if(t==null)return[];let r=t instanceof ArrayBuffer?new Uint8Array(t):typeof t=="string"?Tr(t):t;ve(this,Cr,
|
|
4631
|
-
DM([D(this,Cr,"f"),r]),"f");let n=[],o;for(;(o=
|
|
4632
|
+
DM([D(this,Cr,"f"),r]),"f");let n=[],o;for(;(o=uY(D(this,Cr,"f"),D(this,Rr,"f")))!=null;){if(o.carriage&&D(this,Rr,"f")==
|
|
4632
4633
|
null){ve(this,Rr,o.index,"f");continue}if(D(this,Rr,"f")!=null&&(o.index!==D(this,Rr,"f")+1||o.carriage)){n.push(Tb(D(this,
|
|
4633
4634
|
Cr,"f").subarray(0,D(this,Rr,"f")-1))),ve(this,Cr,D(this,Cr,"f").subarray(D(this,Rr,"f")),"f"),ve(this,Rr,null,"f");continue}
|
|
4634
4635
|
let i=D(this,Rr,"f")!==null?o.preceding-1:o.preceding,s=Tb(D(this,Cr,"f").subarray(0,i));n.push(s),ve(this,Cr,D(this,Cr,
|
|
4635
4636
|
"f").subarray(o.index),"f"),ve(this,Rr,null,"f")}return n}flush(){return D(this,Cr,"f").length?this.decode(`
|
|
4636
4637
|
`):[]}};Cr=new WeakMap,Rr=new WeakMap;cs.NEWLINE_CHARS=new Set([`
|
|
4637
|
-
`,"\r"]);cs.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function
|
|
4638
|
+
`,"\r"]);cs.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function uY(e,t){for(let o=t??0;o<e.length;o++){if(e[o]===10)return{preceding:o,
|
|
4638
4639
|
index:o+1,carriage:!1};if(e[o]===13)return{preceding:o,index:o+1,carriage:!0}}return null}function UM(e){for(let n=0;n<e.
|
|
4639
4640
|
length-1;n++){if(e[n]===10&&e[n+1]===10||e[n]===13&&e[n+1]===13)return n+2;if(e[n]===13&&e[n+1]===10&&n+3<e.length&&e[n+
|
|
4640
4641
|
2]===13&&e[n+3]===10)return n+4}return-1}var mh={off:0,error:200,warn:300,info:400,debug:500},Cb=(e,t,r)=>{if(e){if(wM(mh,e))return e;Et(r).warn(`${t} was set to\
|
|
4641
4642
|
${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(mh))}`)}};function pl(){}function fh(e,t,r){return!t||
|
|
4642
|
-
mh[e]>mh[r]?pl:t[e].bind(t)}var
|
|
4643
|
-
logLevel??"off";if(!t)return
|
|
4643
|
+
mh[e]>mh[r]?pl:t[e].bind(t)}var lY={error:pl,warn:pl,info:pl,debug:pl},zM=new WeakMap;function Et(e){let t=e.logger,r=e.
|
|
4644
|
+
logLevel??"off";if(!t)return lY;let n=zM.get(t);if(n&&n[0]===r)return n[1];let o={error:fh("error",t,r),warn:fh("warn",t,
|
|
4644
4645
|
r),info:fh("info",t,r),debug:fh("debug",t,r)};return zM.set(t,[r,o]),o}var po=e=>(e.options&&(e.options={...e.options},delete e.
|
|
4645
4646
|
options.headers),e.headers&&(e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.
|
|
4646
4647
|
headers)).map(([t,r])=>[t,t.toLowerCase()==="authorization"||t.toLowerCase()==="api-key"||t.toLowerCase()==="x-api-key"||
|
|
4647
4648
|
t.toLowerCase()==="x-amz-security-token"||t.toLowerCase()==="cookie"||t.toLowerCase()==="set-cookie"?"***":r]))),"retryO\
|
|
4648
4649
|
fRequestLogID"in e&&(e.retryOfRequestLogID&&(e.retryOf=e.retryOfRequestLogID),delete e.retryOfRequestLogID),e);var fl,wr=class e{constructor(t,r,n){this.iterator=t,fl.set(this,void 0),this.controller=r,ve(this,fl,n,"f")}static fromSSEResponse(t,r,n,o){
|
|
4649
4650
|
let i=!1,s=n?Et(n):console;async function*a(){if(i)throw new Q("Cannot iterate over a consumed stream, use `.tee()` to s\
|
|
4650
|
-
plit the stream.");i=!0;let c=!1;try{for await(let d of
|
|
4651
|
+
plit the stream.");i=!0;let c=!1;try{for await(let d of pY(t,r))if(!c){if(d.data.startsWith("[DONE]")){c=!0;continue}if(d.
|
|
4651
4652
|
event===null||!d.event.startsWith("thread.")){let u;try{u=JSON.parse(d.data)}catch(l){throw s.error("Could not parse mes\
|
|
4652
4653
|
sage into JSON:",d.data),s.error("From chunk:",d.raw),l}if(u&&u.error)throw new _t(void 0,u.error,void 0,t.headers);yield o?
|
|
4653
4654
|
{event:d.event,data:u}:u}else{let u;try{u=JSON.parse(d.data)}catch(l){throw console.error("Could not parse message into \
|
|
@@ -4664,19 +4665,19 @@ if(i.length===0){let s=n.next();t.push(s),r.push(s)}return i.shift()}});return[n
|
|
|
4664
4665
|
"f")),new e(()=>o(r),this.controller,D(this,fl,"f"))]}toReadableStream(){let t=this,r;return yb({async start(){r=t[Symbol.
|
|
4665
4666
|
asyncIterator]()},async pull(n){try{let{value:o,done:i}=await r.next();if(i)return n.close();let s=Tr(JSON.stringify(o)+
|
|
4666
4667
|
`
|
|
4667
|
-
`);n.enqueue(s)}catch(o){n.error(o)}},async cancel(){await r.return?.()}})}};async function*
|
|
4668
|
+
`);n.enqueue(s)}catch(o){n.error(o)}},async cancel(){await r.return?.()}})}};async function*pY(e,t){if(!e.body)throw t.abort(),
|
|
4668
4669
|
typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative"?new Q("The default react-native fetch impl\
|
|
4669
4670
|
ementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-\
|
|
4670
|
-
api"):new Q("Attempted to iterate over a response with no body");let r=new Rb,n=new cs,o=lh(e.body);for await(let i of
|
|
4671
|
-
o))for(let s of n.decode(i)){let a=r.decode(s);a&&(yield a)}for(let i of n.flush()){let s=r.decode(i);s&&(yield s)}}async function*
|
|
4671
|
+
api"):new Q("Attempted to iterate over a response with no body");let r=new Rb,n=new cs,o=lh(e.body);for await(let i of fY(
|
|
4672
|
+
o))for(let s of n.decode(i)){let a=r.decode(s);a&&(yield a)}for(let i of n.flush()){let s=r.decode(i);s&&(yield s)}}async function*fY(e){
|
|
4672
4673
|
let t=new Uint8Array;for await(let r of e){if(r==null)continue;let n=r instanceof ArrayBuffer?new Uint8Array(r):typeof r==
|
|
4673
4674
|
"string"?Tr(r):r,o=new Uint8Array(t.length+n.length);o.set(t),o.set(n,t.length),t=o;let i;for(;(i=UM(t))!==-1;)yield t.slice(
|
|
4674
4675
|
0,i),t=t.slice(i)}t.length>0&&(yield t)}var Rb=class{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(t){
|
|
4675
4676
|
if(t.endsWith("\r")&&(t=t.substring(0,t.length-1)),!t){if(!this.event&&!this.data.length)return null;let i={event:this.event,
|
|
4676
4677
|
data:this.data.join(`
|
|
4677
4678
|
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],i}if(this.chunks.push(t),t.startsWith(":"))return null;
|
|
4678
|
-
let[r,n,o]=
|
|
4679
|
-
null}};function
|
|
4679
|
+
let[r,n,o]=mY(t,":");return o.startsWith(" ")&&(o=o.substring(1)),r==="event"?this.event=o:r==="data"&&this.data.push(o),
|
|
4680
|
+
null}};function mY(e,t){let r=e.indexOf(t);return r!==-1?[e.substring(0,r),t,e.substring(r+t.length)]:[e,"",""]}async function hh(e,t){let{response:r,requestLogID:n,retryOfRequestLogID:o,startTime:i}=t,s=await(async()=>{if(t.options.
|
|
4680
4681
|
stream)return Et(e).debug("response",r.status,r.url,r.headers,r.body),t.options.__streamClass?t.options.__streamClass.fromSSEResponse(
|
|
4681
4682
|
r,t.controller,e,t.options.__synthesizeEventData):wr.fromSSEResponse(r,t.controller,e,t.options.__synthesizeEventData);if(r.
|
|
4682
4683
|
status===204)return null;if(t.options.__binaryResponse)return r;let c=r.headers.get("content-type")?.split(";")[0]?.trim();
|
|
@@ -4705,13 +4706,13 @@ data??[]}hasNextPage(){return this.has_more===!1?!1:super.hasNextPage()}nextPage
|
|
|
4705
4706
|
{...this.options,query:{...dh(this.options.query),after:t}}:null}},Ot=class extends yc{constructor(t,r,n,o){super(t,r,n,
|
|
4706
4707
|
o),this.data=n.data||[],this.has_more=n.has_more||!1,this.next=n.next||null}getPaginatedItems(){return this.data??[]}hasNextPage(){
|
|
4707
4708
|
return this.has_more===!1?!1:super.hasNextPage()}nextPageRequestOptions(){let t=this.next;return t?{...this.options,query:{
|
|
4708
|
-
...dh(this.options.query),after:t}}:null}};var
|
|
4709
|
+
...dh(this.options.query),after:t}}:null}};var gY={jwt:"urn:ietf:params:oauth:token-type:jwt",id:"urn:ietf:params:oauth:token-type:id_token"},wY="urn:ietf:params:o\
|
|
4709
4710
|
auth:grant-type:token-exchange",wh=class{constructor(t,r){this.cachedToken=null,this.refreshPromise=null,this.tokenExchangeUrl=
|
|
4710
4711
|
"https://auth.openai.com/oauth/token",this.config=t,this.fetch=r??uh()}async getToken(){if(!this.cachedToken||this.isTokenExpired(
|
|
4711
4712
|
this.cachedToken)){if(this.refreshPromise)return await this.refreshPromise;this.refreshPromise=this.refreshToken();try{return await this.
|
|
4712
4713
|
refreshPromise}finally{this.refreshPromise=null}}return this.needsRefresh(this.cachedToken)&&!this.refreshPromise&&(this.
|
|
4713
4714
|
refreshPromise=this.refreshToken().finally(()=>{this.refreshPromise=null})),this.cachedToken.token}async refreshToken(){
|
|
4714
|
-
let t=await this.config.provider.getToken(),r={grant_type:
|
|
4715
|
+
let t=await this.config.provider.getToken(),r={grant_type:wY,subject_token:t,subject_token_type:gY[this.config.provider.
|
|
4715
4716
|
tokenType],identity_provider_id:this.config.identityProviderId,service_account_id:this.config.serviceAccountId};this.config.
|
|
4716
4717
|
clientId&&(r.client_id=this.config.clientId);let n=await this.fetch(this.tokenExchangeUrl,{method:"POST",headers:{"Conte\
|
|
4717
4718
|
nt-Type":"application/json"},body:JSON.stringify(r)});if(!n.ok){let c=await n.text(),d;try{d=JSON.parse(c)}catch{}throw n.
|
|
@@ -4720,11 +4721,11 @@ with status ${n.status}`,n.headers)}let o=await n.json();if(typeof o!="object"||
|
|
|
4720
4721
|
access_token!="string"||o.access_token.trim().length===0)throw new Q("Token exchange response missing 'access_token' fie\
|
|
4721
4722
|
ld");let i=o.access_token,s=o.expires_in??3600,a=Date.now()+s*1e3;return this.cachedToken={token:i,expiresAt:a},i}isTokenExpired(t){
|
|
4722
4723
|
return Date.now()>=t.expiresAt}needsRefresh(t){let n=(this.config.refreshBufferSeconds??1200)*1e3;return Date.now()>=t.expiresAt-
|
|
4723
|
-
n}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};var FM=Symbol("brand.privateNullableHeaders"),
|
|
4724
|
+
n}invalidateToken(){this.cachedToken=null,this.refreshPromise=null}};var FM=Symbol("brand.privateNullableHeaders"),vY=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function*yY(e){if(!e)return;if(FM in e){
|
|
4724
4725
|
let{values:n,nulls:o}=e;yield*n.entries();for(let i of o)yield[i,null];return}let t=!1,r;e instanceof Headers?r=e.entries():
|
|
4725
4726
|
wb(e)?r=e:(t=!0,r=Object.entries(e??{}));for(let n of r){let o=n[0];if(typeof o!="string")throw new TypeError("expected \
|
|
4726
4727
|
header name to be a string");let i=wb(n[1])?n[1]:[n[1]],s=!1;for(let a of i)a!==void 0&&(t&&!s&&(s=!0,yield[o,null]),yield[
|
|
4727
|
-
o,a])}}var J=e=>{let t=new Headers,r=new Set;for(let n of e){let o=new Set;for(let[i,s]of
|
|
4728
|
+
o,a])}}var J=e=>{let t=new Headers,r=new Set;for(let n of e){let o=new Set;for(let[i,s]of yY(n)){if(!vY.test(i))throw new TypeError(
|
|
4728
4729
|
`Header name must be a valid HTTP token ["${i}"]`);let a=i.toLowerCase();o.has(a)||(t.delete(a),o.add(a)),s===null?(t.delete(
|
|
4729
4730
|
a),r.add(a)):(t.append(a,s),r.delete(a))}}return{[FM]:!0,values:t,nulls:r}};var qM=Symbol("brand.privateStreamingFile");function yh(e,t,r){if(!t)throw new TypeError("toStreamingFile requires a non\
|
|
4730
4731
|
-empty file name");return{[qM]:!0,data:e,name:t,...r?.type?{type:r.type}:{}}}var Mb=()=>{if(typeof File>"u"){let{process:e}=globalThis,
|
|
@@ -4734,33 +4735,33 @@ a global, which is required for file uploads."+(t?" Update to Node 20 LTS or new
|
|
|
4734
4735
|
"object"&&e!==null&&("name"in e&&e.name&&String(e.name)||"url"in e&&e.url&&String(e.url)||"filename"in e&&e.filename&&String(
|
|
4735
4736
|
e.filename)||"path"in e&&e.path&&String(e.path))||"").split(/[\\/]/).pop()||void 0}var Sc=e=>e!=null&&typeof e=="object"&&
|
|
4736
4737
|
typeof e[Symbol.asyncIterator]=="function",ti=async(e,t)=>kb(e.body)?vh(e.body)?HM(e):{...e,body:await VM(e.body,t)}:e,nr=async(e,t)=>vh(
|
|
4737
|
-
e.body)?HM(e):{...e,body:await VM(e.body,t)},BM=new WeakMap;function
|
|
4738
|
+
e.body)?HM(e):{...e,body:await VM(e.body,t)},BM=new WeakMap;function _Y(e){let t=typeof e=="function"?e:e.fetch,r=BM.get(
|
|
4738
4739
|
t);if(r)return r;let n=(async()=>{try{let o="Response"in t?t.Response:(await t("data:,")).constructor,i=new FormData;return i.
|
|
4739
|
-
toString()!==await new o(i).text()}catch{return!0}})();return BM.set(t,n),n}var VM=async(e,t)=>{if(!await
|
|
4740
|
+
toString()!==await new o(i).text()}catch{return!0}})();return BM.set(t,n),n}var VM=async(e,t)=>{if(!await _Y(t))throw new TypeError(
|
|
4740
4741
|
"The provided fetch function does not support file uploads with the current global FormData class.");let r=new FormData;
|
|
4741
4742
|
return await Promise.all(Object.entries(e||{}).map(([n,o])=>jb(r,n,o))),r},_h=e=>e instanceof Blob&&"name"in e,Lb=e=>typeof e==
|
|
4742
4743
|
"object"&&e!==null&&"getReader"in e&&typeof e.getReader=="function",gl=e=>typeof e=="object"&&e!==null&&qM in e,$b=e=>typeof e==
|
|
4743
4744
|
"object"&&e!==null&&(e instanceof Response||Sc(e)||Lb(e)||gl(e)||_h(e)),vh=e=>{if(gl(e)||Sc(e)||Lb(e))return!0;if(Array.
|
|
4744
4745
|
isArray(e))return e.some(vh);if(e&&typeof e=="object"&&!_h(e)&&!(e instanceof Response)){for(let t in e)if(vh(e[t]))return!0}
|
|
4745
4746
|
return!1},kb=e=>{if($b(e))return!0;if(Array.isArray(e))return e.some(kb);if(e&&typeof e=="object"){for(let t in e)if(kb(
|
|
4746
|
-
e[t]))return!0}return!1},HM=e=>{let t=`openai-${Math.random().toString(36).slice(2)}`,r=ll(
|
|
4747
|
-
headers:J([{"content-type":`multipart/form-data; boundary=${t}`},e.headers])}};async function*
|
|
4748
|
-
value:n}of
|
|
4749
|
-
`),$b(n)){let o=
|
|
4747
|
+
e[t]))return!0}return!1},HM=e=>{let t=`openai-${Math.random().toString(36).slice(2)}`,r=ll(bY(e.body,t));return{...e,body:r,
|
|
4748
|
+
headers:J([{"content-type":`multipart/form-data; boundary=${t}`},e.headers])}};async function*bY(e,t){for await(let{key:r,
|
|
4749
|
+
value:n}of IY(e)){if(yield Tr(`--${t}\r
|
|
4750
|
+
`),$b(n)){let o=SY(n),i=AY(n);yield Tr(`Content-Disposition: form-data; name="${Pb(r)}"; filename="${Pb(o)}"\r
|
|
4750
4751
|
Content-Type: ${i}\r
|
|
4751
4752
|
\r
|
|
4752
|
-
`),yield*_c(
|
|
4753
|
+
`),yield*_c(EY(n))}else yield Tr(`Content-Disposition: form-data; name="${Pb(r)}"\r
|
|
4753
4754
|
\r
|
|
4754
4755
|
${String(n)}`);yield Tr(`\r
|
|
4755
4756
|
`)}yield Tr(`--${t}--\r
|
|
4756
|
-
`)}async function*
|
|
4757
|
+
`)}async function*IY(e){if(!(!e||typeof e!="object"))for(let[t,r]of Object.entries(e))yield*Nb(t,r)}async function*Nb(e,t){
|
|
4757
4758
|
if(t!==void 0){if(t==null)throw new TypeError(`Received null for "${e}"; to pass null in FormData, you must use the stri\
|
|
4758
4759
|
ng 'null'`);if(typeof t=="string"||typeof t=="number"||typeof t=="boolean"||$b(t))yield{key:e,value:t};else if(Array.isArray(
|
|
4759
4760
|
t))for(let r of t)yield*Nb(e+"[]",r);else if(typeof t=="object")for(let[r,n]of Object.entries(t))yield*Nb(`${e}[${r}]`,n);else
|
|
4760
4761
|
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but go\
|
|
4761
|
-
t ${t} instead`)}}function
|
|
4762
|
+
t ${t} instead`)}}function SY(e){return gl(e)?e.name:bc(e)??"unknown_file"}function AY(e){return gl(e)?e.type||"applicat\
|
|
4762
4763
|
ion/octet-stream":_h(e)&&e.type?e.type:e instanceof Response&&e.headers.get("content-type")||"application/octet-stream"}
|
|
4763
|
-
function
|
|
4764
|
+
function EY(e){return gl(e)?e.data:e}async function*_c(e){if(typeof e=="string")yield Tr(e);else if(ArrayBuffer.isView(e))
|
|
4764
4765
|
yield new Uint8Array(e.buffer,e.byteOffset,e.byteLength);else if(e instanceof ArrayBuffer)yield new Uint8Array(e);else if(e instanceof
|
|
4765
4766
|
Response)e.body?yield*_c(e.body):yield*_c(await e.blob());else if(e instanceof Blob)typeof e.stream=="function"?yield*_c(
|
|
4766
4767
|
e.stream()):yield new Uint8Array(await e.arrayBuffer());else if(Lb(e))for await(let t of lh(e))yield*_c(t);else if(Sc(e))
|
|
@@ -4772,16 +4773,16 @@ r))e.append(t,Ic([await new Response(ll(r)).blob()],bc(r)));else if(_h(r))e.appe
|
|
|
4772
4773
|
all(r.map(n=>jb(e,t+"[]",n)));else if(typeof r=="object")await Promise.all(Object.entries(r).map(([n,o])=>jb(e,`${t}[${n}\
|
|
4773
4774
|
]`,o)));else throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File o\
|
|
4774
4775
|
r Blob but got ${r} instead`)}};var GM=e=>e!=null&&typeof e=="object"&&typeof e.size=="number"&&typeof e.type=="string"&&typeof e.text=="function"&&typeof e.
|
|
4775
|
-
slice=="function"&&typeof e.arrayBuffer=="function",
|
|
4776
|
-
lastModified=="number"&&GM(e),
|
|
4777
|
-
if(Mb(),e=await e,
|
|
4776
|
+
slice=="function"&&typeof e.arrayBuffer=="function",xY=e=>e!=null&&typeof e=="object"&&typeof e.name=="string"&&typeof e.
|
|
4777
|
+
lastModified=="number"&&GM(e),TY=e=>e!=null&&typeof e=="object"&&typeof e.url=="string"&&typeof e.blob=="function";async function bh(e,t,r){
|
|
4778
|
+
if(Mb(),e=await e,xY(e))return e instanceof File?e:Ic([await e.arrayBuffer()],e.name);if(TY(e)){let o=await e.blob();return t||
|
|
4778
4779
|
(t=new URL(e.url).pathname.split(/[\\/]/).pop()),Ic(await Db(o),t,r)}let n=await Db(e);if(t||(t=bc(e)),!r?.type){let o=n.
|
|
4779
4780
|
find(i=>typeof i=="object"&&"type"in i&&i.type);typeof o=="string"&&(r={...r,type:o})}return Ic(n,t,r)}async function Db(e){
|
|
4780
4781
|
let t=[];if(typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(GM(e))t.push(e instanceof
|
|
4781
4782
|
Blob?e:await e.arrayBuffer());else if(Sc(e))for await(let r of e)t.push(...await Db(r));else{let r=e?.constructor?.name;
|
|
4782
|
-
throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${
|
|
4783
|
+
throw new Error(`Unexpected data type: ${typeof e}${r?`; constructor: ${r}`:""}${CY(e)}`)}return t}function CY(e){return typeof e!=
|
|
4783
4784
|
"object"||e===null?"":`; props: [${Object.getOwnPropertyNames(e).map(r=>`"${r}"`).join(", ")}]`}var j=class{constructor(t){this._client=t}};function KM(e){return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var WM=Object.freeze(Object.create(
|
|
4784
|
-
null)),
|
|
4785
|
+
null)),OY=(e=KM)=>function(r,...n){if(r.length===1)return r[0];let o=!1,i=[],s=r.reduce((u,l,p)=>{/[?#]/.test(l)&&(o=!0);
|
|
4785
4786
|
let f=n[p],y=(o?encodeURIComponent:e)(""+f);return p!==n.length&&(f==null||typeof f=="object"&&f.toString===Object.getPrototypeOf(
|
|
4786
4787
|
Object.getPrototypeOf(f.hasOwnProperty??WM)??WM)?.toString)&&(y=f+"",i.push({start:u.length+l.length,length:y.length,error:`\
|
|
4787
4788
|
Value of type ${Object.prototype.toString.call(f).slice(8,-1)} is not a valid path parameter`})),u+l+(p===n.length?"":y)},
|
|
@@ -4792,14 +4793,14 @@ let u=0,l=i.reduce((p,f)=>{let y=" ".repeat(f.start-u),h="^".repeat(f.length);re
|
|
|
4792
4793
|
${i.map(p=>p.error).join(`
|
|
4793
4794
|
`)}
|
|
4794
4795
|
${s}
|
|
4795
|
-
${l}`)}return s},R=
|
|
4796
|
+
${l}`)}return s},R=OY(KM);var us=class extends j{list(t,r={},n){return this._client.getAPIList(R`/chat/completions/${t}/messages`,Ce,{query:r,...n,
|
|
4796
4797
|
__security:{bearerAuth:!0}})}};function wl(e){return e!==void 0&&"function"in e&&e.function!==void 0}function vl(e){return e?.$brand==="auto-parseable-response-format"}function ls(e){return e?.$brand==="auto-parseable-tool"}function XM(e,t){return!t||!Ub(t)?{...e,choices:e.choices.map(r=>(ZM(
|
|
4797
4798
|
r.message.tool_calls),{...r,message:{...r.message,parsed:null,...r.message.tool_calls?{tool_calls:r.message.tool_calls}:
|
|
4798
4799
|
void 0}}))}:yl(e,t)}function yl(e,t){let r=e.choices.map(n=>{if(n.finish_reason==="length")throw new wc;if(n.finish_reason===
|
|
4799
4800
|
"content_filter")throw new vc;return ZM(n.message.tool_calls),{...n,message:{...n.message,...n.message.tool_calls?{tool_calls:n.
|
|
4800
|
-
message.tool_calls?.map(o=>
|
|
4801
|
-
null}}});return{...e,choices:r}}function
|
|
4802
|
-
type==="json_schema"?"$parseRaw"in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}function
|
|
4801
|
+
message.tool_calls?.map(o=>NY(t,o))??void 0}:void 0,parsed:n.message.content&&!n.message.refusal?kY(t,n.message.content):
|
|
4802
|
+
null}}});return{...e,choices:r}}function kY(e,t){return e.response_format?.type!=="json_schema"?null:e.response_format?.
|
|
4803
|
+
type==="json_schema"?"$parseRaw"in e.response_format?e.response_format.$parseRaw(t):JSON.parse(t):null}function NY(e,t){
|
|
4803
4804
|
let r=e.tools?.find(n=>wl(n)&&n.function?.name===t.function.name);return{...t,function:{...t.function,parsed_arguments:ls(
|
|
4804
4805
|
r)?r.$parseRaw(t.function.arguments):r?.function.strict?JSON.parse(t.function.arguments):null}}}function YM(e,t){if(!e||
|
|
4805
4806
|
!("tools"in e)||!e.tools)return!1;let r=e.tools?.find(n=>wl(n)&&n.function?.name===t.function.name);return wl(r)&&(ls(r)||
|
|
@@ -4836,13 +4837,13 @@ El=new WeakMap,xh=new WeakMap,Th=new WeakMap,Ac=new WeakMap,bl=new WeakSet,eL=fu
|
|
|
4836
4837
|
this,Eh,"f").splice(0))t.removeEventListener("abort",r)},zb=function(t){if(ve(this,xh,!0,"f"),t instanceof Error&&t.name===
|
|
4837
4838
|
"AbortError"&&(t=new At),t instanceof At)return ve(this,Th,!0,"f"),this._emit("abort",t);if(t instanceof Q)return this._emit(
|
|
4838
4839
|
"error",t);if(t instanceof Error){let r=new Q(t.message);return r.cause=t,this._emit("error",r)}return this._emit("error",
|
|
4839
|
-
new Q(String(t)))};function tL(e){return typeof e.parse=="function"}var ur,Fb,Ch,Bb,qb,Vb,rL,nL,
|
|
4840
|
-
`call_${ss()}`)}function
|
|
4840
|
+
new Q(String(t)))};function tL(e){return typeof e.parse=="function"}var ur,Fb,Ch,Bb,qb,Vb,rL,nL,jY=10;function MY(e){for(let t of e.choices)for(let r of t.message.tool_calls??[])r.id||(r.id=
|
|
4841
|
+
`call_${ss()}`)}function LY(e){if(!fo(e))return e;let t={role:"assistant"};return e.audio!=null&&(t.audio={id:e.audio.id}),
|
|
4841
4842
|
e.content!==void 0&&(t.content=e.content),e.function_call!=null&&(t.function_call=e.function_call),e.name!==void 0&&(t.name=
|
|
4842
4843
|
e.name),e.refusal!=null&&(t.refusal=e.refusal),e.tool_calls!==void 0&&(t.tool_calls=e.tool_calls.map(r=>r.type==="custom"?
|
|
4843
4844
|
{id:r.id,type:r.type,custom:{input:r.custom.input,name:r.custom.name}}:{id:r.id,type:r.type,function:{arguments:r.function.
|
|
4844
4845
|
arguments,name:r.function.name}})),t}var Ec=class extends ri{constructor(){super(...arguments),ur.add(this),this._chatCompletions=
|
|
4845
|
-
[],this.messages=[]}_addChatCompletion(t){
|
|
4846
|
+
[],this.messages=[]}_addChatCompletion(t){MY(t),this._chatCompletions.push(t),this._emit("chatCompletion",t);let r=t.choices[0]?.
|
|
4846
4847
|
message;return r&&this._addMessage(r),t}_addMessage(t,r=!0){if("content"in t||(t.content=null),this.messages.push(t),r){
|
|
4847
4848
|
if(this._emit("message",t),_l(t)&&t.content)this._emit("functionToolCallResult",t.content);else if(fo(t)&&t.tool_calls)for(let n of t.
|
|
4848
4849
|
tool_calls)n.type==="function"&&this._emit("functionToolCall",n.function)}}async finalChatCompletion(){await this.done();
|
|
@@ -4858,7 +4859,7 @@ some(s=>s.usage)&&this._emit("totalUsage",D(this,ur,"m",Vb).call(this))}async _c
|
|
|
4858
4859
|
n?.signal),D(this,ur,"m",rL).call(this,r);let o=await t.chat.completions.create({...r,stream:!1},{...n,signal:this.controller.
|
|
4859
4860
|
signal});return this._connected(),this._addChatCompletion(yl(o,r))}async _runChatCompletion(t,r,n){for(let o of r.messages)
|
|
4860
4861
|
this._addMessage(o,!1);return await this._createChatCompletion(t,r,n)}async _runTools(t,r,n,o){let i="tool",{tool_choice:s="\
|
|
4861
|
-
auto",stream:a,toolContext:c,...d}=r,u=c,l=typeof s!="string"&&s.type==="function"&&s?.function?.name,{maxChatCompletions:p=
|
|
4862
|
+
auto",stream:a,toolContext:c,...d}=r,u=c,l=typeof s!="string"&&s.type==="function"&&s?.function?.name,{maxChatCompletions:p=jY,
|
|
4862
4863
|
afterCompletion:f}=o||{},y=r.tools.map(m=>{if(ls(m)){if(!m.$callback)throw new Q("Tool given to `.runTools()` that does \
|
|
4863
4864
|
not have an associated function");return{type:"function",function:{function:m.$callback,name:m.function.name,description:m.
|
|
4864
4865
|
function.description||"",parameters:m.function.parameters,parse:m.$parseRaw,strict:!0}}}return m}),h={};for(let m of y)m.
|
|
@@ -4872,7 +4873,7 @@ let L=`Invalid tool_call: ${JSON.stringify(I)}. Available options are: ${Object.
|
|
|
4872
4873
|
content:L},functionCalled:!1}}let T;if(tL(C)){let L;try{L=await C.parse(x)}catch(K){let X=K instanceof Error?K.message:String(
|
|
4873
4874
|
K);return{message:{role:i,tool_call_id:_,content:X},functionCalled:!1}}T=await C.function(L,n,u)}else T=await C.function(
|
|
4874
4875
|
x,n,u);let M=D(this,ur,"m",nL).call(this,T);return{message:{role:i,tool_call_id:_,content:M},functionCalled:!0}};for(let m=0;m<
|
|
4875
|
-
p;++m){let _=await this._createChatCompletion(t,{...d,tool_choice:s,tools:v,messages:this.messages.map(
|
|
4876
|
+
p;++m){let _=await this._createChatCompletion(t,{...d,tool_choice:s,tools:v,messages:this.messages.map(LY)},o),I=_.choices[0]?.
|
|
4876
4877
|
message;if(!I)throw new Q("missing message in ChatCompletion response");if(!I.tool_calls?.length){await f?.(_,n);return}
|
|
4877
4878
|
if(l||r.parallel_tool_calls===!1)for(let x of I.tool_calls){let C=await w(x);if(C.message&&this._addMessage(C.message),l&&
|
|
4878
4879
|
C.functionCalled){await f?.(_,n);return}}else{let x=await Promise.allSettled(I.tool_calls.map(w));for(let C of x)if(C.status===
|
|
@@ -4890,8 +4891,8 @@ rs only support n=1 at this time. To use n>1, please use chat.completions.create
|
|
|
4890
4891
|
"string"?t:t===void 0?"undefined":JSON.stringify(t)};var xl=class e extends Ec{static runTools(t,r,n){let o=new e,i={...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"\
|
|
4891
4892
|
runTools"}};return o._run(()=>o._runTools(t,r,o,i)),o}_addMessage(t,r=!0){super._addMessage(t,r),fo(t)&&t.content&&this.
|
|
4892
4893
|
_emit("content",t.content)}};var Vt={STR:1,NUM:2,ARR:4,OBJ:8,NULL:16,BOOL:32,NAN:64,INFINITY:128,MINUS_INFINITY:256,INF:384,SPECIAL:496,ATOM:499,COLLECTION:12,
|
|
4893
|
-
ALL:511},Hb=class extends Error{},Gb=class extends Error{};function
|
|
4894
|
-
`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return
|
|
4894
|
+
ALL:511},Hb=class extends Error{},Gb=class extends Error{};function $Y(e,t=Vt.ALL){if(typeof e!="string")throw new TypeError(
|
|
4895
|
+
`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return DY(e.trim(),t)}var DY=(e,t)=>{let r=e.
|
|
4895
4896
|
length,n=0,o=p=>{throw new Hb(`${p} at position ${n}`)},i=p=>{throw new Gb(`${p} at position ${n}`)},s=()=>(l(),n>=r&&o(
|
|
4896
4897
|
"Unexpected end of input"),e[n]==='"'?a():e[n]==="{"?c():e[n]==="["?d():e.substring(n,n+4)==="null"||Vt.NULL&t&&r-n<4&&"\
|
|
4897
4898
|
null".startsWith(e.substring(n))?(n+=4,null):e.substring(n,n+4)==="true"||Vt.BOOL&t&&r-n<4&&"true".startsWith(e.substring(
|
|
@@ -4910,10 +4911,10 @@ if(Vt.NUM&t)try{return e[e.length-1]==="."?JSON.parse(e.substring(0,e.lastIndexO
|
|
|
4910
4911
|
"e")))}catch{}i(String(f))}}let p=n;for(e[n]==="-"&&n++;e[n]&&!",]}".includes(e[n]);)n++;n==r&&!(Vt.NUM&t)&&o("Untermina\
|
|
4911
4912
|
ted number literal");try{return JSON.parse(e.substring(p,n))}catch{e.substring(p,n)==="-"&&Vt.NUM&t&&o("Not sure what '-\
|
|
4912
4913
|
' is");try{return JSON.parse(e.substring(p,e.lastIndexOf("e")))}catch(y){i(String(y))}}},l=()=>{for(;n<r&&`
|
|
4913
|
-
\r `.includes(e[n]);)n++};return s()},Wb=e
|
|
4914
|
+
\r `.includes(e[n]);)n++};return s()},Wb=e=>$Y(e,Vt.ALL^Vt.NUM);var Pt,ho,ni,xc,ln,Kb,Rh,Jb,Xb,Yb,Tl,Zb,oL,eI="chat.completion.chunk.message:";function iL(e,t,r){let n={type:"message",
|
|
4914
4915
|
message:t,...r?{tool_call_ids:r}:{}};return{id:e.id,choices:[],created:e.created,model:e.model,object:`${eI}${JSON.stringify(
|
|
4915
|
-
n)}`}}function
|
|
4916
|
-
startsWith(eI)}function
|
|
4916
|
+
n)}`}}function UY(e){return"type"in e&&e.type==="message"&&"message"in e||"object"in e&&typeof e.object=="string"&&e.object.
|
|
4917
|
+
startsWith(eI)}function zY(e){return"type"in e?e:JSON.parse(e.object.slice(eI.length))}var ps=class e extends Ec{constructor(t){
|
|
4917
4918
|
super(),Pt.add(this),ho.set(this,void 0),ni.set(this,void 0),xc.set(this,void 0),ln.set(this,void 0),ve(this,ho,t,"f"),ve(
|
|
4918
4919
|
this,ni,new Set,"f"),ve(this,xc,[],"f")}get currentChatCompletionSnapshot(){return D(this,ln,"f")}static fromReadableStream(t){
|
|
4919
4920
|
let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}static createChatCompletion(t,r,n){let o=new e(r);return o.
|
|
@@ -4922,7 +4923,7 @@ super._createChatCompletion,this._listenForAbort(n?.signal),D(this,Pt,"m",Kb).ca
|
|
|
4922
4923
|
create({...r,stream:!0},{...n,signal:this.controller.signal});this._connected();for await(let i of o)D(this,Pt,"m",Jb).call(
|
|
4923
4924
|
this,i);if(o.controller.signal?.aborted)throw new At;return this._addChatCompletion(D(this,Pt,"m",Tl).call(this))}async _fromReadableStream(t,r){
|
|
4924
4925
|
this._listenForAbort(r?.signal),D(this,Pt,"m",Kb).call(this),this._connected();let n=wr.fromReadableStream(t,this.controller),
|
|
4925
|
-
o;for await(let s of n){if(
|
|
4926
|
+
o;for await(let s of n){if(UY(s)){let c=zY(s);if(D(this,ln,"f")){let d=D(this,ln,"f").choices[0]?.message.tool_calls;for(let[
|
|
4926
4927
|
u,l]of c.tool_call_ids?.entries()??[]){let p=d?.[u];p&&l&&(p.id=l)}this._addChatCompletion(D(this,Pt,"m",Tl).call(this)),
|
|
4927
4928
|
o=void 0}this._addMessage(c.message);continue}let a=s;o&&a.id&&o!==a.id&&this._addChatCompletion(D(this,Pt,"m",Tl).call(
|
|
4928
4929
|
this)),D(this,Pt,"m",Jb).call(this,a),a.id&&(o=a.id)}if(n.controller.signal?.aborted)throw new At;if(D(this,ln,"f"))return this.
|
|
@@ -4954,7 +4955,7 @@ this);this._emit("content.done",{content:r.message.content,parsed:o?o.$parseRaw(
|
|
|
4954
4955
|
(n.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:r.logprobs.content})),r.logprobs?.refusal&&!n.logprobs_refusal_done&&
|
|
4955
4956
|
(n.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:r.logprobs.refusal}))},Tl=function(){if(this.ended)
|
|
4956
4957
|
throw new Q("stream has ended, this shouldn't happen");let r=D(this,ln,"f");if(!r)throw new Q("request ended without sen\
|
|
4957
|
-
ding any chunks");let n=D(this,ni,"f");return ve(this,ni,new Set,"f"),ve(this,ln,void 0,"f"),ve(this,xc,[],"f"),
|
|
4958
|
+
ding any chunks");let n=D(this,ni,"f");return ve(this,ni,new Set,"f"),ve(this,ln,void 0,"f"),ve(this,xc,[],"f"),FY(r,D(this,
|
|
4958
4959
|
ho,"f"),n)},Zb=function(){let r=D(this,ho,"f")?.response_format;return vl(r)?r:null},oL=function(r){var n,o,i,s,a;let c=D(
|
|
4959
4960
|
this,ln,"f"),{choices:d,...u}=r;c?r.id&&Object.assign(c,u):c=ve(this,ln,{...u,choices:[]},"f");for(let{delta:l,finish_reason:p,
|
|
4960
4961
|
index:f,logprobs:y=null,...h}of r.choices){let v=c.choices[f];if(v||(v=c.choices[f]={finish_reason:p,index:f,message:{},
|
|
@@ -4978,9 +4979,9 @@ Symbol.asyncIterator)](){let t=[],r=[],n=!1;return this.on("chunk",o=>{let i=r.s
|
|
|
4978
4979
|
0}),this.on("error",o=>{n=!0;for(let i of r)i.reject(o);r.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:n?
|
|
4979
4980
|
{value:void 0,done:!0}:new Promise((i,s)=>r.push({resolve:i,reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),
|
|
4980
4981
|
return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new wr(this[Symbol.asyncIterator].bind(
|
|
4981
|
-
this),this.controller).toReadableStream()}};function
|
|
4982
|
+
this),this.controller).toReadableStream()}};function FY(e,t,r){let{id:n,choices:o,created:i,model:s,system_fingerprint:a,
|
|
4982
4983
|
...c}=e,d={...c,id:n,choices:o.map(({message:u,finish_reason:l,index:p,logprobs:f,...y})=>{let{content:h=null,function_call:v,
|
|
4983
|
-
tool_calls:w,audio:m,..._}=u,I=l??(r.has(p)&&
|
|
4984
|
+
tool_calls:w,audio:m,..._}=u,I=l??(r.has(p)&&BY(m)?"stop":null);if(!I)throw new Q(`missing finish_reason for choice ${p}`);
|
|
4984
4985
|
let x=m?{audio:m}:{},C=u.role;if(!C)throw new Q(`missing role for choice ${p}`);if(v){let{arguments:T,name:M}=v;if(T==null)
|
|
4985
4986
|
throw new Q(`missing function_call.arguments for choice ${p}`);if(!M)throw new Q(`missing function_call.name for choice ${p}`);
|
|
4986
4987
|
return{...y,message:{...x,content:h,function_call:{arguments:T,name:M},role:C,refusal:u.refusal??null},finish_reason:I,index:p,
|
|
@@ -4991,7 +4992,7 @@ ${Qb(e)}`);if(ye==null)throw new Q(`missing choices[${p}].tool_calls[${M}].funct
|
|
|
4991
4992
|
${Qb(e)}`);if(Z==null)throw new Q(`missing choices[${p}].tool_calls[${M}].function.arguments
|
|
4992
4993
|
${Qb(e)}`);return{...se,id:X||`call_${ss()}`,type:K,function:{...ae,name:ye,arguments:Z}}})}}:{...y,message:{..._,...x,content:h,
|
|
4993
4994
|
role:C,refusal:u.refusal??null},finish_reason:I,index:p,logprobs:f}}),created:i,model:s,object:"chat.completion",...a?{system_fingerprint:a}:
|
|
4994
|
-
{}};return XM(d,t)}function
|
|
4995
|
+
{}};return XM(d,t)}function BY(e){return e?.id!=null&&e.data!=null&&e.transcript!=null&&e.expires_at!=null}function Qb(e){
|
|
4995
4996
|
return JSON.stringify(e)}var Cl=class e extends ps{static fromReadableStream(t){let r=new e(null);return r._run(()=>r._fromReadableStream(t)),r}toReadableStream(){
|
|
4996
4997
|
let t=[],r=[],n=!1,o,i,s=d=>{let u=r.shift();u?u.resolve(d):t.push(d)};this.on("chunk",d=>{o=d,s(d)}),this.on("message",
|
|
4997
4998
|
d=>{if(fo(d)){i=d.tool_calls?.map(u=>u.id);return}if(_l(d)){if(!o)throw new Q("cannot serialize a tool message before re\
|
|
@@ -5355,16 +5356,16 @@ return this._client.getAPIList("/models",rr,{...t,__security:{bearerAuth:!0}})}d
|
|
|
5355
5356
|
headers:J([{Accept:"*/*"},r?.headers]),__security:{bearerAuth:!0}})}refer(t,r,n){return this._client.post(R`/realtime/calls/${t}/refer`,
|
|
5356
5357
|
{body:r,...n,headers:J([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}reject(t,r={},n){return this._client.post(
|
|
5357
5358
|
R`/realtime/calls/${t}/reject`,{body:r,...n,headers:J([{Accept:"*/*"},n?.headers]),__security:{bearerAuth:!0}})}};var yd=class extends j{create(t,r){return this._client.post("/realtime/client_secrets",{body:t,...r,__security:{bearerAuth:!0}})}};var vo=class extends j{constructor(){super(...arguments),this.clientSecrets=new yd(this._client),this.calls=new vd(this.
|
|
5358
|
-
_client)}};vo.ClientSecrets=yd;vo.Calls=vd;function mL(e,t){if(!t||!
|
|
5359
|
+
_client)}};vo.ClientSecrets=yd;vo.Calls=vd;function mL(e,t){if(!t||!e7(t)){let r={...e,output_parsed:null,output:e.output.map(n=>n.type==="function_call"?{...n,parsed_arguments:null}:
|
|
5359
5360
|
n.type==="message"?{...n,content:n.content.map(o=>({...o,parsed:null}))}:n)};return gL(e,r)&&Pr(r),r}return rI(e,t)}function rI(e,t){
|
|
5360
|
-
let r=!e.status||e.status==="completed",n=e.output.map(i=>{if(i.type==="function_call")return r?
|
|
5361
|
-
if(i.type==="message"){let s=i.content.map(a=>a.type==="output_text"?{...a,parsed:r?
|
|
5361
|
+
let r=!e.status||e.status==="completed",n=e.output.map(i=>{if(i.type==="function_call")return r?r7(t,i):{...i,parsed_arguments:null};
|
|
5362
|
+
if(i.type==="message"){let s=i.content.map(a=>a.type==="output_text"?{...a,parsed:r?QZ(t,a.text):null}:a);return{...i,content:s}}
|
|
5362
5363
|
return i}),o=Object.assign({},e,{output:n});return gL(e,o)&&Pr(o),Object.defineProperty(o,"output_parsed",{enumerable:!0,
|
|
5363
5364
|
get(){for(let i of o.output)if(i.type==="message"){for(let s of i.content)if(s.type==="output_text"&&s.parsed!==null)return s.
|
|
5364
|
-
parsed}return null}}),o}function
|
|
5365
|
-
text?.format).$parseRaw(t):JSON.parse(t)}function
|
|
5366
|
-
t=>hL(t)||t.type==="function"&&t.strict===!0)}function hL(e){return e?.$brand==="auto-parseable-tool"}function
|
|
5367
|
-
t)}function
|
|
5365
|
+
parsed}return null}}),o}function QZ(e,t){return e.text?.format?.type!=="json_schema"?null:"$parseRaw"in e.text?.format?(e.
|
|
5366
|
+
text?.format).$parseRaw(t):JSON.parse(t)}function e7(e){return vl(e.text?.format)?!0:Array.isArray(e.tools)&&e.tools.some(
|
|
5367
|
+
t=>hL(t)||t.type==="function"&&t.strict===!0)}function hL(e){return e?.$brand==="auto-parseable-tool"}function t7(e,t){return e.find(r=>r.type==="function"&&r.name===
|
|
5368
|
+
t)}function r7(e,t){let r=t7(e.tools??[],t.name);return{...t,...t,parsed_arguments:hL(r)?r.$parseRaw(t.arguments):r?.strict?
|
|
5368
5369
|
JSON.parse(t.arguments):null}}function gL(e,t){return!Object.getOwnPropertyDescriptor(e,"output_text")||t.output_text==null}function Pr(e){let t=[];for(let r of e.
|
|
5369
5370
|
output)if(r.type==="message")for(let n of r.content)n.type==="output_text"&&t.push(n.text);e.output_text=t.join("")}function vL(e,t){if(!t){if(e.type!=="response.created")throw new Q(`When snapshot hasn't been set yet, expected 'respons\
|
|
5370
5371
|
e.created' event, got ${e.type}`);return wL(e.response)}switch(e.type){case"response.output_item.added":{t.output.push(structuredClone(
|
|
@@ -5424,10 +5425,10 @@ type==="mcp_call"&&(r.status="in_progress");break}case"response.mcp_call.complet
|
|
|
5424
5425
|
d":case"response.failed":case"response.incomplete":{t=wL(e.response);break}case"response.audio.delta":case"response.audi\
|
|
5425
5426
|
o.done":case"response.audio.transcript.delta":case"response.audio.transcript.done":case"response.image_generation_call.p\
|
|
5426
5427
|
artial_image":case"response.mcp_list_tools.in_progress":case"response.mcp_list_tools.completed":case"response.mcp_list_t\
|
|
5427
|
-
ools.failed":case"keepalive":case"error":break;default:
|
|
5428
|
+
ools.failed":case"keepalive":case"error":break;default:n7(e)}return t}function wL(e){let t=structuredClone(e);return(!Object.
|
|
5428
5429
|
getOwnPropertyDescriptor(t,"output_text")||t.output_text==null)&&Pr(t),t}function Ge(e,t){let r=e.output[t];if(!r)throw new Q(
|
|
5429
5430
|
`missing output at index ${t}`);return r}function Xr(e,t){let r=e[t];if(!r)throw new Q(`missing content at index ${t}`);
|
|
5430
|
-
return r}function
|
|
5431
|
+
return r}function n7(e){throw new Q(`Unhandled response stream event: ${JSON.stringify(e)}`)}var hi,jh,Ns,Mh,nI,oI,iI,Lh=class e extends ri{constructor(t){super(),hi.add(this),jh.set(this,void 0),Ns.set(this,void 0),
|
|
5431
5432
|
Mh.set(this,void 0),ve(this,jh,t,"f")}static createResponse(t,r,n){let o=new e(r);return o._run(()=>o._createOrRetrieveResponse(
|
|
5432
5433
|
t,r,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}})),o}static fromReadableStream(t){let r=new e(null);
|
|
5433
5434
|
return r._run(()=>r._fromReadableStream(t)),r}async _createOrRetrieveResponse(t,r,n){this._listenForAbort(n?.signal),D(this,
|
|
@@ -5446,12 +5447,12 @@ ta",{...r,snapshot:a.text})}break}case"response.function_call_arguments.delta":{
|
|
|
5446
5447
|
`missing output at index ${r.output_index}`);s.type==="function_call"&&o("response.function_call_arguments.delta",{...r,
|
|
5447
5448
|
snapshot:s.arguments});break}default:o(r.type,r);break}},iI=function(){if(this.ended)throw new Q("stream has ended, this\
|
|
5448
5449
|
shouldn't happen");let r=D(this,Ns,"f");if(!r)throw new Q("request ended without sending any events");ve(this,Ns,void 0,
|
|
5449
|
-
"f");let n=
|
|
5450
|
+
"f");let n=o7(r,D(this,jh,"f"));return ve(this,Mh,n,"f"),n},Symbol.asyncIterator)](){let t=[],r=[],n=!1;return this.on("\
|
|
5450
5451
|
event",o=>{let i=r.shift();i?i.resolve(o):t.push(o)}),this.on("end",()=>{n=!0;for(let o of r)o.resolve(void 0);r.length=
|
|
5451
5452
|
0}),this.on("abort",o=>{n=!0;for(let i of r)i.reject(o);r.length=0}),this.on("error",o=>{n=!0;for(let i of r)i.reject(o);
|
|
5452
5453
|
r.length=0}),{next:async()=>t.length?{value:t.shift(),done:!1}:n?{value:void 0,done:!0}:new Promise((i,s)=>r.push({resolve:i,
|
|
5453
5454
|
reject:s})).then(i=>i?{value:i,done:!1}:{value:void 0,done:!0}),return:async()=>(this.abort(),{value:void 0,done:!0})}}async finalResponse(){
|
|
5454
|
-
await this.done();let t=D(this,Mh,"f");if(!t)throw new Q("stream ended without producing a ChatCompletion");return t}};function
|
|
5455
|
+
await this.done();let t=D(this,Mh,"f");if(!t)throw new Q("stream ended without producing a ChatCompletion");return t}};function o7(e,t){
|
|
5455
5456
|
return mL(e,t)}var _d=class extends j{list(t,r={},n){return this._client.getAPIList(R`/responses/${t}/input_items`,Ce,{query:r,...n,__security:{
|
|
5456
5457
|
bearerAuth:!0}})}};var bd=class extends j{count(t={},r){return this._client.post("/responses/input_tokens",{body:t,...r,__security:{bearerAuth:!0}})}};var Un=class extends j{constructor(){super(...arguments),this.inputItems=new _d(this._client),this.inputTokens=new bd(this.
|
|
5457
5458
|
_client)}create(t,r){return this._client.post("/responses",{body:t,...r,stream:t.stream??!1,__security:{bearerAuth:!0}}).
|
|
@@ -5540,7 +5541,7 @@ ret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client c
|
|
|
5540
5541
|
or passed to this function")},$h=function(t,r){if(!t)throw new Error("Headers are required");let n=t.get(r);if(n==null)throw new Error(
|
|
5541
5542
|
`Missing required header: ${r}`);return n};var IL=Symbol.for("openai.node.providerDefinitions.v1"),SL=globalThis,AL=SL[IL],EL=AL??new WeakMap;AL||Object.defineProperty(
|
|
5542
5543
|
SL,IL,{value:EL});function xL(e){let t=EL.get(e);if(!t)throw new Error("Invalid provider. Providers must be created with createProvider().");
|
|
5543
|
-
return t.configure()}var sI,aI,kl,TL,
|
|
5544
|
+
return t.configure()}var sI,aI,kl,TL,f7="workload-identity-auth",Re=class{constructor(t={}){sI.add(this),kl.set(this,void 0),this.completions=
|
|
5544
5545
|
new Is(this),this.chat=new oi(this),this.embeddings=new As(this),this.files=new xs(this),this.images=new Os(this),this.audio=
|
|
5545
5546
|
new $n(this),this.moderations=new ks(this),this.models=new Ps(this),this.fineTuning=new mn(this),this.graders=new mi(this),
|
|
5546
5547
|
this.vectorStores=new _o(this),this.webhooks=new Ls(this),this.beta=new Jr(this),this.batches=new ws(this),this.uploads=
|
|
@@ -5607,7 +5608,7 @@ d"} - ${_}`),Et(this).debug(`[${u}] connection ${I?"timed out":"failed"} (${_})`
|
|
|
5607
5608
|
p,message:h.message})),this.retryRequest(o,r,n??u);let x=d?"error; streaming body cannot be retried":"error; no more ret\
|
|
5608
5609
|
ries left";throw Et(this).info(`[${u}] connection ${I?"timed out":"failed"} - ${x}`),Et(this).debug(`[${u}] connection ${I?
|
|
5609
5610
|
"timed out":"failed"} (${x})`,po({retryOfRequestLogID:n,url:a,durationMs:v-p,message:h.message})),h instanceof as||h instanceof
|
|
5610
|
-
dl?h:I?new Qo:new Zo({message:
|
|
5611
|
+
dl?h:I?new Qo:new Zo({message:m7(h),cause:h})}let w=[...h.headers.entries()].filter(([_])=>_==="x-request-id").map(([_,I])=>"\
|
|
5611
5612
|
, "+_+": "+JSON.stringify(I)).join(""),m=`[${u}${l}${w}] ${s.method} ${a} ${h.ok?"succeeded":"failed"} with status ${h.status}\
|
|
5612
5613
|
in ${v-p}ms`;if(!h.ok){if(h.status===401&&this._workloadIdentityAuth&&f.bearerAuth&&!o.__metadata?.hasStreamingBody&&!o.
|
|
5613
5614
|
__metadata?.workloadIdentityTokenRefreshed)return await _b(h.body),this._workloadIdentityAuth.invalidateToken(),this.makeRequest(
|
|
@@ -5622,7 +5623,7 @@ now()-p})),this.makeStatusError(h.status,C,T,h.headers)}return Et(this).info(m),
|
|
|
5622
5623
|
requestLogID:u,retryOfRequestLogID:n,startTime:p}}getAPIList(t,r,n){return this.requestAPIList(r,n&&"then"in n?n.then(o=>({
|
|
5623
5624
|
method:"get",path:t,...o})):{method:"get",path:t,...n})}requestAPIList(t,r){let n=this.makeRequest(r,null,void 0);return new hl(
|
|
5624
5625
|
this,n,t)}async fetchWithAuth(t,r,n,o,i={bearerAuth:!0,adminAPIKeyAuth:!0}){if(this._workloadIdentityAuth&&i.bearerAuth){
|
|
5625
|
-
let a=r.headers,c=a.get("Authorization");if(!c||c===`Bearer ${
|
|
5626
|
+
let a=r.headers,c=a.get("Authorization");if(!c||c===`Bearer ${f7}`){let d=await this._workloadIdentityAuth.getToken();a.
|
|
5626
5627
|
set("Authorization",`Bearer ${d}`)}}return await this.fetchWithTimeout(t,r,n,o)}async fetchWithTimeout(t,r,n,o){let{signal:i,
|
|
5627
5628
|
method:s,...a}=r||{},c=this._makeAbort(o);i&&i.addEventListener("abort",c,{once:!0});let d=setTimeout(c,n),u=globalThis.
|
|
5628
5629
|
ReadableStream&&a.body instanceof globalThis.ReadableStream||typeof a.body=="object"&&a.body!==null&&Symbol.asyncIterator in
|
|
@@ -5659,17 +5660,17 @@ At;Re.NotFoundError=pc;Re.ConflictError=fc;Re.RateLimitError=hc;Re.BadRequestErr
|
|
|
5659
5660
|
gc;Re.PermissionDeniedError=lc;Re.UnprocessableEntityError=mc;Re.InvalidWebhookSignatureError=jn;Re.toFile=bh;Re.toStreamingFile=
|
|
5660
5661
|
yh;Re.Completions=Is;Re.Chat=oi;Re.Embeddings=As;Re.Files=xs;Re.Images=Os;Re.Audio=$n;Re.Moderations=ks;Re.Models=Ps;Re.
|
|
5661
5662
|
FineTuning=mn;Re.Graders=mi;Re.VectorStores=_o;Re.Webhooks=Ls;Re.Beta=Jr;Re.Batches=ws;Re.Uploads=gi;Re.Admin=si;Re.Responses=
|
|
5662
|
-
Un;Re.Realtime=vo;Re.Conversations=pi;Re.Evals=fi;Re.Containers=li;Re.Skills=yo;Re.Videos=Ms;function
|
|
5663
|
+
Un;Re.Realtime=vo;Re.Conversations=pi;Re.Evals=fi;Re.Containers=li;Re.Skills=yo;Re.Videos=Ms;function m7(e){if(h7(e))return"\
|
|
5663
5664
|
Connection error. This may be caused by passing an undici dispatcher, such as ProxyAgent, that is incompatible with the \
|
|
5664
5665
|
fetch implementation. If you are using undici's ProxyAgent, pass the fetch implementation from the same undici package: \
|
|
5665
|
-
import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });"}function
|
|
5666
|
+
import { fetch, ProxyAgent } from 'undici'; new OpenAI({ fetch, fetchOptions: { dispatcher: new ProxyAgent(...) } });"}function h7(e){
|
|
5666
5667
|
let t=e;for(let r=0;r<8&&t&&typeof t=="object";r++){let n=t;if(n.code==="UND_ERR_INVALID_ARG"&&typeof n.message=="string"&&
|
|
5667
|
-
n.message.includes("invalid onRequestStart method"))return!0;t=n.cause}return!1}var cI=Object.freeze(["openai","deepseek","anthropic"]),
|
|
5668
|
-
[kP]:404,vibe64_project_path_not_directory:409,vibe64_project_path_symlink:409});var
|
|
5668
|
+
n.message.includes("invalid onRequestStart method"))return!0;t=n.cause}return!1}var cI=Object.freeze(["openai","deepseek","anthropic"]),t2e=new Set(cI);uI();uI();import{createHash as S7}from"node:crypto";import I7 from"node:path";function Dh({env:e=process.env,credentialHome:t}={}){return e.CLAUDE_CONFIG_DIR||I7.join((t||cp()).home,".claude")}var OL="vibe64_learning_mode_project";var _We=Object.freeze({on:!1,currentAttemptId:"",lessonCode:"",practiceSlug:""});var PL="vibe64_team_ai_required";var VWe=Object.freeze({vibe64_invalid_project_slug:422,vibe64_project_route_unavailable:404,[OL]:403,[PL]:403,vibe64_project_path_not_accessible:404,
|
|
5669
|
+
[kP]:404,vibe64_project_path_not_directory:409,vibe64_project_path_symlink:409});var iKe=Object.freeze({assistant_opencode_stop_unverified:"vibe64_opencode_stop_unverified",assistant_opencode_interrupt_unconfirmed:"\
|
|
5669
5670
|
vibe64_opencode_interrupt_unconfirmed",assistant_opencode_interrupt_timeout:"vibe64_opencode_interrupt_timeout",assistant_opencode_conversation_busy:"\
|
|
5670
|
-
vibe64_opencode_conversation_busy"});var
|
|
5671
|
+
vibe64_opencode_conversation_busy"});var vKe=Vr.CLAUDE,yKe=K0.CLAUDE_STREAM_JSON,A7=e=>S7("sha256").update(e).digest("hex");function kL(e,t,r){return`sha256:${A7(
|
|
5671
5672
|
JSON.stringify([e,t,r]))}`}function lI(e,t){let{engineId:r,modelProviderId:n,modelId:o,variantId:i}=e;return{engine:r,configuration:{systemPrompt:t,
|
|
5672
|
-
model:o,...r==="codex"&&n==="openai"||r==="claude"&&n==="anthropic"?{}:{integrationId:n},...i?{effort:i}:{}}}}var
|
|
5673
|
+
model:o,...r==="codex"&&n==="openai"||r==="claude"&&n==="anthropic"?{}:{integrationId:n},...i?{effort:i}:{}}}}var E7=["Keep replies short by default: usually one or two brief sentences. Give a detailed explanation only when the us\
|
|
5673
5674
|
er asks for one; include essential outcomes, failures or a necessary clarification without padding.","Answer the actual \
|
|
5674
5675
|
request. For a greeting or 'say hi', just greet the user. Do not add a workspace/project/session recap, a list of action\
|
|
5675
5676
|
s you did not take, generic readiness offers or repeated safety assurances unless the user asks or that information is n\
|
|
@@ -5680,7 +5681,7 @@ join(`
|
|
|
5680
5681
|
conversations. When they ask about courses, lessons or learning, say that pressing L switches to Learn mode, which ends\
|
|
5681
5682
|
nothing, and offer to switch them with learning-mode.set; run it only after their direct request or accepted offer. Pra\
|
|
5682
5683
|
ctice projects open only in Learn mode: if opening one is refused, relay its reason, "This is a practice project. Press \
|
|
5683
|
-
L to switch to Learn."',
|
|
5684
|
+
L to switch to Learn."',x7=["The person is in Learn mode and you are their teacher. Vibe64 shows only their practice pro\
|
|
5684
5685
|
jects there. This conversation belongs to Learn mode: each lesson attempt has its own teacher conversation, which resume\
|
|
5685
5686
|
s whenever they come back to that lesson, and Learn mode without a lesson has this learner-level one. Courses, the butto\
|
|
5686
5687
|
n at the right of the lesson step bar (also in the project menu beside L), is the catalogue where lessons are chosen and\
|
|
@@ -5797,14 +5798,14 @@ For a dependency use waitingForAssignmentId and return, never a model polling lo
|
|
|
5797
5798
|
lar waits or a stopped dependency with the user. Do not pass source code or pretend that separate sessions share unsaved\
|
|
5798
5799
|
files.","Do not silently repeat a mutation with an unknown outcome. Inspect actual state first. Reuse issued message an\
|
|
5799
5800
|
d conversation IDs on an explicit retry.","Opening a view requires the browser's acknowledgement; creating a conversatio\
|
|
5800
|
-
n alone does not open it.",
|
|
5801
|
-
`),
|
|
5801
|
+
n alone does not open it.",E7].join(`
|
|
5802
|
+
`),T7="Current response contract: a tool envelope may include a short user-facing progress sentence in text. On the firs\
|
|
5802
5803
|
t tool request for a user's question, say what you are about to check or do, for example 'Let me check your projects.' K\
|
|
5803
5804
|
eep it to one natural sentence, at most 280 characters. This is intent, never a claim of success; do not expose tool nam\
|
|
5804
5805
|
es, arguments, private reasoning or technical discovery steps. If progressAlreadySaid is present, leave tool text empty \
|
|
5805
5806
|
for the rest of that request. Do not emit a reply merely to acknowledge: keep the actual tool call in the same envelope \
|
|
5806
5807
|
and continue to the result. Greetings and direct answers need no progress sentence. Autonomous watch/assignment updates \
|
|
5807
|
-
must leave tool text empty.",
|
|
5808
|
+
must leave tool text empty.",C7=["The tools array describes Vibe64 application operations, NOT native tools in your mode\
|
|
5808
5809
|
l runtime. Request an operation by returning a completed JSON envelope with kind=tool, toolName set to the advertised na\
|
|
5809
5810
|
me, and arguments containing a JSON-encoded object. Vibe64 executes that envelope after your response finishes and suppl\
|
|
5810
5811
|
ies the result in feedback on the next turn. Do not call application tool names as native tools.",'For example, to find \
|
|
@@ -5818,16 +5819,16 @@ turned actionId, then call assistant_action_execute with that actionId and an in
|
|
|
5818
5819
|
guments. Never pass operation fields directly as the execute tool's top-level arguments. If execution reports Action is \
|
|
5819
5820
|
not available, first check that your call supplied the exact actionId; a malformed call does not prove the advertised ac\
|
|
5820
5821
|
tion is missing."].join(`
|
|
5821
|
-
`),
|
|
5822
|
+
`),R7=Cd.replace(NL,x7),jL=e=>[e,C7,T7,'Return exactly one JSON object: {"kind":"reply","text":"your reply","toolName":"\
|
|
5822
5823
|
","arguments":""} OR {"kind":"tool","text":"brief progress sentence or empty","toolName":"exact tool name","arguments":"\
|
|
5823
5824
|
JSON object encoded as a string"}.',"Only a completed response is executed. Do not put tool directives in prose, code fe\
|
|
5824
5825
|
nces, or quoted text."].join(`
|
|
5825
|
-
`),
|
|
5826
|
-
engineId==="claude"&&(
|
|
5827
|
-
"openai"||!!Lr(e.modelProviderId)),fI=(e,t)=>`${e}:${t}`,
|
|
5826
|
+
`),IKe=jL(Cd),SKe=jL(R7);var zh=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/iu,k7=e=>e?.engineId==="claude"&&e.modelProviderId==="anthropic",Fh=e=>e?.
|
|
5827
|
+
engineId==="claude"&&(k7(e)||!!Lr(e.modelProviderId))||e?.engineId==="opencode"||e?.engineId==="codex"&&(e.modelProviderId===
|
|
5828
|
+
"openai"||!!Lr(e.modelProviderId)),fI=(e,t)=>`${e}:${t}`,N7={type:"object",additionalProperties:!1,required:["kind","tex\
|
|
5828
5829
|
t","toolName","arguments"],properties:{kind:{type:"string",enum:["reply","tool"]},text:{type:"string",description:"The f\
|
|
5829
5830
|
inal reply, or a brief progress sentence for the first tool request; empty for subsequent tool requests."},toolName:{type:"\
|
|
5830
|
-
string"},arguments:{type:"string"}}},ML=Nm({outputSchema:
|
|
5831
|
+
string"},arguments:{type:"string"}}},ML=Nm({outputSchema:N7});function LL(e){let t=e.content.filter(r=>r.type==="text").
|
|
5831
5832
|
map(r=>r.text).join(`
|
|
5832
5833
|
`);if(!t.endsWith(ML))return null;try{return JSON.parse(t.slice(0,-ML.length))}catch{return null}}function or(e,t){try{let r=JSON.
|
|
5833
5834
|
parse(e);if(r&&typeof r=="object"&&!Array.isArray(r))return r}catch{}throw new Error(`${t} is invalid. Inspect it before\
|
|
@@ -5869,11 +5870,11 @@ guration.");let kt=Be.join(et.toolHomeSource,".codex"),Nt=Be.join(en.toolHomeSou
|
|
|
5869
5870
|
Nt;Be.isAbsolute(Qt)||T("The original native SQLite home is not an absolute trusted path.");let Eo=Be.join(Qt,"goals_1.s\
|
|
5870
5871
|
qlite");await ge(Qt,Eo);let Nr=await om(Eo,{threadId:I.conversationId});Nr!==null&&!["paused","complete"].includes(Nr.status)&&
|
|
5871
5872
|
T("The original native Codex goal is not paused or complete. Resolve it through its original owner before retrying.");let wn=[];
|
|
5872
|
-
for await(let It of
|
|
5873
|
+
for await(let It of O7([`sessions/*/*/*/rollout-*-${I.conversationId}.jsonl*`,`archived_sessions/rollout-*-${I.conversationId}\
|
|
5873
5874
|
.jsonl*`],{cwd:Nt}))wn.push(Be.join(Nt,It));(wn.length!==1||!wn[0].endsWith(".jsonl"))&&T("The original native Codex rol\
|
|
5874
5875
|
lout is missing, ambiguous or compressed. Keep its original files unchanged until supported inspection is possible.");let Ct=wn[0];
|
|
5875
5876
|
await ge(Nt,Ct);let Ut=await Rd(Ct);(!Ut.isFile()||Ut.isSymbolicLink()||await pI(Ct)!==Ct)&&T("The original Codex rollou\
|
|
5876
|
-
t is not a canonical regular file.");let Qe=await
|
|
5877
|
+
t is not a canonical regular file.");let Qe=await P7(Ct,"r"),Bs=0,jr="",Ld="",Je=null,qs=null,Si="",$d="",Dd=null,at=0,Ai=!0;
|
|
5877
5878
|
try{for await(let{row:It}of by(Qe,0,Ut.size,new AbortController().signal,{strictComplete:!0})){let je=It.payload;if(It.type===
|
|
5878
5879
|
"session_meta"&&(Bs++,(je?.id!==I.conversationId||je.cwd!==M||je.model_provider!==ze||je.forked_from_id||je.parent_thread_id||
|
|
5879
5880
|
je.history_base!=null||je.forked_from_ordinal_exclusive!=null||je.subagent_history_start_ordinal!=null||je.source?.subagent!=
|
|
@@ -6048,13 +6049,13 @@ let h=a({...l,original:p,saved:f});if(!h||!wi(or(h.contents,"Reinspected Colleag
|
|
|
6048
6049
|
pared Colleague instructions differ from the original binding or history. Inspect the verified backup before retrying.")}}
|
|
6049
6050
|
await xe({systemRoot:e,apply:t,backupRoot:r,report:n,prepareUpdates:async()=>{let d=[];for(let u of s){let l=a(u);l&&(n(
|
|
6050
6051
|
"warning",`${u.ownerKey}: restore only the missing Colleague instructions with all product writers stopped. The failed r\
|
|
6051
|
-
equest, native binding, account and full history remain unchanged; no request is sent or retried.`),d.push(l))}return d}})}import{readdir as
|
|
6052
|
+
equest, native binding, account and full history remain unchanged; no request is sent or retried.`),d.push(l))}return d}})}import{readdir as j7}from"node:fs/promises";import vi from"node:path";import{isDeepStrictEqual as zL}from"node:util";var Od=e=>e&&typeof e=="object"&&!Array.isArray(e),M7=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/iu;function Nl(e){try{
|
|
6052
6053
|
let t=JSON.parse(e);if(Od(t))return t}catch{}throw new Error("Colleague operation-receipt state is invalid. Inspect it b\
|
|
6053
|
-
efore repairing.")}function
|
|
6054
|
+
efore repairing.")}function L7(e){if(typeof e.arguments!="string")return!1;let t;try{t=JSON.parse(e.arguments)}catch{return!1}
|
|
6054
6055
|
let r=e.result;return Od(t)&&typeof t.actionId=="string"&&/^vibe64\.[\w.-]{1,128}$/u.test(t.actionId)&&t.version===1&&Od(
|
|
6055
6056
|
t.input)&&Od(r)&&r.ok===!0&&Od(r.result)&&r.result.actionId===t.actionId&&r.result.version===t.version&&Od(r.result.result)&&
|
|
6056
6057
|
r.result.result.ok===!0}async function _I({systemRoot:e,apply:t,backupRoot:r,report:n}){let o=vi.join(e,"colleague");await ge(
|
|
6057
|
-
e,vi.join(o,"placeholder"));let i=await
|
|
6058
|
+
e,vi.join(o,"placeholder"));let i=await j7(o,{withFileTypes:!0}).catch(u=>{if(u.code==="ENOENT")return[];throw u}),s=[];
|
|
6058
6059
|
for(let u of i){if(!u.isDirectory()||!/^[\w-]+$/u.test(u.name))throw new Error("Unexpected Colleague state entry. Inspec\
|
|
6059
6060
|
t it before repairing.");let l=vi.join(o,u.name,"conversation.json");await ge(e,l);let p=await Ae(l);if(p===null)continue;
|
|
6060
6061
|
let f=Nl(p);pt(f,u.name),s.push({ownerKey:u.name,filePath:l,original:p,saved:f})}let a=({ownerKey:u,filePath:l,original:p,
|
|
@@ -6062,8 +6063,8 @@ saved:f})=>{let y=f.retiredConversation;if(!y?.operation||y.assistantSelection?.
|
|
|
6062
6063
|
runtime||f.previousConversations?.length||f.freshOperation)return null;let h=()=>{throw new Error(`${u}: the retired ope\
|
|
6063
6064
|
ration is not an unchanged completed legacy receipt. Inspect original completion and native receipts; no work was replay\
|
|
6064
6065
|
ed.`)},v=y.operation;(f.schemaVersion!==3||f.status!=="ready"||f.operation||!zL(f.assistantSelection,y.assistantSelection)||
|
|
6065
|
-
Object.hasOwn(y,"completedOperationReceipt")||v.status!=="completed"||!
|
|
6066
|
-
_execute"||!
|
|
6066
|
+
Object.hasOwn(y,"completedOperationReceipt")||v.status!=="completed"||!M7.test(v.id||"")||v.toolName!=="assistant_action\
|
|
6067
|
+
_execute"||!L7(v)||["request","replacement","rewind","continuity"].some(I=>Object.hasOwn(f.conversationMetadata||{},I))||
|
|
6067
6068
|
f.conversationLog.some(I=>["running","working","inProgress"].includes(I.metadata?.runtime?.status)||I.metadata?.applicationTools?.
|
|
6068
6069
|
some(x=>x.status!=="complete"||!x.result))||(f.assignments||[]).some(I=>I.turns?.some(x=>["reserved","unknown"].includes(
|
|
6069
6070
|
x.status))))&&h();let{operation:w,...m}=y,_={...f,retiredConversation:{...m,completedOperationReceipt:w}};return pt(_,u),
|
|
@@ -6077,25 +6078,25 @@ v=a({...p,original:f,saved:y});if(!v||!zL(Nl(v.contents),h))throw new Error("The
|
|
|
6077
6078
|
its original marker. Inspect the verified backup before retrying.")}}await xe({systemRoot:e,apply:t,backupRoot:r,report:n,
|
|
6078
6079
|
prepareUpdates:async()=>{let u=[];for(let l of s){let p=a(l);p&&(n("warning",`${l.ownerKey}: retain the completed operat\
|
|
6079
6080
|
ion as a receipt with all writers stopped. Native continuity must still pass its original proof; no request or native fi\
|
|
6080
|
-
le changes.`),u.push(p))}return u}})}import{lstat as
|
|
6081
|
+
le changes.`),u.push(p))}return u}})}import{lstat as $7,readdir as D7}from"node:fs/promises";import bI from"node:path";var U7="learning-task",z7=e=>e&&typeof e=="object"&&!Array.isArray(e);function F7(e){try{let t=JSON.parse(e);if(z7(t))return t}catch{}
|
|
6081
6082
|
throw new Error("Colleague conversation state is invalid. Inspect it before upgrading.")}async function II({systemRoot:e,
|
|
6082
|
-
apply:t,backupRoot:r,report:n}){let o=bI.join(e,"colleague");await ge(e,bI.join(o,"placeholder"));let i;try{if(!(await
|
|
6083
|
-
o)).isDirectory())throw new Error("Colleague state must be a regular directory.");i=await
|
|
6083
|
+
apply:t,backupRoot:r,report:n}){let o=bI.join(e,"colleague");await ge(e,bI.join(o,"placeholder"));let i;try{if(!(await $7(
|
|
6084
|
+
o)).isDirectory())throw new Error("Colleague state must be a regular directory.");i=await D7(o,{withFileTypes:!0})}catch(s){
|
|
6084
6085
|
if(s.code==="ENOENT")i=[];else throw s}await xe({systemRoot:e,apply:t,backupRoot:r,report:n,prepareUpdates:async()=>{let s=[];
|
|
6085
6086
|
for(let a of i.sort((c,d)=>c.name.localeCompare(d.name))){if(!a.isDirectory()||!/^[\w-]+$/u.test(a.name))throw new Error(
|
|
6086
6087
|
"Unexpected Colleague state entry. Inspect it before upgrading.");let c=bI.join(o,a.name,"conversation.json");await ge(e,
|
|
6087
|
-
c);let d=await Ae(c);if(d===null)continue;let u=
|
|
6088
|
+
c);let d=await Ae(c);if(d===null)continue;let u=F7(d);pt(u,a.name);let l=new Set((u.watches||[]).filter(f=>f?.source===U7).
|
|
6088
6089
|
map(f=>f.watchId));if(!l.size)continue;let p={...u,watches:u.watches.filter(f=>!l.has(f.watchId)),...Array.isArray(u.observations)?
|
|
6089
6090
|
{observations:u.observations.filter(f=>!l.has(f.watchId))}:{}};pt(p,a.name),n("info",`${a.name}: retire ${l.size} learni\
|
|
6090
|
-
ng-task watch(es); conversation history is kept.`),s.push({filePath:c,original:d,contents:JSON.stringify(p)})}return s}})}import{randomUUID as FL}from"node:crypto";import{lstat as
|
|
6091
|
-
"big-pickle";function
|
|
6091
|
+
ng-task watch(es); conversation history is kept.`),s.push({filePath:c,original:d,contents:JSON.stringify(p)})}return s}})}import{randomUUID as FL}from"node:crypto";import{lstat as B7,readdir as q7}from"node:fs/promises";import SI from"node:path";var V7=e=>e&&typeof e=="object"&&!Array.isArray(e),H7=e=>e?.engineId==="opencode"&&e.modelProviderId==="opencode"&&e.modelId===
|
|
6092
|
+
"big-pickle";function G7(e){try{let t=JSON.parse(e);if(V7(t))return t}catch{}throw new Error("Colleague conversation sta\
|
|
6092
6093
|
te is invalid. Inspect it before upgrading.")}async function AI({systemRoot:e,apply:t,backupRoot:r,report:n}){let o=SI.join(
|
|
6093
|
-
e,"colleague");await ge(e,SI.join(o,"placeholder"));let i;try{if(!(await
|
|
6094
|
-
state must be a regular directory.");i=await
|
|
6094
|
+
e,"colleague");await ge(e,SI.join(o,"placeholder"));let i;try{if(!(await B7(o)).isDirectory())throw new Error("Colleague\
|
|
6095
|
+
state must be a regular directory.");i=await q7(o,{withFileTypes:!0})}catch(s){if(s.code==="ENOENT")i=[];else throw s}await xe(
|
|
6095
6096
|
{systemRoot:e,apply:t,backupRoot:r,report:n,prepareUpdates:async()=>{let s=[];for(let a of i.sort((c,d)=>c.name.localeCompare(
|
|
6096
6097
|
d.name))){if(!a.isDirectory()||!/^[\w-]+$/u.test(a.name))throw new Error("Unexpected Colleague state entry. Inspect it b\
|
|
6097
|
-
efore upgrading.");let c=SI.join(o,a.name,"conversation.json");await ge(e,c);let d=await Ae(c);if(d===null)continue;let u=
|
|
6098
|
-
d);if(pt(u,a.name),!
|
|
6098
|
+
efore upgrading.");let c=SI.join(o,a.name,"conversation.json");await ge(e,c);let d=await Ae(c);if(d===null)continue;let u=G7(
|
|
6099
|
+
d);if(pt(u,a.name),!H7(u.assistantSelection))continue;if(u.schemaVersion!==3){if(t)throw new Error(`${a.name}: upgrade t\
|
|
6099
6100
|
his Colleague history to the current format first.`);n("info",`${a.name}: earlier upgrades will prepare this Colleague h\
|
|
6100
6101
|
istory first; apply checks it again.`);continue}let l=`colleague_${FL().replaceAll("-","")}`,p=new Date().toISOString(),
|
|
6101
6102
|
f={scopeId:u.scopeId,runtimeId:u.runtimeId,assistantSelection:u.assistantSelection,status:u.status==="working"?"interrup\
|
|
@@ -6180,42 +6181,42 @@ ing.`);if(i?.rewind!=null&&(typeof i.rewind!="object"||Array.isArray(i.rewind)||
|
|
|
6180
6181
|
`${o} has an unfinished conversation Undo. Complete it using the previous release before upgrading; this release cannot \
|
|
6181
6182
|
resume Undo. No history was changed.`)};for(let n of await ut(e.systemRoot))await gt({projectContextRoot:n,projectRuntimeRoot:n}).
|
|
6182
6183
|
prepareAssistantRoutingStateUpgrade({temporaryRoot:t,transform({sessionId:i,metadata:s,conversations:a}){r(s,`Session ${i}`);
|
|
6183
|
-
for(let c of a)r(c.routingMetadata,`Temporary conversation ${c.conversationId} in session ${i}`);return{}}});return[]}})}import{lstat as
|
|
6184
|
-
import{isDeepStrictEqual as
|
|
6185
|
-
import dt from"node:path";import{createHash as
|
|
6186
|
-
import kr from"node:path";import{isDeepStrictEqual as
|
|
6184
|
+
for(let c of a)r(c.routingMetadata,`Temporary conversation ${c.conversationId} in session ${i}`);return{}}});return[]}})}import{lstat as xee,mkdtemp as Tee,readdir as Cee,rm as Ree}from"node:fs/promises";import Oee from"node:os";import xt from"node:path";
|
|
6185
|
+
import{isDeepStrictEqual as Pee}from"node:util";import{createHash as xQ}from"node:crypto";import{lstat as TQ,readFile as CQ,readdir as RQ,realpath as OQ}from"node:fs/promises";
|
|
6186
|
+
import dt from"node:path";import{createHash as wQ}from"node:crypto";import{lstat as vQ,readFile as yQ,readdir as _Q,realpath as c$}from"node:fs/promises";
|
|
6187
|
+
import kr from"node:path";import{isDeepStrictEqual as W7}from"node:util";var Le={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},tt={
|
|
6187
6188
|
...Le,maxLength:64},Ue=(e,t=100)=>({type:"array",required:!0,maxLength:t,items:e,validator:r=>Array.isArray(r)&&r.length>
|
|
6188
|
-
t?`Expected at most ${t} items.`:void 0}),Bh={type:"integer",required:!0,enum:[1]},
|
|
6189
|
+
t?`Expected at most ${t} items.`:void 0}),Bh={type:"integer",required:!0,enum:[1]},K7=Ue(oe({code:tt}),24),J7=oe({id:tt,
|
|
6189
6190
|
kind:{...Le,enum:["answer","practical"]},required:{type:"boolean",required:!0},rubric:Le,evidence:{type:"object",required:!1,
|
|
6190
6191
|
schema:oe({producer:{...Le,enum:["workspace","colleague","exercise","code"]},operation:tt,check:{...tt,required:!1},explanationRequired:{
|
|
6191
|
-
type:"boolean",required:!1},files:{...Ue(Le,8),required:!1,minLength:1}})}}),WL={code:tt,title:Le,prerequisites:
|
|
6192
|
+
type:"boolean",required:!1},files:{...Ue(Le,8),required:!1,minLength:1}})}}),WL={code:tt,title:Le,prerequisites:K7,estimatedMinutes:{
|
|
6192
6193
|
type:"integer",required:!0,min:1,max:180},visuals:Ue(oe({id:tt,descriptor:Le}),12),exercise:{type:"object",required:!1,schema:oe(
|
|
6193
6194
|
{kind:{...Le,enum:["bundled"]},source:Le,reuse:{...Le,enum:["attempt","sequence"]},sequenceId:{...tt,required:!1},sequenceMode:{
|
|
6194
6195
|
...Le,required:!1,enum:["create","continue"]}})},checks:{...Ue(oe({id:tt,file:Le,assets:{...Ue(Le,32),required:!1},kind:{
|
|
6195
6196
|
...Le,required:!1,enum:["response","code"]},timeoutSeconds:{type:"integer",required:!1,min:1,max:60}}),12),required:!1},
|
|
6196
6197
|
appRoutes:{...Ue(oe({method:{...Le,enum:["POST","PUT","PATCH","DELETE"]},path:{...Le,maxLength:128,pattern:"^/[A-Za-z0-9\
|
|
6197
|
-
._~:/-]*$"}}),16),required:!1}},KL=oe({schemaVersion:Bh,...WL,document:Le,assessments:Ue(
|
|
6198
|
+
._~:/-]*$"}}),16),required:!1}},KL=oe({schemaVersion:Bh,...WL,document:Le,assessments:Ue(J7,32)}),X7=oe({id:tt,title:Le,
|
|
6198
6199
|
body:Le,required:{type:"boolean",required:!0},visual:{type:"object",required:!1,schema:oe({id:tt,play:{...Ue(oe({name:tt,
|
|
6199
6200
|
parameters:{type:"object",required:!0}}),16),required:!1}})},guide:{type:"object",required:!1,schema:oe({target:tt,navigate:{
|
|
6200
6201
|
type:"boolean",required:!1},filePath:{...Le,required:!1,maxLength:512},caption:{...Le,required:!1}})},check:{type:"objec\
|
|
6201
6202
|
t",required:!0,schema:oe({kind:{...Le,enum:["auto","choice","review","self","fact","none"]},check:{...tt,required:!1},fact:{
|
|
6202
6203
|
...tt,required:!1},files:{...Ue(Le,8),required:!1},question:{...Le,required:!1,maxLength:2e3},options:{...Ue(Le,8),required:!1},
|
|
6203
6204
|
answer:{...Ue({type:"integer",required:!0,min:0,max:7},8),required:!1},rubric:{...Le,required:!1,maxLength:600},evidence:{
|
|
6204
|
-
...Ue({...Le,enum:["changes","conversation"]},2),required:!1}})}}),JL={...WL,notes:{...Le,required:!1},steps:Ue(
|
|
6205
|
-
|
|
6206
|
-
3]},...JL,stage:{...Le,enum:["studio","project"]}}),
|
|
6207
|
-
3;function qh(e,t){let r=
|
|
6205
|
+
...Ue({...Le,enum:["changes","conversation"]},2),required:!1}})}}),JL={...WL,notes:{...Le,required:!1},steps:Ue(X7,32)},
|
|
6206
|
+
Y7=oe({schemaVersion:{type:"integer",required:!0,enum:[2]},...JL}),Z7=oe({schemaVersion:{type:"integer",required:!0,enum:[
|
|
6207
|
+
3]},...JL,stage:{...Le,enum:["studio","project"]}}),Q7=new Map([[1,KL],[2,Y7],[3,Z7]]),zn=e=>e?.schemaVersion===2||e?.schemaVersion===
|
|
6208
|
+
3;function qh(e,t){let r=Q7.get(e?.schemaVersion)||KL;return Qr(r,e,t)}var XL=oe({schemaVersion:Bh,topicId:tt,domainId:tt,
|
|
6208
6209
|
title:Le,status:{...Le,enum:["preview","released"]},outline:Le,prerequisites:Ue(oe({topicId:tt}),24),lessons:Ue(oe({code:tt,
|
|
6209
6210
|
descriptor:Le,status:{...Le,enum:["draft","published"]},required:{type:"boolean",required:!0}}),64),places:{...Ue(tt,64),
|
|
6210
|
-
required:!1},activities:{...Ue(tt,64),required:!1},facts:{...Ue(tt,64),required:!1}}),
|
|
6211
|
+
required:!1},activities:{...Ue(tt,64),required:!1},facts:{...Ue(tt,64),required:!1}}),CJe=oe({schemaVersion:Bh,courseId:tt,
|
|
6211
6212
|
title:Le,release:Le,status:{...Le,enum:["preview","released"]},topics:Ue(oe({topicId:tt,release:Le}),32),orientation:{...tt,
|
|
6212
6213
|
required:!1}}),YL=oe({schemaVersion:Bh,id:tt,title:Le,svg:Le,controller:Le,assets:{...Ue(Le,32),required:!1},initialState:tt,
|
|
6213
6214
|
states:Ue(tt,32),description:{...Le,maxLength:2e3},commands:Ue(oe({name:tt,parameters:Ue(oe({name:tt,required:{type:"boo\
|
|
6214
6215
|
lean",required:!0},maxLength:{type:"integer",required:!0,min:1,max:256}}),8),completionState:tt,description:{...Le,maxLength:2e3}}),
|
|
6215
|
-
32)});function Qr(e,t,r){let n=Pm({schema:e,mode:"create"},t,{context:r});if(!
|
|
6216
|
-
lds or noncanonical values.`);return n}var So=/^[a-z][a-z0-9-]{0,63}$/u,
|
|
6216
|
+
32)});function Qr(e,t,r){let n=Pm({schema:e,mode:"create"},t,{context:r});if(!W7(t,n))throw new Error(`${r}: unknown fie\
|
|
6217
|
+
lds or noncanonical values.`);return n}var So=/^[a-z][a-z0-9-]{0,63}$/u,eQ=new Set(["studio","project"]),tQ=new Set(["everyone","owner"]),vt=(e,t)=>Object.freeze(
|
|
6217
6218
|
{id:e,label:t}),ZL=vt("preview","Preview"),Io=vt("dashboard","Dashboard"),QL=vt("database","Database"),PI=vt("account-me\
|
|
6218
|
-
nu","Account menu"),
|
|
6219
|
+
nu","Account menu"),rQ=[{id:"preview",label:"Preview",scope:"project",open:{pane:"preview"},steps:[ZL]},{id:"dashboard",
|
|
6219
6220
|
label:"Dashboard",scope:"project",open:null,steps:[Io]},{id:"database-erd",label:"ERD",scope:"project",open:{pane:"datab\
|
|
6220
6221
|
ase",databaseView:"erd"},steps:[Io,QL,vt("database-erd","ERD")]},{id:"database-data",label:"Data",scope:"project",open:{
|
|
6221
6222
|
pane:"database",databaseView:"data"},steps:[Io,QL,vt("database-data","Data")]},{id:"files",label:"Files",scope:"project",
|
|
@@ -6234,13 +6235,13 @@ r")]},{id:"courses",label:"Courses",scope:"studio",open:null,shown:[{learningOpe
|
|
|
6234
6235
|
{id:"colleague",label:"Colleague",scope:"studio",open:null,event:"colleague-opened",steps:[vt("colleague","Colleague")]},
|
|
6235
6236
|
{id:"account-menu",label:"Account menu",scope:"studio",open:null,steps:[PI]},{id:"account-settings",label:"Account setti\
|
|
6236
6237
|
ngs",scope:"studio",open:null,steps:[PI,vt("account-settings","Account settings")]},{id:"ai-setup",label:"AI setup",scope:"\
|
|
6237
|
-
studio",open:null,steps:[PI,vt("ai-setup","AI setup")]}],
|
|
6238
|
+
studio",open:null,steps:[PI,vt("ai-setup","AI setup")]}],nQ=[{id:"send-message",event:"message-sent",place:"chat"},{id:"\
|
|
6238
6239
|
agent-finished",event:"agent-finished"},{id:"file-opened",event:"file-opened",place:"files"},{id:"app-pressed",event:"ap\
|
|
6239
|
-
p-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],
|
|
6240
|
+
p-pressed",place:"preview"},{id:"colleague-minimised",event:"colleague-minimised",place:"colleague"}],oQ=["ai-ready"];function vr(e){
|
|
6240
6241
|
return Object.assign(new Error(e),{code:"VIBE64_TRAINING_VOCABULARY_INVALID"})}var kI=e=>!!e&&typeof e=="object"&&!Array.
|
|
6241
|
-
isArray(e),e$=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;function
|
|
6242
|
-
"A place needs a lowercase id.");let t=`Place ${e.id}`;if(!e$(e.label))throw vr(`${t} needs a label.`);if(!
|
|
6243
|
-
throw vr(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!
|
|
6242
|
+
isArray(e),e$=e=>typeof e=="string"&&e.trim().length>0&&e.length<=64;function iQ(e){if(!kI(e)||!So.test(e.id||""))throw vr(
|
|
6243
|
+
"A place needs a lowercase id.");let t=`Place ${e.id}`;if(!e$(e.label))throw vr(`${t} needs a label.`);if(!eQ.has(e.scope))
|
|
6244
|
+
throw vr(`${t} scope is studio or project.`);let r=e.who??"everyone";if(!tQ.has(r))throw vr(`${t} who is everyone or own\
|
|
6244
6245
|
er.`);let n=e.open??null;if(n!==null){let i=Object.keys(n||{}).sort().join(",");if(!(i==="pane"||i==="databaseView,pane"?
|
|
6245
6246
|
e.scope==="project"&&So.test(n.pane):i==="route"?e.scope==="studio"&&typeof n.route=="string"&&/^\/app(?:\/[a-z0-9-]+)*$/u.
|
|
6246
6247
|
test(n.route):i==="learning"&&n.learning===!0))throw vr(`${t} opens a project pane, a studio /app route, Courses, or not\
|
|
@@ -6250,11 +6251,11 @@ pane,...n.databaseView?{databaseView:n.databaseView}:{}}]:n?.route?[{route:n.rou
|
|
|
6250
6251
|
i)||!Object.keys(i).length))throw vr(`${t} shown is a list of page focus matchers.`);if(e.event!==void 0&&!So.test(e.event))
|
|
6251
6252
|
throw vr(`${t} event is a lowercase activity name.`);return Object.freeze({id:e.id,label:e.label,scope:e.scope,who:r,open:n&&
|
|
6252
6253
|
Object.freeze({...n}),steps:Object.freeze(e.steps.map(i=>vt(i.id,i.label))),shown:Object.freeze(o.map(i=>Object.freeze({
|
|
6253
|
-
...i}))),...e.event?{event:e.event}:{}})}function
|
|
6254
|
+
...i}))),...e.event?{event:e.event}:{}})}function sQ(e){if(!kI(e)||!So.test(e.id||""))throw vr("An activity needs a lowe\
|
|
6254
6255
|
rcase id.");if(!So.test(e.event||""))throw vr(`Activity ${e.id} needs its page activity event.`);if(e.place!==void 0&&!So.
|
|
6255
6256
|
test(e.place))throw vr(`Activity ${e.id} place is a place id.`);return Object.freeze({id:e.id,event:e.event,...e.place?{
|
|
6256
|
-
place:e.place}:{}})}function r$({places:e=
|
|
6257
|
-
stringify(c)===JSON.stringify(d);function a({places:c=[],activities:d=[],facts:u=[]}={}){let l=c.map(
|
|
6257
|
+
place:e.place}:{}})}function r$({places:e=rQ,activities:t=nQ,facts:r=oQ}={}){let n=new Map,o=new Map,i=new Set,s=(c,d)=>JSON.
|
|
6258
|
+
stringify(c)===JSON.stringify(d);function a({places:c=[],activities:d=[],facts:u=[]}={}){let l=c.map(iQ),p=d.map(sQ);for(let f of[
|
|
6258
6259
|
...l,...p])if(n.has(f.id)&&!s(n.get(f.id),f)||o.has(f.id)&&!s(o.get(f.id),f)||l.includes(f)&&o.has(f.id)||p.includes(f)&&
|
|
6259
6260
|
n.has(f.id))throw vr(`${f.id} is already registered with another meaning.`);for(let f of u)if(!So.test(f||""))throw vr("\
|
|
6260
6261
|
A fact needs a lowercase id.");for(let f of l)n.set(f.id,f);for(let f of p)o.set(f.id,f);for(let f of u)i.add(f)}return a(
|
|
@@ -6264,54 +6265,54 @@ event).map(c=>c.event)])})}var kd=r$({facts:[]});function Vh({places:e=[],activi
|
|
|
6264
6265
|
...t,...r])if(!So.test(a||""))throw vr(`Declared name ${a} is not a lowercase id.`);let i=new Set(e.filter(a=>!o.has(a))),
|
|
6265
6266
|
s=new Set(t.filter(a=>!n.activity(a)));return Object.freeze({...n,declared:a=>i.has(a)||s.has(a),declaredPlace:a=>i.has(
|
|
6266
6267
|
a),declaredActivity:a=>s.has(a),hasFact:a=>n.hasFact(a)||r.includes(a)})}var NI=/^(?!\/)(?!.*(?:^|\/)\.\.(?:\/|$))[^\u0000-\u001f\\]{1,512}$/u,
|
|
6267
|
-
t$=256;function yi(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_GUIDE_INVALID",statusCode:422})}var
|
|
6268
|
+
t$=256;function yi(e){return Object.assign(new Error(e),{code:"VIBE64_TRAINING_GUIDE_INVALID",statusCode:422})}var aQ=e=>!!e?.
|
|
6268
6269
|
open;function n$(e={},t=kd){let r=typeof e.target=="string"?t.place(e.target):null,n=!r&&typeof t.declaredPlace=="functi\
|
|
6269
6270
|
on"&&t.declaredPlace(e.target);if(!r&&!n)throw yi(`Use one of this installation's guide places: ${t.places().map(c=>c.id).
|
|
6270
6271
|
join(", ")}.`);let o=e.target,i=e.navigate??!1,s=e.highlight??!0;if(typeof i!="boolean"||typeof s!="boolean")throw yi("n\
|
|
6271
6272
|
avigate and highlight are booleans.");if(!i&&!s)throw yi("Point at the place (highlight) or open it (navigate); this req\
|
|
6272
6273
|
uest does neither.");if(i&&o==="dashboard")throw yi("Dashboard has no single view to open. Point at it, or open one Dash\
|
|
6273
|
-
board section such as files or database-erd.");if(i&&r&&!
|
|
6274
|
+
board section such as files or database-erd.");if(i&&r&&!aQ(r))throw yi(`${r.label} has no view to open; point at it ins\
|
|
6274
6275
|
tead.`);let a={target:o,navigate:i,highlight:s};if(e.filePath!==void 0){if(o!=="files")throw yi("filePath is only for th\
|
|
6275
6276
|
e files place.");if(typeof e.filePath!="string"||!NI.test(e.filePath))throw yi("Use a relative practice project file pat\
|
|
6276
6277
|
h without '..'.");a.filePath=e.filePath}if(e.caption!==void 0){if(typeof e.caption!="string"||!e.caption.trim()||e.caption.
|
|
6277
6278
|
length>t$)throw yi(`Use a caption of 1 to ${t$} characters.`);a.caption=e.caption.trim()}return a}function o$(e,t={},r=kd){let n=r.place(e);return n?.shown.length?n.shown.some(o=>Object.entries(o).every(([i,s])=>i==="r\
|
|
6278
|
-
oute"?typeof t.route=="string"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}var i$=8,
|
|
6279
|
-
|
|
6280
|
-
return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}var
|
|
6281
|
-
o$(e,{},t)!==null||t.declared?.(e)),
|
|
6279
|
+
oute"?typeof t.route=="string"&&(t.route===s||t.route.startsWith(`${s}/`)):t[i]===s)):null}var i$=8,cQ=160,s$=500,dQ=600,jI=Object.freeze({auto:"auto",review:"review",done:"self",fact:"fact"}),uQ=/^```beats[ \t]*$/mu,
|
|
6280
|
+
lQ=/^(show|do|check)[ \t]+([a-z][a-z-]*)(?:[ \t]+([^:]+?))?[ \t]*(?::[ \t]*(.*))?$/u,pQ=/["“]([^"“”]+)["”]/gu;function yr(e){
|
|
6281
|
+
return Object.assign(new Error(e),{code:"VIBE64_TRAINING_BEATS_INVALID"})}var fQ=(e,t)=>!!(t.activity(e)||t.place(e)?.event||
|
|
6282
|
+
o$(e,{},t)!==null||t.declared?.(e)),mQ=(e,t)=>!!(t.place(e)||t.declaredPlace?.(e));function hQ(e,t,r){let n=lQ.exec(e);if(!n)
|
|
6282
6283
|
throw yr(`beat ${t} must read "<show|do|check> <target>: <text>".`);let[,o,i,s,a=""]=n,c=`beat ${t} (${o} ${i})`;if(o===
|
|
6283
6284
|
"check"&&i==="review"){if(a.trim()||s!==void 0)throw yr(`${c} takes no text: the bar shows the step's check.rubric.`);return{
|
|
6284
6285
|
kind:o,target:i,text:""}}if(!a.trim())throw yr(`${c} needs its text after the colon.`);let d={kind:o,target:i,text:a.trim()};
|
|
6285
6286
|
if(s!==void 0&&!(o==="do"&&i==="file-opened"))throw yr(`${c} takes no argument; only do file-opened names a path.`);if(o===
|
|
6286
|
-
"show"&&!
|
|
6287
|
+
"show"&&!mQ(i,r))throw yr(`${c} names an unknown place.`);if(o==="do"&&!fQ(i,r))throw yr(`${c} names nothing the learner\
|
|
6287
6288
|
can do or be at.`);if(o==="check"&&!jI[i])throw yr(`${c} must be check auto, review, done or fact.`);if(s!==void 0){if(!NI.
|
|
6288
|
-
test(s))throw yr(`${c} needs a relative practice project file path without '..'.`);d.path=s}let u=i==="send-message"?
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
t ${s$} characters.`);d.prompt=l[0]}return d}function Hh(e,t=kd){let r=String(e??""),n=
|
|
6289
|
+
test(s))throw yr(`${c} needs a relative practice project file path without '..'.`);d.path=s}let u=i==="send-message"?dQ:
|
|
6290
|
+
cQ;if(d.text.length>u)throw yr(`${c} text is longer than ${u} characters.`);if(i==="send-message"){let l=[...d.text.matchAll(
|
|
6291
|
+
pQ)].map(p=>p[1].trim());if(l.length!==1||!l[0]||l[0].length>s$)throw yr(`${c} needs exactly one quoted prompt of at mos\
|
|
6292
|
+
t ${s$} characters.`);d.prompt=l[0]}return d}function Hh(e,t=kd){let r=String(e??""),n=uQ.exec(r);if(!n)return{body:r,beats:null};
|
|
6292
6293
|
let o=r.slice(n.index+n[0].length),i=/^```[ \t]*$/mu.exec(o);if(!i)throw yr("the beats block is not closed with ```.");if(o.
|
|
6293
6294
|
slice(i.index+i[0].length).trim())throw yr("the beats block must end the step text.");let s=o.slice(0,i.index).split(`
|
|
6294
6295
|
`).map(d=>d.trim()).filter(Boolean);if(!s.length||s.length>i$)throw yr(`a beats block holds 1 to ${i$} beats.`);let a=s.
|
|
6295
|
-
map((d,u)=>
|
|
6296
|
+
map((d,u)=>hQ(d,u+1,t)),c=a.filter(d=>d.kind==="check");if(c.length>1||c.length&&a.at(-1).kind!=="check")throw yr("a ste\
|
|
6296
6297
|
p has at most one check beat, and it is the last.");return{body:r.slice(0,n.index).replace(/\s+$/u,`
|
|
6297
|
-
`),beats:a}}function
|
|
6298
|
-
function a$(e,t=kd){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(
|
|
6299
|
-
scope==="project":!t.declared?.(e.target)}var d$=new Set([".git","node_modules",".genesis"]),Gh=e=>
|
|
6298
|
+
`),beats:a}}function gQ(e,t=kd){if(!e||e.kind==="check")return"";let r=t.activity(e.target);return r?r.place||"":e.target}
|
|
6299
|
+
function a$(e,t=kd){if(e.kind==="check")return e.target==="auto"||e.target==="review";let r=t.place(gQ(e,t));return r?r.
|
|
6300
|
+
scope==="project":!t.declared?.(e.target)}var d$=new Set([".git","node_modules",".genesis"]),Gh=e=>wQ("sha256").update(e).digest("hex"),Wh=e=>/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u.
|
|
6300
6301
|
test(e);function Fn(e,t,r){let n=new Set;for(let o of e){let i=t?o[t]:o;if(!Wh(i)||n.has(i))throw new Error(`${r}: inval\
|
|
6301
6302
|
id or duplicate ID ${i}.`);n.add(i)}return n}function $e(e){return Array.isArray(e)?`[${e.map($e).join(",")}]`:e&&typeof e==
|
|
6302
6303
|
"object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${$e(e[t])}`).join(",")}}`:JSON.stringify(e)}function u$(e,t){
|
|
6303
6304
|
let r=e.get(t.path);if(r&&(r.sha256!==t.sha256||r.bytes!==t.bytes))throw new Error(`Source changed between lesson snapsh\
|
|
6304
6305
|
ots: ${t.path}. Validate and retry.`);e.set(t.path,t)}function MI(e){let t=new Map;for(let r of e)for(let n of r.files)u$(
|
|
6305
|
-
t,n);return[...t.values()]}async function
|
|
6306
|
+
t,n);return[...t.values()]}async function bQ(e){let t=await c$(e);async function r(i,s=t){if(typeof i!="string"||!i||i.includes(
|
|
6306
6307
|
"\\")||kr.isAbsolute(i))throw new Error(`Invalid topic-relative path: ${i}.`);let a=kr.resolve(s,i),c=kr.relative(t,a);if(c===
|
|
6307
6308
|
".."||c.startsWith(`..${kr.sep}`)||kr.isAbsolute(c))throw new Error(`Path escapes topic: ${i}.`);if(await c$(a)!==a)throw new Error(
|
|
6308
6309
|
`Symlink content is not supported: ${i}.`);return{filename:a,relative:c.split(kr.sep).join("/")}}async function n(i,s=t){
|
|
6309
|
-
let a=await r(i,s),c=await
|
|
6310
|
-
t most 1 MiB: ${a.relative}.`);return{...a,bytes:await
|
|
6311
|
-
...a,value:JSON.parse(a.bytes.toString("utf8"))}}return{root:t,resolve:r,read:n,json:o}}function
|
|
6310
|
+
let a=await r(i,s),c=await vQ(a.filename);if(!c.isFile()||c.size>1024*1024)throw new Error(`Expected a regular file of a\
|
|
6311
|
+
t most 1 MiB: ${a.relative}.`);return{...a,bytes:await yQ(a.filename)}}async function o(i,s=t){let a=await n(i,s);return{
|
|
6312
|
+
...a,value:JSON.parse(a.bytes.toString("utf8"))}}return{root:t,resolve:r,read:n,json:o}}function IQ(e){let t=new Map(e.map(
|
|
6312
6313
|
i=>[i.code,i])),r=new Set,n=new Set;function o(i){if(n.has(i))throw new Error(`Prerequisite cycle at ${i}.`);if(r.has(i))
|
|
6313
6314
|
return;let s=t.get(i);if(!s)throw new Error(`Unknown prerequisite ${i}.`);n.add(i);for(let a of s.prerequisites)o(a.code);
|
|
6314
|
-
n.delete(i),r.add(i)}for(let i of e)o(i.code)}function
|
|
6315
|
+
n.delete(i),r.add(i)}for(let i of e)o(i.code)}function SQ(e,t,r,n){r(t);let o=t.bytes.toString("utf8");Fn(e.assessments,
|
|
6315
6316
|
"id","Assessments");for(let i of e.assessments){let[s,a,c]=i.rubric.split("#");if(s!==e.document||!a||c||!new RegExp(`^<\
|
|
6316
6317
|
a id="${i.id}"></a>$`,"mu").test(o)||a!==i.id)throw new Error(`Missing explicit rubric anchor for ${i.id}.`);if(i.kind===
|
|
6317
6318
|
"practical"&&!i.evidence)throw new Error(`Practical assessment ${i.id} needs an evidence producer.`);if(i.kind==="answer"&&
|
|
@@ -6322,7 +6323,7 @@ evidence?.check&&!["exercise","code"].includes(i.evidence.producer))throw new Er
|
|
|
6322
6323
|
a declared check: ${i.id}.`);let d=(e.checks||[]).find(u=>u.id===i.evidence?.check)?.kind||"response";if(i.evidence?.producer===
|
|
6323
6324
|
"code"){if(!e.exercise||!i.evidence.check||d!=="code"||!i.evidence.files?.length)throw new Error(`Code assessment ${i.id}\
|
|
6324
6325
|
needs its declared exercise, files and a code check.`)}else if(i.evidence?.files||i.evidence?.check&&d==="code")throw new Error(
|
|
6325
|
-
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function
|
|
6326
|
+
`Only code evidence names edited files or runs a code check: ${i.id}.`)}}function AQ(e,t,r,n,o,i){let s=a=>{throw new Error(
|
|
6326
6327
|
`Lesson ${n}: ${a}`)};e.schemaVersion===3&&e.stage==="project"&&!e.exercise&&s("a project lesson needs its exercise (a p\
|
|
6327
6328
|
ractice project)."),e.steps.length||s("needs at least one step."),Fn(e.steps,"id","Steps"),e.steps.some(a=>a.required)||
|
|
6328
6329
|
s("needs a required step.");for(let a of e.steps){let c=`step ${a.id}`;if(a.visual){let f=t.get(a.visual.id);f||s(`${c} \
|
|
@@ -6350,13 +6351,13 @@ evidence||["changes"];(f[0]!=="changes"||f.length>2||f.length===2&&f[1]!=="conve
|
|
|
6350
6351
|
changes"] or ["changes", "conversation"].`)}if(u.kind==="choice"){let{question:f,options:y,answer:h}=u;(!f||!y||!h)&&s(`${c}\
|
|
6351
6352
|
choice needs question, options and answer.`),(y.length<2||y.length>8)&&s(`${c} choice needs 2-8 options.`),(!h.length||
|
|
6352
6353
|
new Set(h).size!==h.length||h.some(v=>v>=y.length))&&s(`${c} choice answer must list unique option indexes within its op\
|
|
6353
|
-
tions.`)}}}async function
|
|
6354
|
+
tions.`)}}}async function EQ(e,t,{authoring:r,installed:n,vocabulary:o}){let i=await e.json(t.descriptor),s=qh(i.value,t.
|
|
6354
6355
|
code);if(s.code!==t.code)throw new Error(`Lesson code mismatch: ${t.code}.`);if(r&&s.schemaVersion!==3)throw new Error(`\
|
|
6355
6356
|
Lesson ${t.code} uses retired lesson format ${s.schemaVersion}. Author it in format 3 with steps and its stage.`);let a=kr.
|
|
6356
6357
|
dirname(i.filename),c=new Map;function d(w){if(u$(c,{path:w.relative,sha256:Gh(w.bytes),bytes:w.bytes.length}),c.size>512||
|
|
6357
6358
|
[...c.values()].reduce((m,_)=>m+_.bytes,0)>32*1024*1024)throw new Error(`Lesson ${t.code} exceeds bundle limits.`)}d(i);
|
|
6358
6359
|
let u=new Set,l=new Map;Fn(s.prerequisites,"code","Lesson prerequisites");let p=Fn(s.checks||[],"id","Checks");for(let w of s.
|
|
6359
|
-
checks||[]){d(await e.read(w.file,a));for(let m of w.assets||[])d(await e.read(m,a))}if(s.schemaVersion===1&&
|
|
6360
|
+
checks||[]){d(await e.read(w.file,a));for(let m of w.assets||[])d(await e.read(m,a))}if(s.schemaVersion===1&&SQ(s,await e.
|
|
6360
6361
|
read(s.document,a),d,p),zn(s))for(let w of[s.notes,...new Set(s.steps.map(m=>m.body))]){if(w===void 0)continue;let m=await e.
|
|
6361
6362
|
read(w,a);d(m),u.add(m.relative),l.set(w,m.bytes.toString("utf8"))}if(s.appRoutes&&!s.exercise)throw new Error(`Lesson ${t.
|
|
6362
6363
|
code} can declare app routes only with its exercise.`);let f=new Set;for(let w of s.appRoutes||[]){if(w.path!=="/"&&!w.path.
|
|
@@ -6373,24 +6374,24 @@ dirname(m.filename);for(let C of[_.svg,_.controller,..._.assets||[]]){let T=awai
|
|
|
6373
6374
|
exercise){let w=s.exercise;if(w.reuse==="sequence"){if(!w.sequenceId||!w.sequenceMode)throw new Error(`Invalid exercise \
|
|
6374
6375
|
sequence for ${t.code}.`)}else if(w.sequenceId||w.sequenceMode)throw new Error(`Invalid exercise sequence for ${t.code}.`);
|
|
6375
6376
|
if(w.sequenceId&&!Wh(w.sequenceId))throw new Error("Invalid exercise sequence ID.");let m=await e.resolve(w.source,a);async function _(x){
|
|
6376
|
-
for(let C of(await
|
|
6377
|
+
for(let C of(await _Q(x,{withFileTypes:!0})).sort((T,M)=>T.name<M.name?-1:T.name>M.name?1:0)){if(d$.has(C.name))continue;
|
|
6377
6378
|
let T=kr.relative(e.root,kr.join(x,C.name)),M=await e.resolve(T);if(C.isDirectory())await _(M.filename);else{let L=await e.
|
|
6378
6379
|
read(T);d(L),u.add(L.relative)}}}await _(m.filename);let I=s.schemaVersion===1?s.assessments.map(x=>[`Code assessment ${x.
|
|
6379
6380
|
id}`,x.evidence?.files||[]]):s.steps.map(x=>[`Code step ${x.id}`,x.check.files||[]]);for(let[x,C]of I){for(let T of C){let M=T.
|
|
6380
6381
|
split("/");if(T.includes("\\")||kr.posix.isAbsolute(T)||M.some(L=>!L||L==="."||L===".."||d$.has(L))||!c.has(m.relative?`${m.
|
|
6381
6382
|
relative}/${T}`:T))throw new Error(`${x} names a file outside its bundled exercise: ${T}.`)}if(new Set(C).size!==C.length)
|
|
6382
|
-
throw new Error(`${x} repeats a declared file.`)}}let h="";if(zn(s))try{
|
|
6383
|
+
throw new Error(`${x} repeats a declared file.`)}}let h="";if(zn(s))try{AQ(s,y,p,t.code,l,o)}catch(w){if(!n)throw w;h=w.
|
|
6383
6384
|
message}let v={schemaVersion:1,code:s.code,files:[...c.values()].sort((w,m)=>w.path<m.path?-1:w.path>m.path?1:0)};return{
|
|
6384
6385
|
lesson:s,manifest:v,hash:Gh($e(v)),descriptorPath:i.relative,served:u,...h?{problem:h}:{}}}async function l$(e,{authoring:t=!1,
|
|
6385
|
-
installed:r=!1}={}){let n=await
|
|
6386
|
+
installed:r=!1}={}){let n=await bQ(e),o=await n.json("package.json");if(!/^learn-[a-z0-9-]+$/u.test(o.value.name||"")||!/^\d+\.\d+\.\d+$/u.
|
|
6386
6387
|
test(o.value.version||""))throw new Error("Topic package needs a learn- name and an exact release version.");let i=Qr(XL,
|
|
6387
6388
|
o.value.vibe64Training,"Topic");if(!Wh(i.topicId)||!Wh(i.domainId))throw new Error("Invalid topic or domain ID.");let s=await n.
|
|
6388
6389
|
read(i.outline);if(Fn(i.lessons,"code","Lessons"),Fn(i.prerequisites,"topicId","Topic prerequisites"),!i.lessons.length)
|
|
6389
6390
|
throw new Error("A topic needs lessons.");if(i.status==="released"&&i.lessons.some(f=>f.required&&f.status!=="published"))
|
|
6390
6391
|
throw new Error("A released topic contains required draft lessons.");let a=Vh(i),c=[],d=new Set;for(let f of i.lessons){
|
|
6391
|
-
let{served:y,...h}=await
|
|
6392
|
+
let{served:y,...h}=await EQ(n,f,{authoring:t,installed:r,vocabulary:a});for(let v of y)d.add(v);c.push({...h,status:f.status,
|
|
6392
6393
|
required:f.required})}for(let{descriptorPath:f,lesson:y}of c)if(zn(y)&&d.has(f))throw new Error(`Lesson ${y.code} descri\
|
|
6393
|
-
ptor cannot also be a step body, notes, visual or exercise file.`);
|
|
6394
|
+
ptor cannot also be a step body, notes, visual or exercise file.`);IQ(c.map(f=>f.lesson));for(let[f,y]of c.entries())for(let{
|
|
6394
6395
|
code:h}of y.lesson.prerequisites){let v=c.findIndex(w=>w.lesson.code===h);if(v>=f)throw new Error(`Prerequisite ${h} mus\
|
|
6395
6396
|
t precede ${y.lesson.code}.`);if(y.status==="published"&&c[v].status!=="published")throw new Error(`Published lesson ${y.
|
|
6396
6397
|
lesson.code} requires draft ${h}.`)}let u=new Map;for(let{lesson:f,descriptorPath:y,status:h}of c){if(f.exercise?.reuse!==
|
|
@@ -6400,19 +6401,19 @@ u.set(f.exercise.sequenceId,{source:v,status:h})}else if(!w||w.source!==v||h==="
|
|
|
6400
6401
|
`Invalid create/continue sequence: ${f.code}.`)}let l=[o,s].map(f=>({path:f.relative,sha256:Gh(f.bytes),bytes:f.bytes.length})),
|
|
6401
6402
|
p={schemaVersion:1,topic:i,release:o.value.version,files:l,lessons:c.map(({lesson:f,hash:y,status:h,required:v})=>({code:f.
|
|
6402
6403
|
code,hash:y,status:h,required:v}))};return MI([p,...c.map(f=>f.manifest)]),{topic:i,release:o.value.version,bundles:c,topicManifest:p,
|
|
6403
|
-
topicHash:Gh($e(p))}}var _i=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,$I=/^[a-f0-9]{40}$/u,Ml=/^[a-f0-9]{64}$/u,
|
|
6404
|
-
jl={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},
|
|
6405
|
-
1]},topicId:{...jl,maxLength:64},release:jl,repository:jl,commit:{...jl,maxLength:40},topicHash:{...jl,maxLength:64}}),Kh=e=>
|
|
6404
|
+
topicHash:Gh($e(p))}}var _i=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,$I=/^[a-f0-9]{40}$/u,Ml=/^[a-f0-9]{64}$/u,PQ=/^[a-zA-Z0-9_.-]+\/learn-[a-zA-Z0-9_.-]+$/u,
|
|
6405
|
+
jl={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},kQ=oe({schemaVersion:{type:"integer",required:!0,enum:[
|
|
6406
|
+
1]},topicId:{...jl,maxLength:64},release:jl,repository:jl,commit:{...jl,maxLength:40},topicHash:{...jl,maxLength:64}}),Kh=e=>xQ(
|
|
6406
6407
|
"sha256").update(e).digest("hex");function LI(e){return zn(e)?{...e,steps:e.steps.map(t=>{if(t.check.kind!=="choice")return t;
|
|
6407
|
-
let{answer:r,...n}=t.check;return{...t,check:n}})}:e}function Jh(e,t={}){let r=Qr(
|
|
6408
|
-
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!
|
|
6408
|
+
let{answer:r,...n}=t.check;return{...t,check:n}})}:e}function Jh(e,t={}){let r=Qr(kQ,e,"Installed topic pin");if(!_i.test(r.topicId)||!$I.test(r.commit)||r.topicId!==(t.topicId??
|
|
6409
|
+
r.topicId)||r.commit!==(t.commit??r.commit)||!/^\d+\.\d+\.\d+$/u.test(r.release)||!PQ.test(r.repository)||!Ml.test(r.topicHash))
|
|
6409
6410
|
throw new Error("Installed pin does not match the requested topic, commit or canonical source identity.");if(r.topicHash!==
|
|
6410
6411
|
(t.topicHash??r.topicHash))throw new Error("Installed topic differs from the trusted course or attempt pin.");return r}async function Ll(e,t){
|
|
6411
|
-
let r=await
|
|
6412
|
+
let r=await TQ(e);if(r.isSymbolicLink()||await OQ(e)!==e)throw new Error("Installed content cannot use symlink or direct\
|
|
6412
6413
|
ory aliases.");if(t?!r.isDirectory():!r.isFile())throw new Error(`Installed content needs a regular ${t?"directory":"fil\
|
|
6413
6414
|
e"}.`);return r}async function Nd(e,t){if((await Ll(e,!1)).size>t)throw new Error(`Installed file exceeds its ${t}-byte \
|
|
6414
|
-
limit.`);let n=await
|
|
6415
|
-
let t=[],r=0;async function n(o){await Ll(o,!0);for(let i of await
|
|
6415
|
+
limit.`);let n=await CQ(e);if(n.length>t)throw new Error(`Installed file exceeds its ${t}-byte limit.`);return n}async function NQ(e){
|
|
6416
|
+
let t=[],r=0;async function n(o){await Ll(o,!0);for(let i of await RQ(o,{withFileTypes:!0})){if(++r>65536)throw new Error(
|
|
6416
6417
|
"Installed snapshot exceeds 65536 directory entries.");let s=dt.join(o,i.name);i.isDirectory()?await n(s):(await Ll(s,!1),
|
|
6417
6418
|
t.push(dt.relative(e,s).split(dt.sep).join("/")))}}return await n(e),t.sort()}function Xh({systemRoot:e,allowDraftLessons:t=!1}={}){
|
|
6418
6419
|
if(typeof e!="string"||!e||!dt.isAbsolute(e))throw new Error("Installed teaching content needs an absolute server-owned \
|
|
@@ -6427,7 +6428,7 @@ sh from the course or saved attempt.");let I=JSON.stringify([w,m,_]),x=n.get(I);
|
|
|
6427
6428
|
finally(()=>n.delete(I)),n.set(I,x)),structuredClone(await x)}async function a({topicId:w,commit:m,topicHash:_}){try{let I=dt.
|
|
6428
6429
|
join(r,"training"),x=dt.join(I,"content"),C=dt.join(x,w),T=dt.join(C,m);for(let Ve of[r,I,x,C,T])await Ll(Ve,!0);let M=Jh(
|
|
6429
6430
|
JSON.parse((await Nd(dt.join(T,"pin.json"),4096)).toString("utf8")),{topicId:w,commit:m,topicHash:_}),L=JSON.parse((await Nd(
|
|
6430
|
-
dt.join(T,"bundle.json"),32*1024*1024)).toString("utf8")),K=dt.join(T,"files"),X=await
|
|
6431
|
+
dt.join(T,"bundle.json"),32*1024*1024)).toString("utf8")),K=dt.join(T,"files"),X=await NQ(K),se=await l$(K,{installed:!0}),
|
|
6431
6432
|
Z={schemaVersion:1,topic:se.topic,release:se.release,topicHash:se.topicHash,topicManifest:se.topicManifest,lessons:se.bundles.
|
|
6432
6433
|
map(({lesson:Ve,hash:bt,status:U,required:F,manifest:H})=>({code:Ve.code,hash:bt,status:U,required:F,manifest:H}))};if($e(
|
|
6433
6434
|
L)!==$e(Z))throw new Error("Installed bundle is incomplete, reordered, unsupported or changed from its source files.");if(se.
|
|
@@ -6494,41 +6495,41 @@ new Error(`Lesson ${I} has no declared bundled exercise.`),{code:"VIBE64_TRAININ
|
|
|
6494
6495
|
dt.posix.dirname(L.descriptorPath),K.source),se={pin:L.pin,lessonCode:L.lesson.code,lessonHash:L.hash,exercise:K,sourcePath:X};
|
|
6495
6496
|
if(C===!0)return se;let Z=X==="."?"":`${X}/`,ye=[];for(let ae of L.manifest.files){if(!ae.path.startsWith(Z))continue;let qe=ae.
|
|
6496
6497
|
path.slice(Z.length),st=await c(L,X,qe);ye.push({path:qe,bytes:st.bytes})}return{...se,files:ye}}return{readTopic:i,readLesson:p,
|
|
6497
|
-
readAdmissionIdentity:d,readVisual:y,readCheck:h,readExercise:v,readChoiceAnswer:f}}import hn from"node:path";import{lstat as
|
|
6498
|
-
1024;var
|
|
6498
|
+
readAdmissionIdentity:d,readVisual:y,readCheck:h,readExercise:v,readChoiceAnswer:f}}import hn from"node:path";import{lstat as MQ,mkdir as a3e,readFile as LQ,realpath as $Q,rm as c3e}from"node:fs/promises";import DQ from"node:path";function p$(e,t,{statusCode:r,...n}={}){return Object.assign(new Error(t),{code:e,...r?{statusCode:r}:{},...n})}var e3e=128*
|
|
6499
|
+
1024;var UQ=64,zQ=32,FQ=256,BQ=128*1024,qQ=64,VQ=32,b3e=1024*1024;var I3e=32*1024,HQ=32;var S3e=16*1024;var GQ=["finished","archived","deleted"],$s=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u;var h$=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/u,DI=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/u,Yh=/^[a-f0-9]{64}$/u,
|
|
6499
6500
|
me={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},Zh={type:"integer",required:!0,enum:[1]},bi={type:"in\
|
|
6500
|
-
teger",required:!0,min:0,max:Number.MAX_SAFE_INTEGER},
|
|
6501
|
+
teger",required:!0,min:0,max:Number.MAX_SAFE_INTEGER},WQ=oe({stage:{...me,enum:["project","session","setup"]},code:{...me,
|
|
6501
6502
|
maxLength:64},message:{...me,maxLength:512}}),g$=oe({phase:{...me,enum:["reserved","preparing","ready"]},initialSessionId:{
|
|
6502
|
-
...me,required:!1,maxLength:128},observedAt:{...me,required:!1,maxLength:24},failure:{type:"object",required:!1,schema:
|
|
6503
|
+
...me,required:!1,maxLength:128},observedAt:{...me,required:!1,maxLength:24},failure:{type:"object",required:!1,schema:WQ},
|
|
6503
6504
|
startCommit:{...me,required:!1,maxLength:64}}),w$=oe({code:{...me,maxLength:64},hash:{...me,maxLength:64}}),UI=oe({course:{
|
|
6504
6505
|
type:"object",required:!0,schema:oe({courseId:{...me,maxLength:64},release:me})},topic:{type:"object",required:!0},lesson:{
|
|
6505
|
-
type:"object",required:!0,schema:w$}}),
|
|
6506
|
-
{attemptId:{...me,maxLength:36},requestIds:{...Ue({...me,maxLength:64},
|
|
6506
|
+
type:"object",required:!0,schema:w$}}),KQ=oe({requestId:{...me,maxLength:64},revision:bi,reason:{...me,enum:GQ}}),JQ=oe(
|
|
6507
|
+
{attemptId:{...me,maxLength:36},requestIds:{...Ue({...me,maxLength:64},UQ),minLength:1},createdAt:{...me,maxLength:24},pin:{
|
|
6507
6508
|
type:"object",required:!0,schema:UI},projectSlug:{...me,required:!1,maxLength:48},preparation:{type:"object",required:!1,
|
|
6508
|
-
schema:g$},ended:{type:"object",required:!1,schema:
|
|
6509
|
+
schema:g$},ended:{type:"object",required:!1,schema:KQ}}),A3e=oe({schemaVersion:{type:"integer",required:!0,enum:[2]},learnerId:{
|
|
6509
6510
|
...me,maxLength:128},revision:bi,activeAttemptId:{...me,maxLength:36,nullable:!0},completedLessons:Ue(oe({code:{...me,maxLength:64},
|
|
6510
|
-
hash:{...me,maxLength:64},completedAt:{...me,maxLength:24}}),
|
|
6511
|
+
hash:{...me,maxLength:64},completedAt:{...me,maxLength:24}}),FQ),attempts:Ue(JQ,zQ)}),E3e=oe({schemaVersion:Zh,learnerId:{
|
|
6511
6512
|
...me,maxLength:128},progressRevision:bi,attemptId:{...me,maxLength:36},pin:{type:"object",required:!0,schema:UI},projectSlug:{
|
|
6512
|
-
...me,required:!1,maxLength:48},preparation:{type:"object",required:!1,schema:g$}}),
|
|
6513
|
-
...me,maxLength:128},progressRevision:bi,attemptId:{...me,nullable:!0,maxLength:36}}),
|
|
6514
|
-
er",required:!0,enum:[2]},learnerId:{...me,maxLength:128},on:{type:"boolean",required:!0}}),f$=256,
|
|
6515
|
-
{path:{...me,maxLength:512},sha256:{...me,maxLength:64}}),
|
|
6513
|
+
...me,required:!1,maxLength:48},preparation:{type:"object",required:!1,schema:g$}}),x3e=oe({schemaVersion:Zh,learnerId:{
|
|
6514
|
+
...me,maxLength:128},progressRevision:bi,attemptId:{...me,nullable:!0,maxLength:36}}),T3e=oe({schemaVersion:{type:"integ\
|
|
6515
|
+
er",required:!0,enum:[2]},learnerId:{...me,maxLength:128},on:{type:"boolean",required:!0}}),f$=256,XQ=32,C3e=256*1024,YQ=oe(
|
|
6516
|
+
{path:{...me,maxLength:512},sha256:{...me,maxLength:64}}),R3e=oe({schemaVersion:{type:"integer",required:!0,enum:[2]},learnerId:{
|
|
6516
6517
|
...me,maxLength:128},attemptId:{...me,maxLength:36},steps:{...Ue(oe({stepId:{...me,maxLength:64},enteredRevision:bi,entryStart:{
|
|
6517
|
-
type:"integer",required:!0,min:0,max:f$},baseline:Ue(
|
|
6518
|
+
type:"integer",required:!0,min:0,max:f$},baseline:Ue(YQ,8)}),XQ),minLength:1},entries:Ue(oe({path:{...me,maxLength:512},
|
|
6518
6519
|
baseHash:{...me,maxLength:64},savedHash:{...me,maxLength:64},intendedHash:{...me,maxLength:64},actorId:{...me,maxLength:128},
|
|
6519
|
-
at:{...me,maxLength:24},saves:{type:"integer",required:!0,min:1,max:Number.MAX_SAFE_INTEGER}}),f$)});var
|
|
6520
|
+
at:{...me,maxLength:24},saves:{type:"integer",required:!0,min:1,max:Number.MAX_SAFE_INTEGER}}),f$)});var ZQ=oe({comment:{...me,maxLength:600},hint:{...me,required:!1,maxLength:300},points:{...Ue(oe({text:{...me,maxLength:120},
|
|
6520
6521
|
met:{type:"boolean",required:!0}}),6),required:!1}}),zI=oe({stepId:{...me,maxLength:64},kind:{...me,enum:["auto","choice",
|
|
6521
6522
|
"review","self","read","fact"]},outcome:{...me,enum:["passed","not-yet-passed"]},evidence:{type:"object",required:!0},origin:{
|
|
6522
6523
|
...me,enum:["learner","check"]},requestId:{...me,maxLength:64},recordedAt:{...me,maxLength:24},reason:{...me,required:!1},
|
|
6523
|
-
review:{type:"object",required:!1,schema:
|
|
6524
|
+
review:{type:"object",required:!1,schema:ZQ}}),FI=oe({stepId:{...me,maxLength:64},checkId:{...me,maxLength:64},observationId:{
|
|
6524
6525
|
...me,maxLength:128},instanceId:{...me,maxLength:36},interactionId:{...me,maxLength:36},requestId:{...me,maxLength:36},sessionId:{
|
|
6525
|
-
...me,maxLength:128},observedAt:{...me,maxLength:24}}),
|
|
6526
|
+
...me,maxLength:128},observedAt:{...me,maxLength:24}}),O3e=oe({schemaVersion:{type:"integer",required:!0,enum:[3]},learnerId:{
|
|
6526
6527
|
...me,maxLength:128},revision:bi,attemptId:{...me,maxLength:36},lesson:{type:"object",required:!0,schema:w$},results:Ue(
|
|
6527
|
-
zI,
|
|
6528
|
-
...me,maxLength:64},scroll:{type:"number",required:!0,min:0,max:1e7}}),
|
|
6529
|
-
maxLength:4e3},
|
|
6528
|
+
zI,qQ),receipts:Ue(FI,VQ)}),P3e=oe({schemaVersion:Zh,learnerId:{...me,maxLength:128},attemptId:{...me,maxLength:36},stepId:{
|
|
6529
|
+
...me,maxLength:64},scroll:{type:"number",required:!0,min:0,max:1e7}}),QQ={type:"string",required:!0,noTrim:!0,minLength:0,
|
|
6530
|
+
maxLength:4e3},k3e=oe({schemaVersion:Zh,learnerId:{...me,maxLength:128},revision:bi,text:QQ,updatedAt:{...me,maxLength:24},
|
|
6530
6531
|
updatedBy:{...me,enum:["colleague","learner"]},requests:Ue(oe({requestId:{...me,maxLength:64},textHash:{...me,maxLength:64},
|
|
6531
|
-
revision:bi}),
|
|
6532
|
+
revision:bi}),HQ)}),m$=e=>Number.isFinite(Date.parse(e))&&new Date(e).toISOString()===e;function eee(e){let{kind:t,evidence:r}=e,n=Object.keys(r||{}).sort();return!r||typeof r!="object"||Array.isArray(r)?!1:t===
|
|
6532
6533
|
"self"||t==="read"?n.length===0&&e.origin==="learner":t==="fact"?e.origin==="check"&&$e(n)===$e(["fact"])&&$s.test(r.fact||
|
|
6533
6534
|
""):t==="review"?e.origin==="check"&&$e(n)===$e(["evidenceHash","reviewId"])&&h$.test(r.reviewId||"")&&Yh.test(r.evidenceHash||
|
|
6534
6535
|
""):t==="choice"?e.origin==="learner"&&$e(n)===$e(["selected"])&&Array.isArray(r.selected)&&r.selected.length<=8&&new Set(
|
|
@@ -6536,14 +6537,14 @@ r.selected).size===r.selected.length&&r.selected.every(o=>Number.isSafeInteger(o
|
|
|
6536
6537
|
o=>["checkId","observationId","filesHash"].includes(o))&&$s.test(r.checkId||"")&&(r.observationId===void 0||DI.test(r.observationId))&&
|
|
6537
6538
|
(r.filesHash===void 0||Yh.test(r.filesHash))}function v$(e){if(!$s.test(e.lesson.code)||!Yh.test(e.lesson.hash))throw new Error(
|
|
6538
6539
|
"Step progress names an invalid lesson content identity.");let t=new Set;for(let n of e.results){if(!$s.test(n.stepId)||
|
|
6539
|
-
!DI.test(n.requestId)||t.has(n.requestId)||!m$(n.recordedAt)||!
|
|
6540
|
+
!DI.test(n.requestId)||t.has(n.requestId)||!m$(n.recordedAt)||!eee(n)||n.kind==="review"!=(n.review!==void 0)||[n.reason,
|
|
6540
6541
|
n.review?.comment,n.review?.hint,...(n.review?.points||[]).map(o=>o.text)].some(o=>o!==void 0&&/[\u0000-\u001f\u007f]/u.
|
|
6541
6542
|
test(o)))throw new Error("Step results have an invalid step, request identity, evidence, origin or record time.");t.add(
|
|
6542
6543
|
n.requestId)}let r=new Set;for(let n of e.receipts||[]){if(!$s.test(n.stepId)||r.has(n.stepId)||!$s.test(n.checkId)||!DI.
|
|
6543
|
-
test(n.observationId)||![n.instanceId,n.interactionId,n.requestId].every(o=>h$.test(o))||!
|
|
6544
|
-
throw new Error("Step receipts have an invalid step, interaction identity, session or time.");r.add(n.stepId)}}function
|
|
6545
|
-
lesson.steps:null}var
|
|
6546
|
-
"Step results belong only to a version 2 lesson.");for(let n of e.results){let o=r.find(i=>i.id===n.stepId);if(!o||
|
|
6544
|
+
test(n.observationId)||![n.instanceId,n.interactionId,n.requestId].every(o=>h$.test(o))||!tee(n.sessionId)||!m$(n.observedAt))
|
|
6545
|
+
throw new Error("Step receipts have an invalid step, interaction identity, session or time.");r.add(n.stepId)}}function tee(e){try{return le(e)===e}catch{return!1}}function BI(e){return zn(e.lesson)&&Array.isArray(e.lesson.steps)?e.
|
|
6546
|
+
lesson.steps:null}var ree=e=>e.check?.kind==="none"?"read":e.check?.kind;function y$(e,t){let r=BI(t);if(!r)throw new Error(
|
|
6547
|
+
"Step results belong only to a version 2 lesson.");for(let n of e.results){let o=r.find(i=>i.id===n.stepId);if(!o||ree(o)!==
|
|
6547
6548
|
n.kind||n.kind==="auto"&&n.evidence.checkId!==o.check.check||n.kind==="fact"&&n.evidence.fact!==o.check.fact)throw new Error(
|
|
6548
6549
|
"Saved step results must match the exact pinned lesson step and its declared check.")}for(let n of e.receipts||[]){let o=r.
|
|
6549
6550
|
find(i=>i.id===n.stepId);if(o?.check?.kind!=="auto"||o.check.check!==n.checkId)throw new Error("Saved step receipts must\
|
|
@@ -6556,61 +6557,61 @@ g state requires a bounded nonempty actor identity; no local fallback is used.")
|
|
|
6556
6557
|
"base64url")}}function qI(e){let t=Qr(UI,e,"Learner reservation pin");if(Jh(t.topic),!/^[a-z][a-z0-9-]{0,63}$/u.test(t.course.
|
|
6557
6558
|
courseId)||!/^\d+\.\d+\.\d+$/u.test(t.course.release)||!$s.test(t.lesson.code)||!Yh.test(t.lesson.hash))throw new Error(
|
|
6558
6559
|
"Reserve the exact course release, installed topic pin and published lesson hash.");return{course:{...t.course},topic:{...t.
|
|
6559
|
-
topic},lesson:{...t.lesson}}}async function $l(e,t){let r;try{r=await
|
|
6560
|
-
await
|
|
6561
|
-
gular paths without symlink or file aliases.");return r}async function VI(e){let t
|
|
6562
|
-
t),$l(e,!0)}async function Qh(e,t=
|
|
6563
|
-
KiB record limit.`;if(r.size>t)throw new Error(n);let o=await
|
|
6560
|
+
topic},lesson:{...t.lesson}}}async function $l(e,t){let r;try{r=await MQ(e)}catch(n){if(n.code==="ENOENT")return null;throw n}if(r.isSymbolicLink()||
|
|
6561
|
+
await $Q(e)!==e||(t?!r.isDirectory():!r.isFile())||!t&&r.nlink!==1)throw new Error("Learning state requires canonical re\
|
|
6562
|
+
gular paths without symlink or file aliases.");return r}async function VI(e){let t=DQ.dirname(e);return t!==e&&await VI(
|
|
6563
|
+
t),$l(e,!0)}async function Qh(e,t=BQ){let r=await $l(e,!1);if(!r)return null;let n=`Learning state exceeds its ${t/1024}\
|
|
6564
|
+
KiB record limit.`;if(r.size>t)throw new Error(n);let o=await LQ(e);if(o.length>t)throw new Error(n);let i=JSON.parse(o.
|
|
6564
6565
|
toString("utf8"));if(!i||typeof i!="object"||Array.isArray(i))throw new Error("Learning state must contain a versioned r\
|
|
6565
|
-
ecord object.");return i}var
|
|
6566
|
-
Ds=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/u,
|
|
6567
|
-
WI={type:"integer",required:!0,enum:[1]},Us={type:"integer",required:!0,min:0,max:Number.MAX_SAFE_INTEGER},
|
|
6566
|
+
ecord object.");return i}var nee=64,oee=32,HI=64*1024,iee=64,see=32,aee=128,I$=1024*1024,Dl=/^[a-zA-Z][a-zA-Z0-9-]{0,63}$/u,GI=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u,
|
|
6567
|
+
Ds=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/u,cee=/^[a-f0-9]{64}$/u,be={type:"string",required:!0,noTrim:!0,minLength:1,maxLength:256},
|
|
6568
|
+
WI={type:"integer",required:!0,enum:[1]},Us={type:"integer",required:!0,min:0,max:Number.MAX_SAFE_INTEGER},dee=oe({stage:{
|
|
6568
6569
|
...be,enum:["project","session","setup"]},code:{...be,maxLength:64},message:{...be,maxLength:512}}),S$=oe({phase:{...be,
|
|
6569
6570
|
enum:["reserved","preparing","ready"]},initialSessionId:{...be,required:!1,maxLength:128},observedAt:{...be,required:!1,
|
|
6570
|
-
maxLength:24},failure:{type:"object",required:!1,schema:
|
|
6571
|
+
maxLength:24},failure:{type:"object",required:!1,schema:dee}}),A$=oe({code:{...be,maxLength:64},hash:{...be,maxLength:64}}),
|
|
6571
6572
|
E$=oe({course:{type:"object",required:!0,schema:oe({courseId:{...be,maxLength:64},release:be})},topic:{type:"object",required:!0},
|
|
6572
|
-
lesson:{type:"object",required:!0,schema:A$}}),
|
|
6573
|
+
lesson:{type:"object",required:!0,schema:A$}}),uee=oe({kind:{...be,enum:["answer","observation"]},learnerId:{...be,maxLength:128},
|
|
6573
6574
|
attemptId:{...be,maxLength:36},text:{...be,maxLength:2048},messageId:{...be,required:!1,maxLength:128},questionId:{...be,
|
|
6574
6575
|
required:!1,maxLength:64},observationId:{...be,required:!1,maxLength:128},observedAt:{...be,required:!1,maxLength:24},projectSlug:{
|
|
6575
6576
|
...be,required:!1,maxLength:48},sessionId:{...be,required:!1,maxLength:128},producer:{...be,required:!1,enum:["workspace",
|
|
6576
6577
|
"colleague","exercise","code"]},operation:{...be,required:!1,maxLength:64},origin:{...be,required:!1,enum:["learner","de\
|
|
6577
|
-
monstration"]},check:{...be,required:!1,maxLength:64}}),
|
|
6578
|
+
monstration"]},check:{...be,required:!1,maxLength:64}}),lee=oe({submissionId:{...be,maxLength:64},assessmentId:{...be,maxLength:64},
|
|
6578
6579
|
kind:{...be,enum:["answer","practical"]},outcome:{...be,enum:["passed","not-yet-passed","needs-review"]},evidence:{type:"\
|
|
6579
|
-
object",required:!0,schema:
|
|
6580
|
-
"substantial"]},rubric:be,rubricRevision:{...be,maxLength:64},recordedAt:{...be,maxLength:24}}),
|
|
6580
|
+
object",required:!0,schema:uee},explanation:{...be,maxLength:1024},assistance:{...be,enum:["none","hint","demonstration",
|
|
6581
|
+
"substantial"]},rubric:be,rubricRevision:{...be,maxLength:64},recordedAt:{...be,maxLength:24}}),pee=oe({requestId:{...be,
|
|
6581
6582
|
maxLength:64},revision:Us,stage:{...be,maxLength:64},pendingQuestion:{type:"object",required:!0,nullable:!0,schema:oe({id:{
|
|
6582
6583
|
...be,maxLength:64},assessmentId:{...be,maxLength:64},text:{...be,maxLength:2048},assistance:{...be,required:!1,enum:["n\
|
|
6583
6584
|
one","hint","demonstration","substantial"]},issuedRevision:{...Us,required:!1,min:1}})},visuals:Ue(oe({visualId:{...be,maxLength:64},
|
|
6584
|
-
snapshot:{type:"object",required:!0}}),12),summary:{...be,minLength:0,maxLength:2048}}),x$=oe({submissions:Ue(
|
|
6585
|
-
type:"object",required:!1,schema:
|
|
6586
|
-
inished","discard","restart"]}}),
|
|
6587
|
-
...Ue({...be,maxLength:64},
|
|
6585
|
+
snapshot:{type:"object",required:!0}}),12),summary:{...be,minLength:0,maxLength:2048}}),x$=oe({submissions:Ue(lee,64),resume:{
|
|
6586
|
+
type:"object",required:!1,schema:pee}}),fee=oe({requestId:{...be,maxLength:64},revision:Us,reason:{...be,enum:["left","f\
|
|
6587
|
+
inished","discard","restart"]}}),mee=oe({attemptId:{...be,maxLength:36},practiceId:{...be,required:!1,maxLength:36},requestIds:{
|
|
6588
|
+
...Ue({...be,maxLength:64},nee),minLength:1},createdAt:{...be,maxLength:24},pin:{type:"object",required:!0,schema:E$},projectSlug:{
|
|
6588
6589
|
...be,required:!1,maxLength:48},preparation:{type:"object",required:!1,schema:S$},learning:{type:"object",required:!1,schema:x$},
|
|
6589
|
-
ended:{type:"object",required:!1,schema:
|
|
6590
|
-
...be,maxLength:36,nullable:!0},attempts:Ue(
|
|
6590
|
+
ended:{type:"object",required:!1,schema:fee}}),hee=oe({schemaVersion:WI,learnerId:{...be,maxLength:128},revision:Us,activeAttemptId:{
|
|
6591
|
+
...be,maxLength:36,nullable:!0},attempts:Ue(mee,oee)}),gee=oe({schemaVersion:WI,learnerId:{...be,maxLength:128},progressRevision:Us,
|
|
6591
6592
|
attemptId:{...be,maxLength:36},practiceId:{...be,required:!1,maxLength:36},pin:{type:"object",required:!0,schema:E$},projectSlug:{
|
|
6592
6593
|
...be,required:!1,maxLength:48},preparation:{type:"object",required:!1,schema:S$},learning:{type:"object",required:!1,schema:x$}}),
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
type:"object",required:!0,schema:A$},results:Ue(zI,
|
|
6596
|
-
let r=Qr(
|
|
6597
|
-
let n=new Set;for(let o of r.lessons){let i=$e(o.lesson);if(!Dl.test(o.lesson.code)||!
|
|
6594
|
+
wee=oe({schemaVersion:WI,learnerId:{...be,maxLength:128},progressRevision:Us,attemptId:{...be,nullable:!0,maxLength:36}}),
|
|
6595
|
+
vee=oe({schemaVersion:{type:"integer",required:!0,enum:[2]},learnerId:{...be,maxLength:128},revision:Us,lessons:Ue(oe({lesson:{
|
|
6596
|
+
type:"object",required:!0,schema:A$},results:Ue(zI,iee),receipts:{...Ue(FI,see),required:!1}}),aee)});function yee(e,t){
|
|
6597
|
+
let r=Qr(vee,e,"Learner step progress");if(r.learnerId!==t)throw new Error("Step progress belongs to another learner.");
|
|
6598
|
+
let n=new Set;for(let o of r.lessons){let i=$e(o.lesson);if(!Dl.test(o.lesson.code)||!cee.test(o.lesson.hash)||n.has(i))
|
|
6598
6599
|
throw new Error("Step progress names a repeated or invalid lesson content identity.");n.add(i),v$(o)}if(Buffer.byteLength(
|
|
6599
6600
|
`${JSON.stringify(r,null,2)}
|
|
6600
|
-
`)>I$)throw new Error("Step progress exceeds its 1 MiB record limit. No result was removed or written.");return r}function
|
|
6601
|
+
`)>I$)throw new Error("Step progress exceeds its 1 MiB record limit. No result was removed or written.");return r}function _ee(e,t){
|
|
6601
6602
|
let r=$e({code:t.code,hash:t.hash});return e.find(n=>$e(n.lesson)===r)||{lesson:{code:t.code,hash:t.hash},results:[]}}function eg(e){
|
|
6602
|
-
return e?.lesson?.schemaVersion===1}function T$(e){return e.practiceId??e.attemptId}var
|
|
6603
|
-
"-","")}`);function
|
|
6603
|
+
return e?.lesson?.schemaVersion===1}function T$(e){return e.practiceId??e.attemptId}var bee=e=>Zl(`training-${e.replaceAll(
|
|
6604
|
+
"-","")}`);function Iee(e){return new Set([`training-${T$(e)}`,`training-${e.attemptId}`])}function C$(e,t){if(e.phase===
|
|
6604
6605
|
"reserved"){if($e(e)!==$e({phase:"reserved"}))throw new Error("A reserved attempt must not contain preparation effects o\
|
|
6605
|
-
r a session identity.");return}if(!
|
|
6606
|
+
r a session identity.");return}if(!Iee(t).has(e.initialSessionId)||le(e.initialSessionId)!==e.initialSessionId)throw new Error(
|
|
6606
6607
|
"Preparation must retain the exact server-reserved initial session identity.");if(e.phase==="ready"){if(!Number.isFinite(
|
|
6607
6608
|
Date.parse(e.observedAt))||new Date(e.observedAt).toISOString()!==e.observedAt||e.failure)throw new Error("Ready prepara\
|
|
6608
6609
|
tion requires an observed time and no unresolved failure.")}else if(e.observedAt)throw new Error("Pending preparation mu\
|
|
6609
6610
|
st not claim an observed ready time.");if(e.failure&&(!/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,63}$/u.test(e.failure.code)||e.failure.
|
|
6610
6611
|
message.trim()!==e.failure.message||/[\u0000-\u001f\u007f]/u.test(e.failure.message)))throw new Error("Preparation failu\
|
|
6611
|
-
re must contain a bounded code and a single-line recovery message.")}function
|
|
6612
|
+
re must contain a bounded code and a single-line recovery message.")}function See(e){if(qI(e.pin),!GI.test(e.attemptId)||
|
|
6612
6613
|
e.practiceId!==void 0&&(!GI.test(e.practiceId)||e.practiceId===e.attemptId))throw new Error("Learning state has an inval\
|
|
6613
|
-
id attempt or practice project identity.");e.preparation&&C$(e.preparation,e);let t=e.preparation?
|
|
6614
|
+
id attempt or practice project identity.");e.preparation&&C$(e.preparation,e);let t=e.preparation?bee(T$(e)):void 0;if(e.
|
|
6614
6615
|
projectSlug!==t||!e.preparation&&e.practiceId!==void 0||!Number.isFinite(Date.parse(e.createdAt))||new Date(e.createdAt).
|
|
6615
6616
|
toISOString()!==e.createdAt||!e.requestIds.length||e.requestIds.some(r=>!Ds.test(r))||new Set(e.requestIds).size!==e.requestIds.
|
|
6616
6617
|
length)throw new Error("Learning state has an invalid attempt identity, reservation time or retry inventory.")}function R$(e,t,r,n){
|
|
@@ -6631,9 +6632,9 @@ t identity, revision, question or visual inventory.");for(let c of a?.visuals||[
|
|
|
6631
6632
|
keys(e).sort())!==$e(["labels","paused","state"])||!Dl.test(e.state)||typeof e.paused!="boolean"||!e.labels||typeof e.labels!=
|
|
6632
6633
|
"object"||Array.isArray(e.labels)||Object.keys(e.labels).length>32||Object.entries(e.labels).some(([t,r])=>!Ds.test(t)||
|
|
6633
6634
|
typeof r!="string"||!r.trim()||r.length>256||/[\u0000-\u001f\u007f]/u.test(r))||Buffer.byteLength(JSON.stringify(e))>4096)
|
|
6634
|
-
throw new Error("Save only a bounded semantic visual snapshot.")}function
|
|
6635
|
+
throw new Error("Save only a bounded semantic visual snapshot.")}function Aee(e,t){let r=Qr(hee,e,"Learner progress");if(r.
|
|
6635
6636
|
learnerId!==t||!r.attempts.length&&(r.activeAttemptId!==null||r.revision!==0))throw new Error("Learning state differs fr\
|
|
6636
|
-
om its learner or active reservation.");let n=new Set,o=new Set,i=0,s=0;for(let[a,c]of r.attempts.entries()){if(
|
|
6637
|
+
om its learner or active reservation.");let n=new Set,o=new Set,i=0,s=0;for(let[a,c]of r.attempts.entries()){if(See(c),R$(
|
|
6637
6638
|
c.learning,c,t,c.ended?c.ended.revision-1:r.revision),n.has(c.attemptId))throw new Error("Learning history repeats an at\
|
|
6638
6639
|
tempt identity.");n.add(c.attemptId);for(let d of[...c.requestIds,...c.ended?[c.ended.requestId]:[]]){if(!Ds.test(d)||o.
|
|
6639
6640
|
has(d))throw new Error("Learning history repeats or has an invalid reservation/end request identity.");o.add(d)}if(c.ended){
|
|
@@ -6646,7 +6647,7 @@ ng history must contain exactly one active attempt or only ended attempts.");if(
|
|
|
6646
6647
|
`)>HI)throw new Error("Learning state exceeds its 64 KiB record limit. No evidence was removed or written.");return r}function b$(e){
|
|
6647
6648
|
let t=e.attempts.find(r=>r.attemptId===e.activeAttemptId);return t?{schemaVersion:1,learnerId:e.learnerId,progressRevision:e.
|
|
6648
6649
|
revision,attemptId:t.attemptId,...t.practiceId?{practiceId:t.practiceId}:{},pin:t.pin,...t.preparation?{projectSlug:t.projectSlug,
|
|
6649
|
-
preparation:t.preparation}:{},...t.learning?{learning:t.learning}:{}}:null}function
|
|
6650
|
+
preparation:t.preparation}:{},...t.learning?{learning:t.learning}:{}}:null}function Eee(e,t,r=[e]){if(!eg(t))return[];let n=r.
|
|
6650
6651
|
filter(o=>$e(o.pin.lesson)===$e(e.pin.lesson));return t.lesson.assessments.filter(o=>n.some(i=>i.learning?.submissions.some(
|
|
6651
6652
|
s=>s.assessmentId===o.id&&s.rubricRevision===t.hash&&s.outcome==="passed"))).map(o=>o.id)}function P$({systemRoot:e,content:t}={}){
|
|
6652
6653
|
if(typeof e!="string"||!hn.isAbsolute(e)||hn.resolve(e)!==e||e===hn.parse(e).root)throw new Error("Learning state needs \
|
|
@@ -6654,11 +6655,11 @@ a canonical absolute, non-root server-owned system root.");let r=t;if(typeof r?.
|
|
|
6654
6655
|
"Learning state requires the configured installed-content reader.");function n(m){let _=_$(m),I=hn.join(e,"training"),x=hn.
|
|
6655
6656
|
join(I,"users"),C=hn.join(x,_.key);return{learner:_,directories:[I,x,C],userRoot:C,progress:hn.join(C,"progress.json"),active:hn.
|
|
6656
6657
|
join(C,"active-lesson.json"),lock:hn.join(C,"state.lock"),preparationLock:hn.join(C,"preparation.lock"),stepProgress:hn.
|
|
6657
|
-
join(C,"step-progress.json")}}async function o(m){let _=await Qh(m.progress,HI);return _?
|
|
6658
|
+
join(C,"step-progress.json")}}async function o(m){let _=await Qh(m.progress,HI);return _?Aee(_,m.learner.id):{schemaVersion:1,
|
|
6658
6659
|
learnerId:m.learner.id,revision:0,activeAttemptId:null,attempts:[]}}async function i(m){try{await VI(e);for(let C of m.directories)
|
|
6659
6660
|
await $l(C,!0);for(let C of[m.lock,m.preparationLock]){let T=await $l(C,!1);if(T&&T.size!==0)throw new Error("Learning s\
|
|
6660
6661
|
tate lock contains unexplained data; inspect it before retrying.")}let _=await o(m),I=await Qh(m.active,HI);if(I){let C=I.
|
|
6661
|
-
attemptId===null,T=Qr(C?gee
|
|
6662
|
+
attemptId===null,T=Qr(C?wee:gee,I,"Active learner reservation");if(T.learnerId!==m.learner.id)throw new Error("Active su\
|
|
6662
6663
|
mmary belongs to another learner.");if(T.progressRevision>_.revision&&(_=await o(m)),C){if(!_.attempts.some(M=>M.ended?.
|
|
6663
6664
|
revision===T.progressRevision))throw new Error("An empty active summary must describe an actual retained end revision.")}else{
|
|
6664
6665
|
qI(T.pin),T.preparation&&C$(T.preparation,T),R$(T.learning,T,T.learnerId,T.progressRevision);let M=_.attempts.findIndex(
|
|
@@ -6703,9 +6704,9 @@ mpt ID.");let C=await i(x),T=C.progress.attempts.find(K=>K.attemptId===_);if(!T)
|
|
|
6703
6704
|
G","This learner has no matching saved attempt.",404);if(T.practiceId)throw Ao("VIBE64_TRAINING_ATTEMPT_CONFLICT","This \
|
|
6704
6705
|
attempt continues a learning-space practice project; read it by its practice project.",409);let{active:M,sourcePath:L}=await d(
|
|
6705
6706
|
C,T,I);return u(x,C,T,{active:M,training:{schemaVersion:1,learnerKey:x.learner.key,attemptId:_,pin:structuredClone(T.pin),
|
|
6706
|
-
exercise:{kind:"bundled",sourcePath:L}}})}function p(m,_,I=[m],x=[]){let C=BI(_),T,M;if(C){let{results:L}=
|
|
6707
|
+
exercise:{kind:"bundled",sourcePath:L}}})}function p(m,_,I=[m],x=[]){let C=BI(_),T,M;if(C){let{results:L}=_ee(x,m.pin.lesson);
|
|
6707
6708
|
T=C.filter(K=>K.required).map(K=>K.id),M=T.filter(K=>L.some(X=>X.stepId===K&&X.outcome==="passed"))}else if(eg(_))T=_.lesson.
|
|
6708
|
-
assessments.filter(L=>L.required).map(L=>L.id),M=
|
|
6709
|
+
assessments.filter(L=>L.required).map(L=>L.id),M=Eee(m,_,I).filter(L=>T.includes(L));else throw new Error(`Lesson ${_.lesson.
|
|
6709
6710
|
code} uses an unsupported format.`);return{lessonCode:_.lesson.code,lessonHash:_.hash,required:T.length,passed:M.length,
|
|
6710
6711
|
completed:M.length===T.length}}function f(m,_){if(!eg(_))throw new Error("A lesson resume checkpoint belongs only to a v\
|
|
6711
6712
|
ersion 1 lesson.");if(m.pendingQuestion&&!_.lesson.assessments.some(I=>I.id===m.pendingQuestion.assessmentId))throw new Error(
|
|
@@ -6718,7 +6719,7 @@ essment learning.");m.learning.resume&&f(m.learning.resume,_);for(let I of m.lea
|
|
|
6718
6719
|
find(T=>T.id===I.assessmentId),C=I.evidence;if(!x||I.kind!==x.kind||I.rubric!==x.rubric||I.rubricRevision!==_.hash||x.kind===
|
|
6719
6720
|
"practical"&&(C.producer!==x.evidence.producer||C.operation!==x.evidence.operation||C.check!==x.evidence.check))throw new Error(
|
|
6720
6721
|
"Saved assessment receipts must match the exact pinned assessment, rubric and evidence contract.")}}}async function v(m){
|
|
6721
|
-
let _=await Qh(m.stepProgress,I$);return _?
|
|
6722
|
+
let _=await Qh(m.stepProgress,I$);return _?yee(_,m.learner.id):null}async function w(m,_,I){try{let x=await v(m);for(let C of x?.
|
|
6722
6723
|
lessons||[]){let T=_.attempts.find(M=>$e(M.pin.lesson)===$e(C.lesson));T&&y$(C,I.get(T.attemptId))}return{revision:x?.revision||
|
|
6723
6724
|
0,lessons:x?.lessons||[]}}catch(x){throw Ao("VIBE64_TRAINING_STATE_INVALID",`Learning step progress is invalid: ${x.message}\
|
|
6724
6725
|
Keep the files and ask the owner to inspect them; no automatic conversion was performed.`,null,{cause:x})}}return{readState:c,
|
|
@@ -6733,7 +6734,7 @@ e,l.path),f=p&&xt.relative(e,p);if(!f||f!==l.path||f===".."||f.startsWith(`..${x
|
|
|
6733
6734
|
throw new Error("Practice history backup has an invalid owned path.");await ge(e,xt.join(t,"after",l.path))}}let a=new Set(
|
|
6734
6735
|
await ut(e)),c=new Map,d=[{name:"normal",root:e,content:Xh({systemRoot:e})},{name:"author-preview",root:xt.join(e,"autho\
|
|
6735
6736
|
r-preview"),content:Xh({systemRoot:e,allowDraftLessons:!0})}];for(let l of d){let p=xt.join(l.root,"training","users");await ge(
|
|
6736
|
-
e,xt.join(p,".inventory"));let f;try{f=await
|
|
6737
|
+
e,xt.join(p,".inventory"));let f;try{f=await Cee(p,{withFileTypes:!0})}catch(h){if(h.code==="ENOENT")continue;throw h}let y=P$(
|
|
6737
6738
|
{systemRoot:l.root,content:l.content});for(let h of f.sort((v,w)=>v.name.localeCompare(w.name))){if(!h.isDirectory())throw new Error(
|
|
6738
6739
|
`Practice history ${l.name} learner inventory contains a non-directory. Inspect it before upgrading.`);let v=Buffer.from(
|
|
6739
6740
|
h.name,"base64url").toString("utf8");if(!v||Buffer.from(v).toString("base64url")!==h.name)throw new Error(`Practice hist\
|
|
@@ -6747,11 +6748,11 @@ observe"}),T=C.projectSlug;if(c.has(T))throw new Error(`Practice ${T} is claimed
|
|
|
6747
6748
|
phase==="ready")throw new Error(`Prepared practice ${C.projectSlug} has no original runtime. Restore or inspect its orig\
|
|
6748
6749
|
inal owner before upgrading.`);n("warning",`Practice ${C.projectSlug} has no initial project yet; preparing progress rem\
|
|
6749
6750
|
ains unchanged.`),c.set(T,{...C,phase:I.preparation.phase,missing:!0});continue}let L=Wd({projectRuntimeRoot:M});if(await ge(
|
|
6750
|
-
e,L),await Ae(L)===null)throw new Error(`Practice ${C.projectSlug} has no original project record.`);if((await
|
|
6751
|
+
e,L),await Ae(L)===null)throw new Error(`Practice ${C.projectSlug} has no original project record.`);if((await xee(L)).nlink!==
|
|
6751
6752
|
1)throw new Error(`Practice ${C.projectSlug} has aliased project metadata. Inspect its original owner.`);let K=await Xv(
|
|
6752
|
-
L);if(!
|
|
6753
|
+
L);if(!Pee(K.training,C.training)||K.repository?.mode!=="managed_git"||K.deletion)throw new Error(`Practice ${C.projectSlug}\
|
|
6753
6754
|
differs from its saved Training marker or managed repository. Inspect it before upgrading.`);c.set(T,{...C,phase:I.preparation.
|
|
6754
|
-
phase,store:gt({projectContextRoot:M,projectRuntimeRoot:M})})}}}let u=await
|
|
6755
|
+
phase,store:gt({projectContextRoot:M,projectRuntimeRoot:M})})}}}let u=await Tee(xt.join(Oee.tmpdir(),"vibe64-practice-hi\
|
|
6755
6756
|
story-"));try{let l=[],p=new Set;for(let f of c.values()){if(f.missing)continue;let y=xt.relative(e,f.store.paths().stateRoot),
|
|
6756
6757
|
h=(s?.files||[]).filter(w=>w.path.startsWith(`${y}${xt.sep}`)).map(w=>({filePath:xt.join(e,w.path),replacementPath:xt.join(
|
|
6757
6758
|
t,"after",w.path)})),v=await f.store.prepareLearningSessionBindingUpgrade({temporaryRoot:u,sessionId:f.initialSessionId,
|
|
@@ -6761,38 +6762,38 @@ projectSlug} has no exact saved initial session. Restore or inspect it before up
|
|
|
6761
6762
|
filePath));l.push(...v.updates),n("info",`Verified practice ${f.projectSlug}, initial session ${f.initialSessionId}; ${v.
|
|
6762
6763
|
updates.length?"historical binding staged":"exact binding already current"}.`)}if(s&&s.files.some(f=>!p.has(f.path)))throw new Error(
|
|
6763
6764
|
"Practice history backup has a replacement no longer authorized by a saved preparation. Inspect its owner before retryin\
|
|
6764
|
-
g.");return await xe({systemRoot:e,backupRoot:t,apply:r,report:n,prepareUpdates:async()=>l})}finally{await
|
|
6765
|
-
force:!0})}}import{createHash as L$}from"node:crypto";import{createReadStream as
|
|
6766
|
-
readdir as D$,readFile as U$,readlink as
|
|
6767
|
-
|
|
6768
|
-
son","state.lock","preparation.lock","step-progress.lock","reader.lock","code-ledger.lock","learning-mode.lock"])
|
|
6765
|
+
g.");return await xe({systemRoot:e,backupRoot:t,apply:r,report:n,prepareUpdates:async()=>l})}finally{await Ree(u,{recursive:!0,
|
|
6766
|
+
force:!0})}}import{createHash as L$}from"node:crypto";import{createReadStream as kee}from"node:fs";import{cp as Nee,lstat as $$,mkdir as XI,
|
|
6767
|
+
readdir as D$,readFile as U$,readlink as jee,rename as KI,rm as z$,writeFile as F$}from"node:fs/promises";import it from"node:path";var YI="20261022-learning-space-reset",N$=".learning-reset-20261022",j$=/^training-([a-f0-9]{32})$/u,Mee=/^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/u,
|
|
6768
|
+
Lee=new Set(["progress.json","active-lesson.json","step-progress.json","reader.json","code-ledger.json","learning-mode.j\
|
|
6769
|
+
son","state.lock","preparation.lock","step-progress.lock","reader.lock","code-ledger.lock","learning-mode.lock"]),$ee=new Set(
|
|
6769
6770
|
["learning-sessions","code-ledgers"]),JI=e=>e&&typeof e=="object"&&!Array.isArray(e);async function Ul(e){try{let t=await $$(
|
|
6770
6771
|
e);return t.isSymbolicLink()?"symlink":t.isDirectory()?"directory":t.isFile()?"file":"other"}catch(t){if(t.code==="ENOEN\
|
|
6771
6772
|
T")return"missing";throw t}}async function tg(e){try{return(await D$(e)).sort()}catch(t){if(t.code==="ENOENT")return[];throw t}}
|
|
6772
|
-
function
|
|
6773
|
-
from(e,"base64url").toString("base64url")===e&&Buffer.from(t).toString("base64url")===e}function
|
|
6774
|
-
e?.training).practiceId===Lf(t)}catch{return!1}}function
|
|
6775
|
-
r.learnerKey)&&typeof r.attemptId=="string"&&
|
|
6776
|
-
kind==="bundled"&&e.repository?.mode==="managed_git"?r:null}async function
|
|
6773
|
+
function Dee(e){if(typeof e!="string"||!e||e.length>171)return!1;let t=Buffer.from(e,"base64url").toString("utf8");return Buffer.
|
|
6774
|
+
from(e,"base64url").toString("base64url")===e&&Buffer.from(t).toString("base64url")===e}function Uee(e,t){try{return Zv(
|
|
6775
|
+
e?.training).practiceId===Lf(t)}catch{return!1}}function zee(e,t){let r=e?.training;return JI(r)&&r.schemaVersion===1&&Dee(
|
|
6776
|
+
r.learnerKey)&&typeof r.attemptId=="string"&&Mee.test(r.attemptId)&&r.attemptId.replaceAll("-","")===t&&JI(r.pin)&&r.exercise?.
|
|
6777
|
+
kind==="bundled"&&e.repository?.mode==="managed_git"?r:null}async function Fee(e){let t=L$("sha256");for await(let r of kee(
|
|
6777
6778
|
e))t.update(r);return t.digest("hex")}async function M$(e){let t=[];async function r(n,o){let i=await $$(n);if(i.isSymbolicLink())
|
|
6778
|
-
t.push([o,"link",await
|
|
6779
|
+
t.push([o,"link",await jee(n)]);else if(i.isFile())t.push([o,"file",i.size,await Fee(n)]);else if(i.isDirectory()){t.push(
|
|
6779
6780
|
[o,"directory"]);for(let s of(await D$(n)).sort())await r(it.join(n,s),`${o}/${s}`)}else throw new Error(`Learning reset\
|
|
6780
6781
|
cannot copy a special file: ${n}. Inspect it before upgrading.`)}return await r(e,"."),JSON.stringify(t)}async function B$({
|
|
6781
6782
|
source:e,destination:t},{verifiedRoot:r,removeTree:n}){let o=it.join(r,L$("sha256").update(e).digest("hex"));if(await Ul(
|
|
6782
6783
|
o)!=="file"){if(await M$(e)!==await M$(t))throw new Error(`Learning reset copy differs from its source: ${e}. Inspect bo\
|
|
6783
6784
|
th before retrying.`);await XI(r,{recursive:!0,mode:448}),await F$(o,`${JSON.stringify({source:e,destination:t})}
|
|
6784
|
-
`,{mode:384})}await n(e,{recursive:!0,force:!0})}async function
|
|
6785
|
+
`,{mode:384})}await n(e,{recursive:!0,force:!0})}async function Bee(e,{renamePath:t,...r}){let{source:n,destination:o}=e;
|
|
6785
6786
|
await XI(it.dirname(o),{recursive:!0,mode:448});try{await t(n,o);return}catch(s){if(s.code!=="EXDEV")throw s}let i=`${o}\
|
|
6786
|
-
.partial`;await z$(i,{recursive:!0,force:!0}),await
|
|
6787
|
-
force:!1}),await KI(i,o),await B$(e,r)}async function
|
|
6787
|
+
.partial`;await z$(i,{recursive:!0,force:!0}),await Nee(n,i,{recursive:!0,verbatimSymlinks:!0,preserveTimestamps:!0,errorOnExist:!0,
|
|
6788
|
+
force:!1}),await KI(i,o),await B$(e,r)}async function qee(e){let t=await Ul(e);if(t==="missing")return[];let r;try{t==="\
|
|
6788
6789
|
file"&&(r=JSON.parse(await U$(e,"utf8")))}catch{}if(r?.upgrade!==YI||!Array.isArray(r.moves)||r.moves.some(n=>!JI(n)||!it.
|
|
6789
6790
|
isAbsolute(n.source||"")||!it.isAbsolute(n.destination||"")))throw new Error("Learning reset manifest is invalid. Inspec\
|
|
6790
|
-
t it before upgrading.");return r.moves}async function
|
|
6791
|
+
t it before upgrading.");return r.moves}async function Vee({systemRoot:e,projectsRoot:t,managedSourceRoot:r,planned:n,report:o}){
|
|
6791
6792
|
let i=[],s=[],a=it.join(e,"training","retired",YI),c=f=>({source:f,destination:it.join(a,it.relative(e,f))}),d=async(f,y,h)=>{
|
|
6792
6793
|
let v=await Ul(f);return v!==y&&v!=="missing"&&s.push(`${h} is a ${v}, not a ${y}: ${f}.`),v===y},u=it.join(e,"projects");
|
|
6793
6794
|
await ge(e,it.join(u,"placeholder"));let l=0;for(let f of await tg(u)){let y=j$.exec(f)?.[1];if(!y)continue;let h=it.join(
|
|
6794
6795
|
u,f);if(n.has(h)||!await d(h,"directory","Practice runtime root"))continue;let v=it.join(h,"project.json"),w=null;if(await d(
|
|
6795
|
-
v,"file","Practice project record"))try{w=JSON.parse(await U$(v,"utf8"))}catch{}let m=
|
|
6796
|
+
v,"file","Practice project record"))try{w=JSON.parse(await U$(v,"utf8"))}catch{}let m=zee(w,y);if(!m){Uee(w,f)||o("warni\
|
|
6796
6797
|
ng",`${f} looks like a practice project but has no valid v1 practice marker; it is left unchanged.`);continue}let _=[];if(t){
|
|
6797
6798
|
let I=it.join(t,f);await ge(t,I),await d(I,"directory","Hosted practice namespace")&&_.push({source:I,destination:it.join(
|
|
6798
6799
|
t,N$,f)})}else{let I=it.join(e,"training","practice",m.learnerKey,m.attemptId,f);await ge(e,I),await d(I,"directory","Lo\
|
|
@@ -6803,14 +6804,14 @@ pace (an interrupted deletion); only its runtime state will be retired.`),o("inf
|
|
|
6803
6804
|
ice project(s) may have managed databases or resource profiles keyed by their slugs. This upgrade cannot remove them; th\
|
|
6804
6805
|
ey become unreachable and never collide with new practice projects.`);for(let f of[e,it.join(e,"author-preview")]){let y=it.
|
|
6805
6806
|
join(f,"training","users");await ge(e,it.join(y,"placeholder"));for(let h of await tg(y)){let v=it.join(y,h);if(await d(
|
|
6806
|
-
v,"directory","Learner directory"))for(let w of await tg(v)){let m
|
|
6807
|
+
v,"directory","Learner directory"))for(let w of await tg(v)){let m=$ee.has(w);if(!Lee.has(w)&&!m)continue;let _=it.join(
|
|
6807
6808
|
v,w);await d(_,m?"directory":"file","Learner state")&&(o("info",`Learner state ${it.relative(e,_)} will be retired.`),i.
|
|
6808
6809
|
push(c(_)))}}}let p=(await tg(it.join(e,"project-archives"))).filter(f=>j$.test(f));return p.length&&o("info",`${p.length}\
|
|
6809
6810
|
archived project bundle(s) named like v1 practice projects stay in project-archives and are not part of Learning: ${p.join(
|
|
6810
6811
|
", ")}.`),{moves:i,errors:s}}async function q$({systemRoot:e,projectsRoot:t,managedSourceRoot:r,apply:n,backupRoot:o,report:i,
|
|
6811
6812
|
renamePath:s=KI,removeTree:a=z$}){for(let w of[e,o,t,r])if(w!==void 0&&(!it.isAbsolute(w||"")||it.resolve(w)!==w||w===it.
|
|
6812
6813
|
parse(w).root))throw new Error("Learning reset requires exact absolute installation, projects, managed source and backup\
|
|
6813
|
-
directories.");let c=it.join(o,"manifest.json"),d=await
|
|
6814
|
+
directories.");let c=it.join(o,"manifest.json"),d=await qee(c),u=new Set(d.map(w=>w.source)),{moves:l,errors:p}=await Vee(
|
|
6814
6815
|
{systemRoot:e,projectsRoot:t,managedSourceRoot:r,planned:u,report:i}),f=[...d,...l.filter(w=>!u.has(w.source))],y=[],h=[];
|
|
6815
6816
|
for(let w of f){let[m,_]=await Promise.all([Ul(w.source),Ul(w.destination)]);m==="missing"&&_!=="missing"||(m==="missing"?
|
|
6816
6817
|
p.push(`Neither ${w.source} nor its retired copy exists.`):_!=="missing"&&!u.has(w.source)?p.push(`Unexpected destinatio\
|
|
@@ -6819,13 +6820,13 @@ ect before upgrading.`);if(i("info",`${y.length+h.length} Learning item(s) to re
|
|
|
6819
6820
|
ady retired.`),!n||!(y.length+h.length))return;if(f.length>d.length){await XI(o,{recursive:!0,mode:448});let w=`${c}.tmp`;
|
|
6820
6821
|
await F$(w,`${JSON.stringify({upgrade:YI,moves:f},null,2)}
|
|
6821
6822
|
`,{mode:384}),await KI(w,c)}let v={verifiedRoot:it.join(o,"verified"),removeTree:a};for(let w of h)await B$(w,v);for(let w of y)
|
|
6822
|
-
await
|
|
6823
|
+
await Bee(w,{renamePath:s,...v}),i("info",`Retired ${w.source}`)}import W$ from"node:path";var h8e=Object.freeze([{id:"custom",label:"Custom",description:"Choose a model and thinking level for this chat."},{id:"\
|
|
6823
6824
|
senior",label:"Senior",description:"Talk directly to your most capable model. Ask questions or request changes."},{id:"j\
|
|
6824
6825
|
unior",label:"Junior",description:"Talk directly to your everyday model. Ask questions or request changes."},{id:"auto",
|
|
6825
6826
|
label:"Auto",description:"Name either role, or let Senior handle plans and reviews and Junior handle other requests. Imp\
|
|
6826
|
-
lementation always gets Senior review."}]),
|
|
6827
|
-
ent wrong with the Fix it with AI model."});var
|
|
6828
|
-
freeze(["colleague","fix","explain","quickHelper"])}),
|
|
6827
|
+
lementation always gets Senior review."}]),g8e=Object.freeze({id:"fix",label:"Fix it with AI",description:"Repair what w\
|
|
6828
|
+
ent wrong with the Fix it with AI model."});var w8e=Object.freeze({owner:Object.freeze(["senior","junior","router","colleague","fix","explain","quickHelper"]),nonOwner:Object.
|
|
6829
|
+
freeze(["colleague","fix","explain","quickHelper"])}),v8e=Object.freeze(["colleague","fix","explain"]),y8e=Object.freeze(
|
|
6829
6830
|
[{id:"senior",label:"Senior",description:"Plans, reviews and Deslop in main chat. Your most capable model.",group:"main"},
|
|
6830
6831
|
{id:"junior",label:"Junior",description:"Everyday changes in main chat.",group:"main"},{id:"router",label:"Router",description:"\
|
|
6831
6832
|
Chooses Senior or Junior when main chat is on Auto.",group:"main"},{id:"colleague",label:"Colleague",description:"The de\
|
|
@@ -6833,17 +6834,17 @@ fault for Colleague. Each person can change their own.",group:"helpers"},{id:"fi
|
|
|
6833
6834
|
epair chats opened from errors and conflicts. Can run in a different tool from the chat it fixes.",group:"helpers"},{id:"\
|
|
6834
6835
|
explain",label:"Explain & check",description:"Explain this code, the database assistant and Check my work.",group:"helpe\
|
|
6835
6836
|
rs"},{id:"quickHelper",label:"Quick helper",description:"Titles, commit messages, prompt hints and summaries.",group:"he\
|
|
6836
|
-
lpers"}].map(Object.freeze)),
|
|
6837
|
-
r"}),nonOwner:Object.freeze({fix:"colleague",explain:"quickHelper"})}),
|
|
6838
|
-
lementation","review"]),
|
|
6837
|
+
lpers"}].map(Object.freeze)),_8e=Object.freeze({owner:Object.freeze({colleague:"senior",fix:"junior",explain:"quickHelpe\
|
|
6838
|
+
r"}),nonOwner:Object.freeze({fix:"colleague",explain:"quickHelper"})}),b8e=Object.freeze(["conversation","planning","imp\
|
|
6839
|
+
lementation","review"]),I8e=Object.freeze(["custom","senior","junior","auto","review","deslop","request_routing"]),S8e=Object.
|
|
6839
6840
|
freeze({custom:"custom",senior:"senior",junior:"junior",review:"senior",deslop:"senior",request_routing:"router",colleague:"\
|
|
6840
6841
|
colleague",fix:"fix",source_explanation:"explain",database_assistant:"explain",lesson_review:"explain",commit_title:"qui\
|
|
6841
6842
|
ckHelper",session_title:"quickHelper",prompt_hint:"quickHelper",conversation_summary:"quickHelper",voice_turn:"quickHelp\
|
|
6842
|
-
er",quick_helper:"quickHelper"}),
|
|
6843
|
-
colleague",fix:"fix",explain:"source_explanation",quickHelper:"prompt_hint"});var
|
|
6844
|
-
cepted","failed"]),
|
|
6843
|
+
er",quick_helper:"quickHelper"}),A8e=Object.freeze({senior:"senior",junior:"junior",router:"request_routing",colleague:"\
|
|
6844
|
+
colleague",fix:"fix",explain:"source_explanation",quickHelper:"prompt_hint"});var Hee=Object.freeze(["working","waiting","complete"]),Gee=Object.freeze(["routing","pending","sending","uncertain","ac\
|
|
6845
|
+
cepted","failed"]),Wee=e=>Hee.includes(e?.status)&&Gee.includes(e?.delivery);function V$({metadata:e={},conversations:t=[]}){function r(o){if(!o)return o;let i;try{i=JSON.parse(o)}catch{throw new Error(
|
|
6845
6846
|
"Saved routing request is unreadable. Inspect it before upgrading.")}if(!i||typeof i!="object"||Array.isArray(i))throw new Error(
|
|
6846
|
-
"Saved routing request must be an object.");if(i.schemaVersion===5){if(!
|
|
6847
|
+
"Saved routing request must be an object.");if(i.schemaVersion===5){if(!Wee(i))throw new Error("Saved workflow has an un\
|
|
6847
6848
|
supported state.");return o}let s=["routing","sending","uncertain","sent","failed","cancelled","done","review_pending","\
|
|
6848
6849
|
review_sending","review_uncertain","reviewing","planning_pending","planning_sending","planning_uncertain","planning","im\
|
|
6849
6850
|
plementation_pending","implementation_sending","implementation_uncertain"];if(![3,4].includes(i.schemaVersion)||!s.includes(
|
|
@@ -6861,17 +6862,17 @@ i.task!=="deslop"&&["implementation","review"].includes(y),m=i.status==="done"&&
|
|
|
6861
6862
|
{},stopped:i.stopped===!0||i.status==="cancelled",...m?{}:{error:i.error||"Workflow retained after upgrade. Inspect the \
|
|
6862
6863
|
saved delivery and request a continuation when ready."}})}let n=o=>o.assistant_routing_request?{assistant_routing_request:r(
|
|
6863
6864
|
o.assistant_routing_request)}:{};return{metadata:n(e),conversations:t.map(o=>({...o,routingMetadata:{...o.routingMetadata||
|
|
6864
|
-
{},...n(o.routingMetadata||{})}}))}}import{createHash as
|
|
6865
|
-
e),{code:t,statusCode:409})}function
|
|
6865
|
+
{},...n(o.routingMetadata||{})}}))}}import{createHash as Kee,randomUUID as O8e}from"node:crypto";var H$=256*1024;var zl=e=>Kee("sha256").update(e).digest("hex");function gn(e,t="vibe64_work_plan_invalid"){return Object.assign(new Error(
|
|
6866
|
+
e),{code:t,statusCode:409})}function Jee(e){return zl("vibe64-plan-progress-v1\0"+JSON.stringify([e.planRevision,e.progressRevision]))}function Xee(e,t=""){let r;try{r=JSON.parse(e)}catch{throw gn("The plan and progress record is invalid. Inspect its save\
|
|
6866
6867
|
d snapshot.")}if(!r||r.schemaVersion!==1||!/^[a-f0-9]{64}$/u.test(r.planRevision)||!(r.progressRevision===null||/^[a-f0-9]{64}$/u.
|
|
6867
6868
|
test(r.progressRevision))||Object.keys(r).some(n=>!["schemaVersion","planRevision","progressRevision","archivedAt","lega\
|
|
6868
6869
|
cyArchive"].includes(n))||r.archivedAt!==void 0&&!Number.isFinite(Date.parse(r.archivedAt))||r.legacyArchive!==void 0&&r.
|
|
6869
6870
|
legacyArchive!==!0)throw gn("The plan and progress binding is invalid.");if(t&&!r.archivedAt)throw gn("The archived pair\
|
|
6870
|
-
has no recorded archive time.");if(t&&(r.legacyArchive?r.progressRevision!==null||t!==r.planRevision:t!==
|
|
6871
|
+
has no recorded archive time.");if(t&&(r.legacyArchive?r.progressRevision!==null||t!==r.planRevision:t!==Jee(r)))throw gn(
|
|
6871
6872
|
"The archived plan and progress no longer match their snapshot.");return r}function G$(e){let t=new Map(e.map(a=>[a.name,a])),r=new Map,n=a=>r.has(a)?r.get(a):t.get(a)?.text??null,o=(a,c)=>{let d=n(
|
|
6872
6873
|
a);if(d!==null&&d!==c)throw gn("A prepared plan-progress document conflicts with saved state.");d===null&&r.set(a,c)},i=a=>{
|
|
6873
6874
|
if(Buffer.byteLength(a)>H$||!/^Status: (active|completed)\r?$/mu.test(a))throw gn("A legacy plan is malformed. Inspect i\
|
|
6874
|
-
t before upgrading.")},s=(a,c="")=>{let d=
|
|
6875
|
+
t before upgrading.")},s=(a,c="")=>{let d=Xee(a,c),u=n("plan/"+d.planRevision+".md");if(u===null||zl(u)!==d.planRevision)
|
|
6875
6876
|
throw gn("The paired plan document is missing or changed.");if(i(u),d.progressRevision!==null){let l=n("progress/"+d.progressRevision+
|
|
6876
6877
|
".md");if(l===null||Buffer.byteLength(l)>H$||zl(l)!==d.progressRevision)throw gn("The paired progress document is missin\
|
|
6877
6878
|
g or changed.")}return d};if(t.has("current.json")){if(s(t.get("current.json").text),t.has("current.md"))throw gn("Both \
|
|
@@ -6890,8 +6891,8 @@ e.report("info",`${W$.basename(n)}: ${i.length} paired plan/progress file change
|
|
|
6890
6891
|
reserved.`),r.push(...i)}return r}})}async function J$(e){return xe({...e,prepareUpdates:async t=>{let r=[];for(let n of await ut(
|
|
6891
6892
|
e.systemRoot)){let i=await gt({projectContextRoot:n,projectRuntimeRoot:n}).prepareAssistantRoutingStateUpgrade({temporaryRoot:t,
|
|
6892
6893
|
transform:V$});e.report("info",`${W$.basename(n)}: ${i.length} workflow file change(s). Retained stages and delivery ide\
|
|
6893
|
-
ntities require explicit continuation; nothing is replayed.`),r.push(...i)}return r}})}import Y$ from"node:path";import{isDeepStrictEqual as
|
|
6894
|
-
[]).map(i=>({...i,engineId:i.assistantSelection.engineId,retired:!0}));if(t)return o;for(let[i,s]of Object.entries(r)){let a=
|
|
6894
|
+
ntities require explicit continuation; nothing is replayed.`),r.push(...i)}return r}})}import Y$ from"node:path";import{isDeepStrictEqual as Zee}from"node:util";var Yee=/^(codex(?:_([a-z0-9_-]+))?|claude|opencode)_conversation_id$/u;function X$(e,{retiredOnly:t=!1}={}){let r=e.metadata||{},o=(JSON.parse(r.assistant_changeover||"null")?.retiredConversations||
|
|
6895
|
+
[]).map(i=>({...i,engineId:i.assistantSelection.engineId,retired:!0}));if(t)return o;for(let[i,s]of Object.entries(r)){let a=Yee.
|
|
6895
6896
|
exec(i);if(!a||!s)continue;let[,c,d]=a,u=c.startsWith("codex")?"codex":c,l=r.agent_identity_provider===u&&r.agent_identity_conversation_id===
|
|
6896
6897
|
s,p=u==="claude"?JSON.parse(r[`claude_conversation_${s}`]||"null"):null,f=r[`${c}_conversation_workdir`]||p?.nativeWorkdir||
|
|
6897
6898
|
(l?r.agent_identity_workdir:"")||r.source_path||"",y=u==="codex"?d||r.codex_routing_home_provider||"openai":"";o.push({engineId:u,
|
|
@@ -6910,9 +6911,9 @@ unchanged.`);continue}for(let m of w.commandMessages){let _=u.filter(T=>T.messag
|
|
|
6910
6911
|
data?.native,x=I?.engineId==="claude"&&I.type==="system"&&I.subtype==="local_command_output"&&I.command===void 0&&I.output===
|
|
6911
6912
|
void 0,C=x?{native:{...I,command:m.data.native.command,output:m.data.native.output}}:m.data;if(_.length!==1||_[0].text!==
|
|
6912
6913
|
m.text||I&&!x&&(I.engineId!=="claude"||I.command!==m.data.native.command||I.output!==m.data.native.output)||f.has(m.id)&&
|
|
6913
|
-
!
|
|
6914
|
+
!Zee(f.get(m.id).data,C))throw new Error(`${p}: native command evidence conflicts with its saved message. Inspect the or\
|
|
6914
6915
|
iginal history before upgrading.`);I&&!x||f.set(m.id,{messageId:m.id,data:C})}}return e.report("info",`${p}: ${f.size} n\
|
|
6915
|
-
ative command message(s) verified; text, receipts and native history are retained.`),[...f.values()]}}))}return n}})}import zs from"node:path";import
|
|
6916
|
+
ative command message(s) verified; text, receipts and native history are retained.`),[...f.values()]}}))}return n}})}import zs from"node:path";import Qee from"node:os";import{mkdtemp as ete,rm as tte}from"node:fs/promises";var Q$="Claude has no active turn for this message.",ZI=e=>e&&typeof e=="object"&&!Array.isArray(e);async function rte({
|
|
6916
6917
|
metadata:e,runs:t,configRoot:r}){let n=e.assistant_routing_request;if(!n)return{};let o=JSON.parse(n);if(!ZI(o))throw new Error(
|
|
6917
6918
|
"Saved routing request must be an object.");if(o.delivery!=="uncertain")return{};let i=t.findLast(l=>l.engineId==="claud\
|
|
6918
6919
|
e");if(i?.error!==Q$)return{};let s=()=>{throw new Error("Rejected Claude input has conflicting delivery evidence. Inspe\
|
|
@@ -6928,23 +6929,23 @@ e.backupRoot,"manifest.json");await ge(e.systemRoot,r);let n=await Ae(r)!==null;
|
|
|
6928
6929
|
e.systemRoot)){let c=gt({projectContextRoot:a,projectRuntimeRoot:a}),d=await c.prepareAssistantRoutingStateUpgrade({temporaryRoot:i,
|
|
6929
6930
|
async transform({sessionId:u,metadata:l}){let p=await c.withReadableSessionPaths(u,w=>zs.join(w.metadataRoot,"assistant_\
|
|
6930
6931
|
routing_request")),f=Yl(e.systemRoot,p);if(f===null)return{};let y=zs.join(e.backupRoot,"before",f);await ge(e.backupRoot,
|
|
6931
|
-
y);let h=n?await Ae(y):null,v=await
|
|
6932
|
+
y);let h=n?await Ae(y):null,v=await rte({metadata:h===null?l:{...l,assistant_routing_request:h},runs:await c.readAgentRuns(
|
|
6932
6933
|
u),configRoot:t});if(n&&v.assistant_routing_request){if(h===null)throw new Error("A new rejected Claude input appeared a\
|
|
6933
6934
|
fter preparation. Keep writers stopped and inspect before retrying.");let w=zs.join(e.backupRoot,"after",f);if(await ge(
|
|
6934
6935
|
e.backupRoot,w),await Ae(w)!==`${v.assistant_routing_request}
|
|
6935
6936
|
`)throw new Error("Prepared Claude repair no longer matches its original evidence. Inspect the backup before retrying.")}else if(h!==
|
|
6936
6937
|
null)throw new Error("Original Claude repair evidence is no longer eligible. Inspect before retrying.");return{metadata:v}}});
|
|
6937
6938
|
e.report("info",`${zs.basename(a)}: ${d.length} rejected Claude routing file(s); explicit Retry is required and nothing \
|
|
6938
|
-
is sent.`),s.push(...d)}return s}if(n){let i=await
|
|
6939
|
-
await
|
|
6940
|
-
call(e,t)}function nD(e={},t=process.env,r=""){let n=rD(e)?e:{},o=rD(t)?t:{};return QI(
|
|
6939
|
+
is sent.`),s.push(...d)}return s}if(n){let i=await ete(zs.join(Qee.tmpdir(),"vibe64-claude-repair-"));try{await o(i)}finally{
|
|
6940
|
+
await tte(i,{recursive:!0,force:!0})}}return xe({...e,prepareUpdates:o})}import{readdir as iD}from"node:fs/promises";import Wt from"node:path";import ite from"node:os";import tD from"node:os";import jd from"node:path";var d9e=Object.freeze({CODEX_APP_SERVER:"codex_app_server"});function QI(e=""){return String(e??"").trim()}function rD(e){return e&&typeof e=="object"&&!Array.isArray(e)}function nte(e={},t=""){return Object.prototype.hasOwnProperty.
|
|
6941
|
+
call(e,t)}function nD(e={},t=process.env,r=""){let n=rD(e)?e:{},o=rD(t)?t:{};return QI(nte(n,r)?n[r]:o[r])}function ote(){
|
|
6941
6942
|
return typeof process.getuid=="function"?process.getuid():"user"}function oD({env:e=process.env,hostEnv:t=process.env}={}){
|
|
6942
6943
|
let r=nD(e,t,"VIBE64_AGENT_RUNTIME_DIR");if(r)return jd.resolve(r);let n=nD(e,t,"XDG_RUNTIME_DIR");if(n&&jd.isAbsolute(n))
|
|
6943
6944
|
return jd.join(n,"vibe64","agent-providers");let o=QI(tD.homedir());return o&&jd.isAbsolute(o)?jd.join(o,".cache","vibe6\
|
|
6944
|
-
4","agent-providers"):jd.join(tD.tmpdir(),`vibe64-${
|
|
6945
|
+
4","agent-providers"):jd.join(tD.tmpdir(),`vibe64-${ote()}`,"agent-providers")}var Md=["deepseek","zai","zai-coding-plan"],sD=/^(?:private-[A-Za-z0-9-]+|verify-[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})$/u,
|
|
6945
6946
|
aD=e=>e&&typeof e=="object"&&!Array.isArray(e);function rg(e,t){try{let r=JSON.parse(e);if(aD(r))return r}catch{}throw new Error(
|
|
6946
6947
|
`${t} is invalid. Inspect or restore it before clearing saved provider credentials.`)}async function cD({systemRoot:e,apply:t,
|
|
6947
|
-
backupRoot:r,report:n,env:o=process.env,home:i=
|
|
6948
|
+
backupRoot:r,report:n,env:o=process.env,home:i=ite.homedir()}){let s=Wt.join(e,"ai-connections","connections.json"),a=new Set(
|
|
6948
6949
|
[s]);for(let h of["codex","claude"])for(let v of Md){let w=Hn(e,v,h);for(let m of[w.connectionPath,Wt.join(w.codexHome,"\
|
|
6949
6950
|
config.toml"),_n(w.systemRoot),Hd(w.systemRoot)])a.add(m)}let c=[...new Set([oD({env:o,hostEnv:o}),Wt.join(i,".cache","v\
|
|
6950
6951
|
ibe64","agent-providers"),...Wt.isAbsolute(o.XDG_RUNTIME_DIR||"")?[Wt.join(o.XDG_RUNTIME_DIR,"vibe64","agent-providers")]:
|
|
@@ -6980,31 +6981,31 @@ C=!1,T=I.split(/(?<=\n)/u).filter(M=>{if(/^\s*\[/u.test(M)){let L=/^\s*\[model_p
|
|
|
6980
6981
|
exec(M.trimEnd());x=L?.[1]||L?.[2]||""}if(Md.includes(x)&&/^\s*experimental_bearer_token\s*=/u.test(M)){if(!/^\s*experimental_bearer_token\s*=\s*"(?:[^"\\]|\\.)*"\s*(?:#.*)?$/u.
|
|
6981
6982
|
test(M.trimEnd()))throw new Error("Managed Codex provider credentials have an unsupported TOML shape. Inspect them befor\
|
|
6982
6983
|
e clearing.");return C=!0,!1}return!0}).join("");C&&h.push({filePath:_,original:I,contents:T})}}return n("info",`${h.length}\
|
|
6983
|
-
credential-bearing or connection-state file(s) inventoried; no provider requests or credential copying.`),h}})}import
|
|
6984
|
-
de"&&e.modelId==="big-pickle";async function uD({systemRoot:e,apply:t,backupRoot:r,report:n}){let o=
|
|
6984
|
+
credential-bearing or connection-state file(s) inventoried; no provider requests or credential copying.`),h}})}import ste from"node:path";var ate=["senior","junior","helper","router","sharedBackup"],dD=e=>e?.engineId==="opencode"&&e.modelProviderId==="openco\
|
|
6985
|
+
de"&&e.modelId==="big-pickle";async function uD({systemRoot:e,apply:t,backupRoot:r,report:n}){let o=ste.join(e,"ai-conne\
|
|
6985
6986
|
ctions","routing.json");await ge(e,o),await xe({systemRoot:e,apply:t,backupRoot:r,report:n,prepareUpdates:async()=>{let i=await Ae(
|
|
6986
6987
|
o);if(i===null)return[];let s;try{s=JSON.parse(i)}catch{throw new Error("Saved model routing is unreadable. Inspect it b\
|
|
6987
6988
|
efore upgrading.")}if(!t&&s?.schemaVersion!==4)return n("info","Earlier upgrades will prepare the saved model routing fi\
|
|
6988
6989
|
rst; apply checks it again."),[];try{_r(s)}catch{throw new Error("Saved model routing is not in the current format. Insp\
|
|
6989
|
-
ect it before upgrading.")}let a=structuredClone(s.orchestrators),c=0;for(let[u,l]of Object.entries(a)){for(let p of
|
|
6990
|
+
ect it before upgrading.")}let a=structuredClone(s.orchestrators),c=0;for(let[u,l]of Object.entries(a)){for(let p of ate)
|
|
6990
6991
|
dD(l[p])&&(delete l[p],c+=1);dD(l.helperRoutingReview?.proposed)&&(l.helperRoutingReview.proposed=null,c+=1),Object.keys(
|
|
6991
6992
|
l).length||delete a[u]}if(!c)return[];let d=_r({...s,revision:s.revision+1,orchestrators:a});return n("info",`${c} routi\
|
|
6992
6993
|
ng choice(s) named the retired free model and become unset.`),[{filePath:o,original:i,contents:`${JSON.stringify(d)}
|
|
6993
|
-
`}]}})}import pD from"node:path";var
|
|
6994
|
-
"fix","explain","quickHelper"]}),
|
|
6994
|
+
`}]}})}import pD from"node:path";var cte=Object.freeze({owner:["senior","junior","router","colleague","fix","explain","quickHelper"],nonOwner:["colleague",
|
|
6995
|
+
"fix","explain","quickHelper"]}),dte=["colleague","fix","explain"],ute=/[\x00-\x1f\x7f]/u,Ii=e=>e&&typeof e=="object"&&!Array.
|
|
6995
6996
|
isArray(e);function lD(e){let t=()=>{throw new Error("Saved model routing has an unsupported shape. Restore or repair th\
|
|
6996
6997
|
e settings before changing them.")};(!Ii(e)||e.schemaVersion!==5||!Number.isSafeInteger(e.revision)||e.revision<0||Object.
|
|
6997
6998
|
keys(e).some(i=>!["schemaVersion","revision","owner","nonOwner"].includes(i))||!Ii(e.owner)||!Ii(e.nonOwner))&&t();let r=i=>{
|
|
6998
6999
|
(!Ii(i)||i.schema!=="vibe64.assistant-selection.v1"||Object.keys(i).some(s=>!["schema","engineId","agentId","modelProvid\
|
|
6999
7000
|
erId","modelId","variantId","catalogRevision","selectionSource"].includes(s))||!["codex","claude","opencode"].includes(i.
|
|
7000
7001
|
engineId)||!/^sha256:[a-f0-9]{64}$/u.test(i.catalogRevision||"")||!["engineId","agentId","modelProviderId","modelId","va\
|
|
7001
|
-
riantId"].every(s=>typeof i[s]=="string"&&i[s].length<=512&&(s==="variantId"||i[s].trim().length)&&!
|
|
7002
|
-
recommended","explicit"].includes(i.selectionSource))&&t()};for(let[i,s]of Object.entries(
|
|
7002
|
+
riantId"].every(s=>typeof i[s]=="string"&&i[s].length<=512&&(s==="variantId"||i[s].trim().length)&&!ute.test(i[s]))||!["\
|
|
7003
|
+
recommended","explicit"].includes(i.selectionSource))&&t()};for(let[i,s]of Object.entries(cte)){let a=e[i];Object.keys(a).
|
|
7003
7004
|
some(c=>!s.includes(c))&&t();for(let[c,d]of Object.entries(a)){if(d===null)continue;if(!Ii(d)||!Object.hasOwn(d,"follows")){
|
|
7004
|
-
r(d);continue}let u=a[d.follows];(Object.keys(d).length!==1||!
|
|
7005
|
+
r(d);continue}let u=a[d.follows];(Object.keys(d).length!==1||!dte.includes(c)||d.follows===c||!s.includes(d.follows)||Ii(
|
|
7005
7006
|
u)&&Object.hasOwn(u,"follows"))&&t()}}let{senior:n,junior:o}=e.owner;if(Ii(n)&&Ii(o)&&n.engineId!==o.engineId)throw new Error(
|
|
7006
|
-
"Senior and Junior must run in the same tool.");return e}var
|
|
7007
|
-
Helper",sharedBackup:"Shared backup"};function
|
|
7007
|
+
"Senior and Junior must run in the same tool.");return e}var lte={claude:"Claude Code",codex:"Codex",opencode:"OpenCode"},fD={senior:"Senior",junior:"Junior",router:"Router",helper:"\
|
|
7008
|
+
Helper",sharedBackup:"Shared backup"};function pte(e,t){return e.engineId==="claude"&&e.modelProviderId==="anthropic"||e.
|
|
7008
7009
|
engineId==="codex"&&e.modelProviderId==="openai"||rn.some(({id:r,ownerOnly:n})=>r===e.modelProviderId&&n)?!0:e.engineId===
|
|
7009
7010
|
"opencode"&&t.some(({id:r,ownerOnly:n})=>r===e.modelProviderId&&n)}async function mD({systemRoot:e,apply:t,backupRoot:r,
|
|
7010
7011
|
report:n}){let o=pD.join(e,"ai-connections","routing.json");await ge(e,o),await xe({systemRoot:e,apply:t,backupRoot:r,report:n,
|
|
@@ -7012,31 +7013,31 @@ prepareUpdates:async()=>{let i=await Ae(o);if(i===null)return[];let s;try{s=JSON
|
|
|
7012
7013
|
odel routing is unreadable. Inspect it before upgrading.")}if(s?.schemaVersion===5)return[];if(!t&&s?.schemaVersion!==4)
|
|
7013
7014
|
return n("info","Earlier upgrades will prepare the saved model routing first; apply checks it again."),[];try{_r(s)}catch{
|
|
7014
7015
|
throw new Error("Saved model routing is not in the schema-4 format. Inspect it before upgrading.")}let{orchestrators:a}=s,
|
|
7015
|
-
c=YA(a);for(let f of ep){if(f===c||!a[f])continue;let y=Object.keys(fD).filter(h=>a[f][h]).map(h=>fD[h]);n("warning",`${
|
|
7016
|
+
c=YA(a);for(let f of ep){if(f===c||!a[f])continue;let y=Object.keys(fD).filter(h=>a[f][h]).map(h=>fD[h]);n("warning",`${lte[f]}\
|
|
7016
7017
|
routing${y.length?` (${y.join(", ")})`:""} is left in the backup, not carried over.`)}a[c]?.helperRoutingReview&&n("war\
|
|
7017
7018
|
ning","The Helper choice was waiting for review; Quick helper is off until the owner chooses its model.");let d=a[c]?.sharedBackup??
|
|
7018
7019
|
ep.map(f=>a[f]?.sharedBackup).find(Boolean),u=d?.engineId==="opencode"?await rh({filePath:pD.join(e,"ai-connections","co\
|
|
7019
7020
|
nnections.json"),verifyConnection:()=>{throw new Error("Offline routing upgrade cannot call a provider.")}}).listConnections():
|
|
7020
|
-
[],l={};d&&!
|
|
7021
|
+
[],l={};d&&!pte(d,u)?l={colleague:d,quickHelper:d,fix:{follows:"colleague"},explain:{follows:"quickHelper"}}:n("warning",
|
|
7021
7022
|
"Team members will be asked to wait until the owner sets up team AI.");let p=lD({schemaVersion:5,revision:s.revision+1,owner:tp(
|
|
7022
7023
|
a[c]),nonOwner:l});return[{filePath:o,original:i,contents:`${JSON.stringify(p)}
|
|
7023
|
-
`}]}})}import
|
|
7024
|
+
`}]}})}import fte from"node:path";var ng=e=>e&&typeof e=="object"&&!Array.isArray(e);function wD(e,t){let r;try{r=JSON.parse(e)}catch{throw new Error(`Sav\
|
|
7024
7025
|
ed ${t} is unreadable. Inspect it before upgrading.`)}if(!ng(r))throw new Error(`Saved ${t} must be an object.`);return r}
|
|
7025
|
-
function
|
|
7026
|
+
function mte(e,t){if(!e)return e;let r=wD(e,"chat mode"),{workflowEngineId:n,override:o,...i}=r,s=t&&r.mode!=="custom";return s?
|
|
7026
7027
|
Object.assign(i,{mode:"fix",review:!1}):r.override&&(i.override=r.override),!Object.hasOwn(r,"workflowEngineId")&&(!s||r.
|
|
7027
7028
|
mode==="fix"&&r.review===!1&&!r.override)?e:JSON.stringify(i)}function hD(e,t){if(!e)return e;let r=wD(e,t);if(!ng(r.configuration?.
|
|
7028
7029
|
orchestrators))return e;let n={...r,configuration:{revision:r.configuration.revision,owner:tp(r.configuration.orchestrators[r.
|
|
7029
7030
|
workflowEngineId]||{})}};if(ng(r.assignments)&&Object.hasOwn(r.assignments,"helper")){let{helper:o,...i}=r.assignments;n.
|
|
7030
7031
|
assignments={...i,quickHelper:o}}return r.decision?.role==="helper"&&(n.decision={...r.decision,role:"quickHelper"}),JSON.
|
|
7031
|
-
stringify(n)}function gD(e={},t=!1){let r={};return e.assistant_routing&&(r.assistant_routing=
|
|
7032
|
+
stringify(n)}function gD(e={},t=!1){let r={};return e.assistant_routing&&(r.assistant_routing=mte(e.assistant_routing,t)),
|
|
7032
7033
|
e.assistant_routing_request&&(r.assistant_routing_request=hD(e.assistant_routing_request,"routing request")),e.assistant_routing_goal&&
|
|
7033
|
-
(r.assistant_routing_goal=hD(e.assistant_routing_goal,"routing goal")),r}function
|
|
7034
|
+
(r.assistant_routing_goal=hD(e.assistant_routing_goal,"routing goal")),r}function hte({metadata:e={},conversations:t=[],
|
|
7034
7035
|
renewal:r}){let n={metadata:gD(e),conversations:t.map(i=>i.routingMetadata?{...i,routingMetadata:{...i.routingMetadata,...gD(
|
|
7035
7036
|
i.routingMetadata,i.recoveryOperation==="update")}}:i)},o=r?.successor?.assistantRouting;if(ng(o)&&Object.hasOwn(o,"work\
|
|
7036
7037
|
flowEngineId")){let{workflowEngineId:i,...s}=o;n.renewal={...r,successor:{...r.successor,assistantRouting:s}}}return n}async function vD(e){
|
|
7037
7038
|
return xe({...e,prepareUpdates:async t=>{let r=[];for(let n of await ut(e.systemRoot)){let i=await gt({projectContextRoot:n,
|
|
7038
|
-
projectRuntimeRoot:n}).prepareAssistantRoutingStateUpgrade({temporaryRoot:t,transform:
|
|
7039
|
-
n)}: ${i.length} session file change(s) for the owner and team AI setups.`),r.push(...i)}return r}})}try{let{values:e}=
|
|
7039
|
+
projectRuntimeRoot:n}).prepareAssistantRoutingStateUpgrade({temporaryRoot:t,transform:hte});e.report("info",`${fte.basename(
|
|
7040
|
+
n)}: ${i.length} session file change(s) for the owner and team AI setups.`),r.push(...i)}return r}})}try{let{values:e}=gte({options:{"system-root":{type:"string"},"projects-root":{type:"string"},check:{type:"boolean"},apply:{
|
|
7040
7041
|
type:"boolean"},baseline:{type:"boolean"},"repair-colleague-retired-operation":{type:"boolean"},"repair-colleague-intera\
|
|
7041
7042
|
ctive-continuity":{type:"boolean"}}}),t=[e.check,e.apply,e.baseline].filter(Boolean).length,r=e["repair-colleague-retire\
|
|
7042
7043
|
d-operation"]||e["repair-colleague-interactive-continuity"];if(t!==1||e.baseline&&r)throw new Error("Usage: node bin/upg\
|