@tangle-network/sandbox 0.9.1-develop.20260624210934.e2730e8 → 0.9.2-develop.20260625093856.35d47c0
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/dist/agent/index.js +1026 -1
- package/dist/auth/index.js +273 -1
- package/dist/client-BBZ7YLmq.js +2193 -0
- package/dist/collaboration/index.js +2 -1
- package/dist/collaboration-BxlfZ2Uh.js +201 -1
- package/dist/core.js +4 -1
- package/dist/errors-DZsfJUuc.js +262 -1
- package/dist/index.js +1180 -1
- package/dist/intelligence/index.js +225 -1
- package/dist/openai/index.js +1760 -1
- package/dist/sandbox-joKtQ5y3.js +4457 -0
- package/dist/session-gateway/index.js +667 -1
- package/dist/tangle/index.js +2 -1
- package/dist/tangle-DM0o66lW.js +831 -0
- package/package.json +4 -4
- package/dist/client-DFXGfX9s.js +0 -1
- package/dist/sandbox-CPwJYUuQ.js +0 -1
- package/dist/tangle-KvorROxa.js +0 -1
package/dist/openai/index.js
CHANGED
|
@@ -1 +1,1760 @@
|
|
|
1
|
-
const a0_0x15650e=a0_0x1c70;(function(_0x3372dd,_0x1ea539){const _0x1a015b=a0_0x1c70,_0x1dbdd8=_0x3372dd();while(!![]){try{const _0x57b7fd=parseInt(_0x1a015b(0x254))/0x1*(-parseInt(_0x1a015b(0x297))/0x2)+-parseInt(_0x1a015b(0x243))/0x3+-parseInt(_0x1a015b(0x21c))/0x4*(parseInt(_0x1a015b(0x105))/0x5)+-parseInt(_0x1a015b(0x285))/0x6*(-parseInt(_0x1a015b(0x233))/0x7)+-parseInt(_0x1a015b(0x150))/0x8*(-parseInt(_0x1a015b(0x1a9))/0x9)+parseInt(_0x1a015b(0x236))/0xa+parseInt(_0x1a015b(0x19e))/0xb*(parseInt(_0x1a015b(0x266))/0xc);if(_0x57b7fd===_0x1ea539)break;else _0x1dbdd8['push'](_0x1dbdd8['shift']());}catch(_0x3bcb5a){_0x1dbdd8['push'](_0x1dbdd8['shift']());}}}(a0_0x2d62,0x22278));var HookChain=class{[a0_0x15650e(0x1ab)];constructor(_0x5096a4=[]){const _0x571004=a0_0x15650e;this[_0x571004(0x1ab)]=_0x5096a4;}get['\x73\x69\x7a\x65'](){const _0x2eb87b=a0_0x15650e;return this[_0x2eb87b(0x1ab)][_0x2eb87b(0x132)];}async[a0_0x15650e(0x1ef)](_0x105c65){const _0x51dc78=a0_0x15650e;let _0x3e1cd8=_0x105c65,_0x649e33=null;for(const _0x44bdfd of this['\x68\x6f\x6f\x6b\x73']){if(!_0x44bdfd[_0x51dc78(0x1f9)])continue;const _0x332872=await _0x44bdfd[_0x51dc78(0x1f9)](_0x3e1cd8);if(_0x332872['\x61\x63\x74\x69\x6f\x6e']===_0x51dc78(0x1d1))return _0x332872;_0x332872[_0x51dc78(0x11b)]===_0x51dc78(0x143)&&(_0x3e1cd8={..._0x3e1cd8,'\x61\x72\x67\x73':_0x332872[_0x51dc78(0x29c)]},_0x649e33=_0x332872);}return _0x649e33??{'\x61\x63\x74\x69\x6f\x6e':_0x51dc78(0x1d6)};}async[a0_0x15650e(0x283)](_0x54c289,_0x480b68){const _0x1ede4c=a0_0x15650e,_0x1ed9b6={'\x71\x41\x6c\x6d\x4b':'\x74\x65\x72\x6d\x69\x6e\x61\x74\x65','\x45\x4e\x7a\x52\x45':function(_0xada28f,_0x5c6b2d){return _0xada28f===_0x5c6b2d;},'\x62\x4c\x74\x4b\x5a':_0x1ede4c(0x204)};let _0x5b7a6f=_0x480b68,_0x3abda6=null;for(const _0x464871 of this[_0x1ede4c(0x1ab)]){if(!_0x464871[_0x1ede4c(0x26c)])continue;const _0xf0b6a3=await _0x464871[_0x1ede4c(0x26c)](_0x54c289,_0x5b7a6f);if(_0xf0b6a3[_0x1ede4c(0x11b)]===_0x1ed9b6[_0x1ede4c(0x27c)])return _0xf0b6a3;_0x1ed9b6[_0x1ede4c(0x177)](_0xf0b6a3[_0x1ede4c(0x11b)],_0x1ed9b6[_0x1ede4c(0x1d5)])&&(_0x5b7a6f=_0xf0b6a3[_0x1ede4c(0x241)],_0x3abda6=_0xf0b6a3);}return _0x3abda6??{'\x61\x63\x74\x69\x6f\x6e':_0x1ede4c(0x129)};}};function auditLogHook(_0x343dad={}){const _0x7e7978=a0_0x15650e,_0x27a1eb={'\x79\x79\x79\x53\x50':function(_0x1d4618,_0x48d2c5){return _0x1d4618(_0x48d2c5);},'\x45\x72\x4d\x54\x64':_0x7e7978(0x14c)},_0x49a491=_0x343dad[_0x7e7978(0x1e7)]??(_0x49aa5c=>{const _0x27e8b8=_0x7e7978;console[_0x27e8b8(0x1c3)](_0x27e8b8(0x299),_0x49aa5c);});return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x45096f){const _0x1bb1d2=_0x7e7978;return await _0x49a491({'\x70\x68\x61\x73\x65':_0x1bb1d2(0x291),'\x72\x75\x6e\x49\x64':_0x45096f[_0x1bb1d2(0xf9)],'\x74\x68\x72\x65\x61\x64\x49\x64':_0x45096f[_0x1bb1d2(0x171)],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':_0x45096f[_0x1bb1d2(0x199)],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x45096f['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65'],'\x63\x61\x6c\x6c\x49\x64':_0x45096f['\x63\x61\x6c\x6c\x49\x64'],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':_0x45096f[_0x1bb1d2(0x219)],'\x61\x72\x67\x73':_0x45096f[_0x1bb1d2(0x29c)]}),{'\x61\x63\x74\x69\x6f\x6e':_0x1bb1d2(0x1d6)};},async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x5a42b0,_0x48fc41){const _0x4cc5cc=_0x7e7978;return await _0x27a1eb['\x79\x79\x79\x53\x50'](_0x49a491,{'\x70\x68\x61\x73\x65':_0x27a1eb[_0x4cc5cc(0x18d)],'\x72\x75\x6e\x49\x64':_0x5a42b0[_0x4cc5cc(0xf9)],'\x74\x68\x72\x65\x61\x64\x49\x64':_0x5a42b0[_0x4cc5cc(0x171)],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':_0x5a42b0['\x70\x61\x72\x74\x6e\x65\x72\x49\x64'],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x5a42b0[_0x4cc5cc(0x16b)],'\x63\x61\x6c\x6c\x49\x64':_0x5a42b0[_0x4cc5cc(0x206)],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':_0x5a42b0['\x74\x69\x6d\x65\x73\x74\x61\x6d\x70'],'\x72\x65\x73\x75\x6c\x74':_0x48fc41}),{'\x61\x63\x74\x69\x6f\x6e':_0x4cc5cc(0x129)};}};}const NETWORK_TOOL_REGEX=/^(fetch|http|https|browser|playwright|curl|wget|computer-use:click|computer-use:type)/i,URL_FIELD_NAMES=new Set([a0_0x15650e(0x147),a0_0x15650e(0x222),a0_0x15650e(0x284),a0_0x15650e(0x22a),a0_0x15650e(0x1f3),a0_0x15650e(0x23a),a0_0x15650e(0x1e4)]);function extractUrlsFromArgs(_0x496e0d){const _0x46fd4d={'\x66\x42\x75\x42\x52':'\x6f\x62\x6a\x65\x63\x74','\x41\x57\x6a\x71\x75':function(_0x212bb1,_0x55ef69){return _0x212bb1(_0x55ef69);},'\x65\x65\x49\x75\x76':function(_0x332619,_0x1d5bba){return _0x332619===_0x1d5bba;}},_0x4c0e30=[],_0x3509f1=_0x41adc2=>{const _0x29fa13=a0_0x1c70;if(typeof _0x41adc2===_0x29fa13(0x29e)){if(/^https?:\/\//i[_0x29fa13(0x138)](_0x41adc2))try{const _0x37a551=new URL(_0x41adc2);_0x4c0e30[_0x29fa13(0x1c0)]({'\x72\x61\x77':_0x41adc2,'\x68\x6f\x73\x74':_0x37a551[_0x29fa13(0xe4)]});}catch{_0x4c0e30[_0x29fa13(0x1c0)]({'\x72\x61\x77':_0x41adc2,'\x68\x6f\x73\x74':null});}return;}if(_0x41adc2===null||typeof _0x41adc2!==_0x46fd4d[_0x29fa13(0x14d)])return;if(Array[_0x29fa13(0x153)](_0x41adc2)){for(const _0x65f29e of _0x41adc2)_0x46fd4d['\x41\x57\x6a\x71\x75'](_0x3509f1,_0x65f29e);return;}for(const [_0x55df54,_0xca9e04]of Object['\x65\x6e\x74\x72\x69\x65\x73'](_0x41adc2)){if(URL_FIELD_NAMES['\x68\x61\x73'](_0x55df54[_0x29fa13(0x24e)]())&&_0x46fd4d[_0x29fa13(0x139)](typeof _0xca9e04,_0x29fa13(0x29e))){try{const _0x3e8629=new URL(_0xca9e04);_0x4c0e30[_0x29fa13(0x1c0)]({'\x72\x61\x77':_0xca9e04,'\x68\x6f\x73\x74':_0x3e8629['\x68\x6f\x73\x74']});}catch{_0x4c0e30[_0x29fa13(0x1c0)]({'\x72\x61\x77':_0xca9e04,'\x68\x6f\x73\x74':null});}continue;}_0x3509f1(_0xca9e04);}};return _0x46fd4d['\x41\x57\x6a\x71\x75'](_0x3509f1,_0x496e0d),_0x4c0e30;}function isNetworkLike(_0x57503c,_0x2148c7){const _0x4b4663=a0_0x15650e;if(NETWORK_TOOL_REGEX[_0x4b4663(0x138)](_0x57503c['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65']))return!![];return _0x2148c7[_0x4b4663(0x132)]>0x0;}function hostMatches(_0x5ac052,_0x18195b){const _0x266b3c=a0_0x15650e;if(_0x18195b===_0x5ac052)return!![];if(_0x18195b[_0x266b3c(0xe7)]('\x2a\x2e')){const _0x527cdd=_0x18195b['\x73\x6c\x69\x63\x65'](0x1);return _0x5ac052['\x65\x6e\x64\x73\x57\x69\x74\x68'](_0x527cdd);}return![];}function egressPolicyHook(_0x5be42e={}){const _0x2ad8c8=a0_0x15650e,_0x3831ca={'\x4f\x64\x74\x48\x75':function(_0xfd4e8f,_0x4ba747,_0x21cb61){return _0xfd4e8f(_0x4ba747,_0x21cb61);},'\x64\x67\x56\x49\x77':_0x2ad8c8(0x1d6),'\x4a\x74\x75\x47\x61':'\x62\x6c\x6f\x63\x6b','\x5a\x63\x4b\x57\x4c':_0x2ad8c8(0x22b),'\x78\x4e\x6f\x57\x6c':function(_0x57fa94,_0xeab639){return _0x57fa94>_0xeab639;},'\x45\x4d\x65\x54\x42':_0x2ad8c8(0xe1)},_0x5a5aa7=_0x5be42e['\x64\x65\x6e\x79\x4c\x69\x73\x74']??[],_0x1b9022=_0x5be42e['\x61\x6c\x6c\x6f\x77\x4c\x69\x73\x74'];return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x40dd8c){const _0x428250=_0x2ad8c8,_0x4d69fe=extractUrlsFromArgs(_0x40dd8c[_0x428250(0x29c)]);if(!_0x3831ca[_0x428250(0x124)](isNetworkLike,_0x40dd8c,_0x4d69fe))return{'\x61\x63\x74\x69\x6f\x6e':_0x3831ca[_0x428250(0x248)]};if(_0x5be42e[_0x428250(0x249)])return await _0x5be42e[_0x428250(0x249)](_0x40dd8c)?{'\x61\x63\x74\x69\x6f\x6e':_0x428250(0x1d6)}:{'\x61\x63\x74\x69\x6f\x6e':_0x3831ca['\x4a\x74\x75\x47\x61'],'\x72\x65\x61\x73\x6f\x6e':_0x3831ca[_0x428250(0x1c9)]};for(const _0x105701 of _0x4d69fe){if(!_0x105701[_0x428250(0xe4)])continue;for(const _0x28d2fa of _0x5a5aa7)if(hostMatches(_0x105701[_0x428250(0xe4)],_0x28d2fa))return{'\x61\x63\x74\x69\x6f\x6e':_0x428250(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x428250(0x210)+_0x105701['\x68\x6f\x73\x74']+_0x428250(0x15b)+_0x28d2fa+'\x22'};}if(_0x1b9022&&_0x3831ca[_0x428250(0x213)](_0x1b9022[_0x428250(0x132)],0x0))for(const _0x5e3211 of _0x4d69fe){const _0x231e51=_0x5e3211[_0x428250(0xe4)];if(!_0x231e51)return{'\x61\x63\x74\x69\x6f\x6e':_0x428250(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x3831ca[_0x428250(0x18b)]};if(!_0x1b9022[_0x428250(0xe8)](_0x1f5936=>hostMatches(_0x231e51,_0x1f5936)))return{'\x61\x63\x74\x69\x6f\x6e':_0x428250(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x428250(0x210)+_0x231e51+_0x428250(0x1fd)};}return{'\x61\x63\x74\x69\x6f\x6e':_0x428250(0x1d6)};}};}function costCapHook(_0x420304){const _0x168d69=a0_0x15650e,_0x2ed9b8={'\x48\x71\x69\x78\x68':function(_0x4a27e8,_0x2faa24){return _0x4a27e8(_0x2faa24);},'\x5a\x48\x58\x6a\x67':'\x74\x65\x72\x6d\x69\x6e\x61\x74\x65'},_0x5b3a85=_0x420304[_0x168d69(0x212)]??(async()=>0x0);return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x5d034a){const _0x32bd1c=_0x168d69,_0x1f5716=await _0x2ed9b8[_0x32bd1c(0x1ae)](_0x5b3a85,_0x5d034a['\x70\x61\x72\x74\x6e\x65\x72\x49\x64']);if(_0x1f5716>=_0x420304[_0x32bd1c(0x239)])return{'\x61\x63\x74\x69\x6f\x6e':_0x32bd1c(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x32bd1c(0x175)+_0x1f5716+_0x32bd1c(0x16e)+_0x420304[_0x32bd1c(0x239)]};return{'\x61\x63\x74\x69\x6f\x6e':_0x32bd1c(0x1d6)};},async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x1272be){const _0x212ed9=_0x168d69,_0x4d6207=await _0x2ed9b8['\x48\x71\x69\x78\x68'](_0x5b3a85,_0x1272be[_0x212ed9(0x199)]);if(_0x4d6207>=_0x420304[_0x212ed9(0x239)])return{'\x61\x63\x74\x69\x6f\x6e':_0x2ed9b8['\x5a\x48\x58\x6a\x67'],'\x72\x65\x61\x73\x6f\x6e':_0x212ed9(0x140)+_0x4d6207+'\x20\x3e\x3d\x20'+_0x420304['\x63\x65\x69\x6c\x69\x6e\x67']};return{'\x61\x63\x74\x69\x6f\x6e':_0x212ed9(0x129)};}};}function actionRateLimitHook(_0x4f7c60){const _0x1d96b4=a0_0x15650e,_0x20e2dd={'\x71\x45\x41\x6c\x45':_0x1d96b4(0x1d6),'\x5a\x41\x4d\x6f\x75':function(_0x33c410,_0x1f5989){return _0x33c410-_0x1f5989;},'\x63\x5a\x6a\x49\x6b':function(_0x99ef8e,_0x44f9fc){return _0x99ef8e*_0x44f9fc;}},_0x441881=_0x4f7c60['\x6e\x6f\x77']??Date['\x6e\x6f\x77'],_0x155411=Math[_0x1d96b4(0xde)](0x1,Math[_0x1d96b4(0xd9)](_0x4f7c60[_0x1d96b4(0x1de)])),_0x1e4556=_0x4f7c60[_0x1d96b4(0x1de)]/0x3e8,_0x304bc0=new Map();return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x43b323){const _0x2fb25b=_0x1d96b4;if(!_0x43b323[_0x2fb25b(0x16b)][_0x2fb25b(0xe7)](_0x2fb25b(0x29b)))return{'\x61\x63\x74\x69\x6f\x6e':_0x20e2dd[_0x2fb25b(0x103)]};const _0x175927=_0x43b323[_0x2fb25b(0xf9)],_0x571fdd=_0x441881(),_0x45ac09=_0x304bc0[_0x2fb25b(0xf5)](_0x175927)??{'\x74\x6f\x6b\x65\x6e\x73':_0x155411,'\x6c\x61\x73\x74\x52\x65\x66\x69\x6c\x6c\x4d\x73':_0x571fdd},_0x5520cf=Math[_0x2fb25b(0xde)](0x0,_0x20e2dd[_0x2fb25b(0x2a4)](_0x571fdd,_0x45ac09[_0x2fb25b(0x101)]));_0x45ac09[_0x2fb25b(0x20e)]=Math[_0x2fb25b(0x136)](_0x155411,_0x45ac09[_0x2fb25b(0x20e)]+_0x20e2dd[_0x2fb25b(0x257)](_0x5520cf,_0x1e4556)),_0x45ac09[_0x2fb25b(0x101)]=_0x571fdd;if(_0x45ac09[_0x2fb25b(0x20e)]<0x1)return _0x304bc0['\x73\x65\x74'](_0x175927,_0x45ac09),{'\x61\x63\x74\x69\x6f\x6e':_0x2fb25b(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x2fb25b(0x17c)+_0x4f7c60[_0x2fb25b(0x1de)]+'\x2f\x73'};return _0x45ac09['\x74\x6f\x6b\x65\x6e\x73']-=0x1,_0x304bc0[_0x2fb25b(0x280)](_0x175927,_0x45ac09),{'\x61\x63\x74\x69\x6f\x6e':'\x61\x6c\x6c\x6f\x77'};}};}function readScreenshotPayload(_0x54ba44){const _0x469431=a0_0x15650e,_0x312ad9={'\x61\x52\x4b\x4b\x4d':function(_0xb76bdc,_0x1a002c){return _0xb76bdc===_0x1a002c;},'\x47\x58\x41\x4e\x71':_0x469431(0x29e)},_0x43ae68=[_0x54ba44['\x63\x6f\x6e\x74\x65\x6e\x74'],_0x54ba44['\x64\x65\x74\x61\x69\x6c\x73']?.[_0x469431(0x19d)],_0x54ba44['\x64\x65\x74\x61\x69\x6c\x73']];for(const _0x2de8fa of _0x43ae68)if(_0x2de8fa&&_0x312ad9[_0x469431(0x112)](typeof _0x2de8fa,_0x469431(0x17d))){if(typeof _0x2de8fa[_0x469431(0x20a)]===_0x312ad9[_0x469431(0xf0)])return _0x2de8fa;}return null;}function screenshotRedactionHook(_0x5650a3={}){const _0x5961a6=a0_0x15650e,_0x240cc2={'\x64\x66\x63\x79\x58':_0x5961a6(0x1fe),'\x63\x69\x44\x6b\x66':_0x5961a6(0x129),'\x71\x71\x4c\x56\x6a':function(_0x84c39e,_0x4206c0){return _0x84c39e!==_0x4206c0;}},_0x4b4be2=_0x5650a3[_0x5961a6(0x21d)]??(_0x51b86c=>console[_0x5961a6(0x21d)](_0x51b86c)),_0x3cd307=(_0x5650a3['\x72\x65\x67\x69\x6f\x6e\x73']?.[_0x5961a6(0x132)]??0x0)>0x0;let _0x581431=![];return{async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x2cfb5a,_0x58ea47){const _0x2d4d7c=_0x5961a6,_0x5335dd='\x32\x7c\x33\x7c\x31\x7c\x30\x7c\x34'['\x73\x70\x6c\x69\x74']('\x7c');let _0x2e1b60=0x0;while(!![]){switch(_0x5335dd[_0x2e1b60++]){case'\x30':!_0x581431&&(_0x581431=!![],_0x4b4be2(_0x240cc2[_0x2d4d7c(0x263)]));continue;case'\x31':if(!readScreenshotPayload(_0x58ea47))return{'\x61\x63\x74\x69\x6f\x6e':_0x240cc2[_0x2d4d7c(0x18f)]};continue;case'\x32':if(_0x240cc2['\x71\x71\x4c\x56\x6a'](_0x2cfb5a[_0x2d4d7c(0x16b)],_0x2d4d7c(0x26a)))return{'\x61\x63\x74\x69\x6f\x6e':_0x2d4d7c(0x129)};continue;case'\x33':if(!_0x3cd307)return{'\x61\x63\x74\x69\x6f\x6e':_0x2d4d7c(0x129)};continue;case'\x34':return{'\x61\x63\x74\x69\x6f\x6e':_0x240cc2['\x63\x69\x44\x6b\x66']};}break;}}};}const TYPE_TEXT_FIELDS=[a0_0x15650e(0x19f),a0_0x15650e(0x255),a0_0x15650e(0x1be),'\x71\x75\x65\x72\x79'],CLICK_LABEL_FIELDS=[a0_0x15650e(0x238),a0_0x15650e(0xfb),a0_0x15650e(0xf1),'\x61\x72\x69\x61\x4c\x61\x62\x65\x6c',a0_0x15650e(0x240)];function a0_0x1c70(_0x313bb2,_0x3935ec){_0x313bb2=_0x313bb2-0xd8;const _0x2d62e3=a0_0x2d62();let _0x1c7027=_0x2d62e3[_0x313bb2];if(a0_0x1c70['\x41\x52\x46\x54\x6b\x77']===undefined){var _0x45c7f9=function(_0x516919){const _0x4677b0='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';let _0x1edd60='',_0x5977e='';for(let _0x4c209f=0x0,_0x1a2352,_0x336509,_0x237fd8=0x0;_0x336509=_0x516919['\x63\x68\x61\x72\x41\x74'](_0x237fd8++);~_0x336509&&(_0x1a2352=_0x4c209f%0x4?_0x1a2352*0x40+_0x336509:_0x336509,_0x4c209f++%0x4)?_0x1edd60+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x1a2352>>(-0x2*_0x4c209f&0x6)):0x0){_0x336509=_0x4677b0['\x69\x6e\x64\x65\x78\x4f\x66'](_0x336509);}for(let _0x4c9db9=0x0,_0xba776a=_0x1edd60['\x6c\x65\x6e\x67\x74\x68'];_0x4c9db9<_0xba776a;_0x4c9db9++){_0x5977e+='\x25'+('\x30\x30'+_0x1edd60['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x4c9db9)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x5977e);};a0_0x1c70['\x6a\x62\x44\x57\x61\x76']=_0x45c7f9,a0_0x1c70['\x66\x5a\x5a\x77\x55\x51']={},a0_0x1c70['\x41\x52\x46\x54\x6b\x77']=!![];}const _0x83926d=_0x2d62e3[0x0],_0x2fabef=_0x313bb2+_0x83926d,_0x4b6175=a0_0x1c70['\x66\x5a\x5a\x77\x55\x51'][_0x2fabef];return!_0x4b6175?(_0x1c7027=a0_0x1c70['\x6a\x62\x44\x57\x61\x76'](_0x1c7027),a0_0x1c70['\x66\x5a\x5a\x77\x55\x51'][_0x2fabef]=_0x1c7027):_0x1c7027=_0x4b6175,_0x1c7027;}function readStringField(_0x518220,_0x3d29da){const _0x2e8799=a0_0x15650e,_0x27da4f={'\x59\x57\x71\x64\x7a':_0x2e8799(0x17d),'\x47\x6c\x6c\x74\x49':_0x2e8799(0x29e)};if(!_0x518220||typeof _0x518220!==_0x27da4f[_0x2e8799(0x276)])return null;const _0x4284db=_0x518220;for(const _0x588163 of _0x3d29da){const _0x4322c9=_0x4284db[_0x588163];if(typeof _0x4322c9===_0x27da4f['\x47\x6c\x6c\x74\x49']&&_0x4322c9[_0x2e8799(0x132)]>0x0)return _0x4322c9;}return null;}function destructiveActionGuardHook(_0x4b3315){const _0x1562d2={'\x6c\x6b\x59\x46\x6a':'\x61\x6c\x6c\x6f\x77'},_0x31f3d1=_0x4b3315['\x64\x65\x6e\x79\x50\x61\x74\x74\x65\x72\x6e\x73'];return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x1f91bc){const _0x2846ee=a0_0x1c70;let _0xbf5270=null;if(_0x1f91bc[_0x2846ee(0x16b)]===_0x2846ee(0x1c1))_0xbf5270=readStringField(_0x1f91bc['\x61\x72\x67\x73'],TYPE_TEXT_FIELDS);else{if(_0x1f91bc[_0x2846ee(0x16b)]===_0x2846ee(0x20b))_0xbf5270=readStringField(_0x1f91bc[_0x2846ee(0x29c)],CLICK_LABEL_FIELDS);else return{'\x61\x63\x74\x69\x6f\x6e':_0x2846ee(0x1d6)};}if(!_0xbf5270)return{'\x61\x63\x74\x69\x6f\x6e':_0x1562d2[_0x2846ee(0x1ee)]};for(const _0x363fc5 of _0x31f3d1)if(_0x363fc5[_0x2846ee(0x138)](_0xbf5270))return{'\x61\x63\x74\x69\x6f\x6e':_0x2846ee(0x1d1),'\x72\x65\x61\x73\x6f\x6e':_0x2846ee(0x1f7)+_0x363fc5['\x74\x6f\x53\x74\x72\x69\x6e\x67']()};return{'\x61\x63\x74\x69\x6f\x6e':_0x1562d2[_0x2846ee(0x1ee)]};}};}var InMemoryResponseStore=class{['\x63\x68\x61\x69\x6e\x73']=new Map();async[a0_0x15650e(0x1c4)](_0xe58a3c){const _0x545e69=a0_0x15650e,_0x249b70=this[_0x545e69(0x189)][_0x545e69(0xf5)](_0xe58a3c);return _0x249b70?_0x249b70[_0x545e69(0x251)](_0x3ba6a8=>({..._0x3ba6a8})):null;}async[a0_0x15650e(0x152)](_0x19fc75,_0x4a429a){const _0x22a66f=a0_0x15650e;this[_0x22a66f(0x189)][_0x22a66f(0x280)](_0x19fc75,_0x4a429a[_0x22a66f(0x251)](_0x37bcc9=>({..._0x37bcc9})));}[a0_0x15650e(0x179)](){const _0x2e019b=a0_0x15650e;return this[_0x2e019b(0x189)]['\x73\x69\x7a\x65'];}['\x64\x65\x6c\x65\x74\x65'](_0x25cd24){const _0xe10f9f=a0_0x15650e;return this['\x63\x68\x61\x69\x6e\x73'][_0xe10f9f(0x261)](_0x25cd24);}[a0_0x15650e(0xd8)](){const _0x2964cb=a0_0x15650e;this[_0x2964cb(0x189)]['\x63\x6c\x65\x61\x72']();}};const TERMINAL_STATUSES=new Set([a0_0x15650e(0x19b),a0_0x15650e(0x264),a0_0x15650e(0x1bb),a0_0x15650e(0x20d)]);function isTerminal(_0x4f3aeb){const _0x4694be=a0_0x15650e;return TERMINAL_STATUSES[_0x4694be(0x217)](_0x4f3aeb);}async function*runEvents(_0x256be4,_0x1f6fa2,_0x4f02ed){const _0x1c6095=a0_0x15650e;for await(const _0x1c400a of _0x4f02ed[_0x1c6095(0x142)](_0x256be4,_0x1f6fa2))yield _0x1c400a;}function readToolCallFromFrame(_0x4c6808){const _0x478897=a0_0x15650e,_0x8b238d={'\x46\x4f\x65\x52\x68':function(_0x380969,_0x2e0ee2){return _0x380969===_0x2e0ee2;},'\x71\x4a\x59\x4b\x62':_0x478897(0x1b8),'\x4f\x64\x59\x6e\x74':_0x478897(0x29e),'\x4f\x71\x4a\x75\x62':function(_0x5c1703,_0x4d2d7b){return _0x5c1703===_0x4d2d7b;},'\x62\x4d\x67\x56\x68':function(_0x301c4d,_0x52d8e5){return _0x301c4d||_0x52d8e5;}};if(_0x4c6808[_0x478897(0x141)]==='\x72\x65\x71\x75\x69\x72\x65\x73\x5f\x61\x63\x74\x69\x6f\x6e'||_0x8b238d['\x46\x4f\x65\x52\x68'](_0x4c6808['\x74\x79\x70\x65'],_0x8b238d[_0x478897(0x15d)])){const _0xbb8be0=_0x4c6808['\x64\x61\x74\x61']??_0x4c6808,_0x285921=String(_0xbb8be0[_0x478897(0x206)]??_0xbb8be0['\x63\x61\x6c\x6c\x5f\x69\x64']??_0xbb8be0['\x69\x64']??''),_0x2fca1b=String(_0xbb8be0[_0x478897(0x16b)]??_0xbb8be0[_0x478897(0x25e)]??_0xbb8be0[_0x478897(0x1b2)]??'');if(!_0x285921||!_0x2fca1b)return null;return{'\x63\x61\x6c\x6c\x49\x64':_0x285921,'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x2fca1b,'\x61\x72\x67\x73':_0xbb8be0[_0x478897(0x29c)]??_0xbb8be0['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']??_0xbb8be0[_0x478897(0x1be)]??{},'\x72\x65\x71\x75\x69\x72\x65\x73\x41\x63\x74\x69\x6f\x6e':!![]};}if(_0x4c6808[_0x478897(0x141)]!=='\x72\x61\x77')return null;const _0x419224=_0x4c6808[_0x478897(0x104)]??_0x4c6808,_0x4379d1=_0x8b238d['\x46\x4f\x65\x52\x68'](typeof _0x419224[_0x478897(0x141)],_0x8b238d[_0x478897(0x1a8)])?_0x419224['\x74\x79\x70\x65']:'';if(!(_0x4379d1===_0x478897(0x164)||_0x4379d1==='\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c'||_0x4379d1==='\x63\x6f\x6d\x70\x75\x74\x65\x72\x2d\x75\x73\x65'||_0x4379d1===_0x478897(0x29a)))return null;const _0x3e9999=_0x419224[_0x478897(0x216)]??_0x419224[_0x478897(0x26b)]??_0x419224[_0x478897(0x269)]??_0x419224[_0x478897(0x252)]??_0x419224,_0x4d2937=String(_0x3e9999['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x49\x64']??_0x3e9999[_0x478897(0x18a)]??_0x3e9999[_0x478897(0x206)]??_0x3e9999['\x69\x64']??''),_0x519455=_0x4379d1===_0x478897(0x207)||_0x8b238d[_0x478897(0x1b3)](_0x4379d1,_0x478897(0x29a))?_0x478897(0x29b)+String(_0x3e9999[_0x478897(0x11b)]?.[_0x478897(0x141)]??_0x478897(0x11b)):String(_0x3e9999[_0x478897(0x16b)]??_0x3e9999[_0x478897(0x25e)]??_0x3e9999[_0x478897(0x1b2)]??'');if(_0x8b238d[_0x478897(0x10b)](!_0x4d2937,!_0x519455))return null;return{'\x63\x61\x6c\x6c\x49\x64':_0x4d2937,'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x519455,'\x61\x72\x67\x73':_0x3e9999['\x61\x72\x67\x73']??_0x3e9999['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']??_0x3e9999['\x69\x6e\x70\x75\x74']??{},'\x72\x65\x71\x75\x69\x72\x65\x73\x41\x63\x74\x69\x6f\x6e':![]};}function readTerminal(_0x5d5541){const _0x2b8035=a0_0x15650e,_0x4fcd09={'\x79\x46\x50\x56\x69':function(_0x935b71,_0x33d70e){return _0x935b71===_0x33d70e;},'\x66\x49\x51\x6e\x69':function(_0x400e3b,_0x483c51){return _0x400e3b===_0x483c51;},'\x76\x4d\x47\x79\x6b':function(_0xc50e28,_0xdb2c46){return _0xc50e28===_0xdb2c46;},'\x4f\x52\x46\x6f\x6e':'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64','\x6c\x64\x53\x4a\x79':_0x2b8035(0x264),'\x66\x55\x58\x57\x75':'\x73\x74\x72\x69\x6e\x67','\x64\x54\x50\x54\x65':_0x2b8035(0x234)};if(_0x4fcd09['\x79\x46\x50\x56\x69'](_0x5d5541['\x74\x79\x70\x65'],_0x2b8035(0x194))){const _0x235a44=typeof _0x5d5541[_0x2b8035(0x1d0)]===_0x2b8035(0x29e)&&_0x5d5541[_0x2b8035(0x1d0)]||'\x73\x75\x63\x63\x65\x73\x73';if(_0x4fcd09[_0x2b8035(0x109)](_0x235a44,'\x73\x75\x63\x63\x65\x73\x73')||_0x4fcd09[_0x2b8035(0x1b1)](_0x235a44,_0x4fcd09['\x4f\x52\x46\x6f\x6e'])||_0x235a44===_0x2b8035(0x156)||_0x4fcd09[_0x2b8035(0x1b1)](_0x235a44,_0x2b8035(0x194)))return{'\x73\x74\x61\x74\x75\x73':'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'};return{'\x73\x74\x61\x74\x75\x73':_0x4fcd09[_0x2b8035(0x1c8)],'\x72\x65\x61\x73\x6f\x6e':typeof _0x5d5541[_0x2b8035(0x18e)]===_0x4fcd09['\x66\x55\x58\x57\x75']?_0x5d5541[_0x2b8035(0x18e)]:_0x235a44};}if(_0x5d5541['\x74\x79\x70\x65']===_0x2b8035(0x18e))return{'\x73\x74\x61\x74\x75\x73':_0x2b8035(0x264),'\x72\x65\x61\x73\x6f\x6e':_0x4fcd09[_0x2b8035(0x109)](typeof _0x5d5541['\x6d\x65\x73\x73\x61\x67\x65'],_0x4fcd09['\x66\x55\x58\x57\x75'])&&_0x5d5541['\x6d\x65\x73\x73\x61\x67\x65']||typeof _0x5d5541[_0x2b8035(0x18e)]===_0x2b8035(0x29e)&&_0x5d5541[_0x2b8035(0x18e)]||_0x4fcd09[_0x2b8035(0x1fc)]};return null;}var EventQueue=class{[a0_0x15650e(0x27f)]=[];['\x77\x61\x69\x74\x65\x72\x73']=[];[a0_0x15650e(0x151)]=![];[a0_0x15650e(0x131)]=![];[a0_0x15650e(0x1c0)](_0x16aa4c){const _0x2ac09a=a0_0x15650e;if(this[_0x2ac09a(0x151)])return;const _0x331b07=this['\x77\x61\x69\x74\x65\x72\x73'][_0x2ac09a(0x200)]();if(_0x331b07){_0x331b07({'\x76\x61\x6c\x75\x65':_0x16aa4c,'\x64\x6f\x6e\x65':![]});return;}this[_0x2ac09a(0x27f)]['\x70\x75\x73\x68'](_0x16aa4c);}[a0_0x15650e(0x23b)](){const _0x2263e7=a0_0x15650e,_0x54387a={'\x45\x6a\x4e\x6b\x62':function(_0x4fa77b,_0x2ae7d5){return _0x4fa77b>_0x2ae7d5;}};if(this[_0x2263e7(0x151)])return;this['\x63\x6c\x6f\x73\x65\x64']=!![];while(_0x54387a[_0x2263e7(0x180)](this[_0x2263e7(0x20c)][_0x2263e7(0x132)],0x0))this[_0x2263e7(0x20c)][_0x2263e7(0x200)]()?.({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});}[a0_0x15650e(0x223)](){const _0x4d13d1=a0_0x15650e,_0x47f85d={'\x4b\x4e\x72\x46\x65':function(_0x59ab4f,_0x2e2c50){return _0x59ab4f>_0x2e2c50;}};if(this[_0x4d13d1(0x131)])throw new Error(_0x4d13d1(0x123));this[_0x4d13d1(0x131)]=!![];const _0x28efa8=this;return{[Symbol[_0x4d13d1(0xe0)]](){return this;},'\x6e\x65\x78\x74'(){const _0x1bf485=_0x4d13d1;if(_0x47f85d[_0x1bf485(0x24b)](_0x28efa8[_0x1bf485(0x27f)][_0x1bf485(0x132)],0x0)){const _0x1bb82a=_0x28efa8[_0x1bf485(0x27f)][_0x1bf485(0x200)]();return Promise['\x72\x65\x73\x6f\x6c\x76\x65']({'\x76\x61\x6c\x75\x65':_0x1bb82a,'\x64\x6f\x6e\x65':![]});}if(_0x28efa8['\x63\x6c\x6f\x73\x65\x64'])return Promise[_0x1bf485(0x23d)]({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});return new Promise(_0x2f3839=>{const _0x4c84a5=_0x1bf485;_0x28efa8[_0x4c84a5(0x20c)][_0x4c84a5(0x1c0)](_0x2f3839);});},'\x72\x65\x74\x75\x72\x6e'(){const _0x40444b=_0x4d13d1;return _0x28efa8[_0x40444b(0x23b)](),Promise['\x72\x65\x73\x6f\x6c\x76\x65']({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});}};}},Run=class{['\x69\x64'];[a0_0x15650e(0x171)];[a0_0x15650e(0x199)];[a0_0x15650e(0x1f0)]='\x71\x75\x65\x75\x65\x64';[a0_0x15650e(0x172)];['\x68\x6f\x6f\x6b\x73'];[a0_0x15650e(0x1c2)];[a0_0x15650e(0x1f1)];['\x71\x75\x65\x75\x65']=new EventQueue();[a0_0x15650e(0x12d)]=null;[a0_0x15650e(0x144)]=new Map();[a0_0x15650e(0x273)]=![];constructor(_0x621b71){const _0x421069=a0_0x15650e;this['\x69\x64']=_0x621b71['\x69\x64'],this[_0x421069(0x171)]=_0x621b71[_0x421069(0x171)],this[_0x421069(0x199)]=_0x621b71[_0x421069(0x199)],this[_0x421069(0x172)]=_0x621b71[_0x421069(0x172)],this['\x68\x6f\x6f\x6b\x73']=_0x621b71[_0x421069(0x1ab)],this['\x65\x78\x65\x63\x75\x74\x65\x54\x6f\x6f\x6c']=_0x621b71[_0x421069(0x1c2)],this['\x6f\x6e\x53\x74\x61\x74\x75\x73\x43\x68\x61\x6e\x67\x65']=_0x621b71[_0x421069(0x1f1)];}get['\x73\x74\x61\x74\x75\x73'](){const _0x53fdd8=a0_0x15650e;return this[_0x53fdd8(0x1f0)];}['\x65\x76\x65\x6e\x74\x73'](){const _0x5a3071=a0_0x15650e;return this[_0x5a3071(0x262)][_0x5a3071(0x223)]();}['\x73\x74\x61\x72\x74'](){const _0x459c5c=a0_0x15650e;if(this[_0x459c5c(0x12d)])return this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65'];return this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65']=this['\x64\x72\x69\x76\x65\x53\x74\x72\x65\x61\x6d'](),this[_0x459c5c(0x12d)];}async[a0_0x15650e(0x24a)](_0x4d26fe){const _0x13b178=a0_0x15650e,_0x58471d={'\x6c\x42\x50\x6c\x57':_0x13b178(0x1bb)};if(isTerminal(this['\x5f\x73\x74\x61\x74\x75\x73']))return;this[_0x13b178(0x273)]=!![];if(this[_0x13b178(0x172)][_0x13b178(0x24a)])try{await this[_0x13b178(0x172)][_0x13b178(0x24a)](this['\x74\x68\x72\x65\x61\x64\x49\x64'],this['\x69\x64']);}catch{}this[_0x13b178(0x278)](_0x13b178(0x1bb)),this[_0x13b178(0x262)][_0x13b178(0x1c0)]({'\x74\x79\x70\x65':_0x58471d['\x6c\x42\x50\x6c\x57'],'\x72\x65\x61\x73\x6f\x6e':_0x4d26fe}),this[_0x13b178(0x262)][_0x13b178(0x23b)]();}async[a0_0x15650e(0x19c)](_0x4d5900){const _0x1762b1=a0_0x15650e,_0x157fc6={'\x46\x66\x4b\x56\x63':function(_0x2f259d,_0xcffa39){return _0x2f259d===_0xcffa39;},'\x46\x6a\x61\x46\x48':function(_0x33b2e7,_0x5533de){return _0x33b2e7(_0x5533de);}},_0x41f052=_0x1762b1(0x1df)['\x73\x70\x6c\x69\x74']('\x7c');let _0x1a9d08=0x0;while(!![]){switch(_0x41f052[_0x1a9d08++]){case'\x30':if(!this[_0x1762b1(0x172)][_0x1762b1(0x19c)])throw new Error('\x52\x75\x6e\x45\x76\x65\x6e\x74\x53\x6f\x75\x72\x63\x65\x20\x64\x6f\x65\x73\x20\x6e\x6f\x74\x20\x73\x75\x70\x70\x6f\x72\x74\x20\x73\x74\x65\x65\x72');continue;case'\x31':await this[_0x1762b1(0x12d)];continue;case'\x32':if(_0x157fc6[_0x1762b1(0x1d9)](this[_0x1762b1(0x1f0)],'\x72\x65\x71\x75\x69\x72\x65\x73\x5f\x61\x63\x74\x69\x6f\x6e'))this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x1762b1(0x1ed));continue;case'\x33':this[_0x1762b1(0x12d)]=this[_0x1762b1(0x29f)]();continue;case'\x34':await this[_0x1762b1(0x172)][_0x1762b1(0x19c)](this[_0x1762b1(0x171)],this['\x69\x64'],_0x4d5900);continue;case'\x35':if(_0x157fc6[_0x1762b1(0x230)](isTerminal,this[_0x1762b1(0x1f0)]))throw new Error('\x63\x61\x6e\x6e\x6f\x74\x20\x73\x74\x65\x65\x72\x20\x61\x20'+this[_0x1762b1(0x1f0)]+_0x1762b1(0x162));continue;}break;}}async[a0_0x15650e(0x1b6)](_0x315590){const _0x3b3e93=a0_0x15650e,_0x4173da={'\x4e\x64\x71\x67\x54':_0x3b3e93(0x231)};if(this[_0x3b3e93(0x1f0)]!==_0x3b3e93(0x17b))throw new Error('\x63\x61\x6e\x6e\x6f\x74\x20\x73\x75\x62\x6d\x69\x74\x20\x74\x6f\x6f\x6c\x20\x6f\x75\x74\x70\x75\x74\x73\x20\x69\x6e\x20\x73\x74\x61\x74\x75\x73\x20'+this[_0x3b3e93(0x1f0)]);if(!this[_0x3b3e93(0x172)][_0x3b3e93(0x1b6)])throw new Error(_0x4173da['\x4e\x64\x71\x67\x54']);for(const _0x40fe08 of _0x315590)this[_0x3b3e93(0x144)][_0x3b3e93(0x261)](_0x40fe08[_0x3b3e93(0x25b)]);await this['\x73\x6f\x75\x72\x63\x65']['\x73\x75\x62\x6d\x69\x74\x54\x6f\x6f\x6c\x4f\x75\x74\x70\x75\x74\x73'](this[_0x3b3e93(0x171)],this['\x69\x64'],_0x315590),this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x3b3e93(0x1ed)),this[_0x3b3e93(0x12d)]=this[_0x3b3e93(0x29f)](),await this[_0x3b3e93(0x12d)];}[a0_0x15650e(0x1a2)](){const _0x2abe3f=a0_0x15650e,_0x1ee8df={'\x68\x45\x4b\x45\x42':'\x65\x78\x70\x69\x72\x65\x64'};if(isTerminal(this[_0x2abe3f(0x1f0)]))return;this[_0x2abe3f(0x278)](_0x2abe3f(0x20d)),this['\x71\x75\x65\x75\x65'][_0x2abe3f(0x1c0)]({'\x74\x79\x70\x65':_0x2abe3f(0x264),'\x72\x65\x61\x73\x6f\x6e':_0x1ee8df[_0x2abe3f(0x25f)]}),this[_0x2abe3f(0x262)][_0x2abe3f(0x23b)]();}[a0_0x15650e(0x278)](_0x511063){const _0x17f9b6=a0_0x15650e,_0x471b45={'\x42\x61\x63\x56\x4d':_0x17f9b6(0x13f)};if(this[_0x17f9b6(0x1f0)]===_0x511063)return;const _0x2f7170=this[_0x17f9b6(0x1f0)];this[_0x17f9b6(0x1f0)]=_0x511063,this[_0x17f9b6(0x262)]['\x70\x75\x73\x68']({'\x74\x79\x70\x65':_0x471b45[_0x17f9b6(0x225)],'\x73\x74\x61\x74\x75\x73':_0x511063,'\x70\x72\x65\x76\x69\x6f\x75\x73':_0x2f7170}),this[_0x17f9b6(0x1f1)]?.(_0x511063,_0x2f7170);}async[a0_0x15650e(0x29f)](){const _0x5a3894=a0_0x15650e,_0x54ac1e={'\x62\x47\x6c\x4b\x4a':_0x5a3894(0x19b),'\x6e\x41\x72\x4a\x53':'\x66\x61\x69\x6c\x65\x64','\x53\x58\x4e\x71\x4e':function(_0x10bfdc,_0x4f27e4){return _0x10bfdc(_0x4f27e4);}};try{for await(const _0x5bac2f of runEvents(this[_0x5a3894(0x171)],this['\x69\x64'],this[_0x5a3894(0x172)])){if(this[_0x5a3894(0x273)])return;if(this[_0x5a3894(0x1f0)]===_0x5a3894(0x178))this[_0x5a3894(0x278)]('\x69\x6e\x5f\x70\x72\x6f\x67\x72\x65\x73\x73');this[_0x5a3894(0x262)][_0x5a3894(0x1c0)]({'\x74\x79\x70\x65':'\x73\x74\x72\x65\x61\x6d','\x65\x76\x65\x6e\x74':_0x5bac2f});const _0x3793c5=readToolCallFromFrame(_0x5bac2f);if(_0x3793c5){const _0x4381ff=await this[_0x5a3894(0x10d)](_0x3793c5);if(_0x4381ff===_0x5a3894(0xfc))return;if(_0x4381ff===_0x5a3894(0x17b))return;continue;}const _0x1aca74=readTerminal(_0x5bac2f);if(_0x1aca74){_0x1aca74[_0x5a3894(0x13f)]===_0x54ac1e['\x62\x47\x6c\x4b\x4a']?(this[_0x5a3894(0x278)](_0x54ac1e[_0x5a3894(0x21a)]),this['\x71\x75\x65\x75\x65'][_0x5a3894(0x1c0)]({'\x74\x79\x70\x65':_0x5a3894(0x19b)})):(this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x5a3894(0x264)),this['\x71\x75\x65\x75\x65'][_0x5a3894(0x1c0)]({'\x74\x79\x70\x65':_0x54ac1e[_0x5a3894(0x1b7)],'\x72\x65\x61\x73\x6f\x6e':_0x1aca74[_0x5a3894(0x28b)]??_0x5a3894(0x26e)}));this[_0x5a3894(0x262)][_0x5a3894(0x23b)]();return;}}!isTerminal(this[_0x5a3894(0x1f0)])&&(this[_0x5a3894(0x278)](_0x5a3894(0x19b)),this[_0x5a3894(0x262)][_0x5a3894(0x1c0)]({'\x74\x79\x70\x65':'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'}),this[_0x5a3894(0x262)][_0x5a3894(0x23b)]());}catch(_0x10932f){if(_0x54ac1e[_0x5a3894(0x1a1)](isTerminal,this[_0x5a3894(0x1f0)]))return;const _0x729ddb=_0x10932f instanceof Error?_0x10932f[_0x5a3894(0x126)]:String(_0x10932f);this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x5a3894(0x264)),this[_0x5a3894(0x262)][_0x5a3894(0x1c0)]({'\x74\x79\x70\x65':_0x5a3894(0x264),'\x72\x65\x61\x73\x6f\x6e':_0x729ddb}),this['\x71\x75\x65\x75\x65']['\x63\x6c\x6f\x73\x65']();}}async[a0_0x15650e(0x10d)](_0x4e0bcd){const _0x1a4572=a0_0x15650e,_0x4fede8={'\x56\x69\x62\x71\x54':_0x1a4572(0x185),'\x78\x73\x70\x70\x74':_0x1a4572(0x271),'\x73\x68\x5a\x69\x73':function(_0x4f656e,_0x3dc92d){return _0x4f656e(_0x3dc92d);},'\x4c\x72\x49\x45\x78':function(_0x4d6883,_0x40624f){return _0x4d6883>_0x40624f;},'\x4f\x76\x70\x49\x4c':function(_0x198cea,_0x3fa710){return _0x198cea===_0x3fa710;},'\x67\x51\x72\x44\x72':_0x1a4572(0x264),'\x58\x66\x50\x45\x55':_0x1a4572(0x27b)},_0x1f2aa3={'\x72\x75\x6e\x49\x64':this['\x69\x64'],'\x74\x68\x72\x65\x61\x64\x49\x64':this[_0x1a4572(0x171)],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':this['\x70\x61\x72\x74\x6e\x65\x72\x49\x64'],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x4e0bcd[_0x1a4572(0x16b)],'\x61\x72\x67\x73':_0x4e0bcd[_0x1a4572(0x29c)],'\x63\x61\x6c\x6c\x49\x64':_0x4e0bcd[_0x1a4572(0x206)],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':Date[_0x1a4572(0x209)]()};let _0x167322=_0x1f2aa3;if(this[_0x1a4572(0x1ab)]&&this[_0x1a4572(0x1ab)][_0x1a4572(0x179)]>0x0){const _0x477542=await this[_0x1a4572(0x1ab)][_0x1a4572(0x1ef)](_0x1f2aa3);if(_0x477542[_0x1a4572(0x11b)]===_0x1a4572(0x1d1)){const _0x2ad8d2={'\x63\x6f\x6e\x74\x65\x6e\x74':{'\x65\x72\x72\x6f\x72':_0x477542[_0x1a4572(0x28b)]},'\x69\x73\x45\x72\x72\x6f\x72':!![],'\x64\x65\x74\x61\x69\x6c\x73':{'\x62\x6c\x6f\x63\x6b\x65\x64\x42\x79':'\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'}};this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':'\x74\x6f\x6f\x6c\x5f\x62\x6c\x6f\x63\x6b\x65\x64','\x63\x74\x78':_0x1f2aa3,'\x72\x65\x61\x73\x6f\x6e':_0x477542[_0x1a4572(0x28b)]}),this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x4fede8[_0x1a4572(0x1a5)],'\x63\x74\x78':_0x1f2aa3,'\x72\x65\x73\x75\x6c\x74':_0x2ad8d2});if(_0x4e0bcd['\x72\x65\x71\x75\x69\x72\x65\x73\x41\x63\x74\x69\x6f\x6e'])return this[_0x1a4572(0x144)][_0x1a4572(0x280)](_0x4e0bcd[_0x1a4572(0x206)],_0x1f2aa3),this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x1a4572(0x17b)),this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x1a4572(0x17b),'\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x49\x64\x73':Array[_0x1a4572(0x145)](this[_0x1a4572(0x144)]['\x6b\x65\x79\x73']())}),_0x1a4572(0x17b);return'\x63\x6f\x6e\x74\x69\x6e\x75\x65';}if(_0x477542['\x61\x63\x74\x69\x6f\x6e']===_0x1a4572(0x143))_0x167322={..._0x1f2aa3,'\x61\x72\x67\x73':_0x477542[_0x1a4572(0x29c)]};}if(_0x4e0bcd[_0x1a4572(0xe9)])return this[_0x1a4572(0x144)]['\x73\x65\x74'](_0x4e0bcd[_0x1a4572(0x206)],_0x167322),this[_0x1a4572(0x278)](_0x1a4572(0x17b)),this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x4fede8['\x78\x73\x70\x70\x74'],'\x63\x74\x78':_0x167322}),this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x1a4572(0x17b),'\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x49\x64\x73':Array[_0x1a4572(0x145)](this[_0x1a4572(0x144)][_0x1a4572(0x224)]())}),_0x1a4572(0x17b);if(!this[_0x1a4572(0x1c2)])return this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x4fede8[_0x1a4572(0x247)],'\x63\x74\x78':_0x167322}),_0x1a4572(0x27b);this['\x71\x75\x65\x75\x65'][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x4fede8[_0x1a4572(0x247)],'\x63\x74\x78':_0x167322});let _0xefb241;try{_0xefb241=await this['\x65\x78\x65\x63\x75\x74\x65\x54\x6f\x6f\x6c'](_0x167322);}catch(_0x47b110){_0xefb241={'\x63\x6f\x6e\x74\x65\x6e\x74':{'\x65\x72\x72\x6f\x72':_0x47b110 instanceof Error?_0x47b110[_0x1a4572(0x126)]:_0x4fede8[_0x1a4572(0x201)](String,_0x47b110)},'\x69\x73\x45\x72\x72\x6f\x72':!![]};}let _0x219d6f=_0xefb241;if(this[_0x1a4572(0x1ab)]&&_0x4fede8[_0x1a4572(0x288)](this[_0x1a4572(0x1ab)][_0x1a4572(0x179)],0x0)){const _0x311d08=await this['\x68\x6f\x6f\x6b\x73'][_0x1a4572(0x283)](_0x167322,_0xefb241);if(_0x4fede8[_0x1a4572(0xdf)](_0x311d08[_0x1a4572(0x11b)],_0x1a4572(0xfc)))return this['\x71\x75\x65\x75\x65'][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':_0x4fede8[_0x1a4572(0x1a5)],'\x63\x74\x78':_0x167322,'\x72\x65\x73\x75\x6c\x74':_0xefb241}),this[_0x1a4572(0x278)](_0x4fede8[_0x1a4572(0x21e)]),this[_0x1a4572(0x262)][_0x1a4572(0x1c0)]({'\x74\x79\x70\x65':'\x66\x61\x69\x6c\x65\x64','\x72\x65\x61\x73\x6f\x6e':_0x311d08[_0x1a4572(0x28b)]}),this['\x71\x75\x65\x75\x65'][_0x1a4572(0x23b)](),_0x1a4572(0xfc);if(_0x311d08[_0x1a4572(0x11b)]==='\x6f\x76\x65\x72\x72\x69\x64\x65')_0x219d6f=_0x311d08[_0x1a4572(0x241)];}return this[_0x1a4572(0x262)]['\x70\x75\x73\x68']({'\x74\x79\x70\x65':_0x1a4572(0x185),'\x63\x74\x78':_0x167322,'\x72\x65\x73\x75\x6c\x74':_0x219d6f}),_0x4fede8[_0x1a4572(0x1e6)];}};function outcomeToFinishReason(_0x4d3379,_0x4aff58){const _0x41e7eb=a0_0x15650e,_0x3d42e3={'\x4e\x4c\x4e\x62\x6c':_0x41e7eb(0x24f),'\x78\x44\x75\x73\x59':'\x73\x75\x63\x63\x65\x65\x64\x65\x64','\x4b\x6c\x62\x6a\x74':_0x41e7eb(0x19b),'\x68\x4d\x45\x67\x4f':'\x64\x6f\x6e\x65','\x48\x6f\x5a\x61\x70':_0x41e7eb(0x242),'\x53\x49\x4b\x47\x49':'\x6c\x65\x6e\x67\x74\x68'};switch(_0x4d3379){case _0x3d42e3['\x4e\x4c\x4e\x62\x6c']:case _0x3d42e3[_0x41e7eb(0xe3)]:case _0x3d42e3[_0x41e7eb(0x161)]:case _0x3d42e3[_0x41e7eb(0x135)]:return _0x4aff58?_0x41e7eb(0xea):_0x3d42e3[_0x41e7eb(0x220)];case'\x6c\x65\x6e\x67\x74\x68\x5f\x65\x78\x63\x65\x65\x64\x65\x64':case _0x41e7eb(0x132):case _0x41e7eb(0x295):return _0x3d42e3[_0x41e7eb(0x1e5)];case _0x41e7eb(0x116):case _0x41e7eb(0x1d2):case _0x41e7eb(0x24c):return _0x41e7eb(0x1d2);default:return _0x41e7eb(0x242);}}function readTokenDelta(_0xf1a38c){const _0x541e93=a0_0x15650e,_0xaec4bc={'\x6e\x50\x6f\x75\x65':function(_0x39c065,_0x189d7a){return _0x39c065===_0x189d7a;},'\x69\x71\x6b\x6b\x6b':function(_0x17c74b,_0x3e1ee5){return _0x17c74b===_0x3e1ee5;}};if(_0xaec4bc[_0x541e93(0x15c)](typeof _0xf1a38c['\x64\x65\x6c\x74\x61'],'\x73\x74\x72\x69\x6e\x67'))return _0xf1a38c[_0x541e93(0x163)];if(_0xaec4bc['\x69\x71\x6b\x6b\x6b'](typeof _0xf1a38c[_0x541e93(0x19f)],'\x73\x74\x72\x69\x6e\x67'))return _0xf1a38c['\x74\x65\x78\x74'];if(_0xaec4bc[_0x541e93(0x22d)](typeof _0xf1a38c[_0x541e93(0x227)],'\x73\x74\x72\x69\x6e\x67'))return _0xf1a38c[_0x541e93(0x227)];return null;}function readToolInvocation(_0x1733c5){const _0x4e7e9d=a0_0x15650e,_0x5046d6={'\x74\x54\x4b\x4f\x72':function(_0x1fdb47,_0x5b49e2){return _0x1fdb47===_0x5b49e2;},'\x54\x69\x4b\x70\x71':_0x4e7e9d(0x17d),'\x62\x4b\x71\x43\x42':_0x4e7e9d(0x29e),'\x44\x44\x4f\x4d\x53':function(_0x9cc33f,_0x164a71){return _0x9cc33f===_0x164a71;}};if(_0x1733c5[_0x4e7e9d(0x141)]!=='\x72\x61\x77')return null;const _0xf5c645=_0x1733c5[_0x4e7e9d(0x104)]??_0x1733c5,_0x12d0bc=typeof _0xf5c645[_0x4e7e9d(0x141)]===_0x4e7e9d(0x29e)?_0xf5c645[_0x4e7e9d(0x141)]:typeof _0x1733c5[_0x4e7e9d(0x141)]===_0x4e7e9d(0x29e)?_0x1733c5[_0x4e7e9d(0x141)]:'';if(!(_0x5046d6[_0x4e7e9d(0x1b4)](_0x12d0bc,_0x4e7e9d(0x164))||_0x5046d6['\x74\x54\x4b\x4f\x72'](_0x12d0bc,_0x4e7e9d(0x271))||typeof _0xf5c645[_0x4e7e9d(0x216)]===_0x5046d6[_0x4e7e9d(0x110)]||typeof _0xf5c645[_0x4e7e9d(0x26b)]===_0x4e7e9d(0x17d)))return null;const _0x3d3de9=_0xf5c645['\x74\x6f\x6f\x6c\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e']??_0xf5c645[_0x4e7e9d(0x26b)]??_0xf5c645,_0x55a500=typeof _0x3d3de9['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x49\x64']===_0x4e7e9d(0x29e)?_0x3d3de9[_0x4e7e9d(0x25b)]:typeof _0x3d3de9['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x5f\x69\x64']===_0x5046d6[_0x4e7e9d(0x1a3)]?_0x3d3de9[_0x4e7e9d(0x18a)]:typeof _0x3d3de9['\x69\x64']===_0x5046d6[_0x4e7e9d(0x1a3)]?_0x3d3de9['\x69\x64']:typeof _0x3d3de9['\x63\x61\x6c\x6c\x49\x64']===_0x5046d6[_0x4e7e9d(0x1a3)]?_0x3d3de9[_0x4e7e9d(0x206)]:'',_0x315fbe=typeof _0x3d3de9[_0x4e7e9d(0x16b)]===_0x4e7e9d(0x29e)?_0x3d3de9[_0x4e7e9d(0x16b)]:_0x5046d6[_0x4e7e9d(0x1b4)](typeof _0x3d3de9[_0x4e7e9d(0x25e)],_0x4e7e9d(0x29e))?_0x3d3de9[_0x4e7e9d(0x25e)]:typeof _0x3d3de9['\x6e\x61\x6d\x65']===_0x4e7e9d(0x29e)?_0x3d3de9[_0x4e7e9d(0x1b2)]:'',_0x1c1859=_0x3d3de9[_0x4e7e9d(0x29c)]??_0x3d3de9[_0x4e7e9d(0x1f5)]??_0x3d3de9[_0x4e7e9d(0x1be)]??{};if(!_0x55a500||!_0x315fbe)return null;return{'\x69\x64':_0x55a500,'\x6e\x61\x6d\x65':_0x315fbe,'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x5046d6[_0x4e7e9d(0x26f)](typeof _0x1c1859,_0x4e7e9d(0x29e))?_0x1c1859:JSON[_0x4e7e9d(0x21f)](_0x1c1859)};}function readUsage(_0x14b033){const _0x2cd4b1=a0_0x15650e,_0x496bc3={'\x42\x59\x41\x75\x62':function(_0x203d7f,_0x4b4290){return _0x203d7f(_0x4b4290);},'\x71\x51\x46\x41\x46':function(_0x309ef0,_0x3e4053){return _0x309ef0+_0x3e4053;}},_0x29bbff=_0x14b033[_0x2cd4b1(0x2a6)]??_0x14b033,_0x1fa7d5=_0x496bc3[_0x2cd4b1(0x120)](Number,_0x29bbff[_0x2cd4b1(0x17f)]??_0x29bbff['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x29bbff['\x69\x6e\x70\x75\x74\x54\x6f\x6b\x65\x6e\x73']??0x0),_0x185230=Number(_0x29bbff['\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x29bbff[_0x2cd4b1(0x1ec)]??_0x29bbff[_0x2cd4b1(0x18c)]??0x0);if(_0x1fa7d5===0x0&&_0x185230===0x0)return null;return{'\x70\x72\x6f\x6d\x70\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x1fa7d5,'\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e\x5f\x74\x6f\x6b\x65\x6e\x73':_0x185230,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':Number(_0x29bbff[_0x2cd4b1(0xef)]??_0x496bc3[_0x2cd4b1(0x1f2)](_0x1fa7d5,_0x185230))};}function readOutcome(_0xa4c70a){const _0x30a2c3=a0_0x15650e,_0x159618={'\x78\x75\x46\x64\x79':_0x30a2c3(0x29e),'\x6e\x7a\x67\x56\x59':function(_0x3e5adb,_0x4584ce){return _0x3e5adb===_0x4584ce;},'\x45\x77\x69\x7a\x4e':'\x73\x75\x63\x63\x65\x73\x73'};if(typeof _0xa4c70a[_0x30a2c3(0x1d0)]===_0x159618[_0x30a2c3(0x148)])return _0xa4c70a['\x6f\x75\x74\x63\x6f\x6d\x65'];if(_0x159618[_0x30a2c3(0x1eb)](typeof _0xa4c70a[_0x30a2c3(0x13f)],_0x159618[_0x30a2c3(0x148)]))return _0xa4c70a[_0x30a2c3(0x13f)];if(_0xa4c70a[_0x30a2c3(0x24f)]===![])return _0x30a2c3(0x1cd);return _0x159618[_0x30a2c3(0x1a4)];}function chatBaseChunk(_0x51fe9c){const _0x4cc8af=a0_0x15650e,_0x1bab17={'\x6a\x5a\x46\x6a\x4f':'\x63\x68\x61\x74\x2e\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e\x2e\x63\x68\x75\x6e\x6b'};return _0x51fe9c[_0x4cc8af(0x181)]+=0x1,{'\x69\x64':_0x51fe9c[_0x4cc8af(0xf9)],'\x63\x72\x65\x61\x74\x65\x64':_0x51fe9c[_0x4cc8af(0x12b)],'\x6d\x6f\x64\x65\x6c':_0x51fe9c['\x6d\x6f\x64\x65\x6c\x49\x64'],'\x6f\x62\x6a\x65\x63\x74':_0x1bab17[_0x4cc8af(0x298)]};}function sandboxEventToChatChunk(_0xda4bb3,_0x16d2e9){const _0x1d3585=a0_0x15650e,_0x25b35f={'\x69\x72\x52\x68\x67':_0x1d3585(0xe6),'\x7a\x45\x4c\x76\x42':_0x1d3585(0x258),'\x43\x50\x65\x66\x75':_0x1d3585(0x13f),'\x6d\x71\x42\x48\x50':_0x1d3585(0xe2),'\x4f\x46\x54\x4f\x6f':_0x1d3585(0x227),'\x77\x67\x6c\x75\x50':function(_0x1f38fc,_0x5abe3f){return _0x1f38fc(_0x5abe3f);},'\x58\x50\x42\x72\x58':function(_0x435821,_0x22452e){return _0x435821===_0x22452e;},'\x68\x6c\x79\x61\x41':_0x1d3585(0x1e3),'\x56\x42\x71\x76\x46':'\x66\x75\x6e\x63\x74\x69\x6f\x6e','\x70\x76\x61\x74\x62':'\x65\x72\x72\x6f\x72','\x76\x53\x57\x4b\x6b':function(_0x20a43a,_0x354c7c,_0x528611){return _0x20a43a(_0x354c7c,_0x528611);}};switch(_0xda4bb3[_0x1d3585(0x141)]){case _0x25b35f[_0x1d3585(0x113)]:return null;case _0x25b35f[_0x1d3585(0x134)]:return null;case _0x25b35f[_0x1d3585(0x28f)]:return null;case _0x25b35f['\x6d\x71\x42\x48\x50']:return null;case'\x6d\x65\x73\x73\x61\x67\x65\x2e\x70\x61\x72\x74\x2e\x75\x70\x64\x61\x74\x65\x64':return null;case _0x25b35f[_0x1d3585(0x117)]:{const _0x57a014=_0x25b35f[_0x1d3585(0x1cb)](readTokenDelta,_0xda4bb3);if(_0x57a014==null||_0x25b35f[_0x1d3585(0xfa)](_0x57a014[_0x1d3585(0x132)],0x0))return null;return{...chatBaseChunk(_0x16d2e9),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{'\x72\x6f\x6c\x65':_0x1d3585(0x1e3),'\x63\x6f\x6e\x74\x65\x6e\x74':_0x57a014},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null}]};}case _0x1d3585(0x27a):{const _0x271cce=readToolInvocation(_0xda4bb3);if(!_0x271cce)return null;const _0x1b81f8=_0x16d2e9[_0x1d3585(0x268)][_0x1d3585(0xf5)](_0x271cce['\x69\x64']),_0x169209=_0x1b81f8?_0x1b81f8[_0x1d3585(0x214)]:_0x16d2e9[_0x1d3585(0x268)][_0x1d3585(0x179)];return _0x16d2e9[_0x1d3585(0x268)][_0x1d3585(0x280)](_0x271cce['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0x169209,'\x69\x64':_0x271cce['\x69\x64'],'\x6e\x61\x6d\x65':_0x271cce[_0x1d3585(0x1b2)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x271cce[_0x1d3585(0x1f5)]}),{...chatBaseChunk(_0x16d2e9),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{'\x72\x6f\x6c\x65':_0x25b35f[_0x1d3585(0x13d)],'\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73':[{'\x69\x6e\x64\x65\x78':_0x169209,'\x69\x64':_0x271cce['\x69\x64'],'\x74\x79\x70\x65':_0x25b35f[_0x1d3585(0x160)],'\x66\x75\x6e\x63\x74\x69\x6f\x6e':{'\x6e\x61\x6d\x65':_0x271cce['\x6e\x61\x6d\x65'],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x271cce[_0x1d3585(0x1f5)]}}]},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null}]};}case _0x25b35f[_0x1d3585(0x12a)]:{const _0x5c3636=_0x16d2e9['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x1d3585(0x179)]>0x0;return{...chatBaseChunk(_0x16d2e9),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':outcomeToFinishReason(_0x25b35f[_0x1d3585(0x12a)],_0x5c3636)}]};}case _0x1d3585(0x194):{const _0x24f7c1=_0x16d2e9[_0x1d3585(0x268)][_0x1d3585(0x179)]>0x0,_0x45557c=_0x25b35f[_0x1d3585(0x25d)](outcomeToFinishReason,readOutcome(_0xda4bb3),_0x24f7c1),_0x9b3d06=readUsage(_0xda4bb3),_0x32baad={...chatBaseChunk(_0x16d2e9),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':_0x45557c}]};if(_0x9b3d06)_0x32baad[_0x1d3585(0x2a6)]=_0x9b3d06;return _0x32baad;}default:return null;}}function completionBaseChunk(_0x4184fb){const _0x56da75=a0_0x15650e,_0x35892b={'\x78\x72\x47\x5a\x61':_0x56da75(0x122)};return _0x4184fb[_0x56da75(0x181)]+=0x1,{'\x69\x64':_0x4184fb[_0x56da75(0xf9)],'\x63\x72\x65\x61\x74\x65\x64':_0x4184fb[_0x56da75(0x12b)],'\x6d\x6f\x64\x65\x6c':_0x4184fb[_0x56da75(0x176)],'\x6f\x62\x6a\x65\x63\x74':_0x35892b['\x78\x72\x47\x5a\x61']};}function sandboxEventToCompletionChunk(_0x4b01f7,_0x18555a){const _0x11a393=a0_0x15650e,_0x43f864={'\x74\x54\x46\x58\x72':_0x11a393(0xe6),'\x51\x54\x75\x6e\x71':_0x11a393(0x258),'\x51\x6b\x63\x48\x74':function(_0x298fcd,_0x536735){return _0x298fcd(_0x536735);},'\x48\x42\x5a\x56\x5a':function(_0x44bf28,_0x2da8a0){return _0x44bf28==_0x2da8a0;},'\x6c\x64\x6a\x42\x6c':function(_0xf5f8a2,_0x32aa05){return _0xf5f8a2===_0x32aa05;},'\x6e\x46\x46\x44\x62':function(_0x1b4c5f,_0x13639f){return _0x1b4c5f===_0x13639f;},'\x6b\x4d\x4f\x4c\x4f':_0x11a393(0x18e)};switch(_0x4b01f7['\x74\x79\x70\x65']){case _0x43f864['\x74\x54\x46\x58\x72']:case _0x43f864[_0x11a393(0x11c)]:case _0x11a393(0x13f):case _0x11a393(0xe2):case _0x11a393(0x2a0):case _0x11a393(0x27a):if(_0x4b01f7[_0x11a393(0x141)]===_0x11a393(0x27a)){const _0x457269=readToolInvocation(_0x4b01f7);if(_0x457269){const _0x3a32c8=_0x18555a[_0x11a393(0x268)][_0x11a393(0xf5)](_0x457269['\x69\x64']),_0x4b1666=_0x3a32c8?_0x3a32c8['\x69\x6e\x64\x65\x78']:_0x18555a[_0x11a393(0x268)][_0x11a393(0x179)];_0x18555a[_0x11a393(0x268)][_0x11a393(0x280)](_0x457269['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0x4b1666,'\x69\x64':_0x457269['\x69\x64'],'\x6e\x61\x6d\x65':_0x457269[_0x11a393(0x1b2)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x457269[_0x11a393(0x1f5)]});}}return null;case _0x11a393(0x227):{const _0xcd7fff=_0x43f864['\x51\x6b\x63\x48\x74'](readTokenDelta,_0x4b01f7);if(_0x43f864[_0x11a393(0x246)](_0xcd7fff,null)||_0x43f864[_0x11a393(0x15a)](_0xcd7fff[_0x11a393(0x132)],0x0))return null;return{...completionBaseChunk(_0x18555a),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x74\x65\x78\x74':_0xcd7fff,'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null,'\x6c\x6f\x67\x70\x72\x6f\x62\x73':null}]};}case _0x11a393(0x18e):case _0x11a393(0x194):{const _0x4ed41b=outcomeToFinishReason(_0x43f864[_0x11a393(0x10c)](_0x4b01f7[_0x11a393(0x141)],_0x43f864['\x6b\x4d\x4f\x4c\x4f'])?_0x11a393(0x18e):readOutcome(_0x4b01f7),![]),_0x44cace=_0x4ed41b===_0x11a393(0xea)?_0x11a393(0x242):_0x4ed41b,_0x3ab1ce=readUsage(_0x4b01f7),_0x30ae82={...completionBaseChunk(_0x18555a),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x74\x65\x78\x74':'','\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':_0x44cace,'\x6c\x6f\x67\x70\x72\x6f\x62\x73':null}]};if(_0x3ab1ce)_0x30ae82['\x75\x73\x61\x67\x65']=_0x3ab1ce;return _0x30ae82;}default:return null;}}function getResponsesExtras(_0x2b7710){const _0x13ee5d=a0_0x15650e,_0x1ee11c=_0x2b7710;if(!_0x1ee11c['\x5f\x5f\x72\x65\x73\x70\x6f\x6e\x73\x65\x73\x45\x78\x74\x72\x61\x73'])_0x1ee11c[_0x13ee5d(0x250)]={'\x73\x65\x71\x75\x65\x6e\x63\x65':0x0,'\x74\x6f\x6f\x6c\x4f\x75\x74\x70\x75\x74\x49\x6e\x64\x65\x78':new Map()};return _0x1ee11c['\x5f\x5f\x72\x65\x73\x70\x6f\x6e\x73\x65\x73\x45\x78\x74\x72\x61\x73'];}function nextSeq(_0x32e040){const _0x55ff1d=a0_0x15650e;return _0x32e040[_0x55ff1d(0x228)]+=0x1,_0x32e040['\x73\x65\x71\x75\x65\x6e\x63\x65'];}function emptyResponseUsage(){return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73':0x0},'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x5f\x74\x6f\x6b\x65\x6e\x73':0x0}};}function usageFromTokens(_0x5c8f55){const _0x1fc418=a0_0x15650e;return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x5c8f55[_0x1fc418(0x17f)],'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x5c8f55['\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e\x5f\x74\x6f\x6b\x65\x6e\x73'],'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x5c8f55['\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73'],'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73':0x0},'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x5f\x74\x6f\x6b\x65\x6e\x73':0x0}};}function sandboxEventToResponsesEvent(_0x5c3fe1,_0x1252bc){const _0x23f1cc=a0_0x15650e,_0x1eb880={'\x6d\x67\x76\x4f\x79':function(_0x425d74,_0x4cc3da){return _0x425d74(_0x4cc3da);},'\x6d\x56\x61\x41\x6f':_0x23f1cc(0x13f),'\x45\x57\x57\x6c\x49':_0x23f1cc(0x2a0),'\x63\x61\x66\x48\x6c':_0x23f1cc(0x227),'\x5a\x50\x4a\x50\x4b':function(_0x407f37,_0x4925c2){return _0x407f37==_0x4925c2;},'\x6b\x4e\x61\x79\x67':_0x23f1cc(0x1a0),'\x58\x7a\x5a\x65\x59':_0x23f1cc(0x126),'\x52\x58\x76\x68\x76':function(_0x401a6e,_0x41f5ea){return _0x401a6e(_0x41f5ea);},'\x65\x6e\x48\x73\x48':function(_0x49c240,_0x12aae7){return _0x49c240(_0x12aae7);},'\x4d\x68\x43\x52\x71':_0x23f1cc(0x277)},_0x4737e9=_0x1eb880[_0x23f1cc(0x159)](getResponsesExtras,_0x1252bc);switch(_0x5c3fe1[_0x23f1cc(0x141)]){case _0x23f1cc(0xe6):return null;case'\x65\x78\x65\x63\x75\x74\x69\x6f\x6e\x2e\x73\x74\x61\x72\x74\x65\x64':return null;case _0x1eb880[_0x23f1cc(0x23c)]:return null;case _0x23f1cc(0xe2):return null;case _0x1eb880[_0x23f1cc(0x11a)]:return null;case _0x1eb880[_0x23f1cc(0x174)]:{const _0x424a46=readTokenDelta(_0x5c3fe1);if(_0x1eb880[_0x23f1cc(0x16f)](_0x424a46,null)||_0x424a46[_0x23f1cc(0x132)]===0x0)return null;_0x1252bc[_0x23f1cc(0x181)]+=0x1;if(_0x4737e9['\x6d\x65\x73\x73\x61\x67\x65\x4f\x75\x74\x70\x75\x74\x49\x6e\x64\x65\x78']===void 0x0)_0x4737e9[_0x23f1cc(0x221)]=_0x1252bc[_0x23f1cc(0x268)]['\x73\x69\x7a\x65'];return{'\x74\x79\x70\x65':_0x1eb880['\x6b\x4e\x61\x79\x67'],'\x63\x6f\x6e\x74\x65\x6e\x74\x5f\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':_0x424a46,'\x69\x74\x65\x6d\x5f\x69\x64':_0x23f1cc(0xf3)+_0x1252bc[_0x23f1cc(0xf9)],'\x6c\x6f\x67\x70\x72\x6f\x62\x73':[],'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x4737e9[_0x23f1cc(0x221)],'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':nextSeq(_0x4737e9)};}case _0x23f1cc(0x27a):{const _0x2aa6aa=readToolInvocation(_0x5c3fe1);if(!_0x2aa6aa)return null;_0x1252bc[_0x23f1cc(0x181)]+=0x1;const _0x574fd0=_0x1252bc[_0x23f1cc(0x268)][_0x23f1cc(0xf5)](_0x2aa6aa['\x69\x64']),_0x540210=_0x574fd0?_0x574fd0[_0x23f1cc(0x214)]:_0x1252bc[_0x23f1cc(0x268)][_0x23f1cc(0x179)];_0x1252bc['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x23f1cc(0x280)](_0x2aa6aa['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0x540210,'\x69\x64':_0x2aa6aa['\x69\x64'],'\x6e\x61\x6d\x65':_0x2aa6aa['\x6e\x61\x6d\x65'],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x2aa6aa[_0x23f1cc(0x1f5)]});const _0x4b8ab1=_0x4737e9['\x74\x6f\x6f\x6c\x4f\x75\x74\x70\x75\x74\x49\x6e\x64\x65\x78']['\x67\x65\x74'](_0x2aa6aa['\x69\x64'])??_0x4737e9[_0x23f1cc(0x137)][_0x23f1cc(0x179)];return _0x4737e9[_0x23f1cc(0x137)]['\x73\x65\x74'](_0x2aa6aa['\x69\x64'],_0x4b8ab1),{'\x74\x79\x70\x65':'\x72\x65\x73\x70\x6f\x6e\x73\x65\x2e\x6f\x75\x74\x70\x75\x74\x5f\x69\x74\x65\x6d\x2e\x61\x64\x64\x65\x64','\x69\x74\x65\x6d':{'\x74\x79\x70\x65':_0x23f1cc(0x128),'\x69\x64':'\x66\x63\x5f'+_0x2aa6aa['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0x2aa6aa['\x69\x64'],'\x6e\x61\x6d\x65':_0x2aa6aa[_0x23f1cc(0x1b2)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x2aa6aa[_0x23f1cc(0x1f5)],'\x73\x74\x61\x74\x75\x73':_0x23f1cc(0x19b)},'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x4b8ab1,'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':nextSeq(_0x4737e9)};}case _0x23f1cc(0x18e):{const _0x8e9a2=_0x4737e9[_0x23f1cc(0x221)]??0x0;return{'\x74\x79\x70\x65':_0x23f1cc(0x1a6),'\x69\x74\x65\x6d':{'\x74\x79\x70\x65':_0x1eb880[_0x23f1cc(0x232)],'\x69\x64':_0x23f1cc(0xf3)+_0x1252bc[_0x23f1cc(0xf9)],'\x72\x6f\x6c\x65':_0x23f1cc(0x1e3),'\x73\x74\x61\x74\x75\x73':_0x23f1cc(0x192),'\x63\x6f\x6e\x74\x65\x6e\x74':[]},'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x8e9a2,'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':_0x1eb880[_0x23f1cc(0x2a3)](nextSeq,_0x4737e9)};}case'\x64\x6f\x6e\x65':{const _0x408a6f=_0x1eb880[_0x23f1cc(0x12c)](readUsage,_0x5c3fe1),_0x38bcf6=_0x408a6f?_0x1eb880[_0x23f1cc(0x159)](usageFromTokens,_0x408a6f):emptyResponseUsage();return{'\x74\x79\x70\x65':_0x23f1cc(0xec),'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':nextSeq(_0x4737e9),'\x72\x65\x73\x70\x6f\x6e\x73\x65':{'\x69\x64':_0x1252bc[_0x23f1cc(0xf9)],'\x6f\x62\x6a\x65\x63\x74':_0x1eb880[_0x23f1cc(0x279)],'\x63\x72\x65\x61\x74\x65\x64\x5f\x61\x74':_0x1252bc[_0x23f1cc(0x12b)],'\x6f\x75\x74\x70\x75\x74\x5f\x74\x65\x78\x74':'','\x65\x72\x72\x6f\x72':null,'\x69\x6e\x63\x6f\x6d\x70\x6c\x65\x74\x65\x5f\x64\x65\x74\x61\x69\x6c\x73':null,'\x69\x6e\x73\x74\x72\x75\x63\x74\x69\x6f\x6e\x73':null,'\x6d\x65\x74\x61\x64\x61\x74\x61':null,'\x6d\x6f\x64\x65\x6c':_0x1252bc[_0x23f1cc(0x176)],'\x6f\x75\x74\x70\x75\x74':[],'\x70\x61\x72\x61\x6c\x6c\x65\x6c\x5f\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73':![],'\x74\x65\x6d\x70\x65\x72\x61\x74\x75\x72\x65':null,'\x74\x6f\x6f\x6c\x5f\x63\x68\x6f\x69\x63\x65':'\x61\x75\x74\x6f','\x74\x6f\x6f\x6c\x73':[],'\x74\x6f\x70\x5f\x70':null,'\x73\x74\x61\x74\x75\x73':_0x23f1cc(0x19b),'\x75\x73\x61\x67\x65':_0x38bcf6}};}default:return null;}}var EmbeddingValidationError=class extends Error{['\x74\x79\x70\x65']='\x69\x6e\x76\x61\x6c\x69\x64\x5f\x72\x65\x71\x75\x65\x73\x74\x5f\x65\x72\x72\x6f\x72';['\x63\x6f\x64\x65'];['\x70\x61\x72\x61\x6d'];constructor(_0xad7f2b,_0x363a2,_0x1a19e0){const _0x3d4594=a0_0x15650e;super(_0xad7f2b),this['\x6e\x61\x6d\x65']=_0x3d4594(0x158),this[_0x3d4594(0x188)]=_0x363a2,this[_0x3d4594(0x14b)]=_0x1a19e0;}};const MAX_BATCH=0x800;function reject(_0x4020b6,_0x5a9449,_0x3427eb){throw new EmbeddingValidationError(_0x4020b6,_0x5a9449,_0x3427eb);}function normalizeInput(_0x332cdb){const _0x3f80d3=a0_0x15650e,_0x1716b6={'\x6f\x53\x74\x6a\x6a':function(_0x22b064,_0x3672fd,_0x22f809,_0x4b1dff){return _0x22b064(_0x3672fd,_0x22f809,_0x4b1dff);},'\x4f\x55\x57\x74\x61':_0x3f80d3(0x28d),'\x75\x48\x6b\x55\x44':_0x3f80d3(0x1be),'\x48\x64\x7a\x6a\x74':_0x3f80d3(0x23f),'\x73\x77\x57\x54\x45':_0x3f80d3(0x229),'\x42\x6c\x6e\x4e\x42':function(_0x3492db,_0x5d5fe9){return _0x3492db>_0x5d5fe9;},'\x78\x70\x66\x79\x64':_0x3f80d3(0x1a7),'\x6f\x75\x66\x76\x53':_0x3f80d3(0x29e),'\x4f\x74\x4e\x4a\x71':function(_0x3ecedb,_0x1046ba){return _0x3ecedb<_0x1046ba;},'\x6c\x56\x65\x58\x62':function(_0x2268d7,_0x2b62b9){return _0x2268d7!==_0x2b62b9;},'\x44\x63\x77\x53\x4e':function(_0x4d72c7,_0x48f8a4,_0x512686,_0xce3518){return _0x4d72c7(_0x48f8a4,_0x512686,_0xce3518);},'\x74\x51\x6b\x75\x48':_0x3f80d3(0x17a),'\x4b\x70\x6e\x7a\x45':function(_0x20e52d,_0x2f83b2){return _0x20e52d===_0x2f83b2;},'\x4c\x4b\x67\x44\x63':function(_0x291121,_0x4cd87e,_0x45de4b,_0x2bb811){return _0x291121(_0x4cd87e,_0x45de4b,_0x2bb811);},'\x58\x59\x63\x75\x53':_0x3f80d3(0x19f),'\x44\x53\x4b\x45\x43':_0x3f80d3(0x1ea),'\x68\x69\x74\x77\x52':_0x3f80d3(0x20e),'\x79\x78\x46\x78\x69':function(_0x28ab26,_0x41f80d,_0x27668c,_0x29a5a1){return _0x28ab26(_0x41f80d,_0x27668c,_0x29a5a1);},'\x56\x5a\x7a\x49\x61':function(_0x48e2c5,_0x2e1607){return _0x48e2c5<_0x2e1607;},'\x71\x44\x52\x53\x57':_0x3f80d3(0x187)};if(typeof _0x332cdb===_0x3f80d3(0x29e)){if(_0x332cdb[_0x3f80d3(0x132)]===0x0)_0x1716b6['\x6f\x53\x74\x6a\x6a'](reject,_0x3f80d3(0x1dc),_0x1716b6[_0x3f80d3(0x29d)],_0x1716b6[_0x3f80d3(0x1ce)]);return{'\x6b\x69\x6e\x64':'\x74\x65\x78\x74','\x76\x61\x6c\x75\x65\x73':[_0x332cdb]};}if(!Array[_0x3f80d3(0x153)](_0x332cdb))_0x1716b6[_0x3f80d3(0x274)](reject,_0x3f80d3(0x1e0),_0x1716b6[_0x3f80d3(0x115)],_0x3f80d3(0x1be));if(_0x332cdb['\x6c\x65\x6e\x67\x74\x68']===0x0)reject(_0x1716b6[_0x3f80d3(0x155)],_0x1716b6[_0x3f80d3(0x29d)],_0x3f80d3(0x1be));if(_0x1716b6[_0x3f80d3(0x111)](_0x332cdb[_0x3f80d3(0x132)],MAX_BATCH))reject('\x49\x6e\x70\x75\x74\x20\x61\x72\x72\x61\x79\x20\x65\x78\x63\x65\x65\x64\x73\x20\x6d\x61\x78\x69\x6d\x75\x6d\x20\x62\x61\x74\x63\x68\x20\x73\x69\x7a\x65\x20\x6f\x66\x20'+MAX_BATCH,_0x1716b6[_0x3f80d3(0x1dd)],_0x1716b6[_0x3f80d3(0x1ce)]);const _0x1038a7=_0x332cdb[0x0];if(typeof _0x1038a7===_0x1716b6[_0x3f80d3(0x286)]){const _0x4da83f=[];for(let _0x1e6241=0x0;_0x1716b6[_0x3f80d3(0x196)](_0x1e6241,_0x332cdb[_0x3f80d3(0x132)]);_0x1e6241++){const _0x48dd66=_0x332cdb[_0x1e6241];if(_0x1716b6['\x6c\x56\x65\x58\x62'](typeof _0x48dd66,_0x3f80d3(0x29e)))_0x1716b6[_0x3f80d3(0x14a)](reject,_0x3f80d3(0x14e)+_0x1e6241+'\x20\x69\x73\x20\x6e\x6f\x74\x20\x61\x20\x73\x74\x72\x69\x6e\x67',_0x1716b6[_0x3f80d3(0x133)],_0x1716b6[_0x3f80d3(0x1ce)]);if(_0x1716b6[_0x3f80d3(0x211)](_0x48dd66[_0x3f80d3(0x132)],0x0))_0x1716b6['\x4c\x4b\x67\x44\x63'](reject,_0x3f80d3(0x127)+_0x1e6241+'\x20\x6d\x75\x73\x74\x20\x6e\x6f\x74\x20\x62\x65\x20\x65\x6d\x70\x74\x79','\x65\x6d\x70\x74\x79\x5f\x69\x6e\x70\x75\x74',_0x1716b6[_0x3f80d3(0x1ce)]);_0x4da83f[_0x3f80d3(0x1c0)](_0x48dd66);}return{'\x6b\x69\x6e\x64':_0x1716b6[_0x3f80d3(0x108)],'\x76\x61\x6c\x75\x65\x73':_0x4da83f};}if(typeof _0x1038a7===_0x3f80d3(0x187)){for(let _0x3c862e=0x0;_0x3c862e<_0x332cdb[_0x3f80d3(0x132)];_0x3c862e++)if(typeof _0x332cdb[_0x3c862e]!=='\x6e\x75\x6d\x62\x65\x72')reject(_0x3f80d3(0x2a5)+_0x3c862e+_0x3f80d3(0x289)+typeof _0x332cdb[_0x3c862e],_0x1716b6['\x44\x53\x4b\x45\x43'],_0x3f80d3(0x1be));return{'\x6b\x69\x6e\x64':_0x1716b6[_0x3f80d3(0x16d)],'\x76\x61\x6c\x75\x65\x73':[_0x332cdb]};}if(Array[_0x3f80d3(0x153)](_0x1038a7)){const _0x1d4393=[];for(let _0x183d5d=0x0;_0x183d5d<_0x332cdb[_0x3f80d3(0x132)];_0x183d5d++){const _0x4c9da9=_0x332cdb[_0x183d5d];if(!Array[_0x3f80d3(0x153)](_0x4c9da9))_0x1716b6[_0x3f80d3(0x165)](reject,'\x49\x6e\x70\x75\x74\x20\x61\x72\x72\x61\x79\x20\x6d\x75\x73\x74\x20\x62\x65\x20\x68\x6f\x6d\x6f\x67\x65\x6e\x65\x6f\x75\x73\x3b\x20\x69\x6e\x64\x65\x78\x20'+_0x183d5d+'\x20\x69\x73\x20\x6e\x6f\x74\x20\x61\x6e\x20\x61\x72\x72\x61\x79',_0x1716b6[_0x3f80d3(0x133)],_0x3f80d3(0x1be));if(_0x4c9da9['\x6c\x65\x6e\x67\x74\x68']===0x0)reject(_0x3f80d3(0x1ad)+_0x183d5d+_0x3f80d3(0xf2),_0x1716b6['\x4f\x55\x57\x74\x61'],_0x1716b6[_0x3f80d3(0x1ce)]);for(let _0x13e325=0x0;_0x1716b6[_0x3f80d3(0xf4)](_0x13e325,_0x4c9da9[_0x3f80d3(0x132)]);_0x13e325++)if(typeof _0x4c9da9[_0x13e325]!==_0x1716b6['\x71\x44\x52\x53\x57'])_0x1716b6['\x4c\x4b\x67\x44\x63'](reject,_0x3f80d3(0x1ad)+_0x183d5d+_0x3f80d3(0xdb)+_0x13e325+'\x20\x69\x73\x20'+typeof _0x4c9da9[_0x13e325],_0x1716b6[_0x3f80d3(0x107)],_0x1716b6[_0x3f80d3(0x1ce)]);_0x1d4393[_0x3f80d3(0x1c0)](_0x4c9da9);}return{'\x6b\x69\x6e\x64':_0x3f80d3(0x20e),'\x76\x61\x6c\x75\x65\x73':_0x1d4393};}reject('\x49\x6e\x70\x75\x74\x20\x6d\x75\x73\x74\x20\x62\x65\x20\x61\x20\x73\x74\x72\x69\x6e\x67\x2c\x20\x61\x72\x72\x61\x79\x20\x6f\x66\x20\x73\x74\x72\x69\x6e\x67\x73\x2c\x20\x6f\x72\x20\x61\x72\x72\x61\x79\x20\x6f\x66\x20\x74\x6f\x6b\x65\x6e\x20\x61\x72\x72\x61\x79\x73',_0x1716b6[_0x3f80d3(0x115)],_0x3f80d3(0x1be));}function validateEmbeddingRequest(_0x49ab87){const _0x2a9dda=a0_0x15650e,_0x3064e5={'\x75\x7a\x6c\x4a\x52':function(_0x1fb3cc,_0x3e2a53,_0x3b1d22,_0x22a9a0){return _0x1fb3cc(_0x3e2a53,_0x3b1d22,_0x22a9a0);},'\x48\x49\x4a\x7a\x47':function(_0x1940a3,_0xcb0d3a){return _0x1940a3!==_0xcb0d3a;},'\x7a\x50\x76\x4e\x47':'\x73\x74\x72\x69\x6e\x67','\x43\x6a\x78\x66\x50':function(_0x35ebbd,_0x49e679){return _0x35ebbd===_0x49e679;},'\x69\x49\x79\x53\x56':'\x4d\x6f\x64\x65\x6c\x20\x69\x73\x20\x72\x65\x71\x75\x69\x72\x65\x64','\x4e\x4b\x62\x64\x77':'\x65\x6e\x63\x6f\x64\x69\x6e\x67\x5f\x66\x6f\x72\x6d\x61\x74\x20\x6d\x75\x73\x74\x20\x62\x65\x20\x27\x66\x6c\x6f\x61\x74\x27\x20\x6f\x72\x20\x27\x62\x61\x73\x65\x36\x34\x27'};if(!_0x49ab87||typeof _0x49ab87!=='\x6f\x62\x6a\x65\x63\x74')_0x3064e5[_0x2a9dda(0x119)](reject,_0x2a9dda(0x1e8),_0x2a9dda(0x11e),void 0x0);if(_0x3064e5[_0x2a9dda(0x22e)](typeof _0x49ab87['\x6d\x6f\x64\x65\x6c'],_0x3064e5['\x7a\x50\x76\x4e\x47'])||_0x3064e5[_0x2a9dda(0x208)](_0x49ab87[_0x2a9dda(0xf7)][_0x2a9dda(0x132)],0x0))_0x3064e5[_0x2a9dda(0x119)](reject,_0x3064e5[_0x2a9dda(0x25c)],_0x2a9dda(0x1b9),_0x2a9dda(0xf7));if(_0x49ab87['\x64\x69\x6d\x65\x6e\x73\x69\x6f\x6e\x73']!==void 0x0){if(typeof _0x49ab87[_0x2a9dda(0x293)]!=='\x6e\x75\x6d\x62\x65\x72'||!Number['\x69\x73\x49\x6e\x74\x65\x67\x65\x72'](_0x49ab87[_0x2a9dda(0x293)])||_0x49ab87[_0x2a9dda(0x293)]<=0x0)reject(_0x2a9dda(0x15f),_0x2a9dda(0x193),_0x2a9dda(0x293));}const _0x29eb30=_0x49ab87[_0x2a9dda(0x226)]??'\x66\x6c\x6f\x61\x74';if(_0x29eb30!=='\x66\x6c\x6f\x61\x74'&&_0x3064e5[_0x2a9dda(0x22e)](_0x29eb30,_0x2a9dda(0x13c)))reject(_0x3064e5['\x4e\x4b\x62\x64\x77'],_0x2a9dda(0x19a),'\x65\x6e\x63\x6f\x64\x69\x6e\x67\x5f\x66\x6f\x72\x6d\x61\x74');const _0x6b548c=normalizeInput(_0x49ab87[_0x2a9dda(0x1be)]),_0x15254c={'\x6d\x6f\x64\x65\x6c':_0x49ab87[_0x2a9dda(0xf7)],'\x69\x6e\x70\x75\x74':_0x6b548c,'\x65\x6e\x63\x6f\x64\x69\x6e\x67\x46\x6f\x72\x6d\x61\x74':_0x29eb30};if(_0x3064e5['\x48\x49\x4a\x7a\x47'](_0x49ab87[_0x2a9dda(0x293)],void 0x0))_0x15254c[_0x2a9dda(0x293)]=_0x49ab87[_0x2a9dda(0x293)];if(_0x49ab87['\x75\x73\x65\x72']!==void 0x0)_0x15254c[_0x2a9dda(0x195)]=_0x49ab87[_0x2a9dda(0x195)];return _0x15254c;}function resolveProviderId(_0x2d1cfd){const _0x375655=a0_0x15650e,_0x1ddf20={'\x4c\x55\x49\x67\x57':function(_0x2861a9,_0x28d670){return _0x2861a9===_0x28d670;}},_0x5aaabc=_0x2d1cfd['\x74\x72\x69\x6d'](),_0x3cd67b=_0x5aaabc[_0x375655(0xe7)](_0x375655(0x1fb))?_0x5aaabc[_0x375655(0x168)](0x7):_0x5aaabc;if(!_0x3cd67b)throw new Error(_0x375655(0x10f)+JSON[_0x375655(0x21f)](_0x2d1cfd));const _0x4a36f8=_0x3cd67b['\x69\x6e\x64\x65\x78\x4f\x66']('\x2f');if(_0x1ddf20[_0x375655(0x16c)](_0x4a36f8,-0x1))return{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x3cd67b};const _0x49fe0b=_0x3cd67b[_0x375655(0x168)](0x0,_0x4a36f8),_0x2446d0=_0x3cd67b[_0x375655(0x168)](_0x4a36f8+0x1);if(!_0x49fe0b||!_0x2446d0)throw new Error(_0x375655(0x10f)+JSON[_0x375655(0x21f)](_0x2d1cfd));return{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x49fe0b,'\x76\x61\x72\x69\x61\x6e\x74':_0x2446d0};}function normalizeContent(_0x1bc1b0){const _0x5f70c4=a0_0x15650e,_0x292b54={'\x56\x6d\x6f\x73\x76':function(_0x3472d6,_0x56c1f1){return _0x3472d6==_0x56c1f1;},'\x56\x4e\x70\x6f\x4e':function(_0x19a8df,_0x11813e){return _0x19a8df===_0x11813e;}};if(_0x292b54[_0x5f70c4(0x1e1)](_0x1bc1b0,null))return{'\x74\x65\x78\x74':'','\x70\x61\x72\x74\x73':[]};if(typeof _0x1bc1b0===_0x5f70c4(0x29e))return{'\x74\x65\x78\x74':_0x1bc1b0,'\x70\x61\x72\x74\x73':[]};const _0x5eb2c3=[],_0x35022e=[];for(const _0x390568 of _0x1bc1b0)if(_0x390568['\x74\x79\x70\x65']===_0x5f70c4(0x19f))_0x35022e[_0x5f70c4(0x1c0)](_0x390568[_0x5f70c4(0x19f)]),_0x5eb2c3[_0x5f70c4(0x1c0)]({'\x74\x79\x70\x65':'\x74\x65\x78\x74','\x74\x65\x78\x74':_0x390568[_0x5f70c4(0x19f)]});else{if(_0x292b54[_0x5f70c4(0x1d4)](_0x390568['\x74\x79\x70\x65'],_0x5f70c4(0x1bd)))_0x5eb2c3[_0x5f70c4(0x1c0)]({'\x74\x79\x70\x65':_0x5f70c4(0x1bd),'\x69\x6d\x61\x67\x65\x5f\x75\x72\x6c':{'\x75\x72\x6c':_0x390568[_0x5f70c4(0x1bd)][_0x5f70c4(0x147)],'\x64\x65\x74\x61\x69\x6c':_0x390568[_0x5f70c4(0x1bd)]['\x64\x65\x74\x61\x69\x6c']}});else{if(_0x292b54[_0x5f70c4(0x1d4)](_0x390568[_0x5f70c4(0x141)],_0x5f70c4(0x1d8)))_0x5eb2c3[_0x5f70c4(0x1c0)]({'\x74\x79\x70\x65':_0x5f70c4(0x1d8),'\x69\x6e\x70\x75\x74\x5f\x61\x75\x64\x69\x6f':{'\x64\x61\x74\x61':_0x390568[_0x5f70c4(0x1d8)]['\x64\x61\x74\x61'],'\x66\x6f\x72\x6d\x61\x74':_0x390568[_0x5f70c4(0x1d8)][_0x5f70c4(0x27d)]}});}}return{'\x74\x65\x78\x74':_0x35022e[_0x5f70c4(0x27e)]('\x0a'),'\x70\x61\x72\x74\x73':_0x5eb2c3};}function readAssistantText(_0x2bb6bc){const _0x220b75=a0_0x15650e,_0x271996={'\x74\x4a\x56\x63\x73':function(_0x156385,_0x5d37fc){return _0x156385==_0x5d37fc;},'\x75\x56\x7a\x72\x56':function(_0x26b659,_0x259693){return _0x26b659===_0x259693;}};if(_0x271996[_0x220b75(0x1e9)](_0x2bb6bc,null))return'';if(_0x271996[_0x220b75(0x1bf)](typeof _0x2bb6bc,_0x220b75(0x29e)))return _0x2bb6bc;const _0x224a0c=[];for(const _0x35871f of _0x2bb6bc)if(_0x35871f[_0x220b75(0x141)]===_0x220b75(0x19f))_0x224a0c[_0x220b75(0x1c0)](_0x35871f['\x74\x65\x78\x74']);else{if(_0x35871f['\x74\x79\x70\x65']==='\x72\x65\x66\x75\x73\x61\x6c')_0x224a0c[_0x220b75(0x1c0)](_0x35871f[_0x220b75(0x290)]);}return _0x224a0c[_0x220b75(0x27e)]('\x0a');}function readToolContent(_0x32bee1){const _0x360eb0=a0_0x15650e,_0x4a7bf8={'\x76\x49\x79\x70\x6a':_0x360eb0(0x29e)};if(typeof _0x32bee1===_0x4a7bf8[_0x360eb0(0x2a1)])return _0x32bee1;return _0x32bee1[_0x360eb0(0x251)](_0x2fcc49=>_0x2fcc49['\x74\x65\x78\x74'])[_0x360eb0(0x27e)]('\x0a');}function convertTools(_0x29064a){const _0x54a881=a0_0x15650e,_0x2dd8b2={'\x54\x53\x41\x6c\x75':function(_0x59c5a3,_0x2f0ee3){return _0x59c5a3===_0x2f0ee3;},'\x43\x72\x54\x64\x79':_0x54a881(0x197),'\x5a\x62\x6e\x56\x75':function(_0x4ee91b,_0x18adaf){return _0x4ee91b>_0x18adaf;}};if(!_0x29064a||_0x2dd8b2[_0x54a881(0x270)](_0x29064a[_0x54a881(0x132)],0x0))return void 0x0;const _0x510cd1=[];for(const _0x5c250b of _0x29064a)if(_0x5c250b[_0x54a881(0x141)]===_0x2dd8b2['\x43\x72\x54\x64\x79'])_0x510cd1[_0x54a881(0x1c0)]({'\x74\x79\x70\x65':_0x2dd8b2[_0x54a881(0x184)],'\x66\x75\x6e\x63\x74\x69\x6f\x6e':{'\x6e\x61\x6d\x65':_0x5c250b[_0x54a881(0x197)]['\x6e\x61\x6d\x65'],'\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e':_0x5c250b[_0x54a881(0x197)][_0x54a881(0x21b)],'\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73':_0x5c250b[_0x54a881(0x197)][_0x54a881(0x169)]??null,'\x73\x74\x72\x69\x63\x74':_0x5c250b[_0x54a881(0x197)][_0x54a881(0x146)]??null}});return _0x2dd8b2[_0x54a881(0x259)](_0x510cd1['\x6c\x65\x6e\x67\x74\x68'],0x0)?_0x510cd1:void 0x0;}function openaiMessagesToSandboxInput(_0x103d59,_0x738fc8,_0x51bdb8){const _0x4c8d30=a0_0x15650e,_0xf6c188={'\x42\x6c\x7a\x7a\x4c':function(_0x445d87,_0x5db4ed){return _0x445d87===_0x5db4ed;},'\x54\x7a\x6d\x6f\x63':'\x75\x73\x65\x72','\x45\x4f\x61\x55\x6c':_0x4c8d30(0x1e3),'\x72\x63\x68\x46\x4b':function(_0x1e6d78,_0x416709){return _0x1e6d78(_0x416709);},'\x4f\x65\x61\x48\x65':function(_0x57c64f,_0x4312da){return _0x57c64f!==_0x4312da;},'\x76\x66\x71\x4b\x61':_0x4c8d30(0x29e),'\x4d\x72\x4e\x6a\x44':function(_0x1bdfbe,_0x423e85){return _0x1bdfbe-_0x423e85;},'\x51\x69\x52\x62\x58':function(_0x54d8f9,_0x2b5089){return _0x54d8f9>=_0x2b5089;},'\x58\x43\x44\x49\x78':function(_0x183e8b){return _0x183e8b();},'\x45\x67\x51\x48\x66':function(_0x48a829){return _0x48a829();},'\x63\x59\x50\x4c\x6b':function(_0x27350c,_0xe66e79){return _0x27350c>_0xe66e79;},'\x51\x73\x68\x43\x41':function(_0x4eed26,_0x14bdf0){return _0x4eed26>_0x14bdf0;}},{provider:_0x566af0,variant:_0x5297cc}=resolveProviderId(_0x51bdb8),_0xa254b3=[],_0x13e135=[],_0x6a5d6d=[];let _0x538701=null,_0x31e4bd=[],_0x4a6e51=[],_0x2acd75=![];const _0x5d1b9a=()=>{const _0xbbba32=_0x4c8d30;_0x538701&&(_0x6a5d6d[_0xbbba32(0x1c0)](_0x538701),_0x538701=null);};let _0x51e348=-0x1;for(let _0x5356ad=_0x103d59[_0x4c8d30(0x132)]-0x1;_0x5356ad>=0x0;_0x5356ad--)if(_0xf6c188[_0x4c8d30(0x1bc)](_0x103d59[_0x5356ad][_0x4c8d30(0xda)],_0xf6c188['\x54\x7a\x6d\x6f\x63'])){_0x51e348=_0x5356ad;break;}if(_0x51e348===-0x1)throw new Error('\x6f\x70\x65\x6e\x61\x69\x4d\x65\x73\x73\x61\x67\x65\x73\x54\x6f\x53\x61\x6e\x64\x62\x6f\x78\x49\x6e\x70\x75\x74\x3a\x20\x6d\x65\x73\x73\x61\x67\x65\x73\x20\x6d\x75\x73\x74\x20\x63\x6f\x6e\x74\x61\x69\x6e\x20\x61\x74\x20\x6c\x65\x61\x73\x74\x20\x6f\x6e\x65\x20\x75\x73\x65\x72\x20\x6d\x65\x73\x73\x61\x67\x65');for(let _0x20e099=0x0;_0x20e099<_0x103d59[_0x4c8d30(0x132)];_0x20e099++){const _0x3b9443=_0x103d59[_0x20e099];switch(_0x3b9443[_0x4c8d30(0xda)]){case'\x73\x79\x73\x74\x65\x6d':case _0x4c8d30(0x1f8):{const {text:_0x391eb6}=normalizeContent(_0x3b9443['\x63\x6f\x6e\x74\x65\x6e\x74']);if(_0x391eb6)_0xa254b3[_0x4c8d30(0x1c0)](_0x391eb6);break;}case _0xf6c188[_0x4c8d30(0x267)]:{const {text:_0x59c05e,parts:_0x4f1817}=normalizeContent(_0x3b9443[_0x4c8d30(0x256)]);if(_0x4f1817[_0x4c8d30(0xe8)](_0x3d583c=>_0x3d583c[_0x4c8d30(0x141)]!==_0x4c8d30(0x19f)))_0x2acd75=!![];if(_0x20e099===_0x51e348){_0x13e135[_0x4c8d30(0x1c0)](_0x59c05e);if(_0x4f1817[_0x4c8d30(0x132)]>0x0)_0x4a6e51=_0x4f1817;}else{_0x5d1b9a();_0x4f1817[_0x4c8d30(0x132)]>0x0?(_0x538701={'\x75\x73\x65\x72\x50\x61\x72\x74\x73':_0x4f1817},_0x31e4bd=_0x4f1817):(_0x538701={},_0x31e4bd=[]);if(_0x59c05e)_0x13e135[_0x4c8d30(0x1c0)](_0x59c05e);}break;}case _0xf6c188['\x45\x4f\x61\x55\x6c']:{if(!_0x538701)_0x538701={};const _0x11a733=_0xf6c188[_0x4c8d30(0x282)](readAssistantText,_0x3b9443[_0x4c8d30(0x256)]);if(_0x11a733)_0x538701[_0x4c8d30(0x28a)]=_0x11a733;if(_0x3b9443['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73']&&_0x3b9443[_0x4c8d30(0xea)][_0x4c8d30(0x132)]>0x0){const _0x3a8be4=[];for(const _0x3147dd of _0x3b9443[_0x4c8d30(0xea)]){if(_0x3147dd[_0x4c8d30(0x141)]!==_0x4c8d30(0x197))continue;if(!_0x3147dd['\x69\x64']||!_0x3147dd[_0x4c8d30(0x197)]?.['\x6e\x61\x6d\x65']||_0xf6c188[_0x4c8d30(0x1cc)](typeof _0x3147dd[_0x4c8d30(0x197)][_0x4c8d30(0x1f5)],_0xf6c188[_0x4c8d30(0x1f6)]))throw new Error(_0x4c8d30(0xff)+_0x20e099);_0x3a8be4[_0x4c8d30(0x1c0)]({'\x69\x64':_0x3147dd['\x69\x64'],'\x6e\x61\x6d\x65':_0x3147dd[_0x4c8d30(0x197)][_0x4c8d30(0x1b2)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x3147dd['\x66\x75\x6e\x63\x74\x69\x6f\x6e'][_0x4c8d30(0x1f5)]});}if(_0x3a8be4[_0x4c8d30(0x132)]>0x0)_0x538701['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73']=_0x3a8be4;}if(_0x31e4bd[_0x4c8d30(0x132)]>0x0&&!_0x538701[_0x4c8d30(0x237)])_0x538701[_0x4c8d30(0x237)]=_0x31e4bd;break;}case _0x4c8d30(0x191):{const _0x21625e={'\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x49\x64':_0x3b9443['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x5f\x69\x64'],'\x63\x6f\x6e\x74\x65\x6e\x74':readToolContent(_0x3b9443['\x63\x6f\x6e\x74\x65\x6e\x74'])};let _0x220950=![];if(_0x538701?.[_0x4c8d30(0x1c7)]?.[_0x4c8d30(0xe8)](_0x5cdc60=>_0x5cdc60['\x69\x64']===_0x3b9443[_0x4c8d30(0x18a)])){if(!_0x538701[_0x4c8d30(0x13b)])_0x538701['\x74\x6f\x6f\x6c\x52\x65\x73\x75\x6c\x74\x73']=[];_0x538701[_0x4c8d30(0x13b)]['\x70\x75\x73\x68'](_0x21625e),_0x220950=!![];}else for(let _0x1724dc=_0xf6c188[_0x4c8d30(0x17e)](_0x6a5d6d[_0x4c8d30(0x132)],0x1);_0xf6c188[_0x4c8d30(0x205)](_0x1724dc,0x0);_0x1724dc--){const _0x1a78aa=_0x6a5d6d[_0x1724dc];if(_0x1a78aa[_0x4c8d30(0x1c7)]?.[_0x4c8d30(0xe8)](_0x27adba=>_0x27adba['\x69\x64']===_0x3b9443[_0x4c8d30(0x18a)])){if(!_0x1a78aa[_0x4c8d30(0x13b)])_0x1a78aa[_0x4c8d30(0x13b)]=[];_0x1a78aa[_0x4c8d30(0x13b)][_0x4c8d30(0x1c0)](_0x21625e),_0x220950=!![];break;}}if(!_0x220950)throw new Error(_0x4c8d30(0x14f)+_0x3b9443[_0x4c8d30(0x18a)]);break;}case _0x4c8d30(0x197):break;}if(_0x20e099===_0x51e348)_0xf6c188[_0x4c8d30(0x106)](_0x5d1b9a);}_0xf6c188[_0x4c8d30(0x13e)](_0x5d1b9a);const _0x263d34={'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x566af0,'\x74\x61\x73\x6b':_0x13e135[_0x4c8d30(0x27e)]('\x0a\x0a')};if(_0x5297cc)_0x263d34['\x76\x61\x72\x69\x61\x6e\x74']=_0x5297cc;const _0x401f04=_0xa254b3['\x6a\x6f\x69\x6e']('\x0a\x0a');if(_0x401f04)_0x263d34[_0x4c8d30(0x1c5)]=_0x401f04;if(_0xf6c188[_0x4c8d30(0x149)](_0x4a6e51[_0x4c8d30(0x132)],0x0))_0x263d34[_0x4c8d30(0xdd)]=_0x4a6e51;if(_0xf6c188[_0x4c8d30(0x1cf)](_0x6a5d6d[_0x4c8d30(0x132)],0x0))_0x263d34['\x70\x72\x69\x6f\x72\x54\x75\x72\x6e\x73']=_0x6a5d6d;const _0x508e21=convertTools(_0x738fc8);if(_0x508e21)_0x263d34[_0x4c8d30(0x281)]=_0x508e21;if(_0x2acd75)_0x263d34['\x6d\x75\x6c\x74\x69\x6d\x6f\x64\x61\x6c']=!![];return _0x263d34;}async function resolvePreviousResponseId(_0x3077d0,_0x529b68){const _0x3a3fee=a0_0x15650e,_0x51c9b3={'\x66\x53\x57\x64\x51':function(_0x341cea,_0x1a1874){return _0x341cea===_0x1a1874;}};if(!_0x3077d0)return{'\x70\x72\x69\x6f\x72\x54\x75\x72\x6e\x73':[]};const _0x18b754=await _0x529b68[_0x3a3fee(0x1c4)](_0x3077d0);if(_0x51c9b3['\x66\x53\x57\x64\x51'](_0x18b754,null))throw new Error(_0x3a3fee(0x1af)+_0x3077d0);return{'\x70\x72\x69\x6f\x72\x54\x75\x72\x6e\x73':_0x18b754};}function emptyUsage(){return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':0x0,'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73':0x0},'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x5f\x74\x6f\x6b\x65\x6e\x73':0x0}};}function readUsageFromEvent(_0x305e31){const _0xd5f477=a0_0x15650e,_0x4ce7d9={'\x44\x6e\x5a\x6a\x51':function(_0x588723,_0x3b9961){return _0x588723(_0x3b9961);},'\x47\x42\x4d\x45\x67':function(_0x459fbc,_0x1d6b38){return _0x459fbc in _0x1d6b38;},'\x69\x75\x48\x68\x4c':function(_0x408c3c,_0x163b0d){return _0x408c3c+_0x163b0d;}},_0x2ffa6b=_0x305e31[_0xd5f477(0x2a6)]??_0x305e31,_0x3c1071=_0x4ce7d9['\x44\x6e\x5a\x6a\x51'](Number,_0x2ffa6b[_0xd5f477(0x28c)]??_0x2ffa6b['\x70\x72\x6f\x6d\x70\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x2ffa6b[_0xd5f477(0x28e)]??0x0),_0x234d3e=Number(_0x2ffa6b[_0xd5f477(0x1ec)]??_0x2ffa6b[_0xd5f477(0x292)]??_0x2ffa6b[_0xd5f477(0x18c)]??0x0);if(_0x3c1071===0x0&&_0x234d3e===0x0&&!_0x4ce7d9[_0xd5f477(0x10e)]('\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73',_0x2ffa6b))return null;const _0x2c1586=Number(_0x2ffa6b[_0xd5f477(0xef)]??_0x4ce7d9[_0xd5f477(0x1f4)](_0x3c1071,_0x234d3e)),_0x59cf6f=Number(_0x2ffa6b[_0xd5f477(0x1ba)]?.[_0xd5f477(0x198)]??_0x2ffa6b[_0xd5f477(0x198)]??0x0),_0x40d57b=Number(_0x2ffa6b['\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73']?.[_0xd5f477(0x294)]??_0x2ffa6b[_0xd5f477(0x294)]??0x0);return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x3c1071,'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x234d3e,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x2c1586,'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73':_0x59cf6f},'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x5f\x74\x6f\x6b\x65\x6e\x73':_0x40d57b}};}function readToolInvocationFromRaw(_0x1f3a43){const _0x349504=a0_0x15650e,_0x5303f8={'\x56\x79\x57\x76\x4c':function(_0x5422a9,_0x2fce4e){return _0x5422a9!==_0x2fce4e;},'\x74\x45\x48\x45\x79':_0x349504(0x27a),'\x54\x41\x59\x44\x70':_0x349504(0x29e),'\x4f\x6c\x4f\x52\x49':function(_0xe64150,_0x2f4ff9){return _0xe64150===_0x2f4ff9;},'\x6f\x6b\x59\x4a\x76':function(_0x304ee1,_0x4f85dc){return _0x304ee1===_0x4f85dc;},'\x49\x4c\x4e\x47\x58':function(_0x491c4e,_0x374f3d){return _0x491c4e===_0x374f3d;},'\x6e\x52\x4e\x79\x6e':function(_0x3de606,_0x3e5f73){return _0x3de606===_0x3e5f73;},'\x75\x45\x61\x69\x44':function(_0x2342f1,_0x313e84){return _0x2342f1===_0x313e84;},'\x65\x74\x56\x62\x46':function(_0x423163,_0x572fdf){return _0x423163===_0x572fdf;},'\x67\x67\x67\x68\x63':function(_0xdd7d03,_0x1b464a){return _0xdd7d03||_0x1b464a;}};if(_0x5303f8[_0x349504(0x235)](_0x1f3a43[_0x349504(0x141)],_0x5303f8['\x74\x45\x48\x45\x79']))return null;const _0x3ec8f7=_0x1f3a43[_0x349504(0x104)]??_0x1f3a43,_0xa1d97c=typeof _0x3ec8f7[_0x349504(0x141)]===_0x5303f8[_0x349504(0x15e)]?_0x3ec8f7['\x74\x79\x70\x65']:'',_0x11594c=_0x5303f8['\x4f\x6c\x4f\x52\x49'](_0xa1d97c,'\x63\x6f\x6d\x70\x75\x74\x65\x72\x2d\x75\x73\x65')||_0xa1d97c===_0x349504(0x29a)||typeof _0x3ec8f7[_0x349504(0x269)]===_0x349504(0x17d)||typeof _0x3ec8f7[_0x349504(0x252)]==='\x6f\x62\x6a\x65\x63\x74';if(!(_0x5303f8[_0x349504(0x1b0)](_0xa1d97c,_0x349504(0x164))||_0x5303f8[_0x349504(0x1fa)](_0xa1d97c,_0x349504(0x271))||typeof _0x3ec8f7['\x74\x6f\x6f\x6c\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e']===_0x349504(0x17d)||typeof _0x3ec8f7[_0x349504(0x26b)]===_0x349504(0x17d))&&!_0x11594c)return null;const _0x5ede07=_0x3ec8f7[_0x349504(0x216)]??_0x3ec8f7['\x74\x6f\x6f\x6c\x5f\x69\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e']??_0x3ec8f7['\x63\x6f\x6d\x70\x75\x74\x65\x72\x55\x73\x65']??_0x3ec8f7[_0x349504(0x252)]??_0x3ec8f7,_0x1e65da=typeof _0x5ede07[_0x349504(0x25b)]===_0x5303f8['\x54\x41\x59\x44\x70']?_0x5ede07[_0x349504(0x25b)]:_0x5303f8['\x6e\x52\x4e\x79\x6e'](typeof _0x5ede07['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x5f\x69\x64'],_0x349504(0x29e))?_0x5ede07[_0x349504(0x18a)]:_0x5303f8[_0x349504(0xf8)](typeof _0x5ede07['\x69\x64'],_0x5303f8[_0x349504(0x15e)])?_0x5ede07['\x69\x64']:_0x5303f8[_0x349504(0x244)](typeof _0x5ede07[_0x349504(0x206)],'\x73\x74\x72\x69\x6e\x67')?_0x5ede07[_0x349504(0x206)]:'',_0x33d6f3=_0x11594c?'\x63\x6f\x6d\x70\x75\x74\x65\x72\x5f\x75\x73\x65':typeof _0x5ede07[_0x349504(0x16b)]===_0x349504(0x29e)?_0x5ede07[_0x349504(0x16b)]:typeof _0x5ede07[_0x349504(0x25e)]===_0x5303f8['\x54\x41\x59\x44\x70']?_0x5ede07[_0x349504(0x25e)]:typeof _0x5ede07[_0x349504(0x1b2)]===_0x349504(0x29e)?_0x5ede07[_0x349504(0x1b2)]:'',_0x4fb395=_0x5ede07[_0x349504(0x29c)]??_0x5ede07[_0x349504(0x1f5)]??_0x5ede07[_0x349504(0x1be)]??{};if(_0x5303f8[_0x349504(0x183)](!_0x1e65da,!_0x33d6f3))return null;return{'\x69\x64':_0x1e65da,'\x6e\x61\x6d\x65':_0x33d6f3,'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':typeof _0x4fb395===_0x5303f8['\x54\x41\x59\x44\x70']?_0x4fb395:JSON[_0x349504(0x21f)](_0x4fb395),'\x69\x73\x43\x6f\x6d\x70\x75\x74\x65\x72\x55\x73\x65':_0x11594c,'\x63\x6f\x6d\x70\x75\x74\x65\x72\x41\x63\x74\x69\x6f\x6e':_0x11594c?_0x5ede07['\x61\x63\x74\x69\x6f\x6e']??void 0x0:void 0x0};}function readReasoningFromPart(_0xe40458){const _0x3a86f9=a0_0x15650e,_0x2b0c40={'\x48\x6c\x55\x58\x75':_0x3a86f9(0x1c6),'\x52\x44\x49\x50\x56':function(_0x4d253e,_0x16d5f1){return _0x4d253e!==_0x16d5f1;},'\x4e\x5a\x7a\x71\x50':'\x73\x74\x72\x69\x6e\x67'};if(_0xe40458['\x74\x79\x70\x65']!=='\x6d\x65\x73\x73\x61\x67\x65\x2e\x70\x61\x72\x74\x2e\x75\x70\x64\x61\x74\x65\x64')return null;const _0x2b3afd=_0xe40458[_0x3a86f9(0x10a)]??_0xe40458;if(_0x2b3afd[_0x3a86f9(0x141)]!==_0x2b0c40['\x48\x6c\x55\x58\x75']&&_0x2b0c40[_0x3a86f9(0x130)](_0x2b3afd[_0x3a86f9(0x141)],_0x3a86f9(0x154)))return null;if(typeof _0x2b3afd[_0x3a86f9(0x19f)]===_0x3a86f9(0x29e))return _0x2b3afd['\x74\x65\x78\x74'];if(typeof _0x2b3afd['\x63\x6f\x6e\x74\x65\x6e\x74']===_0x2b0c40[_0x3a86f9(0x245)])return _0x2b3afd[_0x3a86f9(0x256)];return null;}function assembleResponseOutput(_0x14db37){const _0x5e5542=a0_0x15650e,_0x12bddb={'\x64\x68\x59\x66\x76':function(_0x582573){return _0x582573();},'\x77\x41\x42\x53\x4d':function(_0x14e9a4,_0x1729a0){return _0x14e9a4===_0x1729a0;},'\x6a\x47\x79\x50\x4f':_0x5e5542(0x27a),'\x50\x6f\x6c\x6f\x52':function(_0xca8991,_0x4383ab){return _0xca8991(_0x4383ab);},'\x4f\x51\x44\x72\x4b':_0x5e5542(0x128),'\x71\x46\x44\x6a\x51':'\x6d\x65\x73\x73\x61\x67\x65\x2e\x70\x61\x72\x74\x2e\x75\x70\x64\x61\x74\x65\x64','\x70\x6d\x63\x62\x48':function(_0x48cb35,_0x4221fd,_0x2afa74){return _0x48cb35(_0x4221fd,_0x2afa74);},'\x43\x6c\x75\x63\x52':function(_0x303a7d,_0x367bb6){return _0x303a7d>_0x367bb6;},'\x79\x73\x79\x6e\x54':'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67','\x50\x6e\x72\x52\x4e':_0x5e5542(0x1ca),'\x63\x67\x58\x44\x68':_0x5e5542(0x126)},_0x336eaf={'\x74\x65\x78\x74\x50\x69\x65\x63\x65\x73':[],'\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73':new Map(),'\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x4f\x72\x64\x65\x72':[],'\x63\x6f\x6d\x70\x75\x74\x65\x72\x43\x61\x6c\x6c\x73':[],'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x50\x69\x65\x63\x65\x73':[],'\x75\x73\x61\x67\x65':_0x12bddb[_0x5e5542(0x100)](emptyUsage),'\x68\x61\x73\x55\x73\x61\x67\x65':![]};for(const _0x87366d of _0x14db37)switch(_0x87366d['\x74\x79\x70\x65']){case _0x5e5542(0x227):{const _0x54e977=typeof _0x87366d[_0x5e5542(0x163)]===_0x5e5542(0x29e)&&_0x87366d[_0x5e5542(0x163)]||typeof _0x87366d[_0x5e5542(0x19f)]===_0x5e5542(0x29e)&&_0x87366d[_0x5e5542(0x19f)]||_0x12bddb[_0x5e5542(0x260)](typeof _0x87366d[_0x5e5542(0x227)],_0x5e5542(0x29e))&&_0x87366d[_0x5e5542(0x227)]||'';if(_0x54e977)_0x336eaf[_0x5e5542(0xee)][_0x5e5542(0x1c0)](_0x54e977);break;}case _0x12bddb['\x6a\x47\x79\x50\x4f']:{const _0x48d9ea=_0x12bddb[_0x5e5542(0x296)](readToolInvocationFromRaw,_0x87366d);if(!_0x48d9ea)break;if(_0x48d9ea[_0x5e5542(0x1aa)])_0x336eaf['\x63\x6f\x6d\x70\x75\x74\x65\x72\x43\x61\x6c\x6c\x73'][_0x5e5542(0x1c0)]({'\x74\x79\x70\x65':_0x5e5542(0x29a),'\x69\x64':_0x5e5542(0x102)+_0x48d9ea['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0x48d9ea['\x69\x64'],'\x73\x74\x61\x74\x75\x73':_0x5e5542(0x19b),'\x70\x65\x6e\x64\x69\x6e\x67\x5f\x73\x61\x66\x65\x74\x79\x5f\x63\x68\x65\x63\x6b\x73':[],..._0x48d9ea[_0x5e5542(0x25a)]?{'\x61\x63\x74\x69\x6f\x6e':_0x48d9ea[_0x5e5542(0x25a)]}:{}});else{if(!_0x336eaf['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73'][_0x5e5542(0x217)](_0x48d9ea['\x69\x64']))_0x336eaf[_0x5e5542(0x166)][_0x5e5542(0x1c0)](_0x48d9ea['\x69\x64']);_0x336eaf['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73'][_0x5e5542(0x280)](_0x48d9ea['\x69\x64'],{'\x74\x79\x70\x65':_0x12bddb[_0x5e5542(0x218)],'\x69\x64':_0x5e5542(0xdc)+_0x48d9ea['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0x48d9ea['\x69\x64'],'\x6e\x61\x6d\x65':_0x48d9ea[_0x5e5542(0x1b2)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x48d9ea['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73'],'\x73\x74\x61\x74\x75\x73':_0x5e5542(0x19b)});}break;}case _0x12bddb[_0x5e5542(0x16a)]:{const _0x3e7549=readReasoningFromPart(_0x87366d);if(_0x3e7549)_0x336eaf[_0x5e5542(0x13a)][_0x5e5542(0x1c0)](_0x3e7549);break;}case _0x5e5542(0x194):{const _0x1f8cb3=readUsageFromEvent(_0x87366d);_0x1f8cb3&&(_0x336eaf[_0x5e5542(0x2a6)]=_0x12bddb[_0x5e5542(0x20f)](foldUsage,_0x336eaf[_0x5e5542(0x2a6)],_0x1f8cb3),_0x336eaf['\x68\x61\x73\x55\x73\x61\x67\x65']=!![]);break;}}const _0x2ab9f4=[];if(_0x12bddb[_0x5e5542(0xf6)](_0x336eaf['\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x50\x69\x65\x63\x65\x73'][_0x5e5542(0x132)],0x0)){const _0x28e0ae={'\x74\x79\x70\x65':_0x12bddb[_0x5e5542(0xfd)],'\x69\x64':_0x12bddb['\x50\x6e\x72\x52\x4e'],'\x73\x75\x6d\x6d\x61\x72\x79':[],'\x63\x6f\x6e\x74\x65\x6e\x74':_0x336eaf[_0x5e5542(0x13a)][_0x5e5542(0x251)](_0x2a584b=>({'\x74\x79\x70\x65':_0x5e5542(0x173),'\x74\x65\x78\x74':_0x2a584b})),'\x73\x74\x61\x74\x75\x73':_0x5e5542(0x19b)};_0x2ab9f4['\x70\x75\x73\x68'](_0x28e0ae);}if(_0x336eaf[_0x5e5542(0xee)][_0x5e5542(0x132)]>0x0){const _0x59ff4d={'\x74\x79\x70\x65':_0x12bddb[_0x5e5542(0x1d7)],'\x69\x64':_0x5e5542(0x186),'\x72\x6f\x6c\x65':'\x61\x73\x73\x69\x73\x74\x61\x6e\x74','\x73\x74\x61\x74\x75\x73':_0x5e5542(0x19b),'\x63\x6f\x6e\x74\x65\x6e\x74':[{'\x74\x79\x70\x65':'\x6f\x75\x74\x70\x75\x74\x5f\x74\x65\x78\x74','\x74\x65\x78\x74':_0x336eaf['\x74\x65\x78\x74\x50\x69\x65\x63\x65\x73'][_0x5e5542(0x27e)](''),'\x61\x6e\x6e\x6f\x74\x61\x74\x69\x6f\x6e\x73':[]}]};_0x2ab9f4[_0x5e5542(0x1c0)](_0x59ff4d);}for(const _0x4d9757 of _0x336eaf['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x4f\x72\x64\x65\x72']){const _0x2ec00e=_0x336eaf['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73'][_0x5e5542(0xf5)](_0x4d9757);if(_0x2ec00e)_0x2ab9f4[_0x5e5542(0x1c0)](_0x2ec00e);}for(const _0x5ccf75 of _0x336eaf[_0x5e5542(0xe5)])_0x2ab9f4[_0x5e5542(0x1c0)](_0x5ccf75);return{'\x6f\x75\x74\x70\x75\x74':_0x2ab9f4,'\x75\x73\x61\x67\x65':_0x336eaf['\x75\x73\x61\x67\x65']};}function foldUsage(_0x2d4546,_0x7e6a4a){const _0x148a71=a0_0x15650e,_0x387039={'\x70\x71\x62\x73\x73':function(_0x5215de,_0x588275){return _0x5215de+_0x588275;}};return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x387039[_0x148a71(0x23e)](_0x2d4546['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73'],_0x7e6a4a[_0x148a71(0x28c)]),'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x2d4546[_0x148a71(0x1ec)]+_0x7e6a4a[_0x148a71(0x1ec)],'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x2d4546[_0x148a71(0xef)]+_0x7e6a4a['\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73'],'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73':_0x2d4546[_0x148a71(0x1ba)][_0x148a71(0x198)]+_0x7e6a4a[_0x148a71(0x1ba)][_0x148a71(0x198)]},'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73':{'\x72\x65\x61\x73\x6f\x6e\x69\x6e\x67\x5f\x74\x6f\x6b\x65\x6e\x73':_0x2d4546[_0x148a71(0xed)][_0x148a71(0x294)]+_0x7e6a4a[_0x148a71(0xed)][_0x148a71(0x294)]}};}function a0_0x2d62(){const _0x21a8f2=['\x7a\x67\x48\x7a\x7a\x4e\x79','\x42\x67\x66\x5a\x44\x66\x6a\x4c\x7a\x4d\x4c\x53\x42\x65\x31\x5a','\x79\x32\x6e\x46','\x43\x75\x76\x62\x42\x65\x75','\x7a\x67\x66\x30\x79\x71','\x6f\x64\x6d\x32\x6f\x74\x76\x71\x73\x33\x6e\x54\x75\x4d\x69','\x77\x65\x6e\x65\x73\x78\x47','\x72\x66\x6e\x6c\x72\x75\x6d','\x77\x66\x4c\x4a\x44\x76\x6d','\x7a\x4b\x4c\x72\x42\x4d\x4b','\x43\x67\x66\x59\x44\x61','\x79\x4b\x31\x4e\x76\x4d\x47','\x42\x4b\x7a\x67\x72\x67\x69','\x41\x67\x66\x55\x7a\x67\x58\x4c\x76\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x57','\x72\x30\x6a\x6e\x72\x77\x43','\x73\x77\x35\x32\x79\x77\x58\x50\x7a\x63\x62\x54\x42\x32\x72\x4c\x42\x63\x62\x50\x7a\x64\x4f\x47','\x76\x67\x4c\x6c\x43\x68\x65','\x71\x4d\x58\x55\x74\x4b\x69','\x79\x76\x6a\x6c\x73\x30\x30','\x41\x78\x6a\x73\x41\x67\x43','\x7a\x4d\x4c\x53\x44\x67\x76\x59','\x73\x67\x72\x36\x41\x4e\x71','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x66\x39\x4d\x41\x77\x58\x30\x7a\x78\x6a\x4c\x7a\x61','\x74\x30\x7a\x75\x74\x32\x38','\x76\x67\x7a\x63\x79\x4b\x53','\x44\x78\x50\x53\x73\x4c\x69','\x72\x76\x44\x78\x42\x65\x4b','\x79\x77\x6e\x30\x41\x77\x39\x55','\x75\x76\x72\x31\x42\x4e\x65','\x78\x73\x62\x50\x43\x59\x62\x54\x41\x78\x6e\x5a\x41\x77\x35\x4e\x69\x67\x65\x47\x44\x68\x4c\x57\x7a\x73\x62\x4b\x41\x78\x6e\x4a\x43\x4d\x4c\x54\x41\x77\x35\x48\x44\x67\x39\x59','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x59\x7a\x78\x66\x31\x7a\x78\x6e\x30','\x69\x49\x62\x50\x43\x59\x62\x55\x42\x33\x71\x47\x43\x33\x76\x57\x43\x67\x39\x59\x44\x67\x76\x4b\x69\x67\x6a\x35\x69\x68\x72\x4f\x41\x78\x6d\x47\x7a\x77\x35\x4b\x43\x67\x39\x50\x42\x4e\x71','\x71\x4c\x4c\x62\x44\x77\x69','\x44\x67\x39\x56\x42\x68\x6e\x42','\x44\x67\x76\x34\x44\x66\x39\x4a\x42\x32\x31\x57\x42\x67\x76\x30\x41\x77\x39\x55','\x75\x4e\x76\x55\x6c\x4d\x76\x32\x7a\x77\x35\x30\x43\x59\x47\x50\x69\x67\x31\x48\x45\x73\x62\x56\x42\x4d\x58\x35\x69\x67\x6a\x4c\x69\x67\x6e\x56\x42\x4e\x6e\x31\x42\x77\x76\x4b\x69\x67\x39\x55\x79\x32\x75\x55\x69\x65\x31\x31\x42\x68\x72\x50\x43\x67\x58\x4c\x69\x67\x4c\x30\x7a\x78\x6a\x48\x44\x67\x39\x59\x43\x59\x62\x56\x42\x49\x62\x30\x41\x67\x75\x47\x43\x32\x66\x54\x7a\x73\x62\x73\x44\x77\x34\x47\x43\x32\x48\x48\x43\x4d\x75\x47\x43\x33\x72\x48\x44\x67\x75\x47\x79\x77\x35\x4b\x69\x68\x44\x56\x44\x77\x58\x4b\x69\x67\x4c\x55\x44\x67\x76\x59\x42\x67\x76\x48\x44\x4d\x75\x56\x43\x33\x72\x4c\x79\x77\x57\x47\x7a\x78\x7a\x4c\x42\x4e\x72\x5a\x6c\x47','\x74\x32\x72\x30\x73\x68\x75','\x42\x77\x66\x34\x75\x4d\x76\x5a\x44\x77\x58\x30\x43\x57','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x71','\x73\x77\x35\x57\x44\x78\x71\x47\x43\x33\x72\x59\x41\x77\x35\x4e\x69\x67\x66\x30\x69\x67\x4c\x55\x7a\x67\x76\x34\x69\x61','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x35\x46\x79\x32\x66\x53\x42\x61','\x43\x67\x66\x5a\x43\x57','\x43\x68\x7a\x48\x44\x67\x69','\x79\x33\x6a\x4c\x79\x78\x72\x4c\x7a\x65\x66\x30','\x7a\x77\x35\x69\x43\x30\x47','\x43\x33\x72\x48\x43\x4e\x72\x71\x43\x4d\x39\x54\x41\x78\x6e\x4c','\x42\x67\x39\x33','\x44\x32\x76\x49\x78\x33\x6e\x4c\x79\x78\x6a\x4a\x41\x66\x39\x57\x43\x4d\x76\x32\x41\x77\x76\x33','\x75\x4b\x72\x6a\x75\x66\x79','\x41\x78\x72\x4c\x43\x4d\x66\x30\x42\x33\x6a\x64\x43\x4d\x76\x48\x44\x67\x76\x4b','\x42\x67\x76\x55\x7a\x33\x72\x4f','\x44\x66\x66\x52\x44\x75\x47','\x45\x4b\x76\x6d\x44\x4b\x69','\x41\x65\x31\x66\x7a\x30\x38','\x42\x77\x4c\x55','\x44\x67\x39\x56\x42\x65\x39\x31\x44\x68\x62\x31\x44\x65\x4c\x55\x7a\x67\x76\x34','\x44\x67\x76\x5a\x44\x61','\x7a\x77\x76\x6a\x44\x78\x79','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x75\x67\x4c\x4c\x79\x32\x76\x5a','\x44\x67\x39\x56\x42\x66\x6a\x4c\x43\x33\x76\x53\x44\x68\x6d','\x79\x4d\x66\x5a\x7a\x74\x79\x30','\x41\x67\x58\x35\x79\x75\x65','\x72\x77\x44\x72\x73\x67\x79','\x43\x33\x72\x48\x44\x68\x76\x5a','\x79\x32\x39\x5a\x44\x63\x62\x4a\x79\x78\x61\x47\x43\x4d\x76\x48\x79\x32\x48\x4c\x7a\x63\x62\x48\x7a\x4e\x72\x4c\x43\x49\x62\x30\x42\x32\x39\x53\x69\x67\x6e\x48\x42\x67\x57\x36\x69\x61','\x44\x68\x4c\x57\x7a\x71','\x42\x33\x62\x4c\x42\x47','\x43\x4d\x76\x33\x43\x4d\x4c\x30\x7a\x71','\x43\x67\x76\x55\x7a\x67\x4c\x55\x7a\x30\x6e\x48\x42\x67\x58\x5a','\x7a\x4e\x6a\x56\x42\x71','\x43\x33\x72\x59\x41\x77\x6e\x30','\x44\x78\x6a\x53','\x45\x68\x76\x67\x7a\x68\x4b','\x79\x31\x4c\x71\x74\x67\x53','\x72\x67\x6e\x33\x75\x30\x34','\x43\x67\x66\x59\x79\x77\x30','\x79\x77\x7a\x30\x7a\x78\x69','\x7a\x4b\x6a\x31\x71\x4c\x69','\x73\x77\x35\x57\x44\x78\x71\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x42\x78\x76\x5a\x44\x63\x62\x49\x7a\x73\x62\x4f\x42\x32\x31\x56\x7a\x32\x76\x55\x7a\x77\x39\x31\x43\x5a\x53\x47\x41\x77\x35\x4b\x7a\x78\x47\x47','\x42\x33\x62\x4c\x42\x4d\x66\x50\x74\x77\x76\x5a\x43\x32\x66\x4e\x7a\x78\x6e\x75\x42\x31\x6e\x48\x42\x4d\x72\x49\x42\x33\x48\x6a\x42\x4e\x62\x31\x44\x64\x4f\x47\x44\x67\x39\x56\x42\x63\x62\x54\x7a\x78\x6e\x5a\x79\x77\x44\x4c\x69\x68\x6a\x4c\x7a\x4d\x76\x59\x7a\x77\x35\x4a\x7a\x78\x6d\x47\x44\x77\x35\x52\x42\x4d\x39\x33\x42\x49\x62\x30\x42\x32\x39\x53\x78\x32\x6e\x48\x42\x67\x58\x46\x41\x77\x71\x47','\x6f\x67\x66\x68\x42\x4e\x62\x49\x44\x71','\x79\x32\x58\x56\x43\x32\x76\x4b','\x43\x68\x76\x30\x75\x68\x6a\x50\x42\x33\x6a\x75\x44\x78\x6a\x55\x43\x57','\x41\x78\x6e\x62\x43\x4e\x6a\x48\x45\x71','\x44\x67\x48\x50\x42\x4d\x54\x50\x42\x4d\x43','\x43\x33\x44\x78\x76\x65\x75','\x43\x33\x76\x4a\x79\x32\x76\x4c\x7a\x67\x76\x4b','\x43\x68\x6a\x56\x44\x4d\x4c\x4b\x7a\x78\x69','\x72\x77\x31\x49\x7a\x77\x72\x4b\x41\x77\x35\x4e\x76\x4d\x66\x53\x41\x77\x72\x48\x44\x67\x4c\x56\x42\x4b\x76\x59\x43\x4d\x39\x59','\x42\x77\x44\x32\x74\x33\x4b','\x42\x67\x72\x51\x71\x4d\x57','\x69\x49\x62\x54\x79\x78\x72\x4a\x41\x67\x76\x5a\x69\x67\x72\x4c\x42\x4e\x4b\x47\x43\x67\x66\x30\x44\x67\x76\x59\x42\x49\x61\x49','\x42\x4c\x62\x56\x44\x77\x75','\x43\x75\x50\x7a\x73\x32\x69','\x76\x65\x66\x7a\x72\x68\x61','\x72\x67\x4c\x54\x7a\x77\x35\x5a\x41\x77\x39\x55\x43\x59\x62\x54\x44\x78\x6e\x30\x69\x67\x6a\x4c\x69\x67\x65\x47\x43\x67\x39\x5a\x41\x78\x72\x50\x44\x4d\x75\x47\x41\x77\x35\x30\x7a\x77\x44\x4c\x43\x47','\x76\x4b\x6a\x58\x44\x4b\x79','\x73\x32\x58\x49\x41\x4e\x71','\x69\x68\x6a\x31\x42\x47','\x7a\x67\x76\x53\x44\x67\x65','\x44\x67\x39\x56\x42\x63\x31\x50\x42\x4e\x7a\x56\x79\x32\x66\x30\x41\x77\x39\x55','\x45\x78\x48\x67\x45\x67\x4b','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x70\x43\x4d\x72\x4c\x43\x47','\x43\x68\x6a\x4c\x44\x4d\x4c\x56\x44\x78\x6e\x73\x7a\x78\x6e\x57\x42\x32\x35\x5a\x7a\x75\x4c\x4b','\x43\x32\x58\x50\x79\x32\x75','\x43\x67\x66\x59\x79\x77\x31\x4c\x44\x67\x76\x59\x43\x57','\x43\x75\x7a\x65\x41\x4c\x65','\x44\x67\x39\x56\x42\x65\x35\x48\x42\x77\x75','\x74\x66\x76\x6a\x7a\x31\x43','\x41\x67\x4c\x30\x44\x31\x69','\x69\x64\x34\x39\x69\x61','\x77\x4c\x62\x6b\x75\x65\x53','\x77\x65\x39\x77\x76\x76\x71','\x44\x67\x48\x59\x7a\x77\x66\x4b\x73\x77\x71','\x43\x32\x39\x31\x43\x4d\x6e\x4c','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x78\x33\x72\x4c\x45\x68\x71','\x79\x32\x66\x4d\x73\x67\x57','\x79\x32\x39\x5a\x44\x63\x62\x4a\x79\x78\x61\x47\x43\x4d\x76\x48\x79\x32\x48\x4c\x7a\x64\x4f\x47','\x42\x77\x39\x4b\x7a\x77\x58\x6a\x7a\x61','\x72\x75\x35\x36\x75\x4b\x75','\x43\x78\x76\x4c\x44\x77\x76\x4b','\x43\x32\x4c\x36\x7a\x71','\x42\x77\x4c\x34\x7a\x77\x72\x46\x41\x77\x35\x57\x44\x78\x72\x46\x44\x68\x4c\x57\x7a\x78\x6d','\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x78\x6e\x46\x79\x77\x6e\x30\x41\x77\x39\x55','\x79\x77\x6e\x30\x41\x77\x39\x55\x69\x68\x6a\x48\x44\x67\x75\x47\x42\x67\x4c\x54\x41\x78\x71\x47\x7a\x78\x48\x4a\x7a\x77\x76\x4b\x7a\x77\x71\x36\x69\x61','\x42\x32\x6a\x51\x7a\x77\x6e\x30','\x74\x78\x6a\x6f\x41\x4b\x71','\x43\x68\x6a\x56\x42\x78\x62\x30\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x72\x77\x50\x6f\x41\x32\x69','\x79\x32\x48\x31\x42\x4d\x54\x6a\x42\x4d\x72\x4c\x45\x61','\x42\x33\x62\x4c\x42\x4e\x6a\x56\x44\x78\x72\x4c\x43\x4a\x50\x33\x7a\x77\x6a\x46\x43\x32\x76\x48\x43\x4d\x6e\x4f','\x7a\x32\x44\x4e\x41\x67\x6d','\x71\x33\x6a\x75\x7a\x68\x4b','\x44\x67\x39\x56\x42\x66\x39\x59\x7a\x78\x6e\x31\x42\x68\x71','\x42\x78\x6e\x4e\x78\x5a\x61','\x42\x4e\x76\x54\x79\x4d\x76\x59','\x79\x32\x39\x4b\x7a\x71','\x79\x32\x48\x48\x41\x77\x35\x5a','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53\x78\x32\x4c\x4b','\x72\x75\x31\x4c\x76\x65\x69','\x42\x33\x76\x30\x43\x68\x76\x30\x76\x67\x39\x52\x7a\x77\x35\x5a','\x72\x78\x6a\x6e\x76\x67\x71','\x7a\x78\x6a\x59\x42\x33\x69','\x79\x32\x4c\x65\x41\x32\x79','\x76\x75\x39\x76\x71\x76\x4b','\x44\x67\x39\x56\x42\x61','\x41\x77\x35\x4a\x42\x32\x31\x57\x42\x67\x76\x30\x7a\x71','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x4b\x41\x77\x31\x4c\x42\x4e\x6e\x50\x42\x32\x35\x5a','\x7a\x67\x39\x55\x7a\x71','\x44\x78\x6e\x4c\x43\x47','\x74\x33\x72\x6f\x73\x4e\x65','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x34','\x79\x32\x66\x4a\x41\x67\x76\x4b\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x43\x67\x66\x59\x44\x67\x35\x4c\x43\x4b\x4c\x4b','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x4c\x42\x4d\x6e\x56\x7a\x67\x4c\x55\x7a\x31\x39\x4d\x42\x33\x6a\x54\x79\x78\x71','\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x76\x4b','\x43\x33\x72\x4c\x7a\x78\x69','\x43\x32\x6e\x59\x7a\x77\x76\x55\x43\x32\x48\x56\x44\x61','\x6d\x74\x66\x56\x76\x65\x58\x59\x73\x4b\x47','\x44\x67\x76\x34\x44\x61','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75\x55\x42\x33\x76\x30\x43\x68\x76\x30\x78\x33\x72\x4c\x45\x68\x71\x55\x7a\x67\x76\x53\x44\x67\x65','\x75\x31\x48\x6f\x43\x75\x34','\x7a\x78\x48\x57\x41\x78\x6a\x4c','\x79\x4b\x54\x58\x71\x30\x69','\x72\x78\x44\x50\x45\x4b\x34','\x76\x4d\x4c\x49\x43\x76\x71','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75\x55\x42\x33\x76\x30\x43\x68\x76\x30\x78\x32\x4c\x30\x7a\x77\x30\x55\x7a\x67\x39\x55\x7a\x71','\x79\x4d\x66\x30\x79\x32\x48\x46\x44\x67\x39\x56\x78\x32\x58\x48\x43\x4d\x44\x4c','\x74\x32\x72\x7a\x42\x4e\x71','\x6d\x74\x75\x5a\x6f\x74\x61\x35\x6f\x77\x39\x75\x71\x4d\x6e\x71\x77\x61','\x41\x78\x6e\x64\x42\x32\x31\x57\x44\x78\x72\x4c\x43\x4c\x76\x5a\x7a\x71','\x41\x67\x39\x56\x41\x33\x6d','\x44\x32\x76\x49\x78\x33\x6e\x4c\x79\x78\x6a\x4a\x41\x61','\x76\x67\x39\x52\x7a\x77\x34\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x79\x78\x71\x47\x41\x77\x35\x4b\x7a\x78\x47\x47','\x73\x68\x66\x50\x45\x67\x47','\x76\x77\x35\x52\x42\x4d\x39\x33\x42\x49\x62\x57\x43\x4d\x76\x32\x41\x77\x39\x31\x43\x31\x39\x59\x7a\x78\x6e\x57\x42\x32\x35\x5a\x7a\x76\x39\x50\x7a\x64\x4f\x47','\x42\x32\x54\x7a\x73\x4e\x79','\x44\x4b\x31\x68\x45\x77\x53','\x42\x4d\x66\x54\x7a\x71','\x74\x33\x66\x6b\x44\x77\x69','\x44\x66\x72\x6c\x74\x33\x69','\x44\x32\x6e\x77\x75\x4b\x30','\x43\x33\x76\x49\x42\x77\x4c\x30\x76\x67\x39\x56\x42\x65\x39\x31\x44\x68\x62\x31\x44\x68\x6d','\x42\x4b\x66\x59\x73\x4c\x6d','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53\x78\x33\x6a\x4c\x43\x78\x76\x4c\x43\x33\x72\x4c\x7a\x61','\x42\x77\x39\x4b\x7a\x77\x58\x46\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x77\x71','\x41\x77\x35\x57\x44\x78\x72\x46\x44\x67\x39\x52\x7a\x77\x35\x5a\x78\x32\x72\x4c\x44\x67\x66\x50\x42\x68\x6d','\x79\x32\x66\x55\x79\x32\x76\x53\x42\x67\x76\x4b','\x71\x4d\x58\x36\x45\x4b\x57','\x41\x77\x31\x48\x7a\x32\x76\x46\x44\x78\x6a\x53','\x41\x77\x35\x57\x44\x78\x71','\x44\x76\x7a\x36\x43\x4c\x79','\x43\x68\x76\x5a\x41\x61','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x4e\x72\x35\x43\x67\x75','\x7a\x78\x48\x4c\x79\x33\x76\x30\x7a\x76\x72\x56\x42\x32\x57','\x41\x77\x35\x4d\x42\x57','\x7a\x32\x76\x30\x75\x68\x6a\x50\x42\x33\x6a\x75\x44\x78\x6a\x55\x43\x57','\x41\x77\x35\x5a\x44\x68\x6a\x31\x79\x33\x72\x50\x42\x32\x35\x5a','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x5a','\x42\x67\x72\x74\x73\x4e\x4b','\x77\x4d\x6e\x6c\x76\x30\x57','\x43\x4e\x6e\x46\x6d\x61','\x44\x32\x44\x53\x44\x76\x61','\x74\x32\x76\x48\x73\x67\x75','\x7a\x4d\x66\x50\x42\x68\x76\x59\x7a\x71','\x44\x75\x48\x52\x76\x75\x71','\x75\x78\x6e\x4f\x71\x30\x65','\x42\x33\x76\x30\x79\x32\x39\x54\x7a\x71','\x79\x4d\x58\x56\x79\x32\x53','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x66\x39\x4d\x41\x77\x58\x30\x7a\x78\x69','\x78\x73\x35\x30\x45\x78\x62\x4c','\x76\x4b\x35\x57\x42\x30\x34','\x79\x4b\x58\x30\x73\x31\x4f','\x79\x77\x58\x53\x42\x33\x43','\x79\x32\x44\x79\x72\x67\x47','\x41\x77\x35\x57\x44\x78\x72\x46\x79\x78\x76\x4b\x41\x77\x38','\x72\x4d\x7a\x6c\x76\x4d\x6d','\x7a\x4d\x58\x48\x44\x65\x31\x48\x43\x61','\x76\x67\x39\x56\x42\x63\x62\x30\x45\x78\x62\x4c\x69\x63\x69','\x73\x77\x35\x57\x44\x78\x71\x47\x43\x33\x72\x59\x41\x77\x35\x4e\x69\x67\x31\x31\x43\x33\x71\x47\x42\x4d\x39\x30\x69\x67\x6a\x4c\x69\x67\x76\x54\x43\x68\x72\x35','\x45\x68\x62\x4d\x45\x77\x71','\x43\x67\x76\x59\x75\x32\x76\x4a\x42\x32\x35\x4b\x75\x67\x76\x59\x75\x32\x76\x5a\x43\x32\x4c\x56\x42\x47','\x6d\x68\x57\x31\x46\x64\x72\x38\x6d\x4e\x57\x5a\x46\x64\x65','\x73\x77\x35\x57\x44\x78\x71\x47\x42\x78\x76\x5a\x44\x63\x62\x49\x7a\x73\x62\x48\x69\x68\x6e\x30\x43\x4d\x4c\x55\x7a\x59\x57\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x42\x32\x79\x47\x43\x33\x72\x59\x41\x77\x35\x4e\x43\x59\x57\x47\x42\x33\x69\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x42\x32\x79\x47\x44\x67\x39\x52\x7a\x77\x34\x47\x79\x78\x6a\x59\x79\x78\x4c\x5a','\x76\x4d\x31\x56\x43\x33\x79','\x44\x78\x6e\x4c\x43\x4b\x58\x56\x79\x32\x66\x30\x41\x77\x39\x55','\x79\x78\x6e\x5a\x41\x78\x6e\x30\x79\x77\x35\x30','\x79\x77\x72\x4b\x43\x4d\x76\x5a\x43\x57','\x75\x30\x4c\x6c\x72\x30\x4b','\x77\x67\x7a\x71\x72\x76\x75','\x43\x32\x4c\x55\x41\x57','\x75\x4d\x76\x58\x44\x77\x76\x5a\x44\x63\x62\x49\x42\x32\x72\x35\x69\x67\x31\x31\x43\x33\x71\x47\x79\x4d\x75\x47\x79\x77\x34\x47\x42\x32\x6a\x51\x7a\x77\x6e\x30','\x44\x65\x50\x77\x79\x33\x6d','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x30\x42\x32\x54\x4c\x42\x4c\x39\x30\x45\x78\x62\x4c','\x42\x4e\x50\x4e\x76\x4c\x4b','\x42\x33\x76\x30\x43\x68\x76\x30\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x41\x77\x35\x46\x43\x68\x6a\x56\x7a\x33\x6a\x4c\x43\x33\x6d','\x42\x67\x54\x7a\x72\x4d\x4f','\x43\x4e\x76\x55\x71\x4d\x76\x4d\x42\x33\x6a\x4c','\x78\x33\x6e\x30\x79\x78\x72\x31\x43\x57','\x42\x32\x35\x74\x44\x67\x66\x30\x44\x78\x6e\x64\x41\x67\x66\x55\x7a\x32\x75','\x43\x76\x66\x67\x71\x75\x79','\x43\x33\x6a\x4a','\x41\x78\x76\x69\x41\x65\x57','\x79\x78\x6a\x4e\x44\x77\x31\x4c\x42\x4e\x72\x5a','\x44\x4d\x7a\x58\x73\x32\x65','\x7a\x67\x76\x5a\x44\x68\x6a\x31\x79\x33\x72\x50\x44\x4d\x75\x47\x79\x77\x6e\x30\x41\x77\x39\x55\x69\x67\x72\x4c\x42\x4d\x4c\x4c\x7a\x64\x4f\x47\x41\x77\x35\x57\x44\x78\x71\x47\x42\x77\x66\x30\x79\x32\x48\x4c\x43\x59\x61','\x7a\x67\x76\x32\x7a\x77\x58\x56\x43\x67\x76\x59','\x79\x4d\x76\x4d\x42\x33\x6a\x4c\x76\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x57','\x73\x75\x58\x6f\x72\x31\x47','\x44\x67\x66\x55\x7a\x32\x58\x4c\x6c\x57','\x7a\x66\x72\x71\x76\x67\x75','\x69\x49\x62\x50\x43\x59\x62\x55\x42\x33\x71\x47\x42\x32\x34\x47\x44\x67\x48\x4c\x69\x67\x66\x53\x42\x67\x39\x33\x69\x67\x58\x50\x43\x33\x71','\x77\x33\x6e\x4a\x43\x4d\x76\x4c\x42\x4e\x6e\x4f\x42\x33\x72\x73\x7a\x77\x72\x48\x79\x33\x72\x50\x42\x32\x35\x69\x42\x32\x39\x52\x78\x73\x62\x59\x7a\x77\x44\x50\x42\x32\x35\x5a\x69\x67\x6e\x56\x42\x4d\x7a\x50\x7a\x33\x76\x59\x7a\x77\x71\x47\x79\x4e\x76\x30\x69\x67\x62\x5a\x41\x67\x66\x59\x43\x67\x61\x47\x41\x78\x6d\x47\x42\x4d\x39\x30\x69\x67\x65\x47\x7a\x67\x76\x57\x7a\x77\x35\x4b\x7a\x77\x35\x4a\x45\x73\x62\x50\x42\x49\x62\x32\x6d\x74\x53\x47\x43\x67\x66\x5a\x43\x32\x4c\x55\x7a\x59\x62\x5a\x79\x33\x6a\x4c\x7a\x77\x35\x5a\x41\x67\x39\x30\x69\x68\x72\x4f\x43\x4d\x39\x31\x7a\x32\x47\x47\x44\x77\x35\x54\x42\x32\x72\x50\x7a\x4d\x4c\x4c\x7a\x61','\x41\x4c\x50\x67\x76\x4e\x43','\x43\x32\x48\x50\x7a\x4e\x71','\x43\x32\x48\x41\x41\x78\x6d','\x42\x4d\x44\x51\x75\x4e\x79','\x75\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x76\x5a\x76\x4d\x66\x53\x41\x77\x72\x48\x44\x67\x4c\x56\x42\x4b\x76\x59\x43\x4d\x39\x59','\x42\x33\x7a\x4c\x43\x4e\x6a\x50\x7a\x67\x75','\x75\x77\x4c\x73\x79\x4c\x47','\x79\x32\x66\x53\x42\x65\x4c\x4b','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c','\x71\x32\x50\x34\x7a\x4c\x61','\x42\x4d\x39\x33','\x43\x67\x35\x4e\x71\x4d\x66\x5a\x7a\x74\x79\x30','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x4d\x6e\x53\x41\x77\x6e\x52','\x44\x32\x66\x50\x44\x67\x76\x59\x43\x57','\x7a\x78\x48\x57\x41\x78\x6a\x4c\x7a\x61','\x44\x67\x39\x52\x7a\x77\x35\x5a','\x43\x67\x31\x4a\x79\x4b\x47','\x7a\x77\x44\x59\x7a\x78\x6e\x5a\x69\x67\x72\x4c\x42\x4d\x4c\x4c\x7a\x64\x4f\x47\x41\x67\x39\x5a\x44\x63\x61\x49','\x73\x33\x62\x55\x45\x4b\x75','\x7a\x32\x76\x30\x71\x33\x76\x59\x43\x4d\x76\x55\x44\x65\x6e\x56\x43\x33\x71','\x45\x65\x35\x56\x76\x32\x57','\x41\x77\x35\x4b\x7a\x78\x47','\x43\x32\x76\x48\x43\x4d\x6e\x4f\x71\x32\x39\x55\x44\x67\x76\x34\x44\x66\x6e\x50\x45\x4d\x75','\x44\x67\x39\x56\x42\x65\x4c\x55\x44\x4d\x39\x4a\x79\x78\x72\x50\x42\x32\x34','\x41\x67\x66\x5a','\x74\x31\x66\x65\x43\x4b\x53','\x44\x67\x4c\x54\x7a\x78\x6e\x30\x79\x77\x31\x57','\x79\x4b\x44\x53\x73\x30\x4f','\x7a\x67\x76\x5a\x79\x33\x6a\x50\x43\x68\x72\x50\x42\x32\x34','\x6d\x4a\x48\x30\x77\x67\x72\x30\x44\x4b\x43','\x44\x32\x66\x59\x42\x47','\x7a\x31\x66\x59\x72\x68\x69','\x43\x33\x72\x59\x41\x77\x35\x4e\x41\x77\x7a\x35','\x73\x67\x39\x41\x79\x78\x61','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x75\x39\x31\x44\x68\x62\x31\x44\x65\x4c\x55\x7a\x67\x76\x34','\x44\x78\x6a\x50','\x41\x78\x72\x4c\x43\x4d\x66\x30\x42\x33\x69','\x41\x32\x76\x35\x43\x57','\x71\x4d\x66\x4a\x76\x4b\x30','\x7a\x77\x35\x4a\x42\x32\x72\x50\x42\x4d\x44\x46\x7a\x4d\x39\x59\x42\x77\x66\x30','\x44\x67\x39\x52\x7a\x77\x34','\x43\x32\x76\x58\x44\x77\x76\x55\x79\x32\x75','\x73\x77\x35\x57\x44\x78\x71\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x42\x78\x76\x5a\x44\x63\x62\x55\x42\x33\x71\x47\x79\x4d\x75\x47\x7a\x77\x31\x57\x44\x68\x4b','\x41\x68\x6a\x4c\x7a\x47','\x7a\x77\x44\x59\x7a\x78\x6e\x5a\x69\x67\x72\x4c\x42\x4d\x4c\x4c\x7a\x63\x62\x49\x45\x73\x62\x48\x42\x67\x58\x56\x44\x30\x7a\x55','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x46\x44\x78\x6e\x4c\x78\x33\x62\x59\x7a\x78\x7a\x50\x7a\x78\x43','\x41\x78\x66\x52\x41\x32\x53','\x73\x65\x4c\x6b\x45\x4b\x43','\x42\x33\x76\x30\x43\x68\x76\x30','\x72\x4d\x50\x48\x72\x4b\x47','\x75\x4e\x76\x55\x72\x78\x7a\x4c\x42\x4e\x72\x74\x42\x33\x76\x59\x79\x32\x75\x47\x7a\x67\x39\x4c\x43\x59\x62\x55\x42\x33\x71\x47\x43\x33\x76\x57\x43\x67\x39\x59\x44\x63\x62\x5a\x44\x77\x6a\x54\x41\x78\x72\x75\x42\x32\x39\x53\x74\x33\x76\x30\x43\x68\x76\x30\x43\x57','\x77\x68\x50\x41\x7a\x76\x4b','\x6e\x31\x62\x79\x42\x4c\x50\x63\x75\x47','\x43\x33\x72\x59\x7a\x77\x66\x54\x69\x67\x76\x59\x43\x4d\x39\x59','\x76\x4e\x4c\x78\x44\x4b\x57','\x6d\x4a\x65\x58\x6d\x4a\x75\x33\x6d\x66\x7a\x74\x44\x4d\x66\x58\x72\x47','\x44\x78\x6e\x4c\x43\x4c\x62\x48\x43\x4e\x72\x5a','\x42\x67\x66\x49\x7a\x77\x57','\x79\x32\x76\x50\x42\x67\x4c\x55\x7a\x57','\x44\x67\x66\x59\x7a\x32\x76\x30','\x79\x32\x58\x56\x43\x32\x75','\x42\x76\x7a\x48\x71\x77\x38','\x43\x4d\x76\x5a\x42\x32\x58\x32\x7a\x71','\x43\x68\x66\x49\x43\x33\x6d','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x50\x42\x4e\x62\x31\x44\x66\x39\x30\x45\x78\x62\x4c','\x42\x4d\x76\x48\x43\x47','\x43\x4d\x76\x5a\x44\x77\x58\x30','\x43\x33\x72\x56\x43\x61','\x6d\x74\x71\x31\x6e\x74\x4b\x32\x42\x66\x76\x77\x73\x78\x4c\x75','\x7a\x78\x72\x77\x79\x4b\x79','\x74\x4c\x50\x36\x43\x76\x61','\x73\x65\x6a\x41\x76\x4c\x4f','\x45\x68\x6e\x57\x43\x68\x71','\x7a\x67\x44\x77\x73\x78\x43','\x79\x77\x58\x53\x42\x33\x44\x67\x42\x47','\x79\x32\x66\x55\x79\x32\x76\x53','\x73\x30\x35\x59\x72\x4d\x75','\x7a\x4d\x4c\x53\x44\x67\x76\x59\x7a\x77\x71','\x7a\x4d\x4c\x53\x7a\x76\x39\x5a\x7a\x77\x66\x59\x79\x32\x47','\x44\x67\x39\x6d\x42\x33\x44\x4c\x43\x4b\x6e\x48\x43\x32\x75','\x43\x33\x76\x4a\x79\x32\x76\x5a\x43\x57','\x78\x31\x39\x59\x7a\x78\x6e\x57\x42\x32\x35\x5a\x7a\x78\x6e\x66\x45\x68\x72\x59\x79\x78\x6d','\x42\x77\x66\x57','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x46\x44\x78\x6e\x4c','\x42\x77\x76\x4b\x41\x78\x76\x54','\x6d\x74\x43\x30\x6d\x64\x6d\x33\x42\x4d\x72\x30\x73\x65\x6a\x4d','\x44\x4d\x66\x53\x44\x77\x75','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x61','\x79\x31\x50\x51\x73\x77\x53','\x7a\x78\x48\x4c\x79\x33\x76\x30\x41\x77\x39\x55\x6c\x4e\x6e\x30\x79\x78\x6a\x30\x7a\x77\x71','\x77\x4d\x6a\x55\x76\x4e\x75','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x62\x79\x33\x72\x50\x42\x32\x34','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x6a\x7a\x61','\x41\x75\x4c\x35\x75\x31\x79','\x44\x4c\x6e\x78\x73\x32\x53','\x44\x67\x39\x56\x42\x66\x39\x55\x79\x77\x31\x4c','\x41\x65\x76\x6c\x72\x75\x69','\x44\x30\x66\x63\x75\x30\x30','\x7a\x67\x76\x53\x7a\x78\x72\x4c','\x43\x78\x76\x4c\x44\x77\x75','\x7a\x67\x7a\x4a\x45\x76\x47','\x7a\x4d\x66\x50\x42\x67\x76\x4b','\x76\x66\x4c\x66\x43\x66\x65','\x6d\x74\x6d\x32\x6d\x64\x4b\x59\x72\x4e\x76\x34\x76\x76\x72\x48','\x76\x68\x50\x54\x42\x32\x6d','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x63\x44\x77\x7a\x4d\x7a\x78\x69','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x76\x43\x32\x75','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x4e\x6e\x4a\x43\x4d\x76\x4c\x42\x4e\x6e\x4f\x42\x33\x71','\x44\x67\x39\x56\x42\x66\x39\x50\x42\x4e\x7a\x56\x79\x32\x66\x30\x41\x77\x39\x55','\x79\x77\x7a\x30\x7a\x78\x6a\x75\x42\x32\x39\x53\x71\x32\x66\x53\x42\x61','\x43\x32\x76\x48\x43\x4d\x6e\x4f\x78\x32\x6e\x56\x42\x4e\x72\x4c\x45\x68\x72\x46\x43\x32\x4c\x36\x7a\x71','\x44\x77\x35\x52\x42\x4d\x39\x33\x42\x49\x62\x4d\x79\x77\x4c\x53\x44\x78\x6a\x4c','\x72\x65\x72\x70\x74\x76\x6d','\x76\x66\x6e\x62\x42\x68\x75','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53','\x76\x32\x48\x76\x75\x30\x34','\x79\x32\x66\x55\x79\x32\x76\x53\x75\x4d\x76\x58\x44\x77\x76\x5a\x44\x67\x76\x4b','\x42\x31\x6e\x30\x41\x4d\x4f','\x75\x4b\x72\x59\x73\x4d\x79','\x77\x76\x44\x58\x7a\x68\x4f','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75','\x44\x68\x6a\x48\x42\x4e\x6e\x50\x44\x67\x4c\x56\x42\x47','\x74\x77\x48\x64\x75\x4e\x65','\x43\x4d\x66\x33','\x79\x32\x39\x55\x44\x67\x4c\x55\x44\x77\x75','\x43\x75\x66\x53\x42\x75\x53','\x7a\x4d\x39\x59\x42\x77\x66\x30','\x41\x4d\x39\x50\x42\x47','\x79\x4e\x76\x4d\x7a\x4d\x76\x59','\x43\x32\x76\x30','\x44\x67\x39\x56\x42\x68\x6d','\x43\x4d\x6e\x4f\x72\x4b\x53','\x43\x4e\x76\x55\x71\x77\x7a\x30\x7a\x78\x69','\x7a\x77\x35\x4b\x43\x67\x39\x50\x42\x4e\x71','\x6e\x74\x65\x32\x6d\x74\x43\x30\x73\x67\x6a\x76\x71\x4e\x76\x30','\x42\x33\x76\x4d\x44\x4c\x6d','\x7a\x67\x54\x35\x76\x4c\x43','\x74\x68\x6a\x6a\x72\x78\x47','\x69\x67\x4c\x5a\x69\x61','\x79\x78\x6e\x5a\x41\x78\x6e\x30\x79\x77\x35\x30\x76\x67\x76\x34\x44\x61','\x43\x4d\x76\x48\x43\x32\x39\x55','\x41\x77\x35\x57\x44\x78\x72\x46\x44\x67\x39\x52\x7a\x77\x35\x5a','\x7a\x77\x31\x57\x44\x68\x4c\x46\x41\x77\x35\x57\x44\x78\x71','\x41\x77\x35\x57\x44\x78\x72\x75\x42\x32\x54\x4c\x42\x4e\x6d','\x71\x31\x62\x4c\x7a\x4e\x75','\x43\x4d\x76\x4d\x44\x78\x6e\x48\x42\x61','\x79\x4d\x76\x4d\x42\x33\x6a\x4c','\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x4c\x56\x42\x4c\x39\x30\x42\x32\x54\x4c\x42\x4e\x6d','\x7a\x67\x4c\x54\x7a\x77\x35\x5a\x41\x77\x39\x55\x43\x57','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x42\x77\x66\x34\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x75\x67\x39\x53\x42\x31\x69','\x6d\x4b\x39\x6a\x43\x4c\x66\x4e\x7a\x57','\x41\x4c\x50\x67\x41\x4b\x38','\x77\x32\x66\x31\x7a\x67\x4c\x30\x78\x71','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x46\x79\x32\x66\x53\x42\x61','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x47','\x79\x78\x6a\x4e\x43\x57','\x74\x31\x76\x78\x44\x67\x65','\x43\x33\x72\x59\x41\x77\x35\x4e','\x7a\x68\x6a\x50\x44\x4d\x76\x74\x44\x68\x6a\x4c\x79\x77\x30','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x73\x35\x57\x79\x78\x6a\x30\x6c\x4e\x76\x57\x7a\x67\x66\x30\x7a\x77\x71','\x44\x4b\x4c\x35\x43\x67\x4f','\x44\x77\x35\x5a\x44\x78\x62\x57\x42\x33\x6a\x30\x7a\x77\x72\x46\x44\x67\x39\x56\x42\x61','\x75\x4c\x48\x32\x41\x68\x79','\x77\x4b\x66\x6e\x42\x33\x75','\x76\x67\x39\x52\x7a\x77\x34\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x42\x78\x76\x5a\x44\x63\x62\x4a\x42\x32\x35\x30\x79\x77\x4c\x55\x69\x67\x39\x55\x42\x68\x4b\x47\x42\x4e\x76\x54\x79\x4d\x76\x59\x43\x5a\x53\x47\x41\x77\x35\x4b\x7a\x78\x47\x47','\x44\x78\x6e\x48\x7a\x32\x75','\x79\x32\x58\x4c\x79\x78\x69','\x7a\x4d\x58\x56\x42\x33\x69','\x43\x4d\x39\x53\x7a\x71','\x69\x67\x31\x31\x43\x33\x71\x47\x79\x32\x39\x55\x44\x67\x66\x50\x42\x49\x62\x56\x42\x4d\x58\x35\x69\x67\x35\x31\x42\x77\x6a\x4c\x43\x4e\x6d\x37\x69\x67\x76\x53\x7a\x77\x31\x4c\x42\x4e\x71\x47','\x7a\x4d\x6e\x46','\x44\x67\x66\x5a\x41\x31\x62\x48\x43\x4e\x72\x5a','\x42\x77\x66\x34','\x74\x33\x7a\x57\x73\x75\x57','\x79\x78\x6e\x35\x42\x4d\x6e\x6a\x44\x67\x76\x59\x79\x78\x72\x56\x43\x47','\x7a\x77\x44\x59\x7a\x78\x6e\x5a\x69\x67\x72\x4c\x42\x4d\x4c\x4c\x7a\x64\x4f\x47\x44\x77\x35\x57\x79\x78\x6a\x5a\x7a\x77\x66\x49\x42\x67\x75\x47\x44\x78\x6a\x53','\x43\x32\x76\x5a\x43\x32\x4c\x56\x42\x49\x35\x31\x43\x67\x72\x48\x44\x67\x76\x4b','\x45\x65\x72\x31\x43\x31\x4b','\x41\x67\x39\x5a\x44\x61','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x64\x79\x77\x58\x53\x43\x57','\x43\x33\x72\x48\x43\x4e\x71','\x43\x33\x72\x48\x43\x4e\x72\x5a\x76\x32\x4c\x30\x41\x61','\x43\x32\x39\x54\x7a\x71','\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x78\x6e\x62\x79\x33\x72\x50\x42\x32\x34','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53\x43\x57','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x30\x42\x32\x39\x53','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75\x55\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x76\x4b','\x42\x33\x76\x30\x43\x68\x76\x30\x78\x33\x72\x56\x41\x32\x76\x55\x43\x31\x39\x4b\x7a\x78\x72\x48\x41\x77\x58\x5a','\x44\x67\x76\x34\x44\x66\x62\x50\x7a\x77\x6e\x4c\x43\x57','\x44\x67\x39\x30\x79\x77\x58\x46\x44\x67\x39\x52\x7a\x77\x35\x5a','\x72\x31\x48\x62\x74\x4e\x65','\x44\x67\x4c\x30\x42\x67\x75','\x69\x67\x31\x31\x43\x33\x71\x47\x42\x4d\x39\x30\x69\x67\x6a\x4c\x69\x67\x76\x54\x43\x68\x72\x35','\x42\x78\x6e\x4e\x78\x57','\x76\x4c\x50\x36\x73\x77\x65','\x7a\x32\x76\x30','\x71\x32\x58\x31\x79\x31\x69','\x42\x77\x39\x4b\x7a\x77\x57','\x44\x75\x76\x48\x41\x75\x71','\x43\x4e\x76\x55\x73\x77\x71','\x77\x66\x62\x63\x43\x4c\x47','\x79\x77\x58\x30','\x44\x67\x76\x59\x42\x77\x4c\x55\x79\x78\x72\x4c','\x45\x78\x6e\x35\x42\x4c\x71','\x44\x78\x6e\x4c\x43\x4c\x39\x53\x42\x32\x6e\x48\x44\x67\x4c\x56\x42\x47','\x42\x33\x62\x4c\x42\x4d\x66\x50\x74\x77\x76\x5a\x43\x32\x66\x4e\x7a\x78\x6e\x75\x42\x31\x6e\x48\x42\x4d\x72\x49\x42\x33\x48\x6a\x42\x4e\x62\x31\x44\x64\x4f\x47\x42\x77\x66\x53\x7a\x4d\x39\x59\x42\x77\x76\x4b\x69\x67\x66\x5a\x43\x32\x4c\x5a\x44\x67\x66\x55\x44\x63\x62\x30\x42\x32\x39\x53\x78\x32\x6e\x48\x42\x67\x57\x47\x79\x78\x71\x47\x41\x77\x35\x4b\x7a\x78\x47\x47'];a0_0x2d62=function(){return _0x21a8f2;};return a0_0x2d62();}function usageFromEvents(_0x3df0ec){const _0x339bc6=a0_0x15650e,_0x5d850f={'\x58\x4f\x56\x55\x54':function(_0x59f25d){return _0x59f25d();}};let _0x7c4645=_0x5d850f[_0x339bc6(0x170)](emptyUsage);for(const _0x536130 of _0x3df0ec){if(_0x536130[_0x339bc6(0x141)]!==_0x339bc6(0x194))continue;const _0x2832d6=readUsageFromEvent(_0x536130);if(_0x2832d6)_0x7c4645=foldUsage(_0x7c4645,_0x2832d6);}return _0x7c4645;}const SUPPORTED_TOOL_TYPES=new Set(['\x66\x75\x6e\x63\x74\x69\x6f\x6e',a0_0x15650e(0x22c),'\x63\x6f\x64\x65\x5f\x69\x6e\x74\x65\x72\x70\x72\x65\x74\x65\x72',a0_0x15650e(0x1ac),a0_0x15650e(0x12f),a0_0x15650e(0x182)]),REJECTED_TOOL_TYPES=new Set([a0_0x15650e(0x24d)]);var ResponsesValidationError=class extends Error{[a0_0x15650e(0x141)]='\x69\x6e\x76\x61\x6c\x69\x64\x5f\x72\x65\x71\x75\x65\x73\x74\x5f\x65\x72\x72\x6f\x72';['\x63\x6f\x64\x65'];[a0_0x15650e(0x14b)];constructor(_0x110475,_0xa28442,_0x44fde8){const _0x570fda=a0_0x15650e;super(_0x110475),this[_0x570fda(0x1b2)]=_0x570fda(0x203),this['\x63\x6f\x64\x65']=_0xa28442,this[_0x570fda(0x14b)]=_0x44fde8;}};function validateResponsesRequest(_0x187d29){const _0x1aedf8=a0_0x15650e,_0x28d7e7={'\x77\x63\x56\x52\x4d':function(_0x5d59cc,_0x8f7c1d){return _0x5d59cc===_0x8f7c1d;},'\x52\x44\x72\x4a\x66':_0x1aedf8(0x29e),'\x54\x66\x42\x62\x4b':_0x1aedf8(0xeb)},_0x11d8d7=_0x187d29['\x74\x6f\x6f\x6c\x73'];if(!_0x11d8d7||_0x28d7e7[_0x1aedf8(0x1b5)](_0x11d8d7[_0x1aedf8(0x132)],0x0))return;for(let _0xbc1d4e=0x0;_0xbc1d4e<_0x11d8d7[_0x1aedf8(0x132)];_0xbc1d4e++){const _0x2af290=_0x11d8d7[_0xbc1d4e][_0x1aedf8(0x141)];if(typeof _0x2af290!==_0x28d7e7[_0x1aedf8(0x275)])throw new ResponsesValidationError(_0x1aedf8(0x121)+_0xbc1d4e+_0x1aedf8(0x11d),_0x28d7e7[_0x1aedf8(0x118)],_0x1aedf8(0x121)+_0xbc1d4e+_0x1aedf8(0x1d3));if(REJECTED_TOOL_TYPES[_0x1aedf8(0x217)](_0x2af290))throw new ResponsesValidationError(_0x1aedf8(0x1db)+_0x2af290+_0x1aedf8(0x11f),_0x1aedf8(0x2a2),'\x74\x6f\x6f\x6c\x73\x5b'+_0xbc1d4e+'\x5d\x2e\x74\x79\x70\x65');if(!SUPPORTED_TOOL_TYPES[_0x1aedf8(0x217)](_0x2af290))throw new ResponsesValidationError('\x54\x6f\x6f\x6c\x20\x74\x79\x70\x65\x20\x22'+_0x2af290+'\x22\x20\x69\x73\x20\x6e\x6f\x74\x20\x72\x65\x63\x6f\x67\x6e\x69\x7a\x65\x64',_0x1aedf8(0x2a2),_0x1aedf8(0x121)+_0xbc1d4e+_0x1aedf8(0x1d3));}}function normalizeResponsesWebSearchForTangleRouter(_0x6e274f,_0x445bab={}){const _0x5e7a1e=a0_0x15650e,_0x292e50={'\x6c\x71\x6d\x67\x73':function(_0x4cf9f0,_0x9b4ba3){return _0x4cf9f0!==_0x9b4ba3;},'\x55\x4f\x55\x41\x59':_0x5e7a1e(0x17d),'\x79\x68\x4d\x56\x79':'\x77\x65\x62\x5f\x73\x65\x61\x72\x63\x68\x5f\x70\x72\x65\x76\x69\x65\x77'},_0x33d48b=Array['\x69\x73\x41\x72\x72\x61\x79'](_0x6e274f[_0x5e7a1e(0x281)])?_0x6e274f[_0x5e7a1e(0x281)]:void 0x0;if(!_0x33d48b)return _0x6e274f;let _0x46c456=![];const _0x4f0865=_0x33d48b['\x6d\x61\x70'](_0x55449d=>{const _0x18dbea=_0x5e7a1e;if(!_0x55449d||_0x292e50['\x6c\x71\x6d\x67\x73'](typeof _0x55449d,_0x292e50[_0x18dbea(0x190)]))return _0x55449d;const _0x32db13=_0x55449d[_0x18dbea(0x141)];if(_0x32db13!==_0x18dbea(0x1ac)&&_0x32db13!==_0x292e50['\x79\x68\x4d\x56\x79'])return _0x55449d;return _0x46c456=!![],{'\x74\x79\x70\x65':_0x18dbea(0x182),'\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73':{...readNativeWebSearchParameters(_0x55449d),..._0x445bab[_0x18dbea(0x157)]?{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x445bab[_0x18dbea(0x157)]}:{},..._0x445bab[_0x18dbea(0x125)]?{'\x6d\x61\x78\x5f\x72\x65\x73\x75\x6c\x74\x73':_0x445bab[_0x18dbea(0x125)]}:{},..._0x445bab['\x6d\x61\x78\x54\x6f\x74\x61\x6c\x52\x65\x73\x75\x6c\x74\x73']?{'\x6d\x61\x78\x5f\x74\x6f\x74\x61\x6c\x5f\x72\x65\x73\x75\x6c\x74\x73':_0x445bab['\x6d\x61\x78\x54\x6f\x74\x61\x6c\x52\x65\x73\x75\x6c\x74\x73']}:{},..._0x445bab[_0x18dbea(0x215)]?{'\x73\x65\x61\x72\x63\x68\x5f\x63\x6f\x6e\x74\x65\x78\x74\x5f\x73\x69\x7a\x65':_0x445bab[_0x18dbea(0x215)]}:{}}};});return _0x46c456?{..._0x6e274f,'\x74\x6f\x6f\x6c\x73':_0x4f0865}:_0x6e274f;}function readNativeWebSearchParameters(_0x57e95d){const _0xa66627=a0_0x15650e,_0x589611={'\x64\x6b\x79\x56\x57':_0xa66627(0x12e),'\x6a\x5a\x46\x56\x77':_0xa66627(0x253),'\x57\x68\x55\x53\x4e':function(_0x4504d7,_0x167f16){return _0x4504d7===_0x167f16;}},_0x19f9cd=_0x57e95d,_0x51fa7a={},_0x3430db=_0x19f9cd[_0xa66627(0x26d)]??_0x19f9cd[_0xa66627(0x215)];if(_0x3430db===_0x589611[_0xa66627(0x287)]||_0x3430db===_0x589611[_0xa66627(0x1ff)]||_0x3430db==='\x68\x69\x67\x68')_0x51fa7a[_0xa66627(0x26d)]=_0x3430db;const _0x295777=_0x19f9cd[_0xa66627(0xfe)]??_0x19f9cd[_0xa66627(0x1e2)];if(_0x295777&&_0x589611[_0xa66627(0x272)](typeof _0x295777,'\x6f\x62\x6a\x65\x63\x74'))_0x51fa7a['\x75\x73\x65\x72\x5f\x6c\x6f\x63\x61\x74\x69\x6f\x6e']=_0x295777;return _0x51fa7a;}function buildResponseShell(_0xd2843e){const _0x34757b=a0_0x15650e,_0x287a34={'\x6e\x67\x6a\x52\x76':_0x34757b(0x277),'\x54\x59\x45\x70\x51':'\x61\x75\x74\x6f'},_0x3b8add=_0xd2843e[_0x34757b(0x22f)][_0x34757b(0x114)](_0x2b9d61=>_0x2b9d61[_0x34757b(0x141)]===_0x34757b(0x126))[_0x34757b(0x1da)](_0x28a6ac=>_0x28a6ac[_0x34757b(0x256)])[_0x34757b(0x114)](_0x10deb6=>_0x10deb6[_0x34757b(0x141)]==='\x6f\x75\x74\x70\x75\x74\x5f\x74\x65\x78\x74')['\x6d\x61\x70'](_0x3897c0=>_0x3897c0[_0x34757b(0x19f)])[_0x34757b(0x27e)]('');return{'\x69\x64':_0xd2843e['\x69\x64'],'\x6f\x62\x6a\x65\x63\x74':_0x287a34[_0x34757b(0x202)],'\x63\x72\x65\x61\x74\x65\x64\x5f\x61\x74':_0xd2843e['\x63\x72\x65\x61\x74\x65\x64\x41\x74'],'\x6f\x75\x74\x70\x75\x74\x5f\x74\x65\x78\x74':_0x3b8add,'\x65\x72\x72\x6f\x72':null,'\x69\x6e\x63\x6f\x6d\x70\x6c\x65\x74\x65\x5f\x64\x65\x74\x61\x69\x6c\x73':null,'\x69\x6e\x73\x74\x72\x75\x63\x74\x69\x6f\x6e\x73':_0xd2843e[_0x34757b(0x1c5)]??null,'\x6d\x65\x74\x61\x64\x61\x74\x61':null,'\x6d\x6f\x64\x65\x6c':_0xd2843e[_0x34757b(0xf7)],'\x6f\x75\x74\x70\x75\x74':_0xd2843e['\x6f\x75\x74\x70\x75\x74'],'\x70\x61\x72\x61\x6c\x6c\x65\x6c\x5f\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73':![],'\x74\x65\x6d\x70\x65\x72\x61\x74\x75\x72\x65':null,'\x74\x6f\x6f\x6c\x5f\x63\x68\x6f\x69\x63\x65':_0x287a34[_0x34757b(0x265)],'\x74\x6f\x6f\x6c\x73':[],'\x74\x6f\x70\x5f\x70':null,'\x73\x74\x61\x74\x75\x73':_0x34757b(0x19b),'\x75\x73\x61\x67\x65':_0xd2843e['\x75\x73\x61\x67\x65'],'\x70\x72\x65\x76\x69\x6f\x75\x73\x5f\x72\x65\x73\x70\x6f\x6e\x73\x65\x5f\x69\x64':_0xd2843e[_0x34757b(0x167)]??null};}function createTranslatorContext(_0x282100){const _0x2950c8=a0_0x15650e;return{'\x63\x68\x75\x6e\x6b\x49\x6e\x64\x65\x78':0x0,'\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72':new Map(),'\x63\x72\x65\x61\x74\x65\x64\x41\x74':Math[_0x2950c8(0xd9)](Date['\x6e\x6f\x77']()/0x3e8),..._0x282100};}export{EmbeddingValidationError,HookChain,InMemoryResponseStore,ResponsesValidationError,Run,actionRateLimitHook,assembleResponseOutput,auditLogHook,buildResponseShell,costCapHook,createTranslatorContext,destructiveActionGuardHook,egressPolicyHook,normalizeResponsesWebSearchForTangleRouter,openaiMessagesToSandboxInput,outcomeToFinishReason,resolvePreviousResponseId,runEvents,sandboxEventToChatChunk,sandboxEventToCompletionChunk,sandboxEventToResponsesEvent,screenshotRedactionHook,usageFromEvents,validateEmbeddingRequest,validateResponsesRequest};
|
|
1
|
+
//#region src/openai/hooks.ts
|
|
2
|
+
/**
|
|
3
|
+
* Sequential hook composer. Hooks run in registration order; `block` and
|
|
4
|
+
* `terminate` short-circuit. `rewrite` and `override` thread their
|
|
5
|
+
* mutated payloads through to the remaining hooks so subsequent hooks
|
|
6
|
+
* observe the rewritten args / overridden result.
|
|
7
|
+
*/
|
|
8
|
+
var HookChain = class {
|
|
9
|
+
hooks;
|
|
10
|
+
constructor(hooks = []) {
|
|
11
|
+
this.hooks = hooks;
|
|
12
|
+
}
|
|
13
|
+
/** Number of hooks in the chain. */
|
|
14
|
+
get size() {
|
|
15
|
+
return this.hooks.length;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Run every `beforeToolCall` in registration order. Returns the first
|
|
19
|
+
* non-`allow` outcome (block/rewrite), or `allow` if the chain ran
|
|
20
|
+
* clean. `rewrite` outcomes are threaded forward so later hooks see
|
|
21
|
+
* the mutated args.
|
|
22
|
+
*/
|
|
23
|
+
async runBefore(ctx) {
|
|
24
|
+
let current = ctx;
|
|
25
|
+
let lastRewrite = null;
|
|
26
|
+
for (const hook of this.hooks) {
|
|
27
|
+
if (!hook.beforeToolCall) continue;
|
|
28
|
+
const outcome = await hook.beforeToolCall(current);
|
|
29
|
+
if (outcome.action === "block") return outcome;
|
|
30
|
+
if (outcome.action === "rewrite") {
|
|
31
|
+
current = {
|
|
32
|
+
...current,
|
|
33
|
+
args: outcome.args
|
|
34
|
+
};
|
|
35
|
+
lastRewrite = outcome;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return lastRewrite ?? { action: "allow" };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Run every `afterToolCall` in registration order. Returns the first
|
|
42
|
+
* `terminate` outcome immediately. `override` outcomes are threaded
|
|
43
|
+
* forward so later hooks see the mutated result; the final result is
|
|
44
|
+
* surfaced as the last `override`, or `pass` if no hook overrode.
|
|
45
|
+
*/
|
|
46
|
+
async runAfter(ctx, result) {
|
|
47
|
+
let current = result;
|
|
48
|
+
let lastOverride = null;
|
|
49
|
+
for (const hook of this.hooks) {
|
|
50
|
+
if (!hook.afterToolCall) continue;
|
|
51
|
+
const outcome = await hook.afterToolCall(ctx, current);
|
|
52
|
+
if (outcome.action === "terminate") return outcome;
|
|
53
|
+
if (outcome.action === "override") {
|
|
54
|
+
current = outcome.result;
|
|
55
|
+
lastOverride = outcome;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return lastOverride ?? { action: "pass" };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Emits a structured `AuditEvent` for every tool call (before + after).
|
|
63
|
+
* Default sink is `console.info`. The route layer swaps the sink for
|
|
64
|
+
* the eval-runs DuckDB writer.
|
|
65
|
+
*/
|
|
66
|
+
function auditLogHook(opts = {}) {
|
|
67
|
+
const sink = opts.sink ?? ((event) => {
|
|
68
|
+
console.info("[audit]", event);
|
|
69
|
+
});
|
|
70
|
+
return {
|
|
71
|
+
async beforeToolCall(ctx) {
|
|
72
|
+
await sink({
|
|
73
|
+
phase: "before",
|
|
74
|
+
runId: ctx.runId,
|
|
75
|
+
threadId: ctx.threadId,
|
|
76
|
+
partnerId: ctx.partnerId,
|
|
77
|
+
toolName: ctx.toolName,
|
|
78
|
+
callId: ctx.callId,
|
|
79
|
+
timestamp: ctx.timestamp,
|
|
80
|
+
args: ctx.args
|
|
81
|
+
});
|
|
82
|
+
return { action: "allow" };
|
|
83
|
+
},
|
|
84
|
+
async afterToolCall(ctx, result) {
|
|
85
|
+
await sink({
|
|
86
|
+
phase: "after",
|
|
87
|
+
runId: ctx.runId,
|
|
88
|
+
threadId: ctx.threadId,
|
|
89
|
+
partnerId: ctx.partnerId,
|
|
90
|
+
toolName: ctx.toolName,
|
|
91
|
+
callId: ctx.callId,
|
|
92
|
+
timestamp: ctx.timestamp,
|
|
93
|
+
result
|
|
94
|
+
});
|
|
95
|
+
return { action: "pass" };
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const NETWORK_TOOL_REGEX = /^(fetch|http|https|browser|playwright|curl|wget|computer-use:click|computer-use:type)/i;
|
|
100
|
+
const URL_FIELD_NAMES = new Set([
|
|
101
|
+
"url",
|
|
102
|
+
"uri",
|
|
103
|
+
"endpoint",
|
|
104
|
+
"href",
|
|
105
|
+
"src",
|
|
106
|
+
"target",
|
|
107
|
+
"address"
|
|
108
|
+
]);
|
|
109
|
+
function extractUrlsFromArgs(args) {
|
|
110
|
+
const out = [];
|
|
111
|
+
const visit = (val) => {
|
|
112
|
+
if (typeof val === "string") {
|
|
113
|
+
if (/^https?:\/\//i.test(val)) try {
|
|
114
|
+
const u = new URL(val);
|
|
115
|
+
out.push({
|
|
116
|
+
raw: val,
|
|
117
|
+
host: u.host
|
|
118
|
+
});
|
|
119
|
+
} catch {
|
|
120
|
+
out.push({
|
|
121
|
+
raw: val,
|
|
122
|
+
host: null
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (val === null || typeof val !== "object") return;
|
|
128
|
+
if (Array.isArray(val)) {
|
|
129
|
+
for (const item of val) visit(item);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
for (const [k, v] of Object.entries(val)) {
|
|
133
|
+
if (URL_FIELD_NAMES.has(k.toLowerCase()) && typeof v === "string") {
|
|
134
|
+
try {
|
|
135
|
+
const u = new URL(v);
|
|
136
|
+
out.push({
|
|
137
|
+
raw: v,
|
|
138
|
+
host: u.host
|
|
139
|
+
});
|
|
140
|
+
} catch {
|
|
141
|
+
out.push({
|
|
142
|
+
raw: v,
|
|
143
|
+
host: null
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
visit(v);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
visit(args);
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
function isNetworkLike(ctx, urls) {
|
|
155
|
+
if (NETWORK_TOOL_REGEX.test(ctx.toolName)) return true;
|
|
156
|
+
return urls.length > 0;
|
|
157
|
+
}
|
|
158
|
+
function hostMatches(host, pattern) {
|
|
159
|
+
if (pattern === host) return true;
|
|
160
|
+
if (pattern.startsWith("*.")) {
|
|
161
|
+
const suffix = pattern.slice(1);
|
|
162
|
+
return host.endsWith(suffix);
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Best-effort allow/deny filter for tool-call URLs.
|
|
168
|
+
*
|
|
169
|
+
* Block tool calls that look network-ish (toolName matches the network
|
|
170
|
+
* regex OR args contain url-like fields) when the resolved host hits
|
|
171
|
+
* the deny list. The allow list is treated as an explicit allowance —
|
|
172
|
+
* when set, only listed hosts pass; unmatched hosts are blocked.
|
|
173
|
+
* `allowFn` overrides both lists when present.
|
|
174
|
+
*
|
|
175
|
+
* **What this hook does NOT catch.** It inspects URL-shaped strings in
|
|
176
|
+
* the tool-call arguments only. The following bypass it silently:
|
|
177
|
+
*
|
|
178
|
+
* - URLs encoded as base64 / hex / `Buffer.from(...)` literals
|
|
179
|
+
* - URLs assembled at execution time from string fragments
|
|
180
|
+
* - URLs reached via redirects, DNS rebinding, or proxy hosts that
|
|
181
|
+
* match the allow list but forward to denied destinations
|
|
182
|
+
* - Network calls made by spawned subprocesses, generated code, or
|
|
183
|
+
* tools whose argument schema does not name a URL field
|
|
184
|
+
*
|
|
185
|
+
* Treat this hook as a UX guardrail (clearer error messages,
|
|
186
|
+
* short-circuiting obvious mistakes) on top of a real egress boundary
|
|
187
|
+
* — not as one. When egress containment is a security requirement
|
|
188
|
+
* (exfil prevention, data residency), enforce it at the runtime
|
|
189
|
+
* sandbox layer (egress firewall, CNI policy, outbound proxy with
|
|
190
|
+
* mTLS) where the agent cannot evade it.
|
|
191
|
+
*/
|
|
192
|
+
function egressPolicyHook(opts = {}) {
|
|
193
|
+
const denyList = opts.denyList ?? [];
|
|
194
|
+
const allowList = opts.allowList;
|
|
195
|
+
return { async beforeToolCall(ctx) {
|
|
196
|
+
const urls = extractUrlsFromArgs(ctx.args);
|
|
197
|
+
if (!isNetworkLike(ctx, urls)) return { action: "allow" };
|
|
198
|
+
if (opts.allowFn) return await opts.allowFn(ctx) ? { action: "allow" } : {
|
|
199
|
+
action: "block",
|
|
200
|
+
reason: "egress denied by allowFn"
|
|
201
|
+
};
|
|
202
|
+
for (const u of urls) {
|
|
203
|
+
if (!u.host) continue;
|
|
204
|
+
for (const pat of denyList) if (hostMatches(u.host, pat)) return {
|
|
205
|
+
action: "block",
|
|
206
|
+
reason: `egress denied: host "${u.host}" matches deny pattern "${pat}"`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (allowList && allowList.length > 0) for (const u of urls) {
|
|
210
|
+
const host = u.host;
|
|
211
|
+
if (!host) return {
|
|
212
|
+
action: "block",
|
|
213
|
+
reason: "egress denied: unparseable url"
|
|
214
|
+
};
|
|
215
|
+
if (!allowList.some((pat) => hostMatches(host, pat))) return {
|
|
216
|
+
action: "block",
|
|
217
|
+
reason: `egress denied: host "${host}" is not on the allow list`
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return { action: "allow" };
|
|
221
|
+
} };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Terminates the run when the partner's accumulated cost is at or
|
|
225
|
+
* above `ceiling`. The cost lookup is injected so any usage ledger can
|
|
226
|
+
* back it.
|
|
227
|
+
*/
|
|
228
|
+
function costCapHook(opts) {
|
|
229
|
+
const getCurrentCost = opts.getCurrentCost ?? (async () => 0);
|
|
230
|
+
return {
|
|
231
|
+
async beforeToolCall(ctx) {
|
|
232
|
+
const current = await getCurrentCost(ctx.partnerId);
|
|
233
|
+
if (current >= opts.ceiling) return {
|
|
234
|
+
action: "block",
|
|
235
|
+
reason: `cost cap reached: ${current} >= ${opts.ceiling}`
|
|
236
|
+
};
|
|
237
|
+
return { action: "allow" };
|
|
238
|
+
},
|
|
239
|
+
async afterToolCall(ctx) {
|
|
240
|
+
const current = await getCurrentCost(ctx.partnerId);
|
|
241
|
+
if (current >= opts.ceiling) return {
|
|
242
|
+
action: "terminate",
|
|
243
|
+
reason: `cost cap reached after tool call: ${current} >= ${opts.ceiling}`
|
|
244
|
+
};
|
|
245
|
+
return { action: "pass" };
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Token-bucket rate limiter scoped per session id (`runId`) over
|
|
251
|
+
* `computer-use:*` tool calls. Excess calls are blocked with a clear
|
|
252
|
+
* reason. Non-`computer-use` tools pass through untouched.
|
|
253
|
+
*/
|
|
254
|
+
function actionRateLimitHook(opts) {
|
|
255
|
+
const now = opts.now ?? Date.now;
|
|
256
|
+
const capacity = Math.max(1, Math.floor(opts.perSecondPerSession));
|
|
257
|
+
const refillPerMs = opts.perSecondPerSession / 1e3;
|
|
258
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
259
|
+
return { async beforeToolCall(ctx) {
|
|
260
|
+
if (!ctx.toolName.startsWith("computer-use:")) return { action: "allow" };
|
|
261
|
+
const key = ctx.runId;
|
|
262
|
+
const t = now();
|
|
263
|
+
const bucket = buckets.get(key) ?? {
|
|
264
|
+
tokens: capacity,
|
|
265
|
+
lastRefillMs: t
|
|
266
|
+
};
|
|
267
|
+
const elapsed = Math.max(0, t - bucket.lastRefillMs);
|
|
268
|
+
bucket.tokens = Math.min(capacity, bucket.tokens + elapsed * refillPerMs);
|
|
269
|
+
bucket.lastRefillMs = t;
|
|
270
|
+
if (bucket.tokens < 1) {
|
|
271
|
+
buckets.set(key, bucket);
|
|
272
|
+
return {
|
|
273
|
+
action: "block",
|
|
274
|
+
reason: `action rate limit exceeded: ${opts.perSecondPerSession}/s`
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
bucket.tokens -= 1;
|
|
278
|
+
buckets.set(key, bucket);
|
|
279
|
+
return { action: "allow" };
|
|
280
|
+
} };
|
|
281
|
+
}
|
|
282
|
+
function readScreenshotPayload(result) {
|
|
283
|
+
const candidates = [
|
|
284
|
+
result.content,
|
|
285
|
+
result.details?.screenshot,
|
|
286
|
+
result.details
|
|
287
|
+
];
|
|
288
|
+
for (const c of candidates) if (c && typeof c === "object") {
|
|
289
|
+
if (typeof c.pngBase64 === "string") return c;
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Applied AFTER `computer-use:screenshot`. v1 ships without the
|
|
295
|
+
* `sharp` dependency: when regions are configured, we surface a warning
|
|
296
|
+
* exactly once per process and pass the screenshot through untouched.
|
|
297
|
+
* Pixel-blur lands in a follow-up that introduces `sharp` deliberately.
|
|
298
|
+
*/
|
|
299
|
+
function screenshotRedactionHook(opts = {}) {
|
|
300
|
+
const warn = opts.warn ?? ((msg) => console.warn(msg));
|
|
301
|
+
const hasRegions = (opts.regions?.length ?? 0) > 0;
|
|
302
|
+
let warned = false;
|
|
303
|
+
return { async afterToolCall(ctx, result) {
|
|
304
|
+
if (ctx.toolName !== "computer-use:screenshot") return { action: "pass" };
|
|
305
|
+
if (!hasRegions) return { action: "pass" };
|
|
306
|
+
if (!readScreenshotPayload(result)) return { action: "pass" };
|
|
307
|
+
if (!warned) {
|
|
308
|
+
warned = true;
|
|
309
|
+
warn("[screenshotRedactionHook] regions configured but `sharp` is not a dependency in v1; passing screenshot through unmodified");
|
|
310
|
+
}
|
|
311
|
+
return { action: "pass" };
|
|
312
|
+
} };
|
|
313
|
+
}
|
|
314
|
+
const TYPE_TEXT_FIELDS = [
|
|
315
|
+
"text",
|
|
316
|
+
"value",
|
|
317
|
+
"input",
|
|
318
|
+
"query"
|
|
319
|
+
];
|
|
320
|
+
const CLICK_LABEL_FIELDS = [
|
|
321
|
+
"label",
|
|
322
|
+
"alt",
|
|
323
|
+
"title",
|
|
324
|
+
"ariaLabel",
|
|
325
|
+
"near"
|
|
326
|
+
];
|
|
327
|
+
function readStringField(args, fields) {
|
|
328
|
+
if (!args || typeof args !== "object") return null;
|
|
329
|
+
const a = args;
|
|
330
|
+
for (const f of fields) {
|
|
331
|
+
const v = a[f];
|
|
332
|
+
if (typeof v === "string" && v.length > 0) return v;
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Block before-execute when a `computer-use:type` text or
|
|
338
|
+
* `computer-use:click` label matches any deny pattern. Mitigates
|
|
339
|
+
* destructive-action sequences (e.g. "delete account", "wire transfer")
|
|
340
|
+
* before they hit the OS.
|
|
341
|
+
*/
|
|
342
|
+
function destructiveActionGuardHook(opts) {
|
|
343
|
+
const patterns = opts.denyPatterns;
|
|
344
|
+
return { async beforeToolCall(ctx) {
|
|
345
|
+
let candidate = null;
|
|
346
|
+
if (ctx.toolName === "computer-use:type") candidate = readStringField(ctx.args, TYPE_TEXT_FIELDS);
|
|
347
|
+
else if (ctx.toolName === "computer-use:click") candidate = readStringField(ctx.args, CLICK_LABEL_FIELDS);
|
|
348
|
+
else return { action: "allow" };
|
|
349
|
+
if (!candidate) return { action: "allow" };
|
|
350
|
+
for (const re of patterns) if (re.test(candidate)) return {
|
|
351
|
+
action: "block",
|
|
352
|
+
reason: `destructive action denied: input matches ${re.toString()}`
|
|
353
|
+
};
|
|
354
|
+
return { action: "allow" };
|
|
355
|
+
} };
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/openai/responses-store.ts
|
|
359
|
+
var InMemoryResponseStore = class {
|
|
360
|
+
chains = /* @__PURE__ */ new Map();
|
|
361
|
+
async getPriorTurns(responseId) {
|
|
362
|
+
const turns = this.chains.get(responseId);
|
|
363
|
+
return turns ? turns.map((t) => ({ ...t })) : null;
|
|
364
|
+
}
|
|
365
|
+
async putPriorTurns(responseId, priorTurns) {
|
|
366
|
+
this.chains.set(responseId, priorTurns.map((t) => ({ ...t })));
|
|
367
|
+
}
|
|
368
|
+
/** Convenience accessor for tests / debug; not part of `ResponseStore`. */
|
|
369
|
+
size() {
|
|
370
|
+
return this.chains.size;
|
|
371
|
+
}
|
|
372
|
+
/** Drop a chain. */
|
|
373
|
+
delete(responseId) {
|
|
374
|
+
return this.chains.delete(responseId);
|
|
375
|
+
}
|
|
376
|
+
/** Drop everything. Useful between test cases. */
|
|
377
|
+
clear() {
|
|
378
|
+
this.chains.clear();
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/openai/runs.ts
|
|
383
|
+
const TERMINAL_STATUSES = new Set([
|
|
384
|
+
"completed",
|
|
385
|
+
"failed",
|
|
386
|
+
"cancelled",
|
|
387
|
+
"expired"
|
|
388
|
+
]);
|
|
389
|
+
function isTerminal(status) {
|
|
390
|
+
return TERMINAL_STATUSES.has(status);
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Pure async iterator over the underlying source. No state, no
|
|
394
|
+
* buffering. Iteration ends when the source closes or yields a
|
|
395
|
+
* terminal frame; the iterator itself does not classify frames.
|
|
396
|
+
*/
|
|
397
|
+
async function* runEvents(threadId, runId, source) {
|
|
398
|
+
for await (const event of source.open(threadId, runId)) yield event;
|
|
399
|
+
}
|
|
400
|
+
function readToolCallFromFrame(event) {
|
|
401
|
+
if (event.type === "requires_action" || event.type === "tool_call_requested") {
|
|
402
|
+
const data = event.data ?? event;
|
|
403
|
+
const id = String(data.callId ?? data.call_id ?? data.id ?? "");
|
|
404
|
+
const name = String(data.toolName ?? data.tool_name ?? data.name ?? "");
|
|
405
|
+
if (!id || !name) return null;
|
|
406
|
+
return {
|
|
407
|
+
callId: id,
|
|
408
|
+
toolName: name,
|
|
409
|
+
args: data.args ?? data.arguments ?? data.input ?? {},
|
|
410
|
+
requiresAction: true
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (event.type !== "raw") return null;
|
|
414
|
+
const data = event.data ?? event;
|
|
415
|
+
const inner = typeof data.type === "string" ? data.type : "";
|
|
416
|
+
if (!(inner === "tool-invocation" || inner === "tool_call" || inner === "computer-use" || inner === "computer_call")) return null;
|
|
417
|
+
const ti = data.toolInvocation ?? data.tool_invocation ?? data.computerUse ?? data.computer_use ?? data;
|
|
418
|
+
const id = String(ti.toolCallId ?? ti.tool_call_id ?? ti.callId ?? ti.id ?? "");
|
|
419
|
+
const name = inner === "computer-use" || inner === "computer_call" ? `computer-use:${String(ti.action?.type ?? "action")}` : String(ti.toolName ?? ti.tool_name ?? ti.name ?? "");
|
|
420
|
+
if (!id || !name) return null;
|
|
421
|
+
return {
|
|
422
|
+
callId: id,
|
|
423
|
+
toolName: name,
|
|
424
|
+
args: ti.args ?? ti.arguments ?? ti.input ?? {},
|
|
425
|
+
requiresAction: false
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function readTerminal(event) {
|
|
429
|
+
if (event.type === "done") {
|
|
430
|
+
const outcome = typeof event.outcome === "string" && event.outcome || "success";
|
|
431
|
+
if (outcome === "success" || outcome === "completed" || outcome === "succeeded" || outcome === "done") return { status: "completed" };
|
|
432
|
+
return {
|
|
433
|
+
status: "failed",
|
|
434
|
+
reason: typeof event.error === "string" ? event.error : outcome
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
if (event.type === "error") return {
|
|
438
|
+
status: "failed",
|
|
439
|
+
reason: typeof event.message === "string" && event.message || typeof event.error === "string" && event.error || "stream error"
|
|
440
|
+
};
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Internal queue helper: an async iterable backed by a bounded
|
|
445
|
+
* pending-list with a settle promise that resolves whenever a new
|
|
446
|
+
* event lands or the queue closes.
|
|
447
|
+
*
|
|
448
|
+
* Each iterator returned by `iterator()` shares the queue's buffer
|
|
449
|
+
* and waiter list. Two concurrent iterators would therefore steal
|
|
450
|
+
* events from each other (whichever called `next()` first wins),
|
|
451
|
+
* which silently drops events for the second consumer. Because there
|
|
452
|
+
* is only ever one consumer of `Run.events()` by design, this class
|
|
453
|
+
* enforces single-consumption explicitly: a second `iterator()` call
|
|
454
|
+
* throws so the contract violation is loud rather than silent.
|
|
455
|
+
*/
|
|
456
|
+
var EventQueue = class {
|
|
457
|
+
buffer = [];
|
|
458
|
+
waiters = [];
|
|
459
|
+
closed = false;
|
|
460
|
+
iteratorCreated = false;
|
|
461
|
+
push(value) {
|
|
462
|
+
if (this.closed) return;
|
|
463
|
+
const w = this.waiters.shift();
|
|
464
|
+
if (w) {
|
|
465
|
+
w({
|
|
466
|
+
value,
|
|
467
|
+
done: false
|
|
468
|
+
});
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
this.buffer.push(value);
|
|
472
|
+
}
|
|
473
|
+
close() {
|
|
474
|
+
if (this.closed) return;
|
|
475
|
+
this.closed = true;
|
|
476
|
+
while (this.waiters.length > 0) this.waiters.shift()?.({
|
|
477
|
+
value: void 0,
|
|
478
|
+
done: true
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
iterator() {
|
|
482
|
+
if (this.iteratorCreated) throw new Error("Run.events() may only be consumed once. Multiple iterators on the same Run share state and would interleave/steal events.");
|
|
483
|
+
this.iteratorCreated = true;
|
|
484
|
+
const self = this;
|
|
485
|
+
return {
|
|
486
|
+
[Symbol.asyncIterator]() {
|
|
487
|
+
return this;
|
|
488
|
+
},
|
|
489
|
+
next() {
|
|
490
|
+
if (self.buffer.length > 0) {
|
|
491
|
+
const value = self.buffer.shift();
|
|
492
|
+
return Promise.resolve({
|
|
493
|
+
value,
|
|
494
|
+
done: false
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
if (self.closed) return Promise.resolve({
|
|
498
|
+
value: void 0,
|
|
499
|
+
done: true
|
|
500
|
+
});
|
|
501
|
+
return new Promise((resolve) => {
|
|
502
|
+
self.waiters.push(resolve);
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
return() {
|
|
506
|
+
self.close();
|
|
507
|
+
return Promise.resolve({
|
|
508
|
+
value: void 0,
|
|
509
|
+
done: true
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* High-level `Run`. Drives the underlying `RunEventSource`, manages
|
|
517
|
+
* status transitions, dispatches tool calls through the hook chain,
|
|
518
|
+
* and surfaces a typed `RunEvent` stream to consumers.
|
|
519
|
+
*/
|
|
520
|
+
var Run = class {
|
|
521
|
+
id;
|
|
522
|
+
threadId;
|
|
523
|
+
partnerId;
|
|
524
|
+
_status = "queued";
|
|
525
|
+
source;
|
|
526
|
+
hooks;
|
|
527
|
+
executeTool;
|
|
528
|
+
onStatusChange;
|
|
529
|
+
queue = new EventQueue();
|
|
530
|
+
startPromise = null;
|
|
531
|
+
pendingCalls = /* @__PURE__ */ new Map();
|
|
532
|
+
cancelRequested = false;
|
|
533
|
+
constructor(opts) {
|
|
534
|
+
this.id = opts.id;
|
|
535
|
+
this.threadId = opts.threadId;
|
|
536
|
+
this.partnerId = opts.partnerId;
|
|
537
|
+
this.source = opts.source;
|
|
538
|
+
this.hooks = opts.hooks;
|
|
539
|
+
this.executeTool = opts.executeTool;
|
|
540
|
+
this.onStatusChange = opts.onStatusChange;
|
|
541
|
+
}
|
|
542
|
+
get status() {
|
|
543
|
+
return this._status;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Subscribe to typed events. May only be consumed once per Run.
|
|
547
|
+
*
|
|
548
|
+
* The single-consumer constraint is permanent for the lifetime of
|
|
549
|
+
* the Run instance, including AFTER the run completes — calling
|
|
550
|
+
* `events()` a second time always throws, even if the first
|
|
551
|
+
* consumer drained the iterator to completion. This is intentional:
|
|
552
|
+
* the queue is a one-shot stream, not a re-readable buffer, and
|
|
553
|
+
* events are dropped after delivery to avoid unbounded retention.
|
|
554
|
+
* Callers that need to revisit terminal state should keep a handle
|
|
555
|
+
* to the original iterator's drained values, or use the Run's
|
|
556
|
+
* status/result accessors.
|
|
557
|
+
*/
|
|
558
|
+
events() {
|
|
559
|
+
return this.queue.iterator();
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Drive the underlying stream to completion. Idempotent: subsequent
|
|
563
|
+
* calls return the same in-flight promise.
|
|
564
|
+
*/
|
|
565
|
+
start() {
|
|
566
|
+
if (this.startPromise) return this.startPromise;
|
|
567
|
+
this.startPromise = this.driveStream();
|
|
568
|
+
return this.startPromise;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Cancel an in-flight run. Sets status to `cancelled` and closes
|
|
572
|
+
* the event queue. Tries the source-level cancel hint as a
|
|
573
|
+
* best-effort heads-up to the upstream stream.
|
|
574
|
+
*/
|
|
575
|
+
async cancel(reason) {
|
|
576
|
+
if (isTerminal(this._status)) return;
|
|
577
|
+
this.cancelRequested = true;
|
|
578
|
+
if (this.source.cancel) try {
|
|
579
|
+
await this.source.cancel(this.threadId, this.id);
|
|
580
|
+
} catch {}
|
|
581
|
+
this.transition("cancelled");
|
|
582
|
+
this.queue.push({
|
|
583
|
+
type: "cancelled",
|
|
584
|
+
reason
|
|
585
|
+
});
|
|
586
|
+
this.queue.close();
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Append a user message to the thread and restart the stream. The
|
|
590
|
+
* source's `steer` hook is invoked when present; otherwise we throw
|
|
591
|
+
* because a stateless source cannot honor a steer.
|
|
592
|
+
*/
|
|
593
|
+
async steer(message) {
|
|
594
|
+
if (!this.source.steer) throw new Error("RunEventSource does not support steer");
|
|
595
|
+
if (isTerminal(this._status)) throw new Error(`cannot steer a ${this._status} run`);
|
|
596
|
+
await this.source.steer(this.threadId, this.id, message);
|
|
597
|
+
if (this._status === "requires_action") this.transition("in_progress");
|
|
598
|
+
this.startPromise = this.driveStream();
|
|
599
|
+
await this.startPromise;
|
|
600
|
+
}
|
|
601
|
+
/**
|
|
602
|
+
* Resume a `requires_action` run by submitting tool outputs. The
|
|
603
|
+
* outputs are forwarded to the source so the upstream agent can
|
|
604
|
+
* continue. Status transitions back to `in_progress`.
|
|
605
|
+
*/
|
|
606
|
+
async submitToolOutputs(outputs) {
|
|
607
|
+
if (this._status !== "requires_action") throw new Error(`cannot submit tool outputs in status ${this._status}`);
|
|
608
|
+
if (!this.source.submitToolOutputs) throw new Error("RunEventSource does not support submitToolOutputs");
|
|
609
|
+
for (const o of outputs) this.pendingCalls.delete(o.toolCallId);
|
|
610
|
+
await this.source.submitToolOutputs(this.threadId, this.id, outputs);
|
|
611
|
+
this.transition("in_progress");
|
|
612
|
+
this.startPromise = this.driveStream();
|
|
613
|
+
await this.startPromise;
|
|
614
|
+
}
|
|
615
|
+
/** Externally drive the run into the `expired` terminal status. */
|
|
616
|
+
expire() {
|
|
617
|
+
if (isTerminal(this._status)) return;
|
|
618
|
+
this.transition("expired");
|
|
619
|
+
this.queue.push({
|
|
620
|
+
type: "failed",
|
|
621
|
+
reason: "expired"
|
|
622
|
+
});
|
|
623
|
+
this.queue.close();
|
|
624
|
+
}
|
|
625
|
+
transition(next) {
|
|
626
|
+
if (this._status === next) return;
|
|
627
|
+
const prev = this._status;
|
|
628
|
+
this._status = next;
|
|
629
|
+
this.queue.push({
|
|
630
|
+
type: "status",
|
|
631
|
+
status: next,
|
|
632
|
+
previous: prev
|
|
633
|
+
});
|
|
634
|
+
this.onStatusChange?.(next, prev);
|
|
635
|
+
}
|
|
636
|
+
async driveStream() {
|
|
637
|
+
try {
|
|
638
|
+
for await (const event of runEvents(this.threadId, this.id, this.source)) {
|
|
639
|
+
if (this.cancelRequested) return;
|
|
640
|
+
if (this._status === "queued") this.transition("in_progress");
|
|
641
|
+
this.queue.push({
|
|
642
|
+
type: "stream",
|
|
643
|
+
event
|
|
644
|
+
});
|
|
645
|
+
const tool = readToolCallFromFrame(event);
|
|
646
|
+
if (tool) {
|
|
647
|
+
const handled = await this.handleToolCall(tool);
|
|
648
|
+
if (handled === "terminate") return;
|
|
649
|
+
if (handled === "requires_action") return;
|
|
650
|
+
continue;
|
|
651
|
+
}
|
|
652
|
+
const terminal = readTerminal(event);
|
|
653
|
+
if (terminal) {
|
|
654
|
+
if (terminal.status === "completed") {
|
|
655
|
+
this.transition("completed");
|
|
656
|
+
this.queue.push({ type: "completed" });
|
|
657
|
+
} else {
|
|
658
|
+
this.transition("failed");
|
|
659
|
+
this.queue.push({
|
|
660
|
+
type: "failed",
|
|
661
|
+
reason: terminal.reason ?? "unknown failure"
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
this.queue.close();
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if (!isTerminal(this._status)) {
|
|
669
|
+
this.transition("completed");
|
|
670
|
+
this.queue.push({ type: "completed" });
|
|
671
|
+
this.queue.close();
|
|
672
|
+
}
|
|
673
|
+
} catch (err) {
|
|
674
|
+
if (isTerminal(this._status)) return;
|
|
675
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
676
|
+
this.transition("failed");
|
|
677
|
+
this.queue.push({
|
|
678
|
+
type: "failed",
|
|
679
|
+
reason
|
|
680
|
+
});
|
|
681
|
+
this.queue.close();
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
async handleToolCall(tool) {
|
|
685
|
+
const ctx = {
|
|
686
|
+
runId: this.id,
|
|
687
|
+
threadId: this.threadId,
|
|
688
|
+
partnerId: this.partnerId,
|
|
689
|
+
toolName: tool.toolName,
|
|
690
|
+
args: tool.args,
|
|
691
|
+
callId: tool.callId,
|
|
692
|
+
timestamp: Date.now()
|
|
693
|
+
};
|
|
694
|
+
let dispatchCtx = ctx;
|
|
695
|
+
if (this.hooks && this.hooks.size > 0) {
|
|
696
|
+
const before = await this.hooks.runBefore(ctx);
|
|
697
|
+
if (before.action === "block") {
|
|
698
|
+
const blockedResult = {
|
|
699
|
+
content: { error: before.reason },
|
|
700
|
+
isError: true,
|
|
701
|
+
details: { blockedBy: "beforeToolCall" }
|
|
702
|
+
};
|
|
703
|
+
this.queue.push({
|
|
704
|
+
type: "tool_blocked",
|
|
705
|
+
ctx,
|
|
706
|
+
reason: before.reason
|
|
707
|
+
});
|
|
708
|
+
this.queue.push({
|
|
709
|
+
type: "tool_result",
|
|
710
|
+
ctx,
|
|
711
|
+
result: blockedResult
|
|
712
|
+
});
|
|
713
|
+
if (tool.requiresAction) {
|
|
714
|
+
this.pendingCalls.set(tool.callId, ctx);
|
|
715
|
+
this.transition("requires_action");
|
|
716
|
+
this.queue.push({
|
|
717
|
+
type: "requires_action",
|
|
718
|
+
pendingCallIds: Array.from(this.pendingCalls.keys())
|
|
719
|
+
});
|
|
720
|
+
return "requires_action";
|
|
721
|
+
}
|
|
722
|
+
return "continue";
|
|
723
|
+
}
|
|
724
|
+
if (before.action === "rewrite") dispatchCtx = {
|
|
725
|
+
...ctx,
|
|
726
|
+
args: before.args
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
if (tool.requiresAction) {
|
|
730
|
+
this.pendingCalls.set(tool.callId, dispatchCtx);
|
|
731
|
+
this.transition("requires_action");
|
|
732
|
+
this.queue.push({
|
|
733
|
+
type: "tool_call",
|
|
734
|
+
ctx: dispatchCtx
|
|
735
|
+
});
|
|
736
|
+
this.queue.push({
|
|
737
|
+
type: "requires_action",
|
|
738
|
+
pendingCallIds: Array.from(this.pendingCalls.keys())
|
|
739
|
+
});
|
|
740
|
+
return "requires_action";
|
|
741
|
+
}
|
|
742
|
+
if (!this.executeTool) {
|
|
743
|
+
this.queue.push({
|
|
744
|
+
type: "tool_call",
|
|
745
|
+
ctx: dispatchCtx
|
|
746
|
+
});
|
|
747
|
+
return "continue";
|
|
748
|
+
}
|
|
749
|
+
this.queue.push({
|
|
750
|
+
type: "tool_call",
|
|
751
|
+
ctx: dispatchCtx
|
|
752
|
+
});
|
|
753
|
+
let result;
|
|
754
|
+
try {
|
|
755
|
+
result = await this.executeTool(dispatchCtx);
|
|
756
|
+
} catch (err) {
|
|
757
|
+
result = {
|
|
758
|
+
content: { error: err instanceof Error ? err.message : String(err) },
|
|
759
|
+
isError: true
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
let finalResult = result;
|
|
763
|
+
if (this.hooks && this.hooks.size > 0) {
|
|
764
|
+
const after = await this.hooks.runAfter(dispatchCtx, result);
|
|
765
|
+
if (after.action === "terminate") {
|
|
766
|
+
this.queue.push({
|
|
767
|
+
type: "tool_result",
|
|
768
|
+
ctx: dispatchCtx,
|
|
769
|
+
result
|
|
770
|
+
});
|
|
771
|
+
this.transition("failed");
|
|
772
|
+
this.queue.push({
|
|
773
|
+
type: "failed",
|
|
774
|
+
reason: after.reason
|
|
775
|
+
});
|
|
776
|
+
this.queue.close();
|
|
777
|
+
return "terminate";
|
|
778
|
+
}
|
|
779
|
+
if (after.action === "override") finalResult = after.result;
|
|
780
|
+
}
|
|
781
|
+
this.queue.push({
|
|
782
|
+
type: "tool_result",
|
|
783
|
+
ctx: dispatchCtx,
|
|
784
|
+
result: finalResult
|
|
785
|
+
});
|
|
786
|
+
return "continue";
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
//#endregion
|
|
790
|
+
//#region src/openai/translate/finish-reason.ts
|
|
791
|
+
function outcomeToFinishReason(outcome, hasToolCall) {
|
|
792
|
+
switch (outcome) {
|
|
793
|
+
case "success":
|
|
794
|
+
case "succeeded":
|
|
795
|
+
case "completed":
|
|
796
|
+
case "done": return hasToolCall ? "tool_calls" : "stop";
|
|
797
|
+
case "length_exceeded":
|
|
798
|
+
case "length":
|
|
799
|
+
case "max_tokens": return "length";
|
|
800
|
+
case "content_filtered":
|
|
801
|
+
case "content_filter":
|
|
802
|
+
case "filtered": return "content_filter";
|
|
803
|
+
default: return "stop";
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
//#endregion
|
|
807
|
+
//#region src/openai/translate/chunks.ts
|
|
808
|
+
/**
|
|
809
|
+
* Read the text token from a `token` event. Tangle emits the delta as
|
|
810
|
+
* either `delta`, `text`, or `token`; tolerate all three so the
|
|
811
|
+
* translator stays decoupled from minor runtime variations.
|
|
812
|
+
*/
|
|
813
|
+
function readTokenDelta(event) {
|
|
814
|
+
if (typeof event.delta === "string") return event.delta;
|
|
815
|
+
if (typeof event.text === "string") return event.text;
|
|
816
|
+
if (typeof event.token === "string") return event.token;
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
function readToolInvocation(event) {
|
|
820
|
+
if (event.type !== "raw") return null;
|
|
821
|
+
const data = event.data ?? event;
|
|
822
|
+
const inner = typeof data.type === "string" ? data.type : typeof event.type === "string" ? event.type : "";
|
|
823
|
+
if (!(inner === "tool-invocation" || inner === "tool_call" || typeof data.toolInvocation === "object" || typeof data.tool_invocation === "object")) return null;
|
|
824
|
+
const ti = data.toolInvocation ?? data.tool_invocation ?? data;
|
|
825
|
+
const id = typeof ti.toolCallId === "string" ? ti.toolCallId : typeof ti.tool_call_id === "string" ? ti.tool_call_id : typeof ti.id === "string" ? ti.id : typeof ti.callId === "string" ? ti.callId : "";
|
|
826
|
+
const name = typeof ti.toolName === "string" ? ti.toolName : typeof ti.tool_name === "string" ? ti.tool_name : typeof ti.name === "string" ? ti.name : "";
|
|
827
|
+
const args = ti.args ?? ti.arguments ?? ti.input ?? {};
|
|
828
|
+
if (!id || !name) return null;
|
|
829
|
+
return {
|
|
830
|
+
id,
|
|
831
|
+
name,
|
|
832
|
+
arguments: typeof args === "string" ? args : JSON.stringify(args)
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Read a usage payload from a `done` event. The runtime emits usage
|
|
837
|
+
* either at the top level or under a `usage` key; try both.
|
|
838
|
+
*/
|
|
839
|
+
function readUsage(event) {
|
|
840
|
+
const u = event.usage ?? event;
|
|
841
|
+
const prompt = Number(u.prompt_tokens ?? u.input_tokens ?? u.inputTokens ?? 0);
|
|
842
|
+
const completion = Number(u.completion_tokens ?? u.output_tokens ?? u.outputTokens ?? 0);
|
|
843
|
+
if (prompt === 0 && completion === 0) return null;
|
|
844
|
+
return {
|
|
845
|
+
prompt_tokens: prompt,
|
|
846
|
+
completion_tokens: completion,
|
|
847
|
+
total_tokens: Number(u.total_tokens ?? prompt + completion)
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
function readOutcome(event) {
|
|
851
|
+
if (typeof event.outcome === "string") return event.outcome;
|
|
852
|
+
if (typeof event.status === "string") return event.status;
|
|
853
|
+
if (event.success === false) return "failure";
|
|
854
|
+
return "success";
|
|
855
|
+
}
|
|
856
|
+
function chatBaseChunk(ctx) {
|
|
857
|
+
ctx.chunkIndex += 1;
|
|
858
|
+
return {
|
|
859
|
+
id: ctx.runId,
|
|
860
|
+
created: ctx.createdAt,
|
|
861
|
+
model: ctx.modelId,
|
|
862
|
+
object: "chat.completion.chunk"
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function sandboxEventToChatChunk(event, ctx) {
|
|
866
|
+
switch (event.type) {
|
|
867
|
+
case "start": return null;
|
|
868
|
+
case "execution.started": return null;
|
|
869
|
+
case "status": return null;
|
|
870
|
+
case "session.updated": return null;
|
|
871
|
+
case "message.part.updated": return null;
|
|
872
|
+
case "token": {
|
|
873
|
+
const delta = readTokenDelta(event);
|
|
874
|
+
if (delta == null || delta.length === 0) return null;
|
|
875
|
+
return {
|
|
876
|
+
...chatBaseChunk(ctx),
|
|
877
|
+
choices: [{
|
|
878
|
+
index: 0,
|
|
879
|
+
delta: {
|
|
880
|
+
role: "assistant",
|
|
881
|
+
content: delta
|
|
882
|
+
},
|
|
883
|
+
finish_reason: null
|
|
884
|
+
}]
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
case "raw": {
|
|
888
|
+
const tool = readToolInvocation(event);
|
|
889
|
+
if (!tool) return null;
|
|
890
|
+
const existing = ctx.toolCallBuffer.get(tool.id);
|
|
891
|
+
const index = existing ? existing.index : ctx.toolCallBuffer.size;
|
|
892
|
+
ctx.toolCallBuffer.set(tool.id, {
|
|
893
|
+
index,
|
|
894
|
+
id: tool.id,
|
|
895
|
+
name: tool.name,
|
|
896
|
+
arguments: tool.arguments
|
|
897
|
+
});
|
|
898
|
+
return {
|
|
899
|
+
...chatBaseChunk(ctx),
|
|
900
|
+
choices: [{
|
|
901
|
+
index: 0,
|
|
902
|
+
delta: {
|
|
903
|
+
role: "assistant",
|
|
904
|
+
tool_calls: [{
|
|
905
|
+
index,
|
|
906
|
+
id: tool.id,
|
|
907
|
+
type: "function",
|
|
908
|
+
function: {
|
|
909
|
+
name: tool.name,
|
|
910
|
+
arguments: tool.arguments
|
|
911
|
+
}
|
|
912
|
+
}]
|
|
913
|
+
},
|
|
914
|
+
finish_reason: null
|
|
915
|
+
}]
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
case "error": {
|
|
919
|
+
const hasToolCall = ctx.toolCallBuffer.size > 0;
|
|
920
|
+
return {
|
|
921
|
+
...chatBaseChunk(ctx),
|
|
922
|
+
choices: [{
|
|
923
|
+
index: 0,
|
|
924
|
+
delta: {},
|
|
925
|
+
finish_reason: outcomeToFinishReason("error", hasToolCall)
|
|
926
|
+
}]
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
case "done": {
|
|
930
|
+
const hasToolCall = ctx.toolCallBuffer.size > 0;
|
|
931
|
+
const finish = outcomeToFinishReason(readOutcome(event), hasToolCall);
|
|
932
|
+
const usage = readUsage(event);
|
|
933
|
+
const chunk = {
|
|
934
|
+
...chatBaseChunk(ctx),
|
|
935
|
+
choices: [{
|
|
936
|
+
index: 0,
|
|
937
|
+
delta: {},
|
|
938
|
+
finish_reason: finish
|
|
939
|
+
}]
|
|
940
|
+
};
|
|
941
|
+
if (usage) chunk.usage = usage;
|
|
942
|
+
return chunk;
|
|
943
|
+
}
|
|
944
|
+
default: return null;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function completionBaseChunk(ctx) {
|
|
948
|
+
ctx.chunkIndex += 1;
|
|
949
|
+
return {
|
|
950
|
+
id: ctx.runId,
|
|
951
|
+
created: ctx.createdAt,
|
|
952
|
+
model: ctx.modelId,
|
|
953
|
+
object: "text_completion"
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function sandboxEventToCompletionChunk(event, ctx) {
|
|
957
|
+
switch (event.type) {
|
|
958
|
+
case "start":
|
|
959
|
+
case "execution.started":
|
|
960
|
+
case "status":
|
|
961
|
+
case "session.updated":
|
|
962
|
+
case "message.part.updated":
|
|
963
|
+
case "raw":
|
|
964
|
+
if (event.type === "raw") {
|
|
965
|
+
const tool = readToolInvocation(event);
|
|
966
|
+
if (tool) {
|
|
967
|
+
const existing = ctx.toolCallBuffer.get(tool.id);
|
|
968
|
+
const index = existing ? existing.index : ctx.toolCallBuffer.size;
|
|
969
|
+
ctx.toolCallBuffer.set(tool.id, {
|
|
970
|
+
index,
|
|
971
|
+
id: tool.id,
|
|
972
|
+
name: tool.name,
|
|
973
|
+
arguments: tool.arguments
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
return null;
|
|
978
|
+
case "token": {
|
|
979
|
+
const delta = readTokenDelta(event);
|
|
980
|
+
if (delta == null || delta.length === 0) return null;
|
|
981
|
+
return {
|
|
982
|
+
...completionBaseChunk(ctx),
|
|
983
|
+
choices: [{
|
|
984
|
+
index: 0,
|
|
985
|
+
text: delta,
|
|
986
|
+
finish_reason: null,
|
|
987
|
+
logprobs: null
|
|
988
|
+
}]
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
case "error":
|
|
992
|
+
case "done": {
|
|
993
|
+
const finish = outcomeToFinishReason(event.type === "error" ? "error" : readOutcome(event), false);
|
|
994
|
+
const reason = finish === "tool_calls" ? "stop" : finish;
|
|
995
|
+
const usage = readUsage(event);
|
|
996
|
+
const chunk = {
|
|
997
|
+
...completionBaseChunk(ctx),
|
|
998
|
+
choices: [{
|
|
999
|
+
index: 0,
|
|
1000
|
+
text: "",
|
|
1001
|
+
finish_reason: reason,
|
|
1002
|
+
logprobs: null
|
|
1003
|
+
}]
|
|
1004
|
+
};
|
|
1005
|
+
if (usage) chunk.usage = usage;
|
|
1006
|
+
return chunk;
|
|
1007
|
+
}
|
|
1008
|
+
default: return null;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function getResponsesExtras(ctx) {
|
|
1012
|
+
const slot = ctx;
|
|
1013
|
+
if (!slot.__responsesExtras) slot.__responsesExtras = {
|
|
1014
|
+
sequence: 0,
|
|
1015
|
+
toolOutputIndex: /* @__PURE__ */ new Map()
|
|
1016
|
+
};
|
|
1017
|
+
return slot.__responsesExtras;
|
|
1018
|
+
}
|
|
1019
|
+
function nextSeq(extras) {
|
|
1020
|
+
extras.sequence += 1;
|
|
1021
|
+
return extras.sequence;
|
|
1022
|
+
}
|
|
1023
|
+
function emptyResponseUsage() {
|
|
1024
|
+
return {
|
|
1025
|
+
input_tokens: 0,
|
|
1026
|
+
output_tokens: 0,
|
|
1027
|
+
total_tokens: 0,
|
|
1028
|
+
input_tokens_details: { cached_tokens: 0 },
|
|
1029
|
+
output_tokens_details: { reasoning_tokens: 0 }
|
|
1030
|
+
};
|
|
1031
|
+
}
|
|
1032
|
+
function usageFromTokens(usage) {
|
|
1033
|
+
return {
|
|
1034
|
+
input_tokens: usage.prompt_tokens,
|
|
1035
|
+
output_tokens: usage.completion_tokens,
|
|
1036
|
+
total_tokens: usage.total_tokens,
|
|
1037
|
+
input_tokens_details: { cached_tokens: 0 },
|
|
1038
|
+
output_tokens_details: { reasoning_tokens: 0 }
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
function sandboxEventToResponsesEvent(event, ctx) {
|
|
1042
|
+
const extras = getResponsesExtras(ctx);
|
|
1043
|
+
switch (event.type) {
|
|
1044
|
+
case "start": return null;
|
|
1045
|
+
case "execution.started": return null;
|
|
1046
|
+
case "status": return null;
|
|
1047
|
+
case "session.updated": return null;
|
|
1048
|
+
case "message.part.updated": return null;
|
|
1049
|
+
case "token": {
|
|
1050
|
+
const delta = readTokenDelta(event);
|
|
1051
|
+
if (delta == null || delta.length === 0) return null;
|
|
1052
|
+
ctx.chunkIndex += 1;
|
|
1053
|
+
if (extras.messageOutputIndex === void 0) extras.messageOutputIndex = ctx.toolCallBuffer.size;
|
|
1054
|
+
return {
|
|
1055
|
+
type: "response.output_text.delta",
|
|
1056
|
+
content_index: 0,
|
|
1057
|
+
delta,
|
|
1058
|
+
item_id: `msg_${ctx.runId}`,
|
|
1059
|
+
logprobs: [],
|
|
1060
|
+
output_index: extras.messageOutputIndex,
|
|
1061
|
+
sequence_number: nextSeq(extras)
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
case "raw": {
|
|
1065
|
+
const tool = readToolInvocation(event);
|
|
1066
|
+
if (!tool) return null;
|
|
1067
|
+
ctx.chunkIndex += 1;
|
|
1068
|
+
const existing = ctx.toolCallBuffer.get(tool.id);
|
|
1069
|
+
const index = existing ? existing.index : ctx.toolCallBuffer.size;
|
|
1070
|
+
ctx.toolCallBuffer.set(tool.id, {
|
|
1071
|
+
index,
|
|
1072
|
+
id: tool.id,
|
|
1073
|
+
name: tool.name,
|
|
1074
|
+
arguments: tool.arguments
|
|
1075
|
+
});
|
|
1076
|
+
const outputIndex = extras.toolOutputIndex.get(tool.id) ?? extras.toolOutputIndex.size;
|
|
1077
|
+
extras.toolOutputIndex.set(tool.id, outputIndex);
|
|
1078
|
+
return {
|
|
1079
|
+
type: "response.output_item.added",
|
|
1080
|
+
item: {
|
|
1081
|
+
type: "function_call",
|
|
1082
|
+
id: `fc_${tool.id}`,
|
|
1083
|
+
call_id: tool.id,
|
|
1084
|
+
name: tool.name,
|
|
1085
|
+
arguments: tool.arguments,
|
|
1086
|
+
status: "completed"
|
|
1087
|
+
},
|
|
1088
|
+
output_index: outputIndex,
|
|
1089
|
+
sequence_number: nextSeq(extras)
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
case "error": {
|
|
1093
|
+
const outputIndex = extras.messageOutputIndex ?? 0;
|
|
1094
|
+
return {
|
|
1095
|
+
type: "response.output_item.done",
|
|
1096
|
+
item: {
|
|
1097
|
+
type: "message",
|
|
1098
|
+
id: `msg_${ctx.runId}`,
|
|
1099
|
+
role: "assistant",
|
|
1100
|
+
status: "incomplete",
|
|
1101
|
+
content: []
|
|
1102
|
+
},
|
|
1103
|
+
output_index: outputIndex,
|
|
1104
|
+
sequence_number: nextSeq(extras)
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
case "done": {
|
|
1108
|
+
const tokens = readUsage(event);
|
|
1109
|
+
const usage = tokens ? usageFromTokens(tokens) : emptyResponseUsage();
|
|
1110
|
+
return {
|
|
1111
|
+
type: "response.completed",
|
|
1112
|
+
sequence_number: nextSeq(extras),
|
|
1113
|
+
response: {
|
|
1114
|
+
id: ctx.runId,
|
|
1115
|
+
object: "response",
|
|
1116
|
+
created_at: ctx.createdAt,
|
|
1117
|
+
output_text: "",
|
|
1118
|
+
error: null,
|
|
1119
|
+
incomplete_details: null,
|
|
1120
|
+
instructions: null,
|
|
1121
|
+
metadata: null,
|
|
1122
|
+
model: ctx.modelId,
|
|
1123
|
+
output: [],
|
|
1124
|
+
parallel_tool_calls: false,
|
|
1125
|
+
temperature: null,
|
|
1126
|
+
tool_choice: "auto",
|
|
1127
|
+
tools: [],
|
|
1128
|
+
top_p: null,
|
|
1129
|
+
status: "completed",
|
|
1130
|
+
usage
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
default: return null;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
//#endregion
|
|
1138
|
+
//#region src/openai/translate/embeddings.ts
|
|
1139
|
+
/**
|
|
1140
|
+
* Error shape used for rejecting embedding requests. The route layer
|
|
1141
|
+
* lifts these into OpenAI's `{ error: { type, code, message } }` body.
|
|
1142
|
+
*/
|
|
1143
|
+
var EmbeddingValidationError = class extends Error {
|
|
1144
|
+
type = "invalid_request_error";
|
|
1145
|
+
code;
|
|
1146
|
+
param;
|
|
1147
|
+
constructor(message, code, param) {
|
|
1148
|
+
super(message);
|
|
1149
|
+
this.name = "EmbeddingValidationError";
|
|
1150
|
+
this.code = code;
|
|
1151
|
+
this.param = param;
|
|
1152
|
+
}
|
|
1153
|
+
};
|
|
1154
|
+
const MAX_BATCH = 2048;
|
|
1155
|
+
function reject(message, code, param) {
|
|
1156
|
+
throw new EmbeddingValidationError(message, code, param);
|
|
1157
|
+
}
|
|
1158
|
+
function normalizeInput(input) {
|
|
1159
|
+
if (typeof input === "string") {
|
|
1160
|
+
if (input.length === 0) reject("Input string must not be empty", "empty_input", "input");
|
|
1161
|
+
return {
|
|
1162
|
+
kind: "text",
|
|
1163
|
+
values: [input]
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
if (!Array.isArray(input)) reject("Input must be a string, array of strings, or array of token arrays", "invalid_input_type", "input");
|
|
1167
|
+
if (input.length === 0) reject("Input array must not be empty", "empty_input", "input");
|
|
1168
|
+
if (input.length > MAX_BATCH) reject(`Input array exceeds maximum batch size of ${MAX_BATCH}`, "batch_too_large", "input");
|
|
1169
|
+
const first = input[0];
|
|
1170
|
+
if (typeof first === "string") {
|
|
1171
|
+
const values = [];
|
|
1172
|
+
for (let i = 0; i < input.length; i++) {
|
|
1173
|
+
const v = input[i];
|
|
1174
|
+
if (typeof v !== "string") reject(`Input array must be homogeneous; index ${i} is not a string`, "mixed_input_types", "input");
|
|
1175
|
+
if (v.length === 0) reject(`Input string at index ${i} must not be empty`, "empty_input", "input");
|
|
1176
|
+
values.push(v);
|
|
1177
|
+
}
|
|
1178
|
+
return {
|
|
1179
|
+
kind: "text",
|
|
1180
|
+
values
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
if (typeof first === "number") {
|
|
1184
|
+
for (let i = 0; i < input.length; i++) if (typeof input[i] !== "number") reject(`Token array must contain only numbers; index ${i} is ${typeof input[i]}`, "invalid_token_type", "input");
|
|
1185
|
+
return {
|
|
1186
|
+
kind: "tokens",
|
|
1187
|
+
values: [input]
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
if (Array.isArray(first)) {
|
|
1191
|
+
const values = [];
|
|
1192
|
+
for (let i = 0; i < input.length; i++) {
|
|
1193
|
+
const row = input[i];
|
|
1194
|
+
if (!Array.isArray(row)) reject(`Input array must be homogeneous; index ${i} is not an array`, "mixed_input_types", "input");
|
|
1195
|
+
if (row.length === 0) reject(`Token array at index ${i} must not be empty`, "empty_input", "input");
|
|
1196
|
+
for (let j = 0; j < row.length; j++) if (typeof row[j] !== "number") reject(`Token array at index ${i} must contain only numbers; element ${j} is ${typeof row[j]}`, "invalid_token_type", "input");
|
|
1197
|
+
values.push(row);
|
|
1198
|
+
}
|
|
1199
|
+
return {
|
|
1200
|
+
kind: "tokens",
|
|
1201
|
+
values
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
reject("Input must be a string, array of strings, or array of token arrays", "invalid_input_type", "input");
|
|
1205
|
+
}
|
|
1206
|
+
/**
|
|
1207
|
+
* Validate and normalize an embedding request. Throws
|
|
1208
|
+
* `EmbeddingValidationError` on any rejection.
|
|
1209
|
+
*/
|
|
1210
|
+
function validateEmbeddingRequest(req) {
|
|
1211
|
+
if (!req || typeof req !== "object") reject("Request body must be an object", "invalid_request", void 0);
|
|
1212
|
+
if (typeof req.model !== "string" || req.model.length === 0) reject("Model is required", "model_required", "model");
|
|
1213
|
+
if (req.dimensions !== void 0) {
|
|
1214
|
+
if (typeof req.dimensions !== "number" || !Number.isInteger(req.dimensions) || req.dimensions <= 0) reject("Dimensions must be a positive integer", "invalid_dimensions", "dimensions");
|
|
1215
|
+
}
|
|
1216
|
+
const encodingFormat = req.encoding_format ?? "float";
|
|
1217
|
+
if (encodingFormat !== "float" && encodingFormat !== "base64") reject("encoding_format must be 'float' or 'base64'", "invalid_encoding_format", "encoding_format");
|
|
1218
|
+
const input = normalizeInput(req.input);
|
|
1219
|
+
const out = {
|
|
1220
|
+
model: req.model,
|
|
1221
|
+
input,
|
|
1222
|
+
encodingFormat
|
|
1223
|
+
};
|
|
1224
|
+
if (req.dimensions !== void 0) out.dimensions = req.dimensions;
|
|
1225
|
+
if (req.user !== void 0) out.user = req.user;
|
|
1226
|
+
return out;
|
|
1227
|
+
}
|
|
1228
|
+
//#endregion
|
|
1229
|
+
//#region src/openai/translate/messages.ts
|
|
1230
|
+
/**
|
|
1231
|
+
* Strip the leading `tangle/` namespace from a model id and split off an
|
|
1232
|
+
* optional variant. Examples:
|
|
1233
|
+
* - `tangle/claude-code` → `{ provider: "claude-code" }`
|
|
1234
|
+
* - `tangle/opencode/sonnet` → `{ provider: "opencode", variant: "sonnet" }`
|
|
1235
|
+
* - `claude-code` → `{ provider: "claude-code" }` (no prefix)
|
|
1236
|
+
*/
|
|
1237
|
+
function resolveProviderId(model) {
|
|
1238
|
+
const trimmed = model.trim();
|
|
1239
|
+
const withoutPrefix = trimmed.startsWith("tangle/") ? trimmed.slice(7) : trimmed;
|
|
1240
|
+
if (!withoutPrefix) throw new Error(`Invalid model id: ${JSON.stringify(model)}`);
|
|
1241
|
+
const slash = withoutPrefix.indexOf("/");
|
|
1242
|
+
if (slash === -1) return { provider: withoutPrefix };
|
|
1243
|
+
const provider = withoutPrefix.slice(0, slash);
|
|
1244
|
+
const variant = withoutPrefix.slice(slash + 1);
|
|
1245
|
+
if (!provider || !variant) throw new Error(`Invalid model id: ${JSON.stringify(model)}`);
|
|
1246
|
+
return {
|
|
1247
|
+
provider,
|
|
1248
|
+
variant
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* Coerce an OpenAI chat content field into a normalized text + parts pair.
|
|
1253
|
+
* Refusal parts are dropped — they only appear on assistant turns and the
|
|
1254
|
+
* sandbox runtime does not consume them; assistant text is the only field
|
|
1255
|
+
* we need from the assistant side.
|
|
1256
|
+
*/
|
|
1257
|
+
function normalizeContent(content) {
|
|
1258
|
+
if (content == null) return {
|
|
1259
|
+
text: "",
|
|
1260
|
+
parts: []
|
|
1261
|
+
};
|
|
1262
|
+
if (typeof content === "string") return {
|
|
1263
|
+
text: content,
|
|
1264
|
+
parts: []
|
|
1265
|
+
};
|
|
1266
|
+
const parts = [];
|
|
1267
|
+
const textPieces = [];
|
|
1268
|
+
for (const part of content) if (part.type === "text") {
|
|
1269
|
+
textPieces.push(part.text);
|
|
1270
|
+
parts.push({
|
|
1271
|
+
type: "text",
|
|
1272
|
+
text: part.text
|
|
1273
|
+
});
|
|
1274
|
+
} else if (part.type === "image_url") parts.push({
|
|
1275
|
+
type: "image_url",
|
|
1276
|
+
image_url: {
|
|
1277
|
+
url: part.image_url.url,
|
|
1278
|
+
detail: part.image_url.detail
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
else if (part.type === "input_audio") parts.push({
|
|
1282
|
+
type: "input_audio",
|
|
1283
|
+
input_audio: {
|
|
1284
|
+
data: part.input_audio.data,
|
|
1285
|
+
format: part.input_audio.format
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
return {
|
|
1289
|
+
text: textPieces.join("\n"),
|
|
1290
|
+
parts
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
/**
|
|
1294
|
+
* Read assistant text content. Assistant messages can carry an array of
|
|
1295
|
+
* text + refusal parts; refusal text is preserved as plain text so the
|
|
1296
|
+
* provider sees the full assistant turn.
|
|
1297
|
+
*/
|
|
1298
|
+
function readAssistantText(content) {
|
|
1299
|
+
if (content == null) return "";
|
|
1300
|
+
if (typeof content === "string") return content;
|
|
1301
|
+
const pieces = [];
|
|
1302
|
+
for (const part of content) if (part.type === "text") pieces.push(part.text);
|
|
1303
|
+
else if (part.type === "refusal") pieces.push(part.refusal);
|
|
1304
|
+
return pieces.join("\n");
|
|
1305
|
+
}
|
|
1306
|
+
/** Read tool message content (string or array of text parts). */
|
|
1307
|
+
function readToolContent(content) {
|
|
1308
|
+
if (typeof content === "string") return content;
|
|
1309
|
+
return content.map((p) => p.text).join("\n");
|
|
1310
|
+
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Convert an OpenAI tool-spec array into the SDK's internal forwarding
|
|
1313
|
+
* shape. Custom (non-function) tools are dropped at this layer because
|
|
1314
|
+
* downstream providers only accept function-shaped tools; the route
|
|
1315
|
+
* layer is responsible for surfacing a 400 if the caller requested
|
|
1316
|
+
* something the provider can't run.
|
|
1317
|
+
*/
|
|
1318
|
+
function convertTools(tools) {
|
|
1319
|
+
if (!tools || tools.length === 0) return void 0;
|
|
1320
|
+
const out = [];
|
|
1321
|
+
for (const tool of tools) if (tool.type === "function") out.push({
|
|
1322
|
+
type: "function",
|
|
1323
|
+
function: {
|
|
1324
|
+
name: tool.function.name,
|
|
1325
|
+
description: tool.function.description,
|
|
1326
|
+
parameters: tool.function.parameters ?? null,
|
|
1327
|
+
strict: tool.function.strict ?? null
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
return out.length > 0 ? out : void 0;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Translate an OpenAI chat-shape message thread into a SandboxRunInput.
|
|
1334
|
+
*
|
|
1335
|
+
* @param messages Ordered messages as the OpenAI client would send them.
|
|
1336
|
+
* @param tools Optional function tool descriptors to forward unchanged.
|
|
1337
|
+
* @param model Caller-supplied model id (`tangle/<provider>[/<variant>]`).
|
|
1338
|
+
*
|
|
1339
|
+
* @throws when the resolved provider id is empty, when the message thread
|
|
1340
|
+
* lacks any user message, or when an `assistant` `tool_calls` item
|
|
1341
|
+
* is malformed (missing id/name/arguments).
|
|
1342
|
+
*/
|
|
1343
|
+
function openaiMessagesToSandboxInput(messages, tools, model) {
|
|
1344
|
+
const { provider, variant } = resolveProviderId(model);
|
|
1345
|
+
const instructionsPieces = [];
|
|
1346
|
+
const userPieces = [];
|
|
1347
|
+
const priorTurns = [];
|
|
1348
|
+
let pendingTurn = null;
|
|
1349
|
+
let pendingUserParts = [];
|
|
1350
|
+
let trailingUserParts = [];
|
|
1351
|
+
let multimodal = false;
|
|
1352
|
+
const flushPending = () => {
|
|
1353
|
+
if (pendingTurn) {
|
|
1354
|
+
priorTurns.push(pendingTurn);
|
|
1355
|
+
pendingTurn = null;
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
let lastUserIndex = -1;
|
|
1359
|
+
for (let i = messages.length - 1; i >= 0; i--) if (messages[i].role === "user") {
|
|
1360
|
+
lastUserIndex = i;
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
if (lastUserIndex === -1) throw new Error("openaiMessagesToSandboxInput: messages must contain at least one user message");
|
|
1364
|
+
for (let i = 0; i < messages.length; i++) {
|
|
1365
|
+
const msg = messages[i];
|
|
1366
|
+
switch (msg.role) {
|
|
1367
|
+
case "system":
|
|
1368
|
+
case "developer": {
|
|
1369
|
+
const { text } = normalizeContent(msg.content);
|
|
1370
|
+
if (text) instructionsPieces.push(text);
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
case "user": {
|
|
1374
|
+
const { text, parts } = normalizeContent(msg.content);
|
|
1375
|
+
if (parts.some((p) => p.type !== "text")) multimodal = true;
|
|
1376
|
+
if (i === lastUserIndex) {
|
|
1377
|
+
userPieces.push(text);
|
|
1378
|
+
if (parts.length > 0) trailingUserParts = parts;
|
|
1379
|
+
} else {
|
|
1380
|
+
flushPending();
|
|
1381
|
+
if (parts.length > 0) {
|
|
1382
|
+
pendingTurn = { userParts: parts };
|
|
1383
|
+
pendingUserParts = parts;
|
|
1384
|
+
} else {
|
|
1385
|
+
pendingTurn = {};
|
|
1386
|
+
pendingUserParts = [];
|
|
1387
|
+
}
|
|
1388
|
+
if (text) userPieces.push(text);
|
|
1389
|
+
}
|
|
1390
|
+
break;
|
|
1391
|
+
}
|
|
1392
|
+
case "assistant": {
|
|
1393
|
+
if (!pendingTurn) pendingTurn = {};
|
|
1394
|
+
const text = readAssistantText(msg.content);
|
|
1395
|
+
if (text) pendingTurn.assistantText = text;
|
|
1396
|
+
if (msg.tool_calls && msg.tool_calls.length > 0) {
|
|
1397
|
+
const calls = [];
|
|
1398
|
+
for (const call of msg.tool_calls) {
|
|
1399
|
+
if (call.type !== "function") continue;
|
|
1400
|
+
if (!call.id || !call.function?.name || typeof call.function.arguments !== "string") throw new Error(`openaiMessagesToSandboxInput: malformed assistant tool_call at index ${i}`);
|
|
1401
|
+
calls.push({
|
|
1402
|
+
id: call.id,
|
|
1403
|
+
name: call.function.name,
|
|
1404
|
+
arguments: call.function.arguments
|
|
1405
|
+
});
|
|
1406
|
+
}
|
|
1407
|
+
if (calls.length > 0) pendingTurn.toolCalls = calls;
|
|
1408
|
+
}
|
|
1409
|
+
if (pendingUserParts.length > 0 && !pendingTurn.userParts) pendingTurn.userParts = pendingUserParts;
|
|
1410
|
+
break;
|
|
1411
|
+
}
|
|
1412
|
+
case "tool": {
|
|
1413
|
+
const result = {
|
|
1414
|
+
toolCallId: msg.tool_call_id,
|
|
1415
|
+
content: readToolContent(msg.content)
|
|
1416
|
+
};
|
|
1417
|
+
let attached = false;
|
|
1418
|
+
if (pendingTurn?.toolCalls?.some((c) => c.id === msg.tool_call_id)) {
|
|
1419
|
+
if (!pendingTurn.toolResults) pendingTurn.toolResults = [];
|
|
1420
|
+
pendingTurn.toolResults.push(result);
|
|
1421
|
+
attached = true;
|
|
1422
|
+
} else for (let j = priorTurns.length - 1; j >= 0; j--) {
|
|
1423
|
+
const turn = priorTurns[j];
|
|
1424
|
+
if (turn.toolCalls?.some((c) => c.id === msg.tool_call_id)) {
|
|
1425
|
+
if (!turn.toolResults) turn.toolResults = [];
|
|
1426
|
+
turn.toolResults.push(result);
|
|
1427
|
+
attached = true;
|
|
1428
|
+
break;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
if (!attached) throw new Error(`openaiMessagesToSandboxInput: tool message references unknown tool_call_id ${msg.tool_call_id}`);
|
|
1432
|
+
break;
|
|
1433
|
+
}
|
|
1434
|
+
case "function": break;
|
|
1435
|
+
}
|
|
1436
|
+
if (i === lastUserIndex) flushPending();
|
|
1437
|
+
}
|
|
1438
|
+
flushPending();
|
|
1439
|
+
const result = {
|
|
1440
|
+
provider,
|
|
1441
|
+
task: userPieces.join("\n\n")
|
|
1442
|
+
};
|
|
1443
|
+
if (variant) result.variant = variant;
|
|
1444
|
+
const instructions = instructionsPieces.join("\n\n");
|
|
1445
|
+
if (instructions) result.instructions = instructions;
|
|
1446
|
+
if (trailingUserParts.length > 0) result.taskParts = trailingUserParts;
|
|
1447
|
+
if (priorTurns.length > 0) result.priorTurns = priorTurns;
|
|
1448
|
+
const toolSpecs = convertTools(tools);
|
|
1449
|
+
if (toolSpecs) result.tools = toolSpecs;
|
|
1450
|
+
if (multimodal) result.multimodal = true;
|
|
1451
|
+
return result;
|
|
1452
|
+
}
|
|
1453
|
+
//#endregion
|
|
1454
|
+
//#region src/openai/translate/responses.ts
|
|
1455
|
+
/**
|
|
1456
|
+
* Resolve a `previous_response_id` into the prior-turns prefix that
|
|
1457
|
+
* gets prepended to the new request. Throws when the id is supplied but
|
|
1458
|
+
* unknown — silently dropping it would corrupt conversation continuity.
|
|
1459
|
+
*/
|
|
1460
|
+
async function resolvePreviousResponseId(prevId, store) {
|
|
1461
|
+
if (!prevId) return { priorTurns: [] };
|
|
1462
|
+
const turns = await store.getPriorTurns(prevId);
|
|
1463
|
+
if (turns === null) throw new Error(`Unknown previous_response_id: ${prevId}`);
|
|
1464
|
+
return { priorTurns: turns };
|
|
1465
|
+
}
|
|
1466
|
+
function emptyUsage() {
|
|
1467
|
+
return {
|
|
1468
|
+
input_tokens: 0,
|
|
1469
|
+
output_tokens: 0,
|
|
1470
|
+
total_tokens: 0,
|
|
1471
|
+
input_tokens_details: { cached_tokens: 0 },
|
|
1472
|
+
output_tokens_details: { reasoning_tokens: 0 }
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
function readUsageFromEvent(event) {
|
|
1476
|
+
const u = event.usage ?? event;
|
|
1477
|
+
const input = Number(u.input_tokens ?? u.prompt_tokens ?? u.inputTokens ?? 0);
|
|
1478
|
+
const output = Number(u.output_tokens ?? u.completion_tokens ?? u.outputTokens ?? 0);
|
|
1479
|
+
if (input === 0 && output === 0 && !("total_tokens" in u)) return null;
|
|
1480
|
+
const total = Number(u.total_tokens ?? input + output);
|
|
1481
|
+
const cached = Number(u.input_tokens_details?.cached_tokens ?? u.cached_tokens ?? 0);
|
|
1482
|
+
const reasoning = Number(u.output_tokens_details?.reasoning_tokens ?? u.reasoning_tokens ?? 0);
|
|
1483
|
+
return {
|
|
1484
|
+
input_tokens: input,
|
|
1485
|
+
output_tokens: output,
|
|
1486
|
+
total_tokens: total,
|
|
1487
|
+
input_tokens_details: { cached_tokens: cached },
|
|
1488
|
+
output_tokens_details: { reasoning_tokens: reasoning }
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
function readToolInvocationFromRaw(event) {
|
|
1492
|
+
if (event.type !== "raw") return null;
|
|
1493
|
+
const data = event.data ?? event;
|
|
1494
|
+
const inner = typeof data.type === "string" ? data.type : "";
|
|
1495
|
+
const isComputerUse = inner === "computer-use" || inner === "computer_call" || typeof data.computerUse === "object" || typeof data.computer_use === "object";
|
|
1496
|
+
if (!(inner === "tool-invocation" || inner === "tool_call" || typeof data.toolInvocation === "object" || typeof data.tool_invocation === "object") && !isComputerUse) return null;
|
|
1497
|
+
const ti = data.toolInvocation ?? data.tool_invocation ?? data.computerUse ?? data.computer_use ?? data;
|
|
1498
|
+
const id = typeof ti.toolCallId === "string" ? ti.toolCallId : typeof ti.tool_call_id === "string" ? ti.tool_call_id : typeof ti.id === "string" ? ti.id : typeof ti.callId === "string" ? ti.callId : "";
|
|
1499
|
+
const name = isComputerUse ? "computer_use" : typeof ti.toolName === "string" ? ti.toolName : typeof ti.tool_name === "string" ? ti.tool_name : typeof ti.name === "string" ? ti.name : "";
|
|
1500
|
+
const args = ti.args ?? ti.arguments ?? ti.input ?? {};
|
|
1501
|
+
if (!id || !name) return null;
|
|
1502
|
+
return {
|
|
1503
|
+
id,
|
|
1504
|
+
name,
|
|
1505
|
+
arguments: typeof args === "string" ? args : JSON.stringify(args),
|
|
1506
|
+
isComputerUse,
|
|
1507
|
+
computerAction: isComputerUse ? ti.action ?? void 0 : void 0
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
function readReasoningFromPart(event) {
|
|
1511
|
+
if (event.type !== "message.part.updated") return null;
|
|
1512
|
+
const part = event.part ?? event;
|
|
1513
|
+
if (part.type !== "reasoning" && part.type !== "thinking") return null;
|
|
1514
|
+
if (typeof part.text === "string") return part.text;
|
|
1515
|
+
if (typeof part.content === "string") return part.content;
|
|
1516
|
+
return null;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Aggregate a Tangle SSE event sequence into the Responses-API output[]
|
|
1520
|
+
* array plus a usage envelope. This is the non-streaming path: callers
|
|
1521
|
+
* collect every event, hand them all in, and get back a settled response
|
|
1522
|
+
* payload ready to return as JSON.
|
|
1523
|
+
*/
|
|
1524
|
+
function assembleResponseOutput(events) {
|
|
1525
|
+
const accum = {
|
|
1526
|
+
textPieces: [],
|
|
1527
|
+
toolCalls: /* @__PURE__ */ new Map(),
|
|
1528
|
+
toolCallOrder: [],
|
|
1529
|
+
computerCalls: [],
|
|
1530
|
+
reasoningPieces: [],
|
|
1531
|
+
usage: emptyUsage(),
|
|
1532
|
+
hasUsage: false
|
|
1533
|
+
};
|
|
1534
|
+
for (const event of events) switch (event.type) {
|
|
1535
|
+
case "token": {
|
|
1536
|
+
const delta = typeof event.delta === "string" && event.delta || typeof event.text === "string" && event.text || typeof event.token === "string" && event.token || "";
|
|
1537
|
+
if (delta) accum.textPieces.push(delta);
|
|
1538
|
+
break;
|
|
1539
|
+
}
|
|
1540
|
+
case "raw": {
|
|
1541
|
+
const tool = readToolInvocationFromRaw(event);
|
|
1542
|
+
if (!tool) break;
|
|
1543
|
+
if (tool.isComputerUse) accum.computerCalls.push({
|
|
1544
|
+
type: "computer_call",
|
|
1545
|
+
id: `cc_${tool.id}`,
|
|
1546
|
+
call_id: tool.id,
|
|
1547
|
+
status: "completed",
|
|
1548
|
+
pending_safety_checks: [],
|
|
1549
|
+
...tool.computerAction ? { action: tool.computerAction } : {}
|
|
1550
|
+
});
|
|
1551
|
+
else {
|
|
1552
|
+
if (!accum.toolCalls.has(tool.id)) accum.toolCallOrder.push(tool.id);
|
|
1553
|
+
accum.toolCalls.set(tool.id, {
|
|
1554
|
+
type: "function_call",
|
|
1555
|
+
id: `fc_${tool.id}`,
|
|
1556
|
+
call_id: tool.id,
|
|
1557
|
+
name: tool.name,
|
|
1558
|
+
arguments: tool.arguments,
|
|
1559
|
+
status: "completed"
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
break;
|
|
1563
|
+
}
|
|
1564
|
+
case "message.part.updated": {
|
|
1565
|
+
const reasoning = readReasoningFromPart(event);
|
|
1566
|
+
if (reasoning) accum.reasoningPieces.push(reasoning);
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
case "done": {
|
|
1570
|
+
const usage = readUsageFromEvent(event);
|
|
1571
|
+
if (usage) {
|
|
1572
|
+
accum.usage = foldUsage(accum.usage, usage);
|
|
1573
|
+
accum.hasUsage = true;
|
|
1574
|
+
}
|
|
1575
|
+
break;
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
const output = [];
|
|
1579
|
+
if (accum.reasoningPieces.length > 0) {
|
|
1580
|
+
const reasoning = {
|
|
1581
|
+
type: "reasoning",
|
|
1582
|
+
id: "rs_0",
|
|
1583
|
+
summary: [],
|
|
1584
|
+
content: accum.reasoningPieces.map((text) => ({
|
|
1585
|
+
type: "reasoning_text",
|
|
1586
|
+
text
|
|
1587
|
+
})),
|
|
1588
|
+
status: "completed"
|
|
1589
|
+
};
|
|
1590
|
+
output.push(reasoning);
|
|
1591
|
+
}
|
|
1592
|
+
if (accum.textPieces.length > 0) {
|
|
1593
|
+
const message = {
|
|
1594
|
+
type: "message",
|
|
1595
|
+
id: "msg_0",
|
|
1596
|
+
role: "assistant",
|
|
1597
|
+
status: "completed",
|
|
1598
|
+
content: [{
|
|
1599
|
+
type: "output_text",
|
|
1600
|
+
text: accum.textPieces.join(""),
|
|
1601
|
+
annotations: []
|
|
1602
|
+
}]
|
|
1603
|
+
};
|
|
1604
|
+
output.push(message);
|
|
1605
|
+
}
|
|
1606
|
+
for (const id of accum.toolCallOrder) {
|
|
1607
|
+
const call = accum.toolCalls.get(id);
|
|
1608
|
+
if (call) output.push(call);
|
|
1609
|
+
}
|
|
1610
|
+
for (const cc of accum.computerCalls) output.push(cc);
|
|
1611
|
+
return {
|
|
1612
|
+
output,
|
|
1613
|
+
usage: accum.usage
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
function foldUsage(a, b) {
|
|
1617
|
+
return {
|
|
1618
|
+
input_tokens: a.input_tokens + b.input_tokens,
|
|
1619
|
+
output_tokens: a.output_tokens + b.output_tokens,
|
|
1620
|
+
total_tokens: a.total_tokens + b.total_tokens,
|
|
1621
|
+
input_tokens_details: { cached_tokens: a.input_tokens_details.cached_tokens + b.input_tokens_details.cached_tokens },
|
|
1622
|
+
output_tokens_details: { reasoning_tokens: a.output_tokens_details.reasoning_tokens + b.output_tokens_details.reasoning_tokens }
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Fold every usage frame in a Tangle event sequence into a single
|
|
1627
|
+
* ResponseUsage envelope. Multiple `done` events are tolerated (e.g.
|
|
1628
|
+
* during retries) by summing.
|
|
1629
|
+
*/
|
|
1630
|
+
function usageFromEvents(events) {
|
|
1631
|
+
let total = emptyUsage();
|
|
1632
|
+
for (const event of events) {
|
|
1633
|
+
if (event.type !== "done") continue;
|
|
1634
|
+
const u = readUsageFromEvent(event);
|
|
1635
|
+
if (u) total = foldUsage(total, u);
|
|
1636
|
+
}
|
|
1637
|
+
return total;
|
|
1638
|
+
}
|
|
1639
|
+
const SUPPORTED_TOOL_TYPES = new Set([
|
|
1640
|
+
"function",
|
|
1641
|
+
"computer_use_preview",
|
|
1642
|
+
"code_interpreter",
|
|
1643
|
+
"web_search",
|
|
1644
|
+
"web_search_preview",
|
|
1645
|
+
"openrouter:web_search"
|
|
1646
|
+
]);
|
|
1647
|
+
const REJECTED_TOOL_TYPES = new Set(["file_search"]);
|
|
1648
|
+
var ResponsesValidationError = class extends Error {
|
|
1649
|
+
type = "invalid_request_error";
|
|
1650
|
+
code;
|
|
1651
|
+
param;
|
|
1652
|
+
constructor(message, code, param) {
|
|
1653
|
+
super(message);
|
|
1654
|
+
this.name = "ResponsesValidationError";
|
|
1655
|
+
this.code = code;
|
|
1656
|
+
this.param = param;
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
/**
|
|
1660
|
+
* Reject Responses requests that ask for unsupported tool types.
|
|
1661
|
+
* Function tools, computer-use preview, code interpreter, and
|
|
1662
|
+
* web_search/web_search_preview are accepted. file_search is rejected
|
|
1663
|
+
* (no vector-store backend). Unknown types are rejected.
|
|
1664
|
+
*/
|
|
1665
|
+
function validateResponsesRequest(req) {
|
|
1666
|
+
const tools = req.tools;
|
|
1667
|
+
if (!tools || tools.length === 0) return;
|
|
1668
|
+
for (let i = 0; i < tools.length; i++) {
|
|
1669
|
+
const type = tools[i].type;
|
|
1670
|
+
if (typeof type !== "string") throw new ResponsesValidationError(`tools[${i}] is missing a type discriminator`, "invalid_tool", `tools[${i}].type`);
|
|
1671
|
+
if (REJECTED_TOOL_TYPES.has(type)) throw new ResponsesValidationError(`Tool type "${type}" is not supported by this endpoint`, "unsupported_tool", `tools[${i}].type`);
|
|
1672
|
+
if (!SUPPORTED_TOOL_TYPES.has(type)) throw new ResponsesValidationError(`Tool type "${type}" is not recognized`, "unsupported_tool", `tools[${i}].type`);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Tangle Router's `/v1/responses` supports web search through the
|
|
1677
|
+
* OpenRouter-compatible server-tool marker. Native OpenAI Responses
|
|
1678
|
+
* `web_search` / `web_search_preview` tools are not forwarded to OpenAI;
|
|
1679
|
+
* the router uses this marker to run Tangle-billed search first, inject
|
|
1680
|
+
* cited context, and strip the marker before the upstream Responses call.
|
|
1681
|
+
*/
|
|
1682
|
+
function normalizeResponsesWebSearchForTangleRouter(req, options = {}) {
|
|
1683
|
+
const tools = Array.isArray(req.tools) ? req.tools : void 0;
|
|
1684
|
+
if (!tools) return req;
|
|
1685
|
+
let changed = false;
|
|
1686
|
+
const normalized = tools.map((tool) => {
|
|
1687
|
+
if (!tool || typeof tool !== "object") return tool;
|
|
1688
|
+
const type = tool.type;
|
|
1689
|
+
if (type !== "web_search" && type !== "web_search_preview") return tool;
|
|
1690
|
+
changed = true;
|
|
1691
|
+
return {
|
|
1692
|
+
type: "openrouter:web_search",
|
|
1693
|
+
parameters: {
|
|
1694
|
+
...readNativeWebSearchParameters(tool),
|
|
1695
|
+
...options.provider ? { provider: options.provider } : {},
|
|
1696
|
+
...options.maxResults ? { max_results: options.maxResults } : {},
|
|
1697
|
+
...options.maxTotalResults ? { max_total_results: options.maxTotalResults } : {},
|
|
1698
|
+
...options.searchContextSize ? { search_context_size: options.searchContextSize } : {}
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
});
|
|
1702
|
+
return changed ? {
|
|
1703
|
+
...req,
|
|
1704
|
+
tools: normalized
|
|
1705
|
+
} : req;
|
|
1706
|
+
}
|
|
1707
|
+
function readNativeWebSearchParameters(tool) {
|
|
1708
|
+
const input = tool;
|
|
1709
|
+
const result = {};
|
|
1710
|
+
const searchContextSize = input.search_context_size ?? input.searchContextSize;
|
|
1711
|
+
if (searchContextSize === "low" || searchContextSize === "medium" || searchContextSize === "high") result.search_context_size = searchContextSize;
|
|
1712
|
+
const userLocation = input.user_location ?? input.userLocation;
|
|
1713
|
+
if (userLocation && typeof userLocation === "object") result.user_location = userLocation;
|
|
1714
|
+
return result;
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Build a settled `Response` shell from an aggregated output + usage.
|
|
1718
|
+
* Caller fills in the runtime-specific fields (id, model, created_at,
|
|
1719
|
+
* status, instructions, etc.) to avoid having to re-derive them inside
|
|
1720
|
+
* the translator.
|
|
1721
|
+
*/
|
|
1722
|
+
function buildResponseShell(args) {
|
|
1723
|
+
const outputText = args.output.filter((item) => item.type === "message").flatMap((m) => m.content).filter((c) => c.type === "output_text").map((c) => c.text).join("");
|
|
1724
|
+
return {
|
|
1725
|
+
id: args.id,
|
|
1726
|
+
object: "response",
|
|
1727
|
+
created_at: args.createdAt,
|
|
1728
|
+
output_text: outputText,
|
|
1729
|
+
error: null,
|
|
1730
|
+
incomplete_details: null,
|
|
1731
|
+
instructions: args.instructions ?? null,
|
|
1732
|
+
metadata: null,
|
|
1733
|
+
model: args.model,
|
|
1734
|
+
output: args.output,
|
|
1735
|
+
parallel_tool_calls: false,
|
|
1736
|
+
temperature: null,
|
|
1737
|
+
tool_choice: "auto",
|
|
1738
|
+
tools: [],
|
|
1739
|
+
top_p: null,
|
|
1740
|
+
status: "completed",
|
|
1741
|
+
usage: args.usage,
|
|
1742
|
+
previous_response_id: args.previousResponseId ?? null
|
|
1743
|
+
};
|
|
1744
|
+
}
|
|
1745
|
+
//#endregion
|
|
1746
|
+
//#region src/openai/types.ts
|
|
1747
|
+
/**
|
|
1748
|
+
* Construct a fresh translator context. The factory is deliberately tiny
|
|
1749
|
+
* — call sites that need to override fields can do so via the partial.
|
|
1750
|
+
*/
|
|
1751
|
+
function createTranslatorContext(init) {
|
|
1752
|
+
return {
|
|
1753
|
+
chunkIndex: 0,
|
|
1754
|
+
toolCallBuffer: /* @__PURE__ */ new Map(),
|
|
1755
|
+
createdAt: Math.floor(Date.now() / 1e3),
|
|
1756
|
+
...init
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
//#endregion
|
|
1760
|
+
export { EmbeddingValidationError, HookChain, InMemoryResponseStore, ResponsesValidationError, Run, actionRateLimitHook, assembleResponseOutput, auditLogHook, buildResponseShell, costCapHook, createTranslatorContext, destructiveActionGuardHook, egressPolicyHook, normalizeResponsesWebSearchForTangleRouter, openaiMessagesToSandboxInput, outcomeToFinishReason, resolvePreviousResponseId, runEvents, sandboxEventToChatChunk, sandboxEventToCompletionChunk, sandboxEventToResponsesEvent, screenshotRedactionHook, usageFromEvents, validateEmbeddingRequest, validateResponsesRequest };
|