@tangle-network/sandbox 0.9.1 → 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.d.ts +2 -2
- package/dist/agent/index.js +1026 -1
- package/dist/auth/index.js +273 -1
- package/dist/client-BBZ7YLmq.js +2193 -0
- package/dist/{client-DPVYHFLS.d.ts → client-D3FqPlde.d.ts} +11 -2
- package/dist/collaboration/index.js +2 -1
- package/dist/collaboration-BxlfZ2Uh.js +201 -1
- package/dist/core.d.ts +2 -2
- package/dist/core.js +4 -1
- package/dist/errors-DZsfJUuc.js +262 -1
- package/dist/{index-Bm9jAzE2.d.ts → index-Dy1fHLYz.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1180 -1
- package/dist/intelligence/index.js +225 -1
- package/dist/openai/index.js +1760 -1
- package/dist/{sandbox-jfc8yiwF.d.ts → sandbox-B55j2q9K.d.ts} +3 -1
- package/dist/sandbox-joKtQ5y3.js +4457 -0
- package/dist/session-gateway/index.js +667 -1
- package/dist/tangle/index.d.ts +1 -1
- package/dist/tangle/index.js +2 -1
- package/dist/tangle-DM0o66lW.js +831 -0
- package/package.json +4 -4
- package/dist/client-BZn0szu8.js +0 -1
- package/dist/sandbox-CfuxtBeD.js +0 -1
- package/dist/tangle-DbX32r-5.js +0 -1
package/dist/openai/index.js
CHANGED
|
@@ -1 +1,1760 @@
|
|
|
1
|
-
const a0_0x4409d1=a0_0x4d60;(function(_0x341f45,_0x17ec9b){const _0x4f200f=a0_0x4d60,_0x18396b=_0x341f45();while(!![]){try{const _0x3dda0=-parseInt(_0x4f200f(0x286))/0x1*(-parseInt(_0x4f200f(0x34a))/0x2)+-parseInt(_0x4f200f(0x26a))/0x3+parseInt(_0x4f200f(0x2b7))/0x4*(-parseInt(_0x4f200f(0x2a3))/0x5)+parseInt(_0x4f200f(0x237))/0x6+-parseInt(_0x4f200f(0x2c9))/0x7*(parseInt(_0x4f200f(0x327))/0x8)+parseInt(_0x4f200f(0x1f2))/0x9+parseInt(_0x4f200f(0x23d))/0xa;if(_0x3dda0===_0x17ec9b)break;else _0x18396b['push'](_0x18396b['shift']());}catch(_0x346d63){_0x18396b['push'](_0x18396b['shift']());}}}(a0_0x453e,0xf2239));var HookChain=class{[a0_0x4409d1(0x313)];constructor(_0x48f312=[]){const _0x1c0df6=a0_0x4409d1;this[_0x1c0df6(0x313)]=_0x48f312;}get[a0_0x4409d1(0x347)](){const _0x41bbab=a0_0x4409d1;return this[_0x41bbab(0x313)]['\x6c\x65\x6e\x67\x74\x68'];}async[a0_0x4409d1(0x217)](_0x2e820d){const _0x3d7c76=a0_0x4409d1,_0x4d6d3b={'\x67\x42\x4c\x6c\x74':function(_0x19341a,_0x5a68b6){return _0x19341a===_0x5a68b6;},'\x51\x6d\x55\x52\x55':'\x72\x65\x77\x72\x69\x74\x65','\x6d\x74\x62\x4f\x63':function(_0x174768,_0x52f70f){return _0x174768??_0x52f70f;}};let _0x302cba=_0x2e820d,_0x3cd47f=null;for(const _0x42672c of this['\x68\x6f\x6f\x6b\x73']){if(!_0x42672c[_0x3d7c76(0x360)])continue;const _0x153a50=await _0x42672c['\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'](_0x302cba);if(_0x4d6d3b['\x67\x42\x4c\x6c\x74'](_0x153a50[_0x3d7c76(0x1a1)],_0x3d7c76(0x228)))return _0x153a50;_0x4d6d3b['\x67\x42\x4c\x6c\x74'](_0x153a50[_0x3d7c76(0x1a1)],_0x4d6d3b[_0x3d7c76(0x2da)])&&(_0x302cba={..._0x302cba,'\x61\x72\x67\x73':_0x153a50[_0x3d7c76(0x1d0)]},_0x3cd47f=_0x153a50);}return _0x4d6d3b['\x6d\x74\x62\x4f\x63'](_0x3cd47f,{'\x61\x63\x74\x69\x6f\x6e':_0x3d7c76(0x2c2)});}async[a0_0x4409d1(0x32d)](_0x52443e,_0x216768){const _0x2edd53=a0_0x4409d1,_0x24f0aa={'\x58\x46\x64\x4c\x5a':function(_0x3f5c62,_0x31a5c4){return _0x3f5c62===_0x31a5c4;}};let _0x1f948c=_0x216768,_0x4f20df=null;for(const _0x117fba of this[_0x2edd53(0x313)]){if(!_0x117fba[_0x2edd53(0x1ba)])continue;const _0x686dad=await _0x117fba[_0x2edd53(0x1ba)](_0x52443e,_0x1f948c);if(_0x24f0aa[_0x2edd53(0x1c4)](_0x686dad[_0x2edd53(0x1a1)],_0x2edd53(0x281)))return _0x686dad;_0x686dad[_0x2edd53(0x1a1)]===_0x2edd53(0x220)&&(_0x1f948c=_0x686dad[_0x2edd53(0x1c3)],_0x4f20df=_0x686dad);}return _0x4f20df??{'\x61\x63\x74\x69\x6f\x6e':_0x2edd53(0x240)};}};function auditLogHook(_0x142f97={}){const _0x175f13=a0_0x4409d1,_0x4e1aa0={'\x73\x64\x4d\x69\x46':_0x175f13(0x2c2)},_0x54906f=_0x142f97['\x73\x69\x6e\x6b']??(_0x387002=>{const _0x1bc7f5=_0x175f13;console[_0x1bc7f5(0x340)](_0x1bc7f5(0x2f0),_0x387002);});return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x11caca){const _0x1164b8=_0x175f13;return await _0x54906f({'\x70\x68\x61\x73\x65':_0x1164b8(0x2a8),'\x72\x75\x6e\x49\x64':_0x11caca[_0x1164b8(0x22e)],'\x74\x68\x72\x65\x61\x64\x49\x64':_0x11caca['\x74\x68\x72\x65\x61\x64\x49\x64'],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':_0x11caca[_0x1164b8(0x1ef)],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x11caca['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65'],'\x63\x61\x6c\x6c\x49\x64':_0x11caca[_0x1164b8(0x254)],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':_0x11caca['\x74\x69\x6d\x65\x73\x74\x61\x6d\x70'],'\x61\x72\x67\x73':_0x11caca[_0x1164b8(0x1d0)]}),{'\x61\x63\x74\x69\x6f\x6e':_0x4e1aa0[_0x1164b8(0x19c)]};},async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x4932ad,_0x2c357d){const _0x55f3dc=_0x175f13;return await _0x54906f({'\x70\x68\x61\x73\x65':'\x61\x66\x74\x65\x72','\x72\x75\x6e\x49\x64':_0x4932ad[_0x55f3dc(0x22e)],'\x74\x68\x72\x65\x61\x64\x49\x64':_0x4932ad[_0x55f3dc(0x2bf)],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':_0x4932ad[_0x55f3dc(0x1ef)],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x4932ad[_0x55f3dc(0x1c1)],'\x63\x61\x6c\x6c\x49\x64':_0x4932ad['\x63\x61\x6c\x6c\x49\x64'],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':_0x4932ad[_0x55f3dc(0x22f)],'\x72\x65\x73\x75\x6c\x74':_0x2c357d}),{'\x61\x63\x74\x69\x6f\x6e':_0x55f3dc(0x240)};}};}const NETWORK_TOOL_REGEX=/^(fetch|http|https|browser|playwright|curl|wget|computer-use:click|computer-use:type)/i,URL_FIELD_NAMES=new Set(['\x75\x72\x6c',a0_0x4409d1(0x32c),a0_0x4409d1(0x1dd),a0_0x4409d1(0x253),'\x73\x72\x63',a0_0x4409d1(0x362),'\x61\x64\x64\x72\x65\x73\x73']);function extractUrlsFromArgs(_0x46d927){const _0x2522c1=a0_0x4409d1,_0x5ed6cc={'\x56\x42\x56\x71\x49':function(_0x5bde44,_0x552f82){return _0x5bde44===_0x552f82;},'\x55\x5a\x71\x52\x6f':_0x2522c1(0x33c),'\x64\x4c\x6d\x4c\x54':function(_0x46a78e,_0x54d6ff){return _0x46a78e(_0x54d6ff);}},_0x336f8f=[],_0x2bb053=_0x48c0f0=>{const _0x2b95c6=_0x2522c1;if(_0x5ed6cc[_0x2b95c6(0x2a2)](typeof _0x48c0f0,_0x5ed6cc[_0x2b95c6(0x31d)])){if(/^https?:\/\//i[_0x2b95c6(0x30e)](_0x48c0f0))try{const _0x4aa3d9=new URL(_0x48c0f0);_0x336f8f[_0x2b95c6(0x195)]({'\x72\x61\x77':_0x48c0f0,'\x68\x6f\x73\x74':_0x4aa3d9['\x68\x6f\x73\x74']});}catch{_0x336f8f[_0x2b95c6(0x195)]({'\x72\x61\x77':_0x48c0f0,'\x68\x6f\x73\x74':null});}return;}if(_0x5ed6cc[_0x2b95c6(0x2a2)](_0x48c0f0,null)||typeof _0x48c0f0!==_0x2b95c6(0x2cb))return;if(Array[_0x2b95c6(0x1cf)](_0x48c0f0)){for(const _0x204ce1 of _0x48c0f0)_0x5ed6cc[_0x2b95c6(0x2dd)](_0x2bb053,_0x204ce1);return;}for(const [_0x564ce7,_0x4a5f3f]of Object['\x65\x6e\x74\x72\x69\x65\x73'](_0x48c0f0)){if(URL_FIELD_NAMES['\x68\x61\x73'](_0x564ce7['\x74\x6f\x4c\x6f\x77\x65\x72\x43\x61\x73\x65']())&&_0x5ed6cc['\x56\x42\x56\x71\x49'](typeof _0x4a5f3f,_0x2b95c6(0x33c))){try{const _0x5d8b28=new URL(_0x4a5f3f);_0x336f8f[_0x2b95c6(0x195)]({'\x72\x61\x77':_0x4a5f3f,'\x68\x6f\x73\x74':_0x5d8b28['\x68\x6f\x73\x74']});}catch{_0x336f8f[_0x2b95c6(0x195)]({'\x72\x61\x77':_0x4a5f3f,'\x68\x6f\x73\x74':null});}continue;}_0x2bb053(_0x4a5f3f);}};return _0x2bb053(_0x46d927),_0x336f8f;}function isNetworkLike(_0x467106,_0x2ab82){const _0x508f4f=a0_0x4409d1,_0x1f6a15={'\x4a\x45\x58\x76\x4d':function(_0x4f70c9,_0x49bed4){return _0x4f70c9>_0x49bed4;}};if(NETWORK_TOOL_REGEX[_0x508f4f(0x30e)](_0x467106[_0x508f4f(0x1c1)]))return!![];return _0x1f6a15[_0x508f4f(0x2a4)](_0x2ab82[_0x508f4f(0x28a)],0x0);}function hostMatches(_0x2f2b3c,_0x34d629){const _0x52f2c4=a0_0x4409d1,_0x34d7f9={'\x71\x6b\x42\x4b\x43':function(_0x9d36b1,_0x28f599){return _0x9d36b1===_0x28f599;}};if(_0x34d7f9['\x71\x6b\x42\x4b\x43'](_0x34d629,_0x2f2b3c))return!![];if(_0x34d629[_0x52f2c4(0x22c)]('\x2a\x2e')){const _0x3ab0e6=_0x34d629[_0x52f2c4(0x1b5)](0x1);return _0x2f2b3c[_0x52f2c4(0x1de)](_0x3ab0e6);}return![];}function egressPolicyHook(_0x547ba2={}){const _0x362243=a0_0x4409d1,_0x52d572={'\x51\x59\x71\x6e\x7a':function(_0x5ef93c,_0x3081c9){return _0x5ef93c(_0x3081c9);},'\x4a\x4c\x6f\x62\x67':_0x362243(0x228),'\x65\x46\x4d\x64\x49':_0x362243(0x24f)},_0x42b13d=_0x547ba2[_0x362243(0x225)]??[],_0x12d9eb=_0x547ba2[_0x362243(0x2f9)];return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x250a06){const _0x98c7a1=_0x362243,_0x2fc70b=_0x52d572[_0x98c7a1(0x2d4)](extractUrlsFromArgs,_0x250a06[_0x98c7a1(0x1d0)]);if(!isNetworkLike(_0x250a06,_0x2fc70b))return{'\x61\x63\x74\x69\x6f\x6e':'\x61\x6c\x6c\x6f\x77'};if(_0x547ba2['\x61\x6c\x6c\x6f\x77\x46\x6e'])return await _0x547ba2['\x61\x6c\x6c\x6f\x77\x46\x6e'](_0x250a06)?{'\x61\x63\x74\x69\x6f\x6e':_0x98c7a1(0x2c2)}:{'\x61\x63\x74\x69\x6f\x6e':_0x52d572[_0x98c7a1(0x23b)],'\x72\x65\x61\x73\x6f\x6e':_0x52d572[_0x98c7a1(0x2c3)]};for(const _0x3a08dc of _0x2fc70b){if(!_0x3a08dc[_0x98c7a1(0x28b)])continue;for(const _0x405d18 of _0x42b13d)if(hostMatches(_0x3a08dc[_0x98c7a1(0x28b)],_0x405d18))return{'\x61\x63\x74\x69\x6f\x6e':_0x52d572[_0x98c7a1(0x23b)],'\x72\x65\x61\x73\x6f\x6e':_0x98c7a1(0x2e5)+_0x3a08dc[_0x98c7a1(0x28b)]+_0x98c7a1(0x1ec)+_0x405d18+'\x22'};}if(_0x12d9eb&&_0x12d9eb[_0x98c7a1(0x28a)]>0x0)for(const _0xcf055a of _0x2fc70b){const _0x4bf4c9=_0xcf055a['\x68\x6f\x73\x74'];if(!_0x4bf4c9)return{'\x61\x63\x74\x69\x6f\x6e':_0x52d572[_0x98c7a1(0x23b)],'\x72\x65\x61\x73\x6f\x6e':_0x98c7a1(0x282)};if(!_0x12d9eb[_0x98c7a1(0x33d)](_0x3953dd=>hostMatches(_0x4bf4c9,_0x3953dd)))return{'\x61\x63\x74\x69\x6f\x6e':_0x98c7a1(0x228),'\x72\x65\x61\x73\x6f\x6e':_0x98c7a1(0x2e5)+_0x4bf4c9+_0x98c7a1(0x2e9)};}return{'\x61\x63\x74\x69\x6f\x6e':_0x98c7a1(0x2c2)};}};}function costCapHook(_0x4ed304){const _0x41edae=a0_0x4409d1,_0x5e0e61={'\x61\x73\x61\x68\x6e':function(_0x1667c0,_0x4cf0be){return _0x1667c0(_0x4cf0be);},'\x4e\x67\x76\x6c\x6e':function(_0x341231,_0x1a59eb){return _0x341231>=_0x1a59eb;}},_0x35227c=_0x4ed304[_0x41edae(0x2d3)]??(async()=>0x0);return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x3d537d){const _0x14a01e=_0x41edae,_0x2b054e=await _0x35227c(_0x3d537d['\x70\x61\x72\x74\x6e\x65\x72\x49\x64']);if(_0x2b054e>=_0x4ed304['\x63\x65\x69\x6c\x69\x6e\x67'])return{'\x61\x63\x74\x69\x6f\x6e':_0x14a01e(0x228),'\x72\x65\x61\x73\x6f\x6e':_0x14a01e(0x351)+_0x2b054e+_0x14a01e(0x31b)+_0x4ed304[_0x14a01e(0x352)]};return{'\x61\x63\x74\x69\x6f\x6e':'\x61\x6c\x6c\x6f\x77'};},async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x5b2a79){const _0x540fa4=_0x41edae,_0x54f895=await _0x5e0e61[_0x540fa4(0x364)](_0x35227c,_0x5b2a79[_0x540fa4(0x1ef)]);if(_0x5e0e61[_0x540fa4(0x2a5)](_0x54f895,_0x4ed304['\x63\x65\x69\x6c\x69\x6e\x67']))return{'\x61\x63\x74\x69\x6f\x6e':_0x540fa4(0x281),'\x72\x65\x61\x73\x6f\x6e':_0x540fa4(0x2a7)+_0x54f895+_0x540fa4(0x31b)+_0x4ed304[_0x540fa4(0x352)]};return{'\x61\x63\x74\x69\x6f\x6e':_0x540fa4(0x240)};}};}function actionRateLimitHook(_0x31f1a3){const _0x265695=a0_0x4409d1,_0x133249={'\x72\x70\x67\x45\x68':_0x265695(0x35a),'\x4f\x53\x6f\x54\x4a':_0x265695(0x2c2),'\x4f\x53\x6a\x63\x4e':function(_0xa8b794){return _0xa8b794();},'\x72\x77\x73\x75\x6f':function(_0x9f2e67,_0x305b18){return _0x9f2e67-_0x305b18;},'\x50\x67\x6b\x72\x6d':_0x265695(0x228)},_0x339be0=_0x31f1a3['\x6e\x6f\x77']??Date[_0x265695(0x250)],_0x5576f7=Math['\x6d\x61\x78'](0x1,Math[_0x265695(0x1e4)](_0x31f1a3[_0x265695(0x2d2)])),_0x5c0c40=_0x31f1a3['\x70\x65\x72\x53\x65\x63\x6f\x6e\x64\x50\x65\x72\x53\x65\x73\x73\x69\x6f\x6e']/0x3e8,_0x20d3cd=new Map();return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x26ce45){const _0x2202fc=_0x265695;if(!_0x26ce45['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65'][_0x2202fc(0x22c)](_0x133249['\x72\x70\x67\x45\x68']))return{'\x61\x63\x74\x69\x6f\x6e':_0x133249['\x4f\x53\x6f\x54\x4a']};const _0x3cc07d=_0x26ce45['\x72\x75\x6e\x49\x64'],_0x111dc1=_0x133249[_0x2202fc(0x1c7)](_0x339be0),_0x2f39c5=_0x20d3cd[_0x2202fc(0x25b)](_0x3cc07d)??{'\x74\x6f\x6b\x65\x6e\x73':_0x5576f7,'\x6c\x61\x73\x74\x52\x65\x66\x69\x6c\x6c\x4d\x73':_0x111dc1},_0x324178=Math['\x6d\x61\x78'](0x0,_0x133249[_0x2202fc(0x32f)](_0x111dc1,_0x2f39c5[_0x2202fc(0x2ae)]));_0x2f39c5[_0x2202fc(0x19f)]=Math[_0x2202fc(0x1b1)](_0x5576f7,_0x2f39c5[_0x2202fc(0x19f)]+_0x324178*_0x5c0c40),_0x2f39c5[_0x2202fc(0x2ae)]=_0x111dc1;if(_0x2f39c5[_0x2202fc(0x19f)]<0x1)return _0x20d3cd['\x73\x65\x74'](_0x3cc07d,_0x2f39c5),{'\x61\x63\x74\x69\x6f\x6e':_0x133249['\x50\x67\x6b\x72\x6d'],'\x72\x65\x61\x73\x6f\x6e':_0x2202fc(0x314)+_0x31f1a3[_0x2202fc(0x2d2)]+'\x2f\x73'};return _0x2f39c5[_0x2202fc(0x19f)]-=0x1,_0x20d3cd[_0x2202fc(0x2b1)](_0x3cc07d,_0x2f39c5),{'\x61\x63\x74\x69\x6f\x6e':_0x133249[_0x2202fc(0x331)]};}};}function readScreenshotPayload(_0x5e4b63){const _0x2b4d7e=a0_0x4409d1,_0x3c4708={'\x6c\x71\x62\x42\x58':function(_0x3c6ebe,_0x566615){return _0x3c6ebe===_0x566615;}},_0x57b8e3=[_0x5e4b63[_0x2b4d7e(0x34f)],_0x5e4b63['\x64\x65\x74\x61\x69\x6c\x73']?.[_0x2b4d7e(0x1f9)],_0x5e4b63[_0x2b4d7e(0x2f1)]];for(const _0x3e03d1 of _0x57b8e3)if(_0x3e03d1&&_0x3c4708[_0x2b4d7e(0x221)](typeof _0x3e03d1,_0x2b4d7e(0x2cb))){if(typeof _0x3e03d1[_0x2b4d7e(0x1ce)]===_0x2b4d7e(0x33c))return _0x3e03d1;}return null;}function screenshotRedactionHook(_0x1ed31d={}){const _0xd96645=a0_0x4409d1,_0x38a8e8={'\x4a\x56\x77\x67\x4b':_0xd96645(0x23e),'\x6b\x78\x73\x51\x6b':_0xd96645(0x240),'\x53\x5a\x71\x4a\x6f':function(_0x14b1e5,_0x20ec5e){return _0x14b1e5(_0x20ec5e);},'\x61\x6f\x50\x75\x58':_0xd96645(0x1c0)},_0x1a92df=_0x1ed31d[_0xd96645(0x20d)]??(_0x337dd7=>console['\x77\x61\x72\x6e'](_0x337dd7)),_0x9d7dea=(_0x1ed31d[_0xd96645(0x2cf)]?.[_0xd96645(0x28a)]??0x0)>0x0;let _0x20e789=![];return{async '\x61\x66\x74\x65\x72\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x14ebbe,_0x385e3b){const _0xae3249=_0xd96645;if(_0x14ebbe[_0xae3249(0x1c1)]!==_0x38a8e8[_0xae3249(0x285)])return{'\x61\x63\x74\x69\x6f\x6e':_0xae3249(0x240)};if(!_0x9d7dea)return{'\x61\x63\x74\x69\x6f\x6e':_0x38a8e8['\x6b\x78\x73\x51\x6b']};if(!readScreenshotPayload(_0x385e3b))return{'\x61\x63\x74\x69\x6f\x6e':_0x38a8e8[_0xae3249(0x26b)]};return!_0x20e789&&(_0x20e789=!![],_0x38a8e8[_0xae3249(0x299)](_0x1a92df,_0x38a8e8['\x61\x6f\x50\x75\x58'])),{'\x61\x63\x74\x69\x6f\x6e':'\x70\x61\x73\x73'};}};}const TYPE_TEXT_FIELDS=[a0_0x4409d1(0x244),a0_0x4409d1(0x1f8),a0_0x4409d1(0x30c),a0_0x4409d1(0x1ff)],CLICK_LABEL_FIELDS=[a0_0x4409d1(0x316),'\x61\x6c\x74',a0_0x4409d1(0x25f),a0_0x4409d1(0x1ea),a0_0x4409d1(0x2c4)];function readStringField(_0x23e7f5,_0x5e5443){const _0x73d443=a0_0x4409d1,_0x55c1b4={'\x50\x68\x6d\x78\x51':function(_0x4d2725,_0x35a7a8){return _0x4d2725!==_0x35a7a8;},'\x65\x6f\x4e\x5a\x64':_0x73d443(0x2cb),'\x69\x59\x45\x6f\x41':function(_0x3ec37d,_0x468631){return _0x3ec37d===_0x468631;},'\x43\x79\x4c\x57\x41':function(_0xcc1cc1,_0x23a095){return _0xcc1cc1>_0x23a095;}};if(!_0x23e7f5||_0x55c1b4[_0x73d443(0x20a)](typeof _0x23e7f5,_0x55c1b4[_0x73d443(0x25a)]))return null;const _0x11631b=_0x23e7f5;for(const _0x170ee8 of _0x5e5443){const _0x10e79a=_0x11631b[_0x170ee8];if(_0x55c1b4['\x69\x59\x45\x6f\x41'](typeof _0x10e79a,_0x73d443(0x33c))&&_0x55c1b4[_0x73d443(0x302)](_0x10e79a[_0x73d443(0x28a)],0x0))return _0x10e79a;}return null;}function destructiveActionGuardHook(_0x796001){const _0x55e602=a0_0x4409d1,_0x32e093={'\x68\x58\x58\x58\x48':function(_0x44ebbf,_0x3457dc,_0x3e2546){return _0x44ebbf(_0x3457dc,_0x3e2546);},'\x52\x49\x58\x59\x79':_0x55e602(0x2c5)},_0x38ac9b=_0x796001[_0x55e602(0x30f)];return{async '\x62\x65\x66\x6f\x72\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'(_0x5a481b){const _0xbf5d6e=_0x55e602;let _0x28dcbb=null;if(_0x5a481b['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65']==='\x63\x6f\x6d\x70\x75\x74\x65\x72\x2d\x75\x73\x65\x3a\x74\x79\x70\x65')_0x28dcbb=_0x32e093[_0xbf5d6e(0x251)](readStringField,_0x5a481b[_0xbf5d6e(0x1d0)],TYPE_TEXT_FIELDS);else{if(_0x5a481b['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65']===_0x32e093['\x52\x49\x58\x59\x79'])_0x28dcbb=_0x32e093['\x68\x58\x58\x58\x48'](readStringField,_0x5a481b[_0xbf5d6e(0x1d0)],CLICK_LABEL_FIELDS);else return{'\x61\x63\x74\x69\x6f\x6e':_0xbf5d6e(0x2c2)};}if(!_0x28dcbb)return{'\x61\x63\x74\x69\x6f\x6e':'\x61\x6c\x6c\x6f\x77'};for(const _0x41b52e of _0x38ac9b)if(_0x41b52e[_0xbf5d6e(0x30e)](_0x28dcbb))return{'\x61\x63\x74\x69\x6f\x6e':_0xbf5d6e(0x228),'\x72\x65\x61\x73\x6f\x6e':_0xbf5d6e(0x1ed)+_0x41b52e[_0xbf5d6e(0x2f3)]()};return{'\x61\x63\x74\x69\x6f\x6e':_0xbf5d6e(0x2c2)};}};}var InMemoryResponseStore=class{[a0_0x4409d1(0x1fe)]=new Map();async[a0_0x4409d1(0x246)](_0x529f8b){const _0x326ff1=a0_0x4409d1,_0x4df95d=this[_0x326ff1(0x1fe)][_0x326ff1(0x25b)](_0x529f8b);return _0x4df95d?_0x4df95d[_0x326ff1(0x1b9)](_0x1e8238=>({..._0x1e8238})):null;}async[a0_0x4409d1(0x1c6)](_0x409fd5,_0x5087c6){const _0x6035e3=a0_0x4409d1;this[_0x6035e3(0x1fe)][_0x6035e3(0x2b1)](_0x409fd5,_0x5087c6[_0x6035e3(0x1b9)](_0x92097f=>({..._0x92097f})));}[a0_0x4409d1(0x347)](){const _0x4a5008=a0_0x4409d1;return this[_0x4a5008(0x1fe)]['\x73\x69\x7a\x65'];}[a0_0x4409d1(0x326)](_0x242b17){const _0x54ce0e=a0_0x4409d1;return this[_0x54ce0e(0x1fe)][_0x54ce0e(0x326)](_0x242b17);}[a0_0x4409d1(0x1db)](){const _0x1ef7a7=a0_0x4409d1;this[_0x1ef7a7(0x1fe)]['\x63\x6c\x65\x61\x72']();}};const TERMINAL_STATUSES=new Set([a0_0x4409d1(0x227),a0_0x4409d1(0x1dc),a0_0x4409d1(0x27b),a0_0x4409d1(0x345)]);function isTerminal(_0x4480e2){const _0x258963=a0_0x4409d1;return TERMINAL_STATUSES[_0x258963(0x20e)](_0x4480e2);}async function*runEvents(_0x481bcf,_0x5e5a3e,_0x15f07e){for await(const _0x192f58 of _0x15f07e['\x6f\x70\x65\x6e'](_0x481bcf,_0x5e5a3e))yield _0x192f58;}function readToolCallFromFrame(_0x34c0b0){const _0x10a1a0=a0_0x4409d1,_0x359f38={'\x42\x46\x4d\x6f\x59':function(_0x35c113,_0x375542){return _0x35c113===_0x375542;},'\x70\x71\x57\x4f\x58':function(_0x3a58cc,_0x139e40){return _0x3a58cc===_0x139e40;},'\x43\x76\x52\x61\x6f':function(_0x29934b,_0x1a583b){return _0x29934b(_0x1a583b);},'\x4f\x6c\x71\x75\x46':function(_0xbe6e85,_0xf7856d){return _0xbe6e85!==_0xf7856d;},'\x4a\x41\x50\x74\x50':'\x72\x61\x77','\x65\x6e\x6d\x79\x46':_0x10a1a0(0x275),'\x41\x43\x62\x4b\x50':'\x63\x6f\x6d\x70\x75\x74\x65\x72\x5f\x63\x61\x6c\x6c','\x6f\x78\x4c\x4d\x71':_0x10a1a0(0x1a1),'\x6e\x4d\x73\x53\x57':function(_0x2b8e41,_0x3eea53){return _0x2b8e41(_0x3eea53);}};if(_0x359f38[_0x10a1a0(0x1b7)](_0x34c0b0[_0x10a1a0(0x350)],_0x10a1a0(0x260))||_0x359f38['\x70\x71\x57\x4f\x58'](_0x34c0b0[_0x10a1a0(0x350)],_0x10a1a0(0x222))){const _0x25c5ec=_0x34c0b0['\x64\x61\x74\x61']??_0x34c0b0,_0x4e669d=String(_0x25c5ec[_0x10a1a0(0x254)]??_0x25c5ec[_0x10a1a0(0x270)]??_0x25c5ec['\x69\x64']??''),_0xa3d665=_0x359f38[_0x10a1a0(0x21c)](String,_0x25c5ec[_0x10a1a0(0x1c1)]??_0x25c5ec['\x74\x6f\x6f\x6c\x5f\x6e\x61\x6d\x65']??_0x25c5ec[_0x10a1a0(0x1d6)]??'');if(!_0x4e669d||!_0xa3d665)return null;return{'\x63\x61\x6c\x6c\x49\x64':_0x4e669d,'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0xa3d665,'\x61\x72\x67\x73':_0x25c5ec['\x61\x72\x67\x73']??_0x25c5ec[_0x10a1a0(0x19d)]??_0x25c5ec[_0x10a1a0(0x30c)]??{},'\x72\x65\x71\x75\x69\x72\x65\x73\x41\x63\x74\x69\x6f\x6e':!![]};}if(_0x359f38[_0x10a1a0(0x27e)](_0x34c0b0[_0x10a1a0(0x350)],_0x359f38['\x4a\x41\x50\x74\x50']))return null;const _0x3fd3d2=_0x34c0b0[_0x10a1a0(0x358)]??_0x34c0b0,_0x3c4276=typeof _0x3fd3d2[_0x10a1a0(0x350)]===_0x10a1a0(0x33c)?_0x3fd3d2['\x74\x79\x70\x65']:'';if(!(_0x3c4276==='\x74\x6f\x6f\x6c\x2d\x69\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e'||_0x3c4276===_0x10a1a0(0x1d2)||_0x3c4276===_0x359f38[_0x10a1a0(0x2b2)]||_0x359f38[_0x10a1a0(0x1b7)](_0x3c4276,_0x359f38[_0x10a1a0(0x235)])))return null;const _0x5b7369=_0x3fd3d2[_0x10a1a0(0x196)]??_0x3fd3d2[_0x10a1a0(0x25c)]??_0x3fd3d2[_0x10a1a0(0x367)]??_0x3fd3d2[_0x10a1a0(0x279)]??_0x3fd3d2,_0x5c07ec=String(_0x5b7369[_0x10a1a0(0x1c2)]??_0x5b7369[_0x10a1a0(0x1e8)]??_0x5b7369[_0x10a1a0(0x254)]??_0x5b7369['\x69\x64']??''),_0x2747f7=_0x3c4276===_0x359f38[_0x10a1a0(0x2b2)]||_0x359f38[_0x10a1a0(0x1b7)](_0x3c4276,_0x359f38[_0x10a1a0(0x235)])?_0x10a1a0(0x35a)+String(_0x5b7369[_0x10a1a0(0x1a1)]?.[_0x10a1a0(0x350)]??_0x359f38[_0x10a1a0(0x31a)]):_0x359f38['\x6e\x4d\x73\x53\x57'](String,_0x5b7369[_0x10a1a0(0x1c1)]??_0x5b7369[_0x10a1a0(0x223)]??_0x5b7369[_0x10a1a0(0x1d6)]??'');if(!_0x5c07ec||!_0x2747f7)return null;return{'\x63\x61\x6c\x6c\x49\x64':_0x5c07ec,'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x2747f7,'\x61\x72\x67\x73':_0x5b7369[_0x10a1a0(0x1d0)]??_0x5b7369['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']??_0x5b7369[_0x10a1a0(0x30c)]??{},'\x72\x65\x71\x75\x69\x72\x65\x73\x41\x63\x74\x69\x6f\x6e':![]};}function readTerminal(_0x72398e){const _0x4663d1=a0_0x4409d1,_0x3d1246={'\x54\x6f\x4e\x73\x52':function(_0x8c2634,_0x1d6d79){return _0x8c2634===_0x1d6d79;},'\x64\x50\x6a\x75\x44':'\x73\x74\x72\x69\x6e\x67','\x58\x52\x52\x7a\x50':function(_0x1b4dbe,_0xff8a17){return _0x1b4dbe===_0xff8a17;},'\x44\x79\x48\x77\x5a':'\x73\x75\x63\x63\x65\x65\x64\x65\x64','\x51\x64\x4c\x69\x44':_0x4663d1(0x247),'\x76\x68\x4f\x46\x43':_0x4663d1(0x1dc),'\x56\x6c\x68\x42\x70':function(_0x33a067,_0x390a51){return _0x33a067===_0x390a51;},'\x4d\x68\x57\x77\x45':_0x4663d1(0x283)};if(_0x3d1246[_0x4663d1(0x34d)](_0x72398e[_0x4663d1(0x350)],'\x64\x6f\x6e\x65')){const _0x52fa0e=typeof _0x72398e[_0x4663d1(0x1e0)]===_0x3d1246['\x64\x50\x6a\x75\x44']&&_0x72398e['\x6f\x75\x74\x63\x6f\x6d\x65']||_0x4663d1(0x34c);if(_0x3d1246[_0x4663d1(0x34d)](_0x52fa0e,'\x73\x75\x63\x63\x65\x73\x73')||_0x3d1246['\x58\x52\x52\x7a\x50'](_0x52fa0e,'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64')||_0x52fa0e===_0x3d1246[_0x4663d1(0x257)]||_0x52fa0e===_0x3d1246[_0x4663d1(0x261)])return{'\x73\x74\x61\x74\x75\x73':_0x4663d1(0x227)};return{'\x73\x74\x61\x74\x75\x73':_0x3d1246[_0x4663d1(0x18c)],'\x72\x65\x61\x73\x6f\x6e':_0x3d1246[_0x4663d1(0x35b)](typeof _0x72398e[_0x4663d1(0x29e)],'\x73\x74\x72\x69\x6e\x67')?_0x72398e[_0x4663d1(0x29e)]:_0x52fa0e};}if(_0x72398e['\x74\x79\x70\x65']===_0x4663d1(0x29e))return{'\x73\x74\x61\x74\x75\x73':_0x4663d1(0x1dc),'\x72\x65\x61\x73\x6f\x6e':typeof _0x72398e['\x6d\x65\x73\x73\x61\x67\x65']===_0x3d1246[_0x4663d1(0x212)]&&_0x72398e[_0x4663d1(0x30a)]||_0x3d1246[_0x4663d1(0x35b)](typeof _0x72398e[_0x4663d1(0x29e)],_0x4663d1(0x33c))&&_0x72398e[_0x4663d1(0x29e)]||_0x3d1246[_0x4663d1(0x34b)]};return null;}var EventQueue=class{['\x62\x75\x66\x66\x65\x72']=[];[a0_0x4409d1(0x1a2)]=[];[a0_0x4409d1(0x1d4)]=![];[a0_0x4409d1(0x34e)]=![];['\x70\x75\x73\x68'](_0x42c8a3){const _0x121049=a0_0x4409d1;if(this[_0x121049(0x1d4)])return;const _0x538c78=this[_0x121049(0x1a2)][_0x121049(0x25e)]();if(_0x538c78){_0x538c78({'\x76\x61\x6c\x75\x65':_0x42c8a3,'\x64\x6f\x6e\x65':![]});return;}this[_0x121049(0x1f3)][_0x121049(0x195)](_0x42c8a3);}[a0_0x4409d1(0x330)](){const _0x387eb7=a0_0x4409d1;if(this['\x63\x6c\x6f\x73\x65\x64'])return;this[_0x387eb7(0x1d4)]=!![];while(this['\x77\x61\x69\x74\x65\x72\x73'][_0x387eb7(0x28a)]>0x0)this[_0x387eb7(0x1a2)][_0x387eb7(0x25e)]()?.({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});}[a0_0x4409d1(0x209)](){const _0x19d4e6=a0_0x4409d1,_0x3ea1b1={'\x7a\x7a\x57\x6e\x47':function(_0x1cb972,_0x5c86ee){return _0x1cb972>_0x5c86ee;},'\x75\x4e\x79\x44\x6f':'\x52\x75\x6e\x2e\x65\x76\x65\x6e\x74\x73\x28\x29\x20\x6d\x61\x79\x20\x6f\x6e\x6c\x79\x20\x62\x65\x20\x63\x6f\x6e\x73\x75\x6d\x65\x64\x20\x6f\x6e\x63\x65\x2e\x20\x4d\x75\x6c\x74\x69\x70\x6c\x65\x20\x69\x74\x65\x72\x61\x74\x6f\x72\x73\x20\x6f\x6e\x20\x74\x68\x65\x20\x73\x61\x6d\x65\x20\x52\x75\x6e\x20\x73\x68\x61\x72\x65\x20\x73\x74\x61\x74\x65\x20\x61\x6e\x64\x20\x77\x6f\x75\x6c\x64\x20\x69\x6e\x74\x65\x72\x6c\x65\x61\x76\x65\x2f\x73\x74\x65\x61\x6c\x20\x65\x76\x65\x6e\x74\x73\x2e'};if(this[_0x19d4e6(0x34e)])throw new Error(_0x3ea1b1[_0x19d4e6(0x1a3)]);this[_0x19d4e6(0x34e)]=!![];const _0x540d7c=this;return{[Symbol['\x61\x73\x79\x6e\x63\x49\x74\x65\x72\x61\x74\x6f\x72']](){return this;},'\x6e\x65\x78\x74'(){const _0x68671f=_0x19d4e6;if(_0x3ea1b1[_0x68671f(0x18b)](_0x540d7c[_0x68671f(0x1f3)][_0x68671f(0x28a)],0x0)){const _0x3d1838=_0x540d7c[_0x68671f(0x1f3)][_0x68671f(0x25e)]();return Promise['\x72\x65\x73\x6f\x6c\x76\x65']({'\x76\x61\x6c\x75\x65':_0x3d1838,'\x64\x6f\x6e\x65':![]});}if(_0x540d7c[_0x68671f(0x1d4)])return Promise[_0x68671f(0x348)]({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});return new Promise(_0x5af25c=>{const _0x4a9c6b=_0x68671f;_0x540d7c['\x77\x61\x69\x74\x65\x72\x73'][_0x4a9c6b(0x195)](_0x5af25c);});},'\x72\x65\x74\x75\x72\x6e'(){const _0x1fe3c9=_0x19d4e6;return _0x540d7c[_0x1fe3c9(0x330)](),Promise[_0x1fe3c9(0x348)]({'\x76\x61\x6c\x75\x65':void 0x0,'\x64\x6f\x6e\x65':!![]});}};}},Run=class{['\x69\x64'];[a0_0x4409d1(0x2bf)];[a0_0x4409d1(0x1ef)];[a0_0x4409d1(0x27f)]=a0_0x4409d1(0x264);[a0_0x4409d1(0x359)];['\x68\x6f\x6f\x6b\x73'];[a0_0x4409d1(0x233)];[a0_0x4409d1(0x213)];[a0_0x4409d1(0x2a6)]=new EventQueue();['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65']=null;[a0_0x4409d1(0x1df)]=new Map();[a0_0x4409d1(0x24a)]=![];constructor(_0x536fb8){const _0xc141e7=a0_0x4409d1,_0x1b268c=_0xc141e7(0x2bb)[_0xc141e7(0x19b)]('\x7c');let _0x2522d9=0x0;while(!![]){switch(_0x1b268c[_0x2522d9++]){case'\x30':this['\x65\x78\x65\x63\x75\x74\x65\x54\x6f\x6f\x6c']=_0x536fb8[_0xc141e7(0x233)];continue;case'\x31':this[_0xc141e7(0x359)]=_0x536fb8[_0xc141e7(0x359)];continue;case'\x32':this[_0xc141e7(0x213)]=_0x536fb8[_0xc141e7(0x213)];continue;case'\x33':this['\x68\x6f\x6f\x6b\x73']=_0x536fb8['\x68\x6f\x6f\x6b\x73'];continue;case'\x34':this['\x74\x68\x72\x65\x61\x64\x49\x64']=_0x536fb8[_0xc141e7(0x2bf)];continue;case'\x35':this['\x69\x64']=_0x536fb8['\x69\x64'];continue;case'\x36':this[_0xc141e7(0x1ef)]=_0x536fb8[_0xc141e7(0x1ef)];continue;}break;}}get[a0_0x4409d1(0x1da)](){return this['\x5f\x73\x74\x61\x74\x75\x73'];}[a0_0x4409d1(0x2ab)](){const _0x28858f=a0_0x4409d1;return this[_0x28858f(0x2a6)]['\x69\x74\x65\x72\x61\x74\x6f\x72']();}[a0_0x4409d1(0x1a5)](){const _0x56f789=a0_0x4409d1;if(this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65'])return this[_0x56f789(0x328)];return this[_0x56f789(0x328)]=this[_0x56f789(0x249)](),this[_0x56f789(0x328)];}async[a0_0x4409d1(0x319)](_0x242d6d){const _0x28453b=a0_0x4409d1,_0x44cb74={'\x55\x70\x55\x62\x66':_0x28453b(0x27b)};if(isTerminal(this[_0x28453b(0x27f)]))return;this[_0x28453b(0x24a)]=!![];if(this[_0x28453b(0x359)]['\x63\x61\x6e\x63\x65\x6c'])try{await this[_0x28453b(0x359)][_0x28453b(0x319)](this[_0x28453b(0x2bf)],this['\x69\x64']);}catch{}this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x44cb74[_0x28453b(0x224)]),this[_0x28453b(0x2a6)][_0x28453b(0x195)]({'\x74\x79\x70\x65':_0x44cb74[_0x28453b(0x224)],'\x72\x65\x61\x73\x6f\x6e':_0x242d6d}),this[_0x28453b(0x2a6)][_0x28453b(0x330)]();}async[a0_0x4409d1(0x208)](_0x51542c){const _0x3a3b2c=a0_0x4409d1,_0x4cd1c7={'\x67\x54\x68\x70\x57':_0x3a3b2c(0x260)};if(!this[_0x3a3b2c(0x359)]['\x73\x74\x65\x65\x72'])throw new Error(_0x3a3b2c(0x26c));if(isTerminal(this[_0x3a3b2c(0x27f)]))throw new Error(_0x3a3b2c(0x30d)+this[_0x3a3b2c(0x27f)]+_0x3a3b2c(0x26e));await this[_0x3a3b2c(0x359)]['\x73\x74\x65\x65\x72'](this[_0x3a3b2c(0x2bf)],this['\x69\x64'],_0x51542c);if(this['\x5f\x73\x74\x61\x74\x75\x73']===_0x4cd1c7['\x67\x54\x68\x70\x57'])this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x3a3b2c(0x2e3));this[_0x3a3b2c(0x328)]=this[_0x3a3b2c(0x249)](),await this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65'];}async[a0_0x4409d1(0x357)](_0x299637){const _0x5472f0=a0_0x4409d1,_0x19d8f7={'\x67\x73\x7a\x63\x59':_0x5472f0(0x1b8)};if(this[_0x5472f0(0x27f)]!==_0x5472f0(0x260))throw new Error(_0x5472f0(0x27a)+this[_0x5472f0(0x27f)]);if(!this[_0x5472f0(0x359)]['\x73\x75\x62\x6d\x69\x74\x54\x6f\x6f\x6c\x4f\x75\x74\x70\x75\x74\x73'])throw new Error(_0x19d8f7[_0x5472f0(0x2c7)]);for(const _0x263718 of _0x299637)this['\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x73']['\x64\x65\x6c\x65\x74\x65'](_0x263718['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x49\x64']);await this[_0x5472f0(0x359)][_0x5472f0(0x357)](this[_0x5472f0(0x2bf)],this['\x69\x64'],_0x299637),this[_0x5472f0(0x1e1)]('\x69\x6e\x5f\x70\x72\x6f\x67\x72\x65\x73\x73'),this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65']=this[_0x5472f0(0x249)](),await this['\x73\x74\x61\x72\x74\x50\x72\x6f\x6d\x69\x73\x65'];}[a0_0x4409d1(0x323)](){const _0xcacf9a=a0_0x4409d1,_0x2e387f={'\x63\x4a\x6b\x74\x6f':_0xcacf9a(0x1dc)};if(isTerminal(this[_0xcacf9a(0x27f)]))return;this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0xcacf9a(0x345)),this[_0xcacf9a(0x2a6)][_0xcacf9a(0x195)]({'\x74\x79\x70\x65':_0x2e387f[_0xcacf9a(0x2d5)],'\x72\x65\x61\x73\x6f\x6e':_0xcacf9a(0x345)}),this['\x71\x75\x65\x75\x65'][_0xcacf9a(0x330)]();}['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0xc32cab){const _0xbc4ba5=a0_0x4409d1,_0x3adebe={'\x6f\x75\x54\x74\x72':function(_0x37cfe3,_0x3edb3e){return _0x37cfe3===_0x3edb3e;}};if(_0x3adebe[_0xbc4ba5(0x2e2)](this['\x5f\x73\x74\x61\x74\x75\x73'],_0xc32cab))return;const _0x202c3d=this[_0xbc4ba5(0x27f)];this[_0xbc4ba5(0x27f)]=_0xc32cab,this['\x71\x75\x65\x75\x65'][_0xbc4ba5(0x195)]({'\x74\x79\x70\x65':_0xbc4ba5(0x1da),'\x73\x74\x61\x74\x75\x73':_0xc32cab,'\x70\x72\x65\x76\x69\x6f\x75\x73':_0x202c3d}),this['\x6f\x6e\x53\x74\x61\x74\x75\x73\x43\x68\x61\x6e\x67\x65']?.(_0xc32cab,_0x202c3d);}async[a0_0x4409d1(0x249)](){const _0x27a0a2=a0_0x4409d1,_0x70f40a={'\x70\x4f\x63\x6b\x67':function(_0x205ec4,_0x41a228,_0x59baa7,_0x56fe0f){return _0x205ec4(_0x41a228,_0x59baa7,_0x56fe0f);},'\x76\x55\x4b\x49\x71':function(_0x147bbc,_0x28e3d6){return _0x147bbc===_0x28e3d6;},'\x5a\x41\x4d\x74\x70':_0x27a0a2(0x264),'\x52\x42\x58\x73\x64':_0x27a0a2(0x2f8),'\x6e\x68\x43\x4a\x78':function(_0x597e8d,_0x2f06ed){return _0x597e8d(_0x2f06ed);},'\x6c\x56\x54\x4a\x69':_0x27a0a2(0x281),'\x7a\x41\x48\x46\x64':_0x27a0a2(0x227),'\x73\x55\x68\x75\x41':function(_0x279487,_0x436d8d){return _0x279487(_0x436d8d);},'\x72\x6e\x75\x51\x57':function(_0x5cc1fa,_0x4c7a46){return _0x5cc1fa(_0x4c7a46);},'\x67\x4f\x7a\x72\x52':function(_0x525960,_0x1cba76){return _0x525960(_0x1cba76);}};try{for await(const _0x402a0b of _0x70f40a[_0x27a0a2(0x296)](runEvents,this['\x74\x68\x72\x65\x61\x64\x49\x64'],this['\x69\x64'],this['\x73\x6f\x75\x72\x63\x65'])){if(this['\x63\x61\x6e\x63\x65\x6c\x52\x65\x71\x75\x65\x73\x74\x65\x64'])return;if(_0x70f40a[_0x27a0a2(0x2d0)](this[_0x27a0a2(0x27f)],_0x70f40a['\x5a\x41\x4d\x74\x70']))this[_0x27a0a2(0x1e1)]('\x69\x6e\x5f\x70\x72\x6f\x67\x72\x65\x73\x73');this[_0x27a0a2(0x2a6)][_0x27a0a2(0x195)]({'\x74\x79\x70\x65':_0x70f40a[_0x27a0a2(0x356)],'\x65\x76\x65\x6e\x74':_0x402a0b});const _0x240a67=_0x70f40a[_0x27a0a2(0x2c0)](readToolCallFromFrame,_0x402a0b);if(_0x240a67){const _0x12e1cb=await this['\x68\x61\x6e\x64\x6c\x65\x54\x6f\x6f\x6c\x43\x61\x6c\x6c'](_0x240a67);if(_0x70f40a[_0x27a0a2(0x2d0)](_0x12e1cb,_0x70f40a[_0x27a0a2(0x210)]))return;if(_0x12e1cb===_0x27a0a2(0x260))return;continue;}const _0x2d53df=readTerminal(_0x402a0b);if(_0x2d53df){_0x70f40a[_0x27a0a2(0x2d0)](_0x2d53df[_0x27a0a2(0x1da)],_0x70f40a['\x7a\x41\x48\x46\x64'])?(this[_0x27a0a2(0x1e1)]('\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'),this[_0x27a0a2(0x2a6)][_0x27a0a2(0x195)]({'\x74\x79\x70\x65':'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'})):(this[_0x27a0a2(0x1e1)]('\x66\x61\x69\x6c\x65\x64'),this[_0x27a0a2(0x2a6)][_0x27a0a2(0x195)]({'\x74\x79\x70\x65':_0x27a0a2(0x1dc),'\x72\x65\x61\x73\x6f\x6e':_0x2d53df[_0x27a0a2(0x203)]??'\x75\x6e\x6b\x6e\x6f\x77\x6e\x20\x66\x61\x69\x6c\x75\x72\x65'}));this[_0x27a0a2(0x2a6)][_0x27a0a2(0x330)]();return;}}!_0x70f40a[_0x27a0a2(0x309)](isTerminal,this['\x5f\x73\x74\x61\x74\x75\x73'])&&(this[_0x27a0a2(0x1e1)]('\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'),this['\x71\x75\x65\x75\x65'][_0x27a0a2(0x195)]({'\x74\x79\x70\x65':_0x70f40a['\x7a\x41\x48\x46\x64']}),this[_0x27a0a2(0x2a6)][_0x27a0a2(0x330)]());}catch(_0x527821){if(_0x70f40a['\x72\x6e\x75\x51\x57'](isTerminal,this[_0x27a0a2(0x27f)]))return;const _0x36a15f=_0x527821 instanceof Error?_0x527821[_0x27a0a2(0x30a)]:_0x70f40a[_0x27a0a2(0x20c)](String,_0x527821);this[_0x27a0a2(0x1e1)](_0x27a0a2(0x1dc)),this['\x71\x75\x65\x75\x65'][_0x27a0a2(0x195)]({'\x74\x79\x70\x65':_0x27a0a2(0x1dc),'\x72\x65\x61\x73\x6f\x6e':_0x36a15f}),this['\x71\x75\x65\x75\x65'][_0x27a0a2(0x330)]();}}async[a0_0x4409d1(0x231)](_0x3ed82d){const _0x342785=a0_0x4409d1,_0x48359f={'\x4a\x64\x56\x6f\x67':function(_0x128f52,_0x2438f5){return _0x128f52===_0x2438f5;},'\x57\x7a\x53\x50\x48':_0x342785(0x260),'\x74\x77\x4b\x6c\x4b':_0x342785(0x1cc),'\x61\x7a\x66\x77\x55':_0x342785(0x1d2),'\x6b\x41\x68\x4a\x45':function(_0x3f34d0,_0x36cbda){return _0x3f34d0 instanceof _0x36cbda;},'\x41\x64\x5a\x67\x52':function(_0x475753,_0x59f1b2){return _0x475753(_0x59f1b2);},'\x49\x4f\x6d\x59\x79':_0x342785(0x281),'\x75\x66\x54\x77\x43':'\x74\x6f\x6f\x6c\x5f\x72\x65\x73\x75\x6c\x74','\x65\x69\x6d\x52\x65':_0x342785(0x1dc),'\x4f\x47\x68\x46\x4d':_0x342785(0x1a4)},_0x401b6d={'\x72\x75\x6e\x49\x64':this['\x69\x64'],'\x74\x68\x72\x65\x61\x64\x49\x64':this['\x74\x68\x72\x65\x61\x64\x49\x64'],'\x70\x61\x72\x74\x6e\x65\x72\x49\x64':this[_0x342785(0x1ef)],'\x74\x6f\x6f\x6c\x4e\x61\x6d\x65':_0x3ed82d[_0x342785(0x1c1)],'\x61\x72\x67\x73':_0x3ed82d['\x61\x72\x67\x73'],'\x63\x61\x6c\x6c\x49\x64':_0x3ed82d[_0x342785(0x254)],'\x74\x69\x6d\x65\x73\x74\x61\x6d\x70':Date[_0x342785(0x250)]()};let _0x54b06a=_0x401b6d;if(this[_0x342785(0x313)]&&this[_0x342785(0x313)]['\x73\x69\x7a\x65']>0x0){const _0x458c7b=await this[_0x342785(0x313)][_0x342785(0x217)](_0x401b6d);if(_0x48359f['\x4a\x64\x56\x6f\x67'](_0x458c7b[_0x342785(0x1a1)],_0x342785(0x228))){const _0x2e753b={'\x63\x6f\x6e\x74\x65\x6e\x74':{'\x65\x72\x72\x6f\x72':_0x458c7b[_0x342785(0x203)]},'\x69\x73\x45\x72\x72\x6f\x72':!![],'\x64\x65\x74\x61\x69\x6c\x73':{'\x62\x6c\x6f\x63\x6b\x65\x64\x42\x79':_0x342785(0x360)}};this['\x71\x75\x65\x75\x65'][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x342785(0x1fd),'\x63\x74\x78':_0x401b6d,'\x72\x65\x61\x73\x6f\x6e':_0x458c7b['\x72\x65\x61\x73\x6f\x6e']}),this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x342785(0x2f7),'\x63\x74\x78':_0x401b6d,'\x72\x65\x73\x75\x6c\x74':_0x2e753b});if(_0x3ed82d[_0x342785(0x18d)])return this['\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x73'][_0x342785(0x2b1)](_0x3ed82d[_0x342785(0x254)],_0x401b6d),this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x48359f[_0x342785(0x2fc)]),this[_0x342785(0x2a6)]['\x70\x75\x73\x68']({'\x74\x79\x70\x65':_0x342785(0x260),'\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x49\x64\x73':Array[_0x342785(0x1d1)](this[_0x342785(0x1df)][_0x342785(0x2ad)]())}),_0x48359f[_0x342785(0x2fc)];return'\x63\x6f\x6e\x74\x69\x6e\x75\x65';}if(_0x48359f[_0x342785(0x23a)](_0x458c7b[_0x342785(0x1a1)],_0x48359f['\x74\x77\x4b\x6c\x4b']))_0x54b06a={..._0x401b6d,'\x61\x72\x67\x73':_0x458c7b[_0x342785(0x1d0)]};}if(_0x3ed82d[_0x342785(0x18d)]){const _0x6b98d='\x34\x7c\x32\x7c\x31\x7c\x30\x7c\x33'[_0x342785(0x19b)]('\x7c');let _0x30ae47=0x0;while(!![]){switch(_0x6b98d[_0x30ae47++]){case'\x30':this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':'\x72\x65\x71\x75\x69\x72\x65\x73\x5f\x61\x63\x74\x69\x6f\x6e','\x70\x65\x6e\x64\x69\x6e\x67\x43\x61\x6c\x6c\x49\x64\x73':Array[_0x342785(0x1d1)](this[_0x342785(0x1df)]['\x6b\x65\x79\x73']())});continue;case'\x31':this['\x71\x75\x65\x75\x65'][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x48359f[_0x342785(0x265)],'\x63\x74\x78':_0x54b06a});continue;case'\x32':this[_0x342785(0x1e1)](_0x48359f[_0x342785(0x2fc)]);continue;case'\x33':return _0x342785(0x260);case'\x34':this[_0x342785(0x1df)][_0x342785(0x2b1)](_0x3ed82d[_0x342785(0x254)],_0x54b06a);continue;}break;}}if(!this[_0x342785(0x233)])return this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x342785(0x1d2),'\x63\x74\x78':_0x54b06a}),_0x342785(0x1a4);this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x342785(0x1d2),'\x63\x74\x78':_0x54b06a});let _0x309183;try{_0x309183=await this[_0x342785(0x233)](_0x54b06a);}catch(_0x5787f5){_0x309183={'\x63\x6f\x6e\x74\x65\x6e\x74':{'\x65\x72\x72\x6f\x72':_0x48359f[_0x342785(0x2ef)](_0x5787f5,Error)?_0x5787f5['\x6d\x65\x73\x73\x61\x67\x65']:_0x48359f['\x41\x64\x5a\x67\x52'](String,_0x5787f5)},'\x69\x73\x45\x72\x72\x6f\x72':!![]};}let _0x465978=_0x309183;if(this[_0x342785(0x313)]&&this['\x68\x6f\x6f\x6b\x73']['\x73\x69\x7a\x65']>0x0){const _0x1de025=await this['\x68\x6f\x6f\x6b\x73'][_0x342785(0x32d)](_0x54b06a,_0x309183);if(_0x1de025[_0x342785(0x1a1)]===_0x48359f['\x49\x4f\x6d\x59\x79'])return this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x48359f[_0x342785(0x2fb)],'\x63\x74\x78':_0x54b06a,'\x72\x65\x73\x75\x6c\x74':_0x309183}),this['\x74\x72\x61\x6e\x73\x69\x74\x69\x6f\x6e'](_0x48359f['\x65\x69\x6d\x52\x65']),this[_0x342785(0x2a6)]['\x70\x75\x73\x68']({'\x74\x79\x70\x65':_0x342785(0x1dc),'\x72\x65\x61\x73\x6f\x6e':_0x1de025[_0x342785(0x203)]}),this[_0x342785(0x2a6)]['\x63\x6c\x6f\x73\x65'](),'\x74\x65\x72\x6d\x69\x6e\x61\x74\x65';if(_0x1de025[_0x342785(0x1a1)]===_0x342785(0x220))_0x465978=_0x1de025['\x72\x65\x73\x75\x6c\x74'];}return this[_0x342785(0x2a6)][_0x342785(0x195)]({'\x74\x79\x70\x65':_0x48359f['\x75\x66\x54\x77\x43'],'\x63\x74\x78':_0x54b06a,'\x72\x65\x73\x75\x6c\x74':_0x465978}),_0x48359f[_0x342785(0x20f)];}};function outcomeToFinishReason(_0x12a1b5,_0x3e7fa6){const _0x2eb065=a0_0x4409d1,_0xbc0b1b={'\x67\x59\x41\x4d\x4a':_0x2eb065(0x34c),'\x55\x4c\x69\x4a\x59':_0x2eb065(0x247),'\x72\x55\x4b\x78\x65':_0x2eb065(0x304),'\x7a\x51\x65\x62\x53':_0x2eb065(0x26f)};switch(_0x12a1b5){case _0xbc0b1b[_0x2eb065(0x1b2)]:case _0x2eb065(0x1e5):case _0x2eb065(0x227):case _0xbc0b1b[_0x2eb065(0x338)]:return _0x3e7fa6?_0x2eb065(0x320):_0xbc0b1b['\x72\x55\x4b\x78\x65'];case'\x6c\x65\x6e\x67\x74\x68\x5f\x65\x78\x63\x65\x65\x64\x65\x64':case'\x6c\x65\x6e\x67\x74\x68':case _0x2eb065(0x31c):return _0x2eb065(0x28a);case _0xbc0b1b[_0x2eb065(0x232)]:case'\x63\x6f\x6e\x74\x65\x6e\x74\x5f\x66\x69\x6c\x74\x65\x72':case _0x2eb065(0x339):return'\x63\x6f\x6e\x74\x65\x6e\x74\x5f\x66\x69\x6c\x74\x65\x72';default:return _0xbc0b1b[_0x2eb065(0x288)];}}function readTokenDelta(_0x4ae98b){const _0x4c7871=a0_0x4409d1,_0x4b6cd9={'\x4d\x41\x49\x6b\x4c':function(_0x4622ca,_0x490556){return _0x4622ca===_0x490556;},'\x4e\x53\x67\x54\x70':function(_0x4ca176,_0xa74428){return _0x4ca176===_0xa74428;}};if(_0x4b6cd9['\x4d\x41\x49\x6b\x4c'](typeof _0x4ae98b['\x64\x65\x6c\x74\x61'],_0x4c7871(0x33c)))return _0x4ae98b[_0x4c7871(0x29d)];if(typeof _0x4ae98b[_0x4c7871(0x244)]===_0x4c7871(0x33c))return _0x4ae98b[_0x4c7871(0x244)];if(_0x4b6cd9['\x4e\x53\x67\x54\x70'](typeof _0x4ae98b[_0x4c7871(0x317)],_0x4c7871(0x33c)))return _0x4ae98b[_0x4c7871(0x317)];return null;}function readToolInvocation(_0x4b3221){const _0x14dcc4=a0_0x4409d1,_0x4d0723={'\x71\x53\x67\x79\x6c':function(_0x5eb2fd,_0x181dd9){return _0x5eb2fd===_0x181dd9;},'\x5a\x73\x64\x53\x49':_0x14dcc4(0x33c),'\x6b\x4c\x50\x5a\x64':_0x14dcc4(0x2e4),'\x6f\x4f\x63\x49\x64':function(_0x124f20,_0x30e642){return _0x124f20===_0x30e642;},'\x61\x42\x53\x6c\x62':_0x14dcc4(0x2cb),'\x78\x73\x44\x7a\x63':function(_0x173da4,_0x54e507){return _0x173da4===_0x54e507;},'\x78\x66\x4e\x43\x51':function(_0x3a2823,_0x3b3310){return _0x3a2823||_0x3b3310;},'\x75\x72\x77\x64\x4c':function(_0x25401a,_0x472f1c){return _0x25401a===_0x472f1c;}};if(_0x4b3221[_0x14dcc4(0x350)]!=='\x72\x61\x77')return null;const _0x4e440b=_0x4b3221['\x64\x61\x74\x61']??_0x4b3221,_0x4c3f68=typeof _0x4e440b[_0x14dcc4(0x350)]===_0x14dcc4(0x33c)?_0x4e440b[_0x14dcc4(0x350)]:_0x4d0723[_0x14dcc4(0x1b3)](typeof _0x4b3221[_0x14dcc4(0x350)],_0x4d0723[_0x14dcc4(0x276)])?_0x4b3221['\x74\x79\x70\x65']:'';if(!(_0x4c3f68===_0x4d0723['\x6b\x4c\x50\x5a\x64']||_0x4c3f68==='\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c'||_0x4d0723[_0x14dcc4(0x342)](typeof _0x4e440b[_0x14dcc4(0x196)],_0x14dcc4(0x2cb))||typeof _0x4e440b[_0x14dcc4(0x25c)]===_0x4d0723[_0x14dcc4(0x1cd)]))return null;const _0x394fe4=_0x4e440b[_0x14dcc4(0x196)]??_0x4e440b[_0x14dcc4(0x25c)]??_0x4e440b,_0x4cbd17=typeof _0x394fe4[_0x14dcc4(0x1c2)]===_0x14dcc4(0x33c)?_0x394fe4[_0x14dcc4(0x1c2)]:typeof _0x394fe4[_0x14dcc4(0x1e8)]===_0x4d0723[_0x14dcc4(0x276)]?_0x394fe4[_0x14dcc4(0x1e8)]:_0x4d0723[_0x14dcc4(0x294)](typeof _0x394fe4['\x69\x64'],_0x14dcc4(0x33c))?_0x394fe4['\x69\x64']:typeof _0x394fe4[_0x14dcc4(0x254)]===_0x4d0723[_0x14dcc4(0x276)]?_0x394fe4[_0x14dcc4(0x254)]:'',_0x2e66ba=typeof _0x394fe4['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65']===_0x14dcc4(0x33c)?_0x394fe4[_0x14dcc4(0x1c1)]:_0x4d0723[_0x14dcc4(0x294)](typeof _0x394fe4[_0x14dcc4(0x223)],'\x73\x74\x72\x69\x6e\x67')?_0x394fe4[_0x14dcc4(0x223)]:typeof _0x394fe4[_0x14dcc4(0x1d6)]===_0x14dcc4(0x33c)?_0x394fe4[_0x14dcc4(0x1d6)]:'',_0x5bcdde=_0x394fe4[_0x14dcc4(0x1d0)]??_0x394fe4[_0x14dcc4(0x19d)]??_0x394fe4[_0x14dcc4(0x30c)]??{};if(_0x4d0723[_0x14dcc4(0x2e0)](!_0x4cbd17,!_0x2e66ba))return null;return{'\x69\x64':_0x4cbd17,'\x6e\x61\x6d\x65':_0x2e66ba,'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x4d0723[_0x14dcc4(0x353)](typeof _0x5bcdde,_0x14dcc4(0x33c))?_0x5bcdde:JSON[_0x14dcc4(0x332)](_0x5bcdde)};}function readUsage(_0x4b2df2){const _0x1792d5=a0_0x4409d1,_0x3d9fe9={'\x6d\x42\x72\x74\x4f':function(_0x4b2ffd,_0x23d814){return _0x4b2ffd(_0x23d814);},'\x5a\x77\x6c\x48\x72':function(_0x24f73f,_0x1d9a6e){return _0x24f73f(_0x1d9a6e);},'\x63\x49\x71\x72\x78':function(_0x24e688,_0x1b1c30){return _0x24e688===_0x1b1c30;},'\x4a\x67\x55\x58\x76':function(_0x39c0ae,_0x5f0da3){return _0x39c0ae+_0x5f0da3;}},_0x2e7c30=_0x4b2df2[_0x1792d5(0x269)]??_0x4b2df2,_0x11ff48=_0x3d9fe9[_0x1792d5(0x2ee)](Number,_0x2e7c30['\x70\x72\x6f\x6d\x70\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x2e7c30['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x2e7c30[_0x1792d5(0x218)]??0x0),_0x5ddbc0=_0x3d9fe9[_0x1792d5(0x1d7)](Number,_0x2e7c30[_0x1792d5(0x206)]??_0x2e7c30['\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x2e7c30['\x6f\x75\x74\x70\x75\x74\x54\x6f\x6b\x65\x6e\x73']??0x0);if(_0x3d9fe9[_0x1792d5(0x306)](_0x11ff48,0x0)&&_0x5ddbc0===0x0)return null;return{'\x70\x72\x6f\x6d\x70\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x11ff48,'\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e\x5f\x74\x6f\x6b\x65\x6e\x73':_0x5ddbc0,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':Number(_0x2e7c30[_0x1792d5(0x1d8)]??_0x3d9fe9[_0x1792d5(0x344)](_0x11ff48,_0x5ddbc0))};}function readOutcome(_0x2bb9c9){const _0x3701ed=a0_0x4409d1,_0x2b2ad9={'\x52\x50\x4b\x61\x76':function(_0x3fa8ca,_0x3527f6){return _0x3fa8ca===_0x3527f6;},'\x55\x50\x4c\x65\x51':function(_0x17e40d,_0x2a2ef6){return _0x17e40d===_0x2a2ef6;},'\x59\x6f\x69\x64\x6f':'\x66\x61\x69\x6c\x75\x72\x65','\x74\x5a\x66\x47\x51':_0x3701ed(0x34c)};if(_0x2b2ad9[_0x3701ed(0x355)](typeof _0x2bb9c9[_0x3701ed(0x1e0)],_0x3701ed(0x33c)))return _0x2bb9c9[_0x3701ed(0x1e0)];if(typeof _0x2bb9c9['\x73\x74\x61\x74\x75\x73']===_0x3701ed(0x33c))return _0x2bb9c9[_0x3701ed(0x1da)];if(_0x2b2ad9[_0x3701ed(0x28d)](_0x2bb9c9[_0x3701ed(0x34c)],![]))return _0x2b2ad9[_0x3701ed(0x287)];return _0x2b2ad9['\x74\x5a\x66\x47\x51'];}function chatBaseChunk(_0x396ad4){const _0x3ee90c=a0_0x4409d1;return _0x396ad4[_0x3ee90c(0x214)]+=0x1,{'\x69\x64':_0x396ad4['\x72\x75\x6e\x49\x64'],'\x63\x72\x65\x61\x74\x65\x64':_0x396ad4[_0x3ee90c(0x290)],'\x6d\x6f\x64\x65\x6c':_0x396ad4[_0x3ee90c(0x21d)],'\x6f\x62\x6a\x65\x63\x74':_0x3ee90c(0x307)};}function sandboxEventToChatChunk(_0x366b39,_0xde4487){const _0x3c2631=a0_0x4409d1,_0x24af61={'\x49\x61\x4c\x67\x77':_0x3c2631(0x1f1),'\x6a\x53\x54\x79\x79':_0x3c2631(0x1da),'\x59\x42\x72\x72\x69':function(_0xf88abe,_0x1351b6){return _0xf88abe(_0x1351b6);},'\x72\x4e\x57\x62\x50':function(_0x4948fa,_0x4ee9f7){return _0x4948fa(_0x4ee9f7);},'\x58\x6b\x50\x79\x45':function(_0x15ef42,_0x5a8288){return _0x15ef42(_0x5a8288);},'\x4c\x46\x66\x73\x64':_0x3c2631(0x247),'\x6a\x67\x68\x74\x4e':function(_0x3895ff,_0x12642f){return _0x3895ff(_0x12642f);},'\x79\x68\x68\x68\x43':function(_0x5984f8,_0x3eee4a){return _0x5984f8(_0x3eee4a);}};switch(_0x366b39['\x74\x79\x70\x65']){case _0x3c2631(0x1a5):return null;case _0x24af61['\x49\x61\x4c\x67\x77']:return null;case _0x24af61['\x6a\x53\x54\x79\x79']:return null;case _0x3c2631(0x295):return null;case _0x3c2631(0x266):return null;case'\x74\x6f\x6b\x65\x6e':{const _0x4a7f8e=_0x24af61[_0x3c2631(0x24b)](readTokenDelta,_0x366b39);if(_0x4a7f8e==null||_0x4a7f8e[_0x3c2631(0x28a)]===0x0)return null;return{..._0x24af61[_0x3c2631(0x35d)](chatBaseChunk,_0xde4487),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{'\x72\x6f\x6c\x65':_0x3c2631(0x2aa),'\x63\x6f\x6e\x74\x65\x6e\x74':_0x4a7f8e},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null}]};}case _0x3c2631(0x365):{const _0x457c3a=readToolInvocation(_0x366b39);if(!_0x457c3a)return null;const _0x5ecfeb=_0xde4487['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x3c2631(0x25b)](_0x457c3a['\x69\x64']),_0x7cb779=_0x5ecfeb?_0x5ecfeb[_0x3c2631(0x298)]:_0xde4487['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x3c2631(0x347)];return _0xde4487[_0x3c2631(0x2d8)]['\x73\x65\x74'](_0x457c3a['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0x7cb779,'\x69\x64':_0x457c3a['\x69\x64'],'\x6e\x61\x6d\x65':_0x457c3a['\x6e\x61\x6d\x65'],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x457c3a['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']}),{...chatBaseChunk(_0xde4487),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':{'\x72\x6f\x6c\x65':_0x3c2631(0x2aa),'\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73':[{'\x69\x6e\x64\x65\x78':_0x7cb779,'\x69\x64':_0x457c3a['\x69\x64'],'\x74\x79\x70\x65':_0x3c2631(0x207),'\x66\x75\x6e\x63\x74\x69\x6f\x6e':{'\x6e\x61\x6d\x65':_0x457c3a[_0x3c2631(0x1d6)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x457c3a[_0x3c2631(0x19d)]}}]},'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null}]};}case'\x65\x72\x72\x6f\x72':{const _0x236ff9=_0xde4487[_0x3c2631(0x2d8)]['\x73\x69\x7a\x65']>0x0;return{..._0x24af61[_0x3c2631(0x1e7)](chatBaseChunk,_0xde4487),'\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(_0x3c2631(0x29e),_0x236ff9)}]};}case _0x24af61[_0x3c2631(0x334)]:{const _0x105b87=_0xde4487['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x3c2631(0x347)]>0x0,_0x332738=outcomeToFinishReason(readOutcome(_0x366b39),_0x105b87),_0x97d73=_0x24af61[_0x3c2631(0x29c)](readUsage,_0x366b39),_0x5cd463={..._0x24af61['\x79\x68\x68\x68\x43'](chatBaseChunk,_0xde4487),'\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':_0x332738}]};if(_0x97d73)_0x5cd463[_0x3c2631(0x269)]=_0x97d73;return _0x5cd463;}default:return null;}}function completionBaseChunk(_0x22e1f0){const _0x3e4dc1=a0_0x4409d1;return _0x22e1f0[_0x3e4dc1(0x214)]+=0x1,{'\x69\x64':_0x22e1f0['\x72\x75\x6e\x49\x64'],'\x63\x72\x65\x61\x74\x65\x64':_0x22e1f0['\x63\x72\x65\x61\x74\x65\x64\x41\x74'],'\x6d\x6f\x64\x65\x6c':_0x22e1f0[_0x3e4dc1(0x21d)],'\x6f\x62\x6a\x65\x63\x74':'\x74\x65\x78\x74\x5f\x63\x6f\x6d\x70\x6c\x65\x74\x69\x6f\x6e'};}function sandboxEventToCompletionChunk(_0x2cb86b,_0x37b09c){const _0x3e11de=a0_0x4409d1,_0x4dd31b={'\x69\x53\x4b\x74\x77':_0x3e11de(0x1a5),'\x63\x4e\x63\x51\x75':_0x3e11de(0x295),'\x4c\x55\x4e\x57\x5a':_0x3e11de(0x365),'\x75\x61\x46\x78\x6e':_0x3e11de(0x317),'\x53\x6d\x4b\x4b\x69':function(_0x5e9dbb,_0x3c2813){return _0x5e9dbb==_0x3c2813;},'\x50\x47\x4e\x66\x74':_0x3e11de(0x29e),'\x4a\x4e\x65\x47\x4c':function(_0x5e7505,_0x1bd616){return _0x5e7505===_0x1bd616;},'\x6e\x70\x73\x64\x79':function(_0x3b991e,_0x15b0d7){return _0x3b991e===_0x15b0d7;},'\x4a\x72\x64\x6e\x4f':'\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73'};switch(_0x2cb86b[_0x3e11de(0x350)]){case _0x4dd31b[_0x3e11de(0x300)]:case _0x3e11de(0x1f1):case'\x73\x74\x61\x74\x75\x73':case _0x4dd31b[_0x3e11de(0x29a)]:case _0x3e11de(0x266):case _0x4dd31b[_0x3e11de(0x21f)]:if(_0x2cb86b[_0x3e11de(0x350)]===_0x4dd31b[_0x3e11de(0x21f)]){const _0x221a97=readToolInvocation(_0x2cb86b);if(_0x221a97){const _0x5a3d31=_0x37b09c[_0x3e11de(0x2d8)][_0x3e11de(0x25b)](_0x221a97['\x69\x64']),_0xbf2f0a=_0x5a3d31?_0x5a3d31['\x69\x6e\x64\x65\x78']:_0x37b09c['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72']['\x73\x69\x7a\x65'];_0x37b09c[_0x3e11de(0x2d8)]['\x73\x65\x74'](_0x221a97['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0xbf2f0a,'\x69\x64':_0x221a97['\x69\x64'],'\x6e\x61\x6d\x65':_0x221a97[_0x3e11de(0x1d6)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x221a97['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']});}}return null;case _0x4dd31b[_0x3e11de(0x337)]:{const _0x5d1e4a=readTokenDelta(_0x2cb86b);if(_0x4dd31b['\x53\x6d\x4b\x4b\x69'](_0x5d1e4a,null)||_0x5d1e4a[_0x3e11de(0x28a)]===0x0)return null;return{...completionBaseChunk(_0x37b09c),'\x63\x68\x6f\x69\x63\x65\x73':[{'\x69\x6e\x64\x65\x78':0x0,'\x74\x65\x78\x74':_0x5d1e4a,'\x66\x69\x6e\x69\x73\x68\x5f\x72\x65\x61\x73\x6f\x6e':null,'\x6c\x6f\x67\x70\x72\x6f\x62\x73':null}]};}case _0x4dd31b[_0x3e11de(0x27d)]:case'\x64\x6f\x6e\x65':{const _0x59ee5b=outcomeToFinishReason(_0x4dd31b[_0x3e11de(0x280)](_0x2cb86b['\x74\x79\x70\x65'],_0x3e11de(0x29e))?_0x3e11de(0x29e):readOutcome(_0x2cb86b),![]),_0x56aa39=_0x4dd31b[_0x3e11de(0x26d)](_0x59ee5b,_0x4dd31b[_0x3e11de(0x1bd)])?_0x3e11de(0x304):_0x59ee5b,_0xa345ca=readUsage(_0x2cb86b),_0x352399={...completionBaseChunk(_0x37b09c),'\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':_0x56aa39,'\x6c\x6f\x67\x70\x72\x6f\x62\x73':null}]};if(_0xa345ca)_0x352399[_0x3e11de(0x269)]=_0xa345ca;return _0x352399;}default:return null;}}function getResponsesExtras(_0x27f3cd){const _0x27806e=a0_0x4409d1,_0x312f88=_0x27f3cd;if(!_0x312f88[_0x27806e(0x24d)])_0x312f88['\x5f\x5f\x72\x65\x73\x70\x6f\x6e\x73\x65\x73\x45\x78\x74\x72\x61\x73']={'\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 _0x312f88[_0x27806e(0x24d)];}function nextSeq(_0x22c82d){const _0x391aa1=a0_0x4409d1;return _0x22c82d[_0x391aa1(0x28f)]+=0x1,_0x22c82d[_0x391aa1(0x28f)];}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(_0x1ee867){const _0x58889b=a0_0x4409d1;return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x1ee867[_0x58889b(0x2b9)],'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x1ee867[_0x58889b(0x206)],'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x1ee867[_0x58889b(0x1d8)],'\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(_0x2ea910,_0x3205a9){const _0x2e9910=a0_0x4409d1,_0x4ec86d={'\x53\x4d\x72\x59\x4d':_0x2e9910(0x1f1),'\x67\x45\x6a\x6f\x71':'\x73\x74\x61\x74\x75\x73','\x50\x6e\x71\x67\x6e':_0x2e9910(0x295),'\x51\x4b\x74\x58\x42':_0x2e9910(0x317),'\x70\x77\x63\x75\x47':function(_0x5d9d98,_0x3029db){return _0x5d9d98(_0x3029db);},'\x49\x71\x79\x79\x4f':function(_0x45f2f6,_0x473f65){return _0x45f2f6===_0x473f65;},'\x76\x4e\x78\x62\x41':_0x2e9910(0x29e),'\x52\x72\x52\x65\x6c':_0x2e9910(0x1a0),'\x76\x4e\x52\x54\x63':'\x69\x6e\x63\x6f\x6d\x70\x6c\x65\x74\x65','\x42\x6f\x59\x58\x66':function(_0x10175e,_0x418d09){return _0x10175e(_0x418d09);},'\x62\x69\x4c\x65\x64':_0x2e9910(0x2e1)},_0x5b2f62=getResponsesExtras(_0x3205a9);switch(_0x2ea910[_0x2e9910(0x350)]){case _0x2e9910(0x1a5):return null;case _0x4ec86d[_0x2e9910(0x303)]:return null;case _0x4ec86d[_0x2e9910(0x312)]:return null;case _0x4ec86d[_0x2e9910(0x242)]: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 _0x4ec86d['\x51\x4b\x74\x58\x42']:{const _0x482cfe=_0x4ec86d[_0x2e9910(0x2f5)](readTokenDelta,_0x2ea910);if(_0x482cfe==null||_0x482cfe[_0x2e9910(0x28a)]===0x0)return null;_0x3205a9[_0x2e9910(0x214)]+=0x1;if(_0x4ec86d[_0x2e9910(0x1a6)](_0x5b2f62[_0x2e9910(0x2de)],void 0x0))_0x5b2f62[_0x2e9910(0x2de)]=_0x3205a9[_0x2e9910(0x2d8)][_0x2e9910(0x347)];return{'\x74\x79\x70\x65':_0x2e9910(0x24e),'\x63\x6f\x6e\x74\x65\x6e\x74\x5f\x69\x6e\x64\x65\x78':0x0,'\x64\x65\x6c\x74\x61':_0x482cfe,'\x69\x74\x65\x6d\x5f\x69\x64':_0x2e9910(0x18f)+_0x3205a9[_0x2e9910(0x22e)],'\x6c\x6f\x67\x70\x72\x6f\x62\x73':[],'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x5b2f62[_0x2e9910(0x2de)],'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':_0x4ec86d[_0x2e9910(0x2f5)](nextSeq,_0x5b2f62)};}case _0x2e9910(0x365):{const _0xa56a29=readToolInvocation(_0x2ea910);if(!_0xa56a29)return null;_0x3205a9['\x63\x68\x75\x6e\x6b\x49\x6e\x64\x65\x78']+=0x1;const _0x21322e=_0x3205a9[_0x2e9910(0x2d8)][_0x2e9910(0x25b)](_0xa56a29['\x69\x64']),_0x558517=_0x21322e?_0x21322e[_0x2e9910(0x298)]:_0x3205a9['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72']['\x73\x69\x7a\x65'];_0x3205a9['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x42\x75\x66\x66\x65\x72'][_0x2e9910(0x2b1)](_0xa56a29['\x69\x64'],{'\x69\x6e\x64\x65\x78':_0x558517,'\x69\x64':_0xa56a29['\x69\x64'],'\x6e\x61\x6d\x65':_0xa56a29[_0x2e9910(0x1d6)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0xa56a29['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']});const _0x1fe555=_0x5b2f62[_0x2e9910(0x1ab)][_0x2e9910(0x25b)](_0xa56a29['\x69\x64'])??_0x5b2f62[_0x2e9910(0x1ab)][_0x2e9910(0x347)];return _0x5b2f62[_0x2e9910(0x1ab)][_0x2e9910(0x2b1)](_0xa56a29['\x69\x64'],_0x1fe555),{'\x74\x79\x70\x65':_0x2e9910(0x274),'\x69\x74\x65\x6d':{'\x74\x79\x70\x65':_0x2e9910(0x2c6),'\x69\x64':_0x2e9910(0x2bd)+_0xa56a29['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0xa56a29['\x69\x64'],'\x6e\x61\x6d\x65':_0xa56a29[_0x2e9910(0x1d6)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0xa56a29['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73'],'\x73\x74\x61\x74\x75\x73':_0x2e9910(0x227)},'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x1fe555,'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':nextSeq(_0x5b2f62)};}case _0x4ec86d[_0x2e9910(0x248)]:{const _0x385716=_0x5b2f62[_0x2e9910(0x2de)]??0x0;return{'\x74\x79\x70\x65':_0x4ec86d['\x52\x72\x52\x65\x6c'],'\x69\x74\x65\x6d':{'\x74\x79\x70\x65':_0x2e9910(0x30a),'\x69\x64':'\x6d\x73\x67\x5f'+_0x3205a9[_0x2e9910(0x22e)],'\x72\x6f\x6c\x65':_0x2e9910(0x2aa),'\x73\x74\x61\x74\x75\x73':_0x4ec86d[_0x2e9910(0x1ae)],'\x63\x6f\x6e\x74\x65\x6e\x74':[]},'\x6f\x75\x74\x70\x75\x74\x5f\x69\x6e\x64\x65\x78':_0x385716,'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':_0x4ec86d[_0x2e9910(0x1e9)](nextSeq,_0x5b2f62)};}case _0x2e9910(0x247):{const _0x380cc0=readUsage(_0x2ea910),_0x58ac12=_0x380cc0?_0x4ec86d['\x42\x6f\x59\x58\x66'](usageFromTokens,_0x380cc0):emptyResponseUsage();return{'\x74\x79\x70\x65':_0x2e9910(0x35c),'\x73\x65\x71\x75\x65\x6e\x63\x65\x5f\x6e\x75\x6d\x62\x65\x72':_0x4ec86d[_0x2e9910(0x2f5)](nextSeq,_0x5b2f62),'\x72\x65\x73\x70\x6f\x6e\x73\x65':{'\x69\x64':_0x3205a9[_0x2e9910(0x22e)],'\x6f\x62\x6a\x65\x63\x74':_0x4ec86d[_0x2e9910(0x35f)],'\x63\x72\x65\x61\x74\x65\x64\x5f\x61\x74':_0x3205a9['\x63\x72\x65\x61\x74\x65\x64\x41\x74'],'\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':_0x3205a9['\x6d\x6f\x64\x65\x6c\x49\x64'],'\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':_0x2e9910(0x305),'\x74\x6f\x6f\x6c\x73':[],'\x74\x6f\x70\x5f\x70':null,'\x73\x74\x61\x74\x75\x73':_0x2e9910(0x227),'\x75\x73\x61\x67\x65':_0x58ac12}};}default:return null;}}function a0_0x453e(){const _0x258a97=['\x69\x67\x4c\x5a\x69\x67\x35\x56\x44\x63\x62\x48\x69\x68\x6e\x30\x43\x4d\x4c\x55\x7a\x57','\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x76\x4b','\x79\x4d\x58\x56\x79\x32\x53','\x42\x33\x76\x30\x43\x68\x76\x30\x78\x33\x72\x4c\x45\x68\x71','\x42\x33\x50\x77\x71\x76\x65','\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','\x43\x33\x72\x48\x43\x4e\x72\x5a\x76\x32\x4c\x30\x41\x61','\x73\x4b\x72\x50\x43\x76\x69','\x43\x4e\x76\x55\x73\x77\x71','\x44\x67\x4c\x54\x7a\x78\x6e\x30\x79\x77\x31\x57','\x43\x67\x66\x59\x79\x77\x31\x4c\x44\x67\x76\x59\x43\x57','\x41\x67\x66\x55\x7a\x67\x58\x4c\x76\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x57','\x45\x4c\x66\x4c\x79\x4c\x6d','\x7a\x78\x48\x4c\x79\x33\x76\x30\x7a\x76\x72\x56\x42\x32\x57','\x41\x76\x62\x36\x7a\x78\x79','\x71\x75\x6e\x49\x73\x31\x61','\x42\x33\x76\x30\x43\x68\x76\x30','\x6e\x64\x65\x5a\x6e\x64\x4b\x5a\x6d\x67\x31\x6f\x44\x33\x66\x63\x43\x61','\x43\x68\x6a\x56\x44\x4d\x4c\x4b\x7a\x78\x69','\x44\x67\x48\x50\x42\x4d\x54\x50\x42\x4d\x43','\x73\x4d\x72\x77\x42\x32\x43','\x73\x4b\x58\x56\x79\x4d\x43','\x7a\x4d\x39\x33\x72\x32\x79','\x6d\x74\x43\x33\x6d\x74\x75\x58\x6f\x64\x62\x73\x76\x65\x6e\x35\x7a\x32\x30','\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','\x74\x75\x58\x53\x75\x78\x47','\x43\x67\x66\x5a\x43\x57','\x43\x31\x48\x48\x71\x4d\x30','\x75\x67\x35\x58\x7a\x32\x34','\x7a\x67\x76\x30\x79\x77\x4c\x53','\x44\x67\x76\x34\x44\x61','\x79\x31\x50\x6e\x76\x77\x4b','\x7a\x32\x76\x30\x75\x68\x6a\x50\x42\x33\x6a\x75\x44\x78\x6a\x55\x43\x57','\x7a\x67\x39\x55\x7a\x71','\x44\x4b\x35\x34\x79\x4b\x65','\x7a\x68\x6a\x50\x44\x4d\x76\x74\x44\x68\x6a\x4c\x79\x77\x30','\x79\x32\x66\x55\x79\x32\x76\x53\x75\x4d\x76\x58\x44\x77\x76\x5a\x44\x67\x76\x4b','\x77\x75\x6a\x59\x43\x4d\x4b','\x76\x75\x6e\x51\x76\x68\x69','\x78\x31\x39\x59\x7a\x78\x6e\x57\x42\x32\x35\x5a\x7a\x78\x6e\x66\x45\x68\x72\x59\x79\x78\x6d','\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','\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','\x42\x4d\x39\x33','\x41\x66\x48\x79\x77\x65\x47','\x45\x67\x39\x74\x75\x4e\x43','\x41\x68\x6a\x4c\x7a\x47','\x79\x32\x66\x53\x42\x65\x4c\x4b','\x44\x30\x4c\x51\x43\x32\x43','\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','\x72\x68\x4c\x69\x44\x31\x4f','\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\x76\x5a\x43\x32\x66\x4e\x7a\x78\x6d\x47\x42\x78\x76\x5a\x44\x63\x62\x4a\x42\x32\x35\x30\x79\x77\x4c\x55\x69\x67\x66\x30\x69\x67\x58\x4c\x79\x78\x6e\x30\x69\x67\x39\x55\x7a\x73\x62\x31\x43\x32\x76\x59\x69\x67\x31\x4c\x43\x33\x6e\x48\x7a\x32\x75','\x7a\x67\x4c\x54\x7a\x77\x35\x5a\x41\x77\x39\x55\x43\x57','\x7a\x77\x39\x6f\x77\x4d\x71','\x7a\x32\x76\x30','\x44\x67\x39\x56\x42\x66\x39\x50\x42\x4e\x7a\x56\x79\x32\x66\x30\x41\x77\x39\x55','\x76\x68\x50\x62\x79\x77\x75','\x43\x32\x48\x50\x7a\x4e\x71','\x44\x67\x4c\x30\x42\x67\x75','\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x78\x6e\x46\x79\x77\x6e\x30\x41\x77\x39\x55','\x75\x77\x72\x6d\x41\x75\x71','\x71\x75\x6a\x6e\x77\x76\x69','\x43\x67\x66\x59\x79\x77\x30','\x43\x78\x76\x4c\x44\x77\x76\x4b','\x79\x78\x50\x4d\x44\x31\x75','\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','\x42\x68\x72\x50\x7a\x32\x30','\x73\x77\x35\x57\x44\x78\x71\x47\x79\x78\x6a\x59\x79\x78\x4b\x47\x7a\x78\x48\x4a\x7a\x77\x76\x4b\x43\x59\x62\x54\x79\x78\x48\x50\x42\x78\x76\x54\x69\x67\x6a\x48\x44\x67\x6e\x4f\x69\x68\x6e\x50\x45\x4d\x75\x47\x42\x32\x79\x47','\x44\x78\x6e\x48\x7a\x32\x75','\x6e\x74\x75\x59\x6d\x5a\x6d\x57\x6d\x33\x44\x64\x75\x75\x58\x41\x43\x71','\x41\x33\x48\x5a\x75\x77\x53','\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\x67\x76\x4c\x43\x47','\x42\x4e\x62\x5a\x7a\x68\x4b','\x69\x68\x6a\x31\x42\x47','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x66\x39\x4d\x41\x77\x58\x30\x7a\x78\x6a\x4c\x7a\x61','\x79\x32\x66\x53\x42\x66\x39\x50\x7a\x61','\x42\x4d\x54\x70\x41\x78\x75','\x72\x33\x72\x48\x45\x66\x61','\x73\x77\x35\x32\x79\x77\x58\x50\x7a\x63\x62\x54\x42\x32\x72\x4c\x42\x63\x62\x50\x7a\x64\x4f\x47','\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\x79\x77\x72\x4b\x7a\x77\x71','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c','\x77\x4e\x6e\x4b\x75\x30\x4b','\x73\x77\x54\x70\x42\x68\x6d','\x7a\x77\x35\x4a\x42\x32\x72\x50\x42\x4d\x44\x46\x7a\x4d\x39\x59\x42\x77\x66\x30\x69\x67\x31\x31\x43\x33\x71\x47\x79\x4d\x75\x47\x6a\x32\x7a\x53\x42\x32\x66\x30\x6a\x59\x62\x56\x43\x49\x61\x4e\x79\x4d\x66\x5a\x7a\x74\x79\x30\x6a\x57','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x46\x44\x78\x6e\x4c','\x79\x32\x66\x55\x42\x4d\x39\x30\x69\x68\x6e\x31\x79\x4d\x31\x50\x44\x63\x62\x30\x42\x32\x39\x53\x69\x67\x39\x31\x44\x68\x62\x31\x44\x68\x6d\x47\x41\x77\x34\x47\x43\x33\x72\x48\x44\x68\x76\x5a\x69\x61','\x79\x32\x66\x55\x79\x32\x76\x53\x42\x67\x76\x4b','\x76\x4d\x35\x30\x43\x31\x6d','\x75\x65\x44\x6f\x7a\x4e\x71','\x74\x32\x58\x58\x44\x75\x79','\x78\x33\x6e\x30\x79\x78\x72\x31\x43\x57','\x73\x4b\x35\x4c\x72\x30\x57','\x44\x67\x76\x59\x42\x77\x4c\x55\x79\x78\x72\x4c','\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\x33\x72\x59\x7a\x77\x66\x54\x69\x67\x76\x59\x43\x4d\x39\x59','\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','\x73\x4c\x7a\x33\x7a\x30\x53','\x6d\x75\x48\x65\x75\x30\x76\x62\x43\x61','\x77\x77\x39\x50\x7a\x67\x38','\x43\x4c\x76\x6c\x45\x67\x75','\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\x67\x76\x55\x7a\x33\x72\x4f','\x41\x67\x39\x5a\x44\x61','\x74\x4d\x44\x74\x75\x65\x47','\x76\x76\x62\x6d\x7a\x76\x65','\x79\x32\x54\x49\x42\x4e\x4f','\x43\x32\x76\x58\x44\x77\x76\x55\x79\x32\x75','\x79\x33\x6a\x4c\x79\x78\x72\x4c\x7a\x65\x66\x30','\x43\x68\x6a\x50\x42\x33\x6a\x75\x44\x78\x6a\x55\x43\x57','\x72\x66\x50\x49\x7a\x32\x4b','\x79\x32\x66\x4a\x41\x67\x76\x4b\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x45\x68\x6e\x65\x45\x4d\x6d','\x43\x32\x76\x5a\x43\x32\x4c\x56\x42\x49\x35\x31\x43\x67\x72\x48\x44\x67\x76\x4b','\x43\x65\x39\x4a\x41\x32\x43','\x78\x73\x35\x30\x45\x78\x62\x4c','\x41\x77\x35\x4b\x7a\x78\x47','\x75\x31\x50\x58\x73\x4d\x38','\x79\x30\x35\x4a\x75\x78\x75','\x7a\x4d\x4c\x53\x7a\x76\x39\x5a\x7a\x77\x66\x59\x79\x32\x47','\x41\x4d\x44\x4f\x44\x65\x34','\x7a\x67\x76\x53\x44\x67\x65','\x7a\x78\x6a\x59\x42\x33\x69','\x76\x76\x48\x78\x44\x75\x38','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x5a','\x7a\x4e\x66\x64\x43\x32\x79','\x76\x4b\x6a\x77\x43\x75\x4b','\x6d\x74\x62\x31\x74\x31\x7a\x32\x42\x77\x79','\x73\x4b\x76\x79\x44\x4b\x30','\x74\x4d\x44\x32\x42\x67\x34','\x43\x78\x76\x4c\x44\x77\x75','\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','\x79\x4d\x76\x4d\x42\x33\x6a\x4c','\x42\x4e\x76\x54\x79\x4d\x76\x59','\x79\x78\x6e\x5a\x41\x78\x6e\x30\x79\x77\x35\x30','\x7a\x78\x7a\x4c\x42\x4e\x72\x5a','\x44\x68\x6a\x50\x42\x71','\x41\x32\x76\x35\x43\x57','\x42\x67\x66\x5a\x44\x66\x6a\x4c\x7a\x4d\x4c\x53\x42\x65\x31\x5a','\x69\x49\x62\x50\x43\x59\x62\x55\x42\x33\x71\x47\x43\x4d\x76\x4a\x42\x32\x44\x55\x41\x78\x50\x4c\x7a\x61','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x46\x79\x32\x66\x53\x42\x61','\x43\x32\x76\x30','\x7a\x77\x35\x54\x45\x75\x79','\x44\x77\x35\x31\x41\x76\x4b','\x41\x67\x66\x5a\x76\x78\x6e\x48\x7a\x32\x75','\x79\x78\x6e\x5a\x41\x78\x6e\x30\x79\x77\x35\x30\x76\x67\x76\x34\x44\x61','\x69\x67\x4c\x5a\x69\x61','\x6d\x74\x43\x57\x6d\x4a\x47\x58\x6e\x4d\x44\x50\x73\x4d\x39\x35\x76\x47','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x70\x43\x4d\x72\x4c\x43\x47','\x43\x68\x6a\x56\x42\x78\x62\x30\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x74\x78\x48\x31\x72\x4c\x6d','\x6e\x78\x57\x30\x46\x64\x7a\x38\x6d\x78\x57\x5a\x46\x64\x62\x38\x6d\x47','\x76\x4e\x6e\x7a\x43\x68\x4b','\x7a\x4d\x6e\x46','\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','\x44\x67\x48\x59\x7a\x77\x66\x4b\x73\x77\x71','\x42\x4d\x48\x64\x73\x4e\x47','\x42\x77\x39\x4b\x7a\x77\x58\x46\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x77\x71','\x79\x77\x58\x53\x42\x33\x43','\x7a\x75\x7a\x6e\x7a\x65\x4b','\x42\x4d\x76\x48\x43\x47','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x4d\x6e\x53\x41\x77\x6e\x52','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x35\x46\x79\x32\x66\x53\x42\x61','\x7a\x33\x6e\x36\x79\x31\x4b','\x75\x32\x35\x62\x72\x4b\x4b','\x6d\x74\x69\x30\x6d\x64\x69\x58\x6d\x77\x35\x52\x44\x67\x48\x5a\x71\x71','\x41\x77\x31\x48\x7a\x32\x76\x46\x44\x78\x6a\x53','\x42\x32\x6a\x51\x7a\x77\x6e\x30','\x7a\x77\x31\x57\x44\x68\x4c\x46\x41\x77\x35\x57\x44\x78\x71','\x42\x78\x76\x53\x44\x67\x4c\x54\x42\x32\x72\x48\x42\x61','\x79\x4b\x58\x49\x74\x32\x69','\x43\x4d\x76\x4e\x41\x77\x39\x55\x43\x57','\x44\x4c\x76\x6c\x73\x78\x65','\x72\x4b\x4c\x6b\x7a\x76\x43','\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','\x7a\x32\x76\x30\x71\x33\x76\x59\x43\x4d\x76\x55\x44\x65\x6e\x56\x43\x33\x71','\x75\x76\x4c\x58\x42\x4e\x4f','\x79\x30\x50\x52\x44\x67\x38','\x7a\x77\x6e\x65\x7a\x31\x47','\x74\x33\x6a\x64\x45\x68\x69','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x63\x44\x77\x7a\x4d\x7a\x78\x69','\x74\x67\x4c\x68\x74\x67\x65','\x75\x77\x31\x76\x75\x4c\x75','\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','\x41\x78\x6e\x64\x42\x32\x31\x57\x44\x78\x72\x4c\x43\x4c\x76\x5a\x7a\x71','\x7a\x65\x58\x54\x74\x66\x71','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x75\x39\x31\x44\x68\x62\x31\x44\x65\x4c\x55\x7a\x67\x76\x34','\x42\x33\x76\x30\x43\x68\x76\x30\x76\x67\x39\x52\x7a\x77\x35\x5a','\x45\x67\x7a\x6f\x71\x31\x65','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75','\x42\x33\x76\x75\x44\x68\x69','\x41\x77\x35\x46\x43\x68\x6a\x56\x7a\x33\x6a\x4c\x43\x33\x6d','\x44\x67\x39\x56\x42\x63\x31\x50\x42\x4e\x7a\x56\x79\x32\x66\x30\x41\x77\x39\x55','\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','\x7a\x66\x50\x77\x74\x66\x43','\x43\x33\x72\x59\x41\x77\x6e\x30','\x42\x31\x6e\x6f\x42\x76\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','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x50\x42\x4e\x62\x31\x44\x66\x39\x30\x45\x78\x62\x4c','\x7a\x75\x44\x76\x41\x68\x61','\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\x77\x66\x34\x75\x4d\x76\x5a\x44\x77\x58\x30\x43\x57','\x42\x75\x6a\x59\x44\x65\x38','\x41\x30\x66\x4f\x73\x4b\x75','\x77\x32\x66\x31\x7a\x67\x4c\x30\x78\x71','\x7a\x67\x76\x30\x79\x77\x4c\x53\x43\x57','\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','\x44\x67\x39\x74\x44\x68\x6a\x50\x42\x4d\x43','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x59\x7a\x78\x66\x31\x7a\x78\x6e\x30\x78\x32\x76\x59\x43\x4d\x39\x59','\x43\x68\x44\x4a\x44\x75\x43','\x44\x67\x39\x56\x42\x68\x6e\x42','\x44\x67\x39\x56\x42\x66\x39\x59\x7a\x78\x6e\x31\x42\x68\x71','\x43\x33\x72\x59\x7a\x77\x66\x54','\x79\x77\x58\x53\x42\x33\x44\x6d\x41\x78\x6e\x30','\x42\x78\x6e\x4e\x78\x5a\x61','\x44\x77\x7a\x75\x44\x30\x6d','\x76\x33\x50\x74\x75\x65\x47','\x76\x78\x72\x49\x44\x4b\x71','\x74\x33\x44\x73\x43\x30\x4f','\x44\x67\x39\x56\x42\x61','\x41\x76\x6e\x6c\x44\x68\x43','\x72\x68\x6e\x71\x72\x4d\x57','\x71\x33\x4c\x6d\x76\x30\x65','\x75\x30\x31\x59\x77\x75\x30','\x43\x33\x72\x56\x43\x61','\x79\x78\x76\x30\x42\x57','\x79\x30\x4c\x58\x43\x4e\x47','\x79\x32\x48\x48\x44\x63\x35\x4a\x42\x32\x31\x57\x42\x67\x76\x30\x41\x77\x39\x55\x6c\x4d\x6e\x4f\x44\x77\x35\x52','\x44\x4b\x54\x53\x76\x32\x79','\x43\x31\x76\x4f\x44\x75\x65','\x42\x77\x76\x5a\x43\x32\x66\x4e\x7a\x71','\x75\x4b\x54\x58\x42\x4e\x65','\x41\x77\x35\x57\x44\x78\x71','\x79\x32\x66\x55\x42\x4d\x39\x30\x69\x68\x6e\x30\x7a\x77\x76\x59\x69\x67\x65\x47','\x44\x67\x76\x5a\x44\x61','\x7a\x67\x76\x55\x45\x76\x62\x48\x44\x68\x72\x4c\x43\x4d\x35\x5a','\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','\x45\x67\x6a\x6c\x77\x78\x4b','\x7a\x30\x76\x51\x42\x33\x65','\x41\x67\x39\x56\x41\x33\x6d','\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','\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','\x42\x67\x66\x49\x7a\x77\x57','\x44\x67\x39\x52\x7a\x77\x34','\x73\x4d\x48\x65\x75\x4d\x47','\x79\x32\x66\x55\x79\x32\x76\x53','\x42\x33\x48\x6d\x74\x78\x65','\x69\x64\x34\x39\x69\x61','\x42\x77\x66\x34\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x76\x76\x50\x58\x75\x4d\x38','\x44\x78\x6e\x4c\x43\x4c\x39\x53\x42\x32\x6e\x48\x44\x67\x4c\x56\x42\x47','\x7a\x4d\x58\x48\x44\x65\x31\x48\x43\x61','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53\x43\x57','\x41\x4d\x39\x50\x42\x47','\x44\x67\x39\x56\x42\x66\x6a\x4c\x43\x33\x76\x53\x44\x68\x6d','\x7a\x78\x48\x57\x41\x78\x6a\x4c','\x41\x75\x50\x4e\x43\x67\x57','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x30\x42\x32\x54\x4c\x42\x4c\x39\x30\x45\x78\x62\x4c','\x7a\x67\x76\x53\x7a\x78\x72\x4c','\x6d\x74\x7a\x30\x73\x30\x48\x6a\x76\x31\x69','\x43\x33\x72\x48\x43\x4e\x72\x71\x43\x4d\x39\x54\x41\x78\x6e\x4c','\x79\x32\x6e\x46','\x41\x78\x6e\x6a\x42\x4e\x72\x4c\x7a\x32\x76\x59','\x71\x33\x62\x53\x75\x75\x75','\x44\x78\x6a\x50','\x43\x4e\x76\x55\x71\x77\x7a\x30\x7a\x78\x69','\x45\x65\x72\x72\x72\x75\x53','\x43\x4e\x44\x5a\x44\x77\x38','\x79\x32\x58\x56\x43\x32\x75','\x74\x31\x6e\x56\x76\x65\x4f','\x43\x33\x72\x59\x41\x77\x35\x4e\x41\x77\x7a\x35','\x43\x4d\x76\x4d\x44\x78\x6e\x48\x42\x61','\x74\x65\x7a\x4d\x43\x32\x71','\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\x4b\x4c\x41\x75\x31\x75','\x44\x77\x66\x67\x45\x67\x34','\x76\x75\x58\x50\x73\x4c\x4b','\x7a\x4d\x4c\x53\x44\x67\x76\x59\x7a\x77\x71','\x41\x77\x35\x32\x79\x77\x58\x50\x7a\x66\x39\x59\x7a\x78\x66\x31\x7a\x78\x6e\x30','\x79\x32\x39\x4b\x7a\x76\x39\x50\x42\x4e\x72\x4c\x43\x4e\x62\x59\x7a\x78\x72\x4c\x43\x47','\x43\x33\x72\x59\x41\x77\x35\x4e','\x43\x32\x39\x54\x7a\x71','\x42\x4e\x72\x4e\x75\x30\x71','\x41\x67\x6a\x71\x44\x4c\x4b','\x41\x77\x35\x4d\x42\x57','\x44\x67\x76\x34\x44\x66\x62\x50\x7a\x77\x6e\x4c\x43\x57','\x42\x30\x39\x4a\x73\x77\x71','\x44\x4e\x6e\x4b\x74\x67\x79','\x73\x4d\x44\x76\x77\x68\x79','\x7a\x78\x48\x57\x41\x78\x6a\x4c\x7a\x61','\x42\x67\x6a\x6e\x74\x30\x4f','\x43\x32\x4c\x36\x7a\x71','\x43\x4d\x76\x5a\x42\x32\x58\x32\x7a\x71','\x44\x78\x6e\x4c\x43\x47','\x6d\x74\x61\x33\x6d\x5a\x61\x30\x6d\x4b\x54\x48\x74\x30\x31\x4f\x43\x47','\x74\x77\x48\x78\x44\x30\x75','\x43\x33\x76\x4a\x79\x32\x76\x5a\x43\x57','\x76\x67\x39\x6f\x43\x31\x69','\x41\x78\x72\x4c\x43\x4d\x66\x30\x42\x33\x6a\x64\x43\x4d\x76\x48\x44\x67\x76\x4b','\x79\x32\x39\x55\x44\x67\x76\x55\x44\x61','\x44\x68\x4c\x57\x7a\x71','\x79\x32\x39\x5a\x44\x63\x62\x4a\x79\x78\x61\x47\x43\x4d\x76\x48\x79\x32\x48\x4c\x7a\x64\x4f\x47','\x79\x32\x76\x50\x42\x67\x4c\x55\x7a\x57','\x44\x78\x6a\x33\x7a\x65\x57','\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','\x75\x4c\x62\x6c\x79\x78\x79','\x75\x4b\x6a\x79\x43\x32\x71','\x43\x33\x76\x49\x42\x77\x4c\x30\x76\x67\x39\x56\x42\x65\x39\x31\x44\x68\x62\x31\x44\x68\x6d','\x7a\x67\x66\x30\x79\x71','\x43\x32\x39\x31\x43\x4d\x6e\x4c','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x69\x54\x44\x78\x6e\x4c\x6f\x47','\x76\x4d\x58\x4f\x71\x4e\x61','\x43\x4d\x76\x5a\x43\x67\x39\x55\x43\x32\x75\x55\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x76\x4b','\x43\x4b\x35\x78\x79\x4c\x61','\x72\x31\x48\x68\x76\x65\x30','\x79\x4d\x4c\x6d\x7a\x77\x71','\x79\x4d\x76\x4d\x42\x33\x6a\x4c\x76\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x57','\x41\x77\x35\x4b\x7a\x78\x48\x70\x7a\x47','\x44\x67\x66\x59\x7a\x32\x76\x30','\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','\x79\x78\x6e\x48\x41\x67\x34','\x43\x4d\x66\x33','\x43\x33\x4c\x5a\x44\x67\x76\x54','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x76\x43\x32\x75','\x45\x4e\x50\x78\x42\x4b\x43','\x44\x4d\x48\x70\x72\x4b\x6d','\x43\x4d\x76\x58\x44\x77\x4c\x59\x7a\x78\x6e\x62\x79\x33\x72\x50\x42\x32\x34','\x44\x32\x76\x49\x78\x33\x6e\x4c\x79\x78\x6a\x4a\x41\x66\x39\x57\x43\x4d\x76\x32\x41\x77\x76\x33','\x42\x78\x6e\x4e\x78\x57','\x41\x77\x35\x57\x44\x78\x72\x46\x79\x78\x76\x4b\x41\x77\x38','\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','\x42\x77\x4c\x34\x7a\x77\x72\x46\x41\x77\x35\x57\x44\x78\x72\x46\x44\x68\x4c\x57\x7a\x78\x6d','\x72\x4d\x50\x6b\x71\x32\x75','\x72\x65\x76\x30\x45\x65\x75','\x43\x68\x76\x5a\x41\x61','\x44\x67\x39\x56\x42\x65\x4c\x55\x44\x4d\x39\x4a\x79\x78\x72\x50\x42\x32\x34','\x7a\x4d\x4c\x53\x44\x67\x76\x59','\x42\x76\x76\x49\x42\x4b\x79','\x75\x75\x7a\x70\x43\x78\x6d','\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','\x43\x33\x62\x53\x41\x78\x71','\x43\x32\x72\x6e\x41\x75\x79','\x79\x78\x6a\x4e\x44\x77\x31\x4c\x42\x4e\x72\x5a','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x78\x33\x72\x4c\x45\x68\x71','\x44\x67\x39\x52\x7a\x77\x35\x5a','\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\x77\x6e\x30\x41\x77\x39\x55','\x44\x32\x66\x50\x44\x67\x76\x59\x43\x57','\x44\x75\x35\x35\x72\x67\x38','\x79\x32\x39\x55\x44\x67\x4c\x55\x44\x77\x75','\x43\x33\x72\x48\x43\x4e\x71','\x73\x78\x66\x35\x45\x75\x38','\x71\x4c\x48\x34\x45\x77\x4b','\x41\x31\x50\x4d\x74\x68\x69','\x43\x32\x76\x48\x43\x4d\x6e\x4f\x71\x32\x39\x55\x44\x67\x76\x34\x44\x66\x6e\x50\x45\x4d\x75','\x41\x77\x35\x5a\x44\x68\x6a\x31\x79\x33\x72\x50\x42\x32\x35\x5a','\x44\x67\x39\x56\x42\x65\x39\x31\x44\x68\x62\x31\x44\x65\x4c\x55\x7a\x67\x76\x34','\x44\x78\x6e\x4c\x43\x4b\x58\x56\x79\x32\x66\x30\x41\x77\x39\x55','\x43\x4d\x39\x53\x7a\x71','\x44\x4b\x35\x73\x76\x67\x6d','\x74\x77\x6e\x75\x74\x77\x38','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x64\x79\x77\x58\x53\x43\x57','\x42\x77\x4c\x55','\x7a\x31\x4c\x62\x74\x75\x4f','\x43\x76\x6e\x4e\x45\x77\x57','\x71\x4d\x66\x69\x76\x33\x65','\x43\x32\x58\x50\x79\x32\x75','\x41\x77\x35\x57\x44\x78\x72\x46\x44\x67\x39\x52\x7a\x77\x35\x5a','\x71\x4b\x7a\x6e\x42\x31\x4b','\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','\x42\x77\x66\x57','\x79\x77\x7a\x30\x7a\x78\x6a\x75\x42\x32\x39\x53\x71\x32\x66\x53\x42\x61','\x76\x67\x39\x56\x42\x63\x62\x30\x45\x78\x62\x4c\x69\x63\x69','\x73\x65\x7a\x58\x75\x4e\x65','\x73\x4e\x6a\x4b\x42\x4b\x38','\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','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x75\x67\x4c\x4c\x79\x32\x76\x5a','\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','\x44\x67\x39\x56\x42\x65\x35\x48\x42\x77\x75','\x44\x67\x39\x56\x42\x65\x6e\x48\x42\x67\x58\x6a\x7a\x61','\x43\x4d\x76\x5a\x44\x77\x58\x30','\x77\x65\x7a\x4b\x74\x66\x4f','\x42\x67\x7a\x56\x75\x4b\x6d','\x43\x68\x76\x30\x75\x68\x6a\x50\x42\x33\x6a\x75\x44\x78\x6a\x55\x43\x57','\x74\x31\x6e\x51\x79\x30\x34','\x74\x30\x31\x6e\x41\x4e\x4f','\x7a\x68\x62\x48\x76\x78\x43','\x42\x77\x39\x4b\x7a\x77\x57','\x75\x4b\x66\x36\x76\x30\x47','\x43\x4d\x76\x33\x43\x4d\x4c\x30\x7a\x71','\x79\x75\x6a\x74\x42\x67\x69','\x43\x67\x35\x4e\x71\x4d\x66\x5a\x7a\x74\x79\x30','\x41\x78\x6e\x62\x43\x4e\x6a\x48\x45\x71','\x79\x78\x6a\x4e\x43\x57','\x7a\x4e\x6a\x56\x42\x71','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53','\x79\x4d\x66\x30\x79\x32\x48\x46\x44\x67\x39\x56\x78\x32\x58\x48\x43\x4d\x44\x4c','\x79\x32\x58\x56\x43\x32\x76\x4b','\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','\x42\x4d\x66\x54\x7a\x71','\x77\x4e\x44\x53\x73\x68\x69','\x44\x67\x39\x30\x79\x77\x58\x46\x44\x67\x39\x52\x7a\x77\x35\x5a','\x42\x33\x76\x30\x43\x68\x76\x30\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x43\x33\x72\x48\x44\x68\x76\x5a','\x79\x32\x58\x4c\x79\x78\x69','\x7a\x4d\x66\x50\x42\x67\x76\x4b','\x7a\x77\x35\x4b\x43\x67\x39\x50\x42\x4e\x71','\x7a\x77\x35\x4b\x43\x31\x44\x50\x44\x67\x47','\x43\x67\x76\x55\x7a\x67\x4c\x55\x7a\x30\x6e\x48\x42\x67\x58\x5a','\x42\x33\x76\x30\x79\x32\x39\x54\x7a\x71','\x44\x68\x6a\x48\x42\x4e\x6e\x50\x44\x67\x4c\x56\x42\x47','\x79\x32\x39\x54\x43\x68\x76\x30\x7a\x78\x6a\x62\x79\x33\x72\x50\x42\x32\x34','\x72\x30\x72\x73\x75\x33\x4b','\x7a\x4d\x58\x56\x42\x33\x69','\x43\x33\x76\x4a\x79\x32\x76\x4c\x7a\x67\x76\x4b','\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','\x77\x67\x54\x71\x45\x75\x75','\x44\x67\x39\x56\x42\x66\x39\x4a\x79\x77\x58\x53\x78\x32\x4c\x4b','\x71\x4d\x39\x7a\x77\x67\x79','\x79\x78\x6a\x50\x79\x75\x58\x48\x79\x4d\x76\x53','\x42\x66\x44\x76\x45\x4d\x43','\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','\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','\x44\x78\x6a\x53','\x43\x67\x66\x59\x44\x67\x35\x4c\x43\x4b\x4c\x4b','\x7a\x77\x35\x4a\x42\x32\x72\x50\x42\x4d\x44\x46\x7a\x4d\x39\x59\x42\x77\x66\x30','\x7a\x78\x48\x4c\x79\x33\x76\x30\x41\x77\x39\x55\x6c\x4e\x6e\x30\x79\x78\x6a\x30\x7a\x77\x71','\x6f\x74\x6d\x33\x6d\x5a\x65\x31\x6f\x67\x72\x75\x71\x4b\x48\x51\x43\x47','\x79\x4e\x76\x4d\x7a\x4d\x76\x59','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e\x78\x33\x72\x56\x41\x32\x76\x55\x43\x57','\x44\x67\x66\x55\x7a\x32\x58\x4c\x6c\x57','\x79\x32\x39\x4b\x7a\x71','\x71\x77\x39\x77\x42\x4e\x61','\x44\x4d\x66\x53\x44\x77\x75','\x43\x32\x6e\x59\x7a\x77\x76\x55\x43\x32\x48\x56\x44\x61','\x43\x67\x54\x57\x75\x75\x79','\x41\x4e\x48\x73\x74\x33\x69','\x44\x4d\x66\x59\x41\x77\x66\x55\x44\x61','\x44\x67\x39\x56\x42\x66\x39\x49\x42\x67\x39\x4a\x41\x32\x76\x4b','\x79\x32\x48\x48\x41\x77\x35\x5a','\x43\x78\x76\x4c\x43\x4e\x4b','\x44\x32\x76\x49\x78\x33\x6e\x4c\x79\x78\x6a\x4a\x41\x61','\x44\x67\x39\x56\x42\x68\x6d','\x42\x66\x6a\x50\x41\x66\x6d','\x43\x4d\x76\x48\x43\x32\x39\x55','\x7a\x4d\x58\x56\x79\x78\x71','\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','\x79\x32\x39\x54\x43\x67\x58\x4c\x44\x67\x4c\x56\x42\x4c\x39\x30\x42\x32\x54\x4c\x42\x4e\x6d','\x7a\x4e\x76\x55\x79\x33\x72\x50\x42\x32\x34','\x43\x33\x72\x4c\x7a\x78\x69','\x41\x78\x72\x4c\x43\x4d\x66\x30\x42\x33\x69','\x75\x67\x48\x54\x45\x66\x65','\x71\x77\x58\x50\x44\x4d\x71','\x7a\x30\x39\x36\x43\x4c\x69','\x44\x32\x66\x59\x42\x47','\x41\x67\x66\x5a','\x74\x30\x44\x4f\x72\x4b\x30','\x42\x66\x7a\x75\x73\x4d\x4b','\x44\x77\x35\x5a\x44\x78\x62\x57\x42\x33\x6a\x30\x7a\x77\x72\x46\x44\x67\x39\x56\x42\x61','\x7a\x66\x62\x51\x44\x75\x71','\x42\x32\x35\x74\x44\x67\x66\x30\x44\x78\x6e\x64\x41\x67\x66\x55\x7a\x32\x75','\x79\x32\x48\x31\x42\x4d\x54\x6a\x42\x4d\x72\x4c\x45\x61','\x69\x67\x31\x31\x43\x33\x71\x47\x42\x4d\x39\x30\x69\x67\x6a\x4c\x69\x67\x76\x54\x43\x68\x72\x35','\x43\x4d\x76\x48\x43\x32\x39\x55\x41\x77\x35\x4e','\x43\x4e\x76\x55\x71\x4d\x76\x4d\x42\x33\x6a\x4c','\x41\x77\x35\x57\x44\x78\x72\x75\x42\x32\x54\x4c\x42\x4e\x6d','\x42\x77\x76\x4b\x41\x78\x76\x54','\x76\x4b\x39\x78\x75\x66\x71','\x76\x75\x54\x6c\x75\x32\x43','\x71\x33\x7a\x73\x79\x77\x38','\x42\x77\x39\x4b\x7a\x77\x58\x6a\x7a\x61','\x43\x4d\x35\x5a\x7a\x32\x47','\x74\x66\x76\x6f\x76\x31\x4f','\x42\x33\x7a\x4c\x43\x4e\x6a\x50\x7a\x67\x75','\x42\x68\x66\x49\x71\x4c\x47','\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','\x44\x67\x39\x56\x42\x66\x39\x55\x79\x77\x31\x4c','\x76\x78\x62\x76\x79\x4d\x79','\x7a\x67\x76\x55\x45\x75\x58\x50\x43\x33\x71'];a0_0x453e=function(){return _0x258a97;};return a0_0x453e();}var EmbeddingValidationError=class extends Error{[a0_0x4409d1(0x350)]=a0_0x4409d1(0x2f4);[a0_0x4409d1(0x1f6)];[a0_0x4409d1(0x263)];constructor(_0x3ee373,_0x71a99,_0x469324){const _0x936c36=a0_0x4409d1;super(_0x3ee373),this['\x6e\x61\x6d\x65']=_0x936c36(0x335),this[_0x936c36(0x1f6)]=_0x71a99,this['\x70\x61\x72\x61\x6d']=_0x469324;}};function a0_0x4d60(_0x29a98f,_0x3ae1cb){_0x29a98f=_0x29a98f-0x18b;const _0x453e67=a0_0x453e();let _0x4d6009=_0x453e67[_0x29a98f];if(a0_0x4d60['\x6b\x4e\x6e\x58\x6d\x71']===undefined){var _0x14adb3=function(_0x26b49e){const _0x2517bb='\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 _0x4b5af2='',_0x227450='';for(let _0x31e51b=0x0,_0x2ef146,_0x23f3be,_0x59f89e=0x0;_0x23f3be=_0x26b49e['\x63\x68\x61\x72\x41\x74'](_0x59f89e++);~_0x23f3be&&(_0x2ef146=_0x31e51b%0x4?_0x2ef146*0x40+_0x23f3be:_0x23f3be,_0x31e51b++%0x4)?_0x4b5af2+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0xff&_0x2ef146>>(-0x2*_0x31e51b&0x6)):0x0){_0x23f3be=_0x2517bb['\x69\x6e\x64\x65\x78\x4f\x66'](_0x23f3be);}for(let _0x37cbca=0x0,_0x353508=_0x4b5af2['\x6c\x65\x6e\x67\x74\x68'];_0x37cbca<_0x353508;_0x37cbca++){_0x227450+='\x25'+('\x30\x30'+_0x4b5af2['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x37cbca)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x10))['\x73\x6c\x69\x63\x65'](-0x2);}return decodeURIComponent(_0x227450);};a0_0x4d60['\x53\x56\x6e\x74\x70\x4f']=_0x14adb3,a0_0x4d60['\x78\x67\x4d\x55\x51\x69']={},a0_0x4d60['\x6b\x4e\x6e\x58\x6d\x71']=!![];}const _0x5007ca=_0x453e67[0x0],_0x2a74e6=_0x29a98f+_0x5007ca,_0x3d2973=a0_0x4d60['\x78\x67\x4d\x55\x51\x69'][_0x2a74e6];return!_0x3d2973?(_0x4d6009=a0_0x4d60['\x53\x56\x6e\x74\x70\x4f'](_0x4d6009),a0_0x4d60['\x78\x67\x4d\x55\x51\x69'][_0x2a74e6]=_0x4d6009):_0x4d6009=_0x3d2973,_0x4d6009;}const MAX_BATCH=0x800;function reject(_0x3acacf,_0x7a6f66,_0x4c5097){throw new EmbeddingValidationError(_0x3acacf,_0x7a6f66,_0x4c5097);}function normalizeInput(_0x1fa5dd){const _0x1b41b7=a0_0x4409d1,_0x524c93={'\x78\x62\x4b\x59\x79':function(_0x247bd7,_0x59d7fe){return _0x247bd7===_0x59d7fe;},'\x42\x58\x78\x79\x69':_0x1b41b7(0x33c),'\x47\x44\x52\x53\x79':function(_0x23d484,_0x381549){return _0x23d484===_0x381549;},'\x70\x4b\x73\x65\x4e':_0x1b41b7(0x19a),'\x4d\x63\x54\x4d\x6f':function(_0x2824ed,_0x2eb710,_0x4f752f,_0x22f11c){return _0x2824ed(_0x2eb710,_0x4f752f,_0x22f11c);},'\x70\x6b\x70\x51\x46':'\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','\x55\x74\x62\x76\x44':'\x69\x6e\x76\x61\x6c\x69\x64\x5f\x69\x6e\x70\x75\x74\x5f\x74\x79\x70\x65','\x44\x45\x74\x78\x45':'\x69\x6e\x70\x75\x74','\x78\x44\x51\x45\x4b':function(_0x25ad55,_0x19f8d2){return _0x25ad55>_0x19f8d2;},'\x69\x4a\x67\x70\x6c':function(_0x128960,_0x1513eb){return _0x128960<_0x1513eb;},'\x6e\x74\x67\x53\x44':_0x1b41b7(0x192),'\x46\x49\x4a\x65\x57':'\x65\x6d\x70\x74\x79\x5f\x69\x6e\x70\x75\x74','\x59\x47\x4c\x6e\x68':_0x1b41b7(0x244),'\x56\x4f\x57\x50\x54':'\x6e\x75\x6d\x62\x65\x72','\x75\x6e\x75\x69\x59':function(_0x5ee0ea,_0x5bcf41,_0x2d04d4,_0x342ec9){return _0x5ee0ea(_0x5bcf41,_0x2d04d4,_0x342ec9);},'\x4a\x68\x44\x52\x68':function(_0x570d97,_0x37c2aa){return _0x570d97<_0x37c2aa;}};if(_0x524c93[_0x1b41b7(0x311)](typeof _0x1fa5dd,_0x524c93[_0x1b41b7(0x1a7)])){if(_0x524c93[_0x1b41b7(0x1e3)](_0x1fa5dd[_0x1b41b7(0x28a)],0x0))reject(_0x524c93['\x70\x4b\x73\x65\x4e'],_0x1b41b7(0x2cc),_0x1b41b7(0x30c));return{'\x6b\x69\x6e\x64':_0x1b41b7(0x244),'\x76\x61\x6c\x75\x65\x73':[_0x1fa5dd]};}if(!Array[_0x1b41b7(0x1cf)](_0x1fa5dd))_0x524c93[_0x1b41b7(0x1af)](reject,_0x524c93[_0x1b41b7(0x1fa)],_0x524c93[_0x1b41b7(0x2fd)],_0x524c93[_0x1b41b7(0x194)]);if(_0x524c93[_0x1b41b7(0x311)](_0x1fa5dd[_0x1b41b7(0x28a)],0x0))reject('\x49\x6e\x70\x75\x74\x20\x61\x72\x72\x61\x79\x20\x6d\x75\x73\x74\x20\x6e\x6f\x74\x20\x62\x65\x20\x65\x6d\x70\x74\x79',_0x1b41b7(0x2cc),_0x1b41b7(0x30c));if(_0x524c93[_0x1b41b7(0x32e)](_0x1fa5dd[_0x1b41b7(0x28a)],MAX_BATCH))reject(_0x1b41b7(0x268)+MAX_BATCH,_0x1b41b7(0x1d3),_0x1b41b7(0x30c));const _0x91e3bc=_0x1fa5dd[0x0];if(typeof _0x91e3bc===_0x524c93['\x42\x58\x78\x79\x69']){const _0x1985b4=[];for(let _0x1ee546=0x0;_0x524c93[_0x1b41b7(0x324)](_0x1ee546,_0x1fa5dd[_0x1b41b7(0x28a)]);_0x1ee546++){const _0x927f1e=_0x1fa5dd[_0x1ee546];if(typeof _0x927f1e!=='\x73\x74\x72\x69\x6e\x67')reject(_0x1b41b7(0x289)+_0x1ee546+_0x1b41b7(0x226),_0x524c93[_0x1b41b7(0x33e)],'\x69\x6e\x70\x75\x74');if(_0x927f1e[_0x1b41b7(0x28a)]===0x0)reject(_0x1b41b7(0x2f2)+_0x1ee546+_0x1b41b7(0x215),_0x524c93[_0x1b41b7(0x2d1)],'\x69\x6e\x70\x75\x74');_0x1985b4[_0x1b41b7(0x195)](_0x927f1e);}return{'\x6b\x69\x6e\x64':_0x524c93['\x59\x47\x4c\x6e\x68'],'\x76\x61\x6c\x75\x65\x73':_0x1985b4};}if(typeof _0x91e3bc===_0x524c93[_0x1b41b7(0x21a)]){for(let _0x4b372c=0x0;_0x4b372c<_0x1fa5dd[_0x1b41b7(0x28a)];_0x4b372c++)if(typeof _0x1fa5dd[_0x4b372c]!==_0x1b41b7(0x2a9))_0x524c93[_0x1b41b7(0x1af)](reject,_0x1b41b7(0x205)+_0x4b372c+_0x1b41b7(0x2b6)+typeof _0x1fa5dd[_0x4b372c],_0x1b41b7(0x325),_0x524c93[_0x1b41b7(0x194)]);return{'\x6b\x69\x6e\x64':_0x1b41b7(0x19f),'\x76\x61\x6c\x75\x65\x73':[_0x1fa5dd]};}if(Array[_0x1b41b7(0x1cf)](_0x91e3bc)){const _0x3e64ff=[];for(let _0x1476eb=0x0;_0x1476eb<_0x1fa5dd[_0x1b41b7(0x28a)];_0x1476eb++){const _0xd89fb1=_0x1fa5dd[_0x1476eb];if(!Array['\x69\x73\x41\x72\x72\x61\x79'](_0xd89fb1))reject(_0x1b41b7(0x289)+_0x1476eb+'\x20\x69\x73\x20\x6e\x6f\x74\x20\x61\x6e\x20\x61\x72\x72\x61\x79',_0x1b41b7(0x192),_0x524c93[_0x1b41b7(0x194)]);if(_0xd89fb1[_0x1b41b7(0x28a)]===0x0)_0x524c93[_0x1b41b7(0x2b3)](reject,_0x1b41b7(0x1d5)+_0x1476eb+'\x20\x6d\x75\x73\x74\x20\x6e\x6f\x74\x20\x62\x65\x20\x65\x6d\x70\x74\x79',_0x524c93[_0x1b41b7(0x2d1)],_0x524c93[_0x1b41b7(0x194)]);for(let _0x3b4163=0x0;_0x524c93[_0x1b41b7(0x318)](_0x3b4163,_0xd89fb1[_0x1b41b7(0x28a)]);_0x3b4163++)if(typeof _0xd89fb1[_0x3b4163]!==_0x1b41b7(0x2a9))reject('\x54\x6f\x6b\x65\x6e\x20\x61\x72\x72\x61\x79\x20\x61\x74\x20\x69\x6e\x64\x65\x78\x20'+_0x1476eb+_0x1b41b7(0x191)+_0x3b4163+'\x20\x69\x73\x20'+typeof _0xd89fb1[_0x3b4163],_0x1b41b7(0x325),_0x524c93[_0x1b41b7(0x194)]);_0x3e64ff[_0x1b41b7(0x195)](_0xd89fb1);}return{'\x6b\x69\x6e\x64':_0x1b41b7(0x19f),'\x76\x61\x6c\x75\x65\x73':_0x3e64ff};}reject(_0x1b41b7(0x2be),_0x1b41b7(0x2ea),_0x1b41b7(0x30c));}function validateEmbeddingRequest(_0x3639e7){const _0x2ea4c9=a0_0x4409d1,_0xce8588={'\x69\x51\x65\x61\x6a':_0x2ea4c9(0x2cb),'\x55\x58\x57\x75\x4f':function(_0x44c4b3,_0x305be6,_0x37265f,_0x146c5c){return _0x44c4b3(_0x305be6,_0x37265f,_0x146c5c);},'\x41\x6f\x56\x6e\x70':_0x2ea4c9(0x33a),'\x4f\x72\x43\x78\x72':function(_0x45ba7c,_0x4dfcf7,_0x5f4da0,_0xea415f){return _0x45ba7c(_0x4dfcf7,_0x5f4da0,_0xea415f);},'\x63\x6b\x62\x6e\x7a':'\x6d\x6f\x64\x65\x6c','\x69\x50\x7a\x65\x76':'\x44\x69\x6d\x65\x6e\x73\x69\x6f\x6e\x73\x20\x6d\x75\x73\x74\x20\x62\x65\x20\x61\x20\x70\x6f\x73\x69\x74\x69\x76\x65\x20\x69\x6e\x74\x65\x67\x65\x72','\x6c\x66\x6f\x52\x43':'\x69\x6e\x76\x61\x6c\x69\x64\x5f\x64\x69\x6d\x65\x6e\x73\x69\x6f\x6e\x73','\x49\x6b\x4f\x6c\x73':_0x2ea4c9(0x204),'\x4a\x69\x50\x4d\x54':'\x62\x61\x73\x65\x36\x34','\x73\x58\x61\x42\x6d':_0x2ea4c9(0x278),'\x55\x4b\x4b\x53\x67':function(_0x252a58,_0x3a3e37){return _0x252a58!==_0x3a3e37;}};if(!_0x3639e7||typeof _0x3639e7!==_0xce8588['\x69\x51\x65\x61\x6a'])_0xce8588[_0x2ea4c9(0x29f)](reject,_0x2ea4c9(0x284),_0xce8588[_0x2ea4c9(0x1f7)],void 0x0);if(typeof _0x3639e7[_0x2ea4c9(0x1ca)]!==_0x2ea4c9(0x33c)||_0x3639e7[_0x2ea4c9(0x1ca)]['\x6c\x65\x6e\x67\x74\x68']===0x0)_0xce8588[_0x2ea4c9(0x2d7)](reject,'\x4d\x6f\x64\x65\x6c\x20\x69\x73\x20\x72\x65\x71\x75\x69\x72\x65\x64',_0x2ea4c9(0x2c1),_0xce8588[_0x2ea4c9(0x28e)]);if(_0x3639e7[_0x2ea4c9(0x259)]!==void 0x0){if(typeof _0x3639e7['\x64\x69\x6d\x65\x6e\x73\x69\x6f\x6e\x73']!=='\x6e\x75\x6d\x62\x65\x72'||!Number[_0x2ea4c9(0x32a)](_0x3639e7['\x64\x69\x6d\x65\x6e\x73\x69\x6f\x6e\x73'])||_0x3639e7[_0x2ea4c9(0x259)]<=0x0)reject(_0xce8588[_0x2ea4c9(0x234)],_0xce8588[_0x2ea4c9(0x1c5)],_0x2ea4c9(0x259));}const _0x10c311=_0x3639e7[_0x2ea4c9(0x1f0)]??'\x66\x6c\x6f\x61\x74';if(_0x10c311!==_0xce8588[_0x2ea4c9(0x277)]&&_0x10c311!==_0xce8588['\x4a\x69\x50\x4d\x54'])_0xce8588['\x4f\x72\x43\x78\x72'](reject,_0xce8588[_0x2ea4c9(0x241)],_0x2ea4c9(0x1be),_0x2ea4c9(0x1f0));const _0x17b25d=normalizeInput(_0x3639e7[_0x2ea4c9(0x30c)]),_0x135348={'\x6d\x6f\x64\x65\x6c':_0x3639e7[_0x2ea4c9(0x1ca)],'\x69\x6e\x70\x75\x74':_0x17b25d,'\x65\x6e\x63\x6f\x64\x69\x6e\x67\x46\x6f\x72\x6d\x61\x74':_0x10c311};if(_0x3639e7[_0x2ea4c9(0x259)]!==void 0x0)_0x135348[_0x2ea4c9(0x259)]=_0x3639e7[_0x2ea4c9(0x259)];if(_0xce8588[_0x2ea4c9(0x21b)](_0x3639e7['\x75\x73\x65\x72'],void 0x0))_0x135348[_0x2ea4c9(0x349)]=_0x3639e7['\x75\x73\x65\x72'];return _0x135348;}function resolveProviderId(_0x30c2fd){const _0x4fe49f=a0_0x4409d1,_0x4b6022={'\x57\x64\x6c\x65\x44':function(_0x50e358,_0x5cef5b){return _0x50e358===_0x5cef5b;}},_0x376bc5=_0x30c2fd[_0x4fe49f(0x2ac)](),_0x57f1f2=_0x376bc5[_0x4fe49f(0x22c)](_0x4fe49f(0x1f5))?_0x376bc5[_0x4fe49f(0x1b5)](0x7):_0x376bc5;if(!_0x57f1f2)throw new Error(_0x4fe49f(0x273)+JSON[_0x4fe49f(0x332)](_0x30c2fd));const _0x501860=_0x57f1f2[_0x4fe49f(0x361)]('\x2f');if(_0x4b6022['\x57\x64\x6c\x65\x44'](_0x501860,-0x1))return{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x57f1f2};const _0x3d0720=_0x57f1f2['\x73\x6c\x69\x63\x65'](0x0,_0x501860),_0x27dd41=_0x57f1f2['\x73\x6c\x69\x63\x65'](_0x501860+0x1);if(!_0x3d0720||!_0x27dd41)throw new Error('\x49\x6e\x76\x61\x6c\x69\x64\x20\x6d\x6f\x64\x65\x6c\x20\x69\x64\x3a\x20'+JSON['\x73\x74\x72\x69\x6e\x67\x69\x66\x79'](_0x30c2fd));return{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x3d0720,'\x76\x61\x72\x69\x61\x6e\x74':_0x27dd41};}function normalizeContent(_0x1133c2){const _0x542a8e=a0_0x4409d1,_0x138950={'\x51\x46\x4f\x71\x73':function(_0x16ddf2,_0x56106f){return _0x16ddf2===_0x56106f;},'\x62\x4c\x62\x4f\x62':function(_0x4d716a,_0x914352){return _0x4d716a===_0x914352;},'\x4d\x4c\x6c\x51\x78':_0x542a8e(0x2ca),'\x6c\x74\x69\x67\x6d':function(_0x107341,_0x5520c6){return _0x107341===_0x5520c6;}};if(_0x1133c2==null)return{'\x74\x65\x78\x74':'','\x70\x61\x72\x74\x73':[]};if(typeof _0x1133c2===_0x542a8e(0x33c))return{'\x74\x65\x78\x74':_0x1133c2,'\x70\x61\x72\x74\x73':[]};const _0x11e642=[],_0x4cab20=[];for(const _0x25a13a of _0x1133c2)if(_0x138950[_0x542a8e(0x199)](_0x25a13a['\x74\x79\x70\x65'],_0x542a8e(0x244)))_0x4cab20['\x70\x75\x73\x68'](_0x25a13a['\x74\x65\x78\x74']),_0x11e642[_0x542a8e(0x195)]({'\x74\x79\x70\x65':_0x542a8e(0x244),'\x74\x65\x78\x74':_0x25a13a[_0x542a8e(0x244)]});else{if(_0x138950[_0x542a8e(0x2ce)](_0x25a13a[_0x542a8e(0x350)],'\x69\x6d\x61\x67\x65\x5f\x75\x72\x6c'))_0x11e642[_0x542a8e(0x195)]({'\x74\x79\x70\x65':_0x138950[_0x542a8e(0x23f)],'\x69\x6d\x61\x67\x65\x5f\x75\x72\x6c':{'\x75\x72\x6c':_0x25a13a[_0x542a8e(0x2ca)][_0x542a8e(0x1ee)],'\x64\x65\x74\x61\x69\x6c':_0x25a13a[_0x542a8e(0x2ca)][_0x542a8e(0x243)]}});else{if(_0x138950[_0x542a8e(0x267)](_0x25a13a[_0x542a8e(0x350)],_0x542a8e(0x190)))_0x11e642[_0x542a8e(0x195)]({'\x74\x79\x70\x65':_0x542a8e(0x190),'\x69\x6e\x70\x75\x74\x5f\x61\x75\x64\x69\x6f':{'\x64\x61\x74\x61':_0x25a13a[_0x542a8e(0x190)][_0x542a8e(0x358)],'\x66\x6f\x72\x6d\x61\x74':_0x25a13a[_0x542a8e(0x190)]['\x66\x6f\x72\x6d\x61\x74']}});}}return{'\x74\x65\x78\x74':_0x4cab20['\x6a\x6f\x69\x6e']('\x0a'),'\x70\x61\x72\x74\x73':_0x11e642};}function readAssistantText(_0x477b9b){const _0x59ad28=a0_0x4409d1,_0x2e514e={'\x6c\x70\x72\x67\x71':function(_0xc2d2cb,_0x2a1a4a){return _0xc2d2cb==_0x2a1a4a;},'\x6f\x7a\x56\x41\x51':function(_0x515b9d,_0xf291fe){return _0x515b9d===_0xf291fe;},'\x63\x5a\x4d\x55\x69':_0x59ad28(0x244)};if(_0x2e514e['\x6c\x70\x72\x67\x71'](_0x477b9b,null))return'';if(_0x2e514e[_0x59ad28(0x22a)](typeof _0x477b9b,_0x59ad28(0x33c)))return _0x477b9b;const _0x570353=[];for(const _0x1b941e of _0x477b9b)if(_0x1b941e['\x74\x79\x70\x65']===_0x2e514e[_0x59ad28(0x245)])_0x570353[_0x59ad28(0x195)](_0x1b941e[_0x59ad28(0x244)]);else{if(_0x1b941e[_0x59ad28(0x350)]===_0x59ad28(0x333))_0x570353[_0x59ad28(0x195)](_0x1b941e[_0x59ad28(0x333)]);}return _0x570353[_0x59ad28(0x321)]('\x0a');}function readToolContent(_0x30a9df){const _0x30a9f6=a0_0x4409d1;if(typeof _0x30a9df===_0x30a9f6(0x33c))return _0x30a9df;return _0x30a9df[_0x30a9f6(0x1b9)](_0x5844af=>_0x5844af[_0x30a9f6(0x244)])[_0x30a9f6(0x321)]('\x0a');}function convertTools(_0x1fe075){const _0x2aa735=a0_0x4409d1,_0x4f50f3={'\x55\x43\x6a\x54\x72':function(_0x4df63d,_0xa3be85){return _0x4df63d===_0xa3be85;},'\x6c\x62\x4d\x4f\x4a':function(_0x42253a,_0xa1146b){return _0x42253a>_0xa1146b;}};if(!_0x1fe075||_0x1fe075['\x6c\x65\x6e\x67\x74\x68']===0x0)return void 0x0;const _0x460837=[];for(const _0x1f476c of _0x1fe075)if(_0x4f50f3[_0x2aa735(0x24c)](_0x1f476c[_0x2aa735(0x350)],_0x2aa735(0x207)))_0x460837[_0x2aa735(0x195)]({'\x74\x79\x70\x65':'\x66\x75\x6e\x63\x74\x69\x6f\x6e','\x66\x75\x6e\x63\x74\x69\x6f\x6e':{'\x6e\x61\x6d\x65':_0x1f476c[_0x2aa735(0x207)][_0x2aa735(0x1d6)],'\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e':_0x1f476c['\x66\x75\x6e\x63\x74\x69\x6f\x6e']['\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6f\x6e'],'\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73':_0x1f476c['\x66\x75\x6e\x63\x74\x69\x6f\x6e'][_0x2aa735(0x230)]??null,'\x73\x74\x72\x69\x63\x74':_0x1f476c[_0x2aa735(0x207)][_0x2aa735(0x2e7)]??null}});return _0x4f50f3[_0x2aa735(0x346)](_0x460837[_0x2aa735(0x28a)],0x0)?_0x460837:void 0x0;}function openaiMessagesToSandboxInput(_0x2035a1,_0x1c8f3d,_0x346e09){const _0x250356=a0_0x4409d1,_0x4db51d={'\x78\x6f\x53\x52\x77':_0x250356(0x258),'\x52\x4b\x71\x6e\x71':function(_0x183d91,_0x53858b){return _0x183d91<_0x53858b;},'\x4f\x6a\x69\x71\x58':'\x64\x65\x76\x65\x6c\x6f\x70\x65\x72','\x48\x46\x71\x52\x71':function(_0x166dc1,_0x4916ce){return _0x166dc1(_0x4916ce);},'\x44\x5a\x62\x67\x69':function(_0xcf3fcd,_0x12da5b){return _0xcf3fcd===_0x12da5b;},'\x53\x6e\x41\x46\x49':function(_0x43dfbc,_0x1d57d8){return _0x43dfbc>_0x1d57d8;},'\x6f\x53\x4e\x6d\x55':function(_0x817642){return _0x817642();},'\x52\x41\x7a\x57\x48':'\x66\x75\x6e\x63\x74\x69\x6f\x6e','\x41\x6c\x69\x76\x64':_0x250356(0x33c),'\x4f\x77\x52\x73\x4a':function(_0x378720,_0x6fbaa8){return _0x378720>_0x6fbaa8;},'\x6e\x49\x5a\x53\x55':_0x250356(0x2ff),'\x4d\x78\x75\x46\x53':function(_0x1b15ce,_0x4b9449){return _0x1b15ce>_0x4b9449;}},{provider:_0x2b7a36,variant:_0x29c572}=resolveProviderId(_0x346e09),_0x4435e4=[],_0x2cbe7d=[],_0x3775cb=[];let _0x5b8060=null,_0x48d772=[],_0x114857=[],_0x35f706=![];const _0x14cc36=()=>{const _0x28a1f8=_0x250356;_0x5b8060&&(_0x3775cb[_0x28a1f8(0x195)](_0x5b8060),_0x5b8060=null);};let _0x5c446d=-0x1;for(let _0x3b596a=_0x2035a1[_0x250356(0x28a)]-0x1;_0x3b596a>=0x0;_0x3b596a--)if(_0x2035a1[_0x3b596a][_0x250356(0x1ad)]===_0x250356(0x349)){_0x5c446d=_0x3b596a;break;}if(_0x5c446d===-0x1)throw new Error(_0x4db51d[_0x250356(0x252)]);for(let _0xa438bf=0x0;_0x4db51d[_0x250356(0x30b)](_0xa438bf,_0x2035a1[_0x250356(0x28a)]);_0xa438bf++){const _0x3c1bcd=_0x2035a1[_0xa438bf];switch(_0x3c1bcd[_0x250356(0x1ad)]){case _0x250356(0x366):case _0x4db51d['\x4f\x6a\x69\x71\x58']:{const {text:_0x13a0b2}=_0x4db51d['\x48\x46\x71\x52\x71'](normalizeContent,_0x3c1bcd['\x63\x6f\x6e\x74\x65\x6e\x74']);if(_0x13a0b2)_0x4435e4['\x70\x75\x73\x68'](_0x13a0b2);break;}case _0x250356(0x349):{const {text:_0x409014,parts:_0x84a9ef}=_0x4db51d[_0x250356(0x1bc)](normalizeContent,_0x3c1bcd[_0x250356(0x34f)]);if(_0x84a9ef[_0x250356(0x33d)](_0xa67d35=>_0xa67d35['\x74\x79\x70\x65']!==_0x250356(0x244)))_0x35f706=!![];if(_0x4db51d[_0x250356(0x292)](_0xa438bf,_0x5c446d)){_0x2cbe7d[_0x250356(0x195)](_0x409014);if(_0x4db51d['\x53\x6e\x41\x46\x49'](_0x84a9ef['\x6c\x65\x6e\x67\x74\x68'],0x0))_0x114857=_0x84a9ef;}else{_0x4db51d[_0x250356(0x2e8)](_0x14cc36);_0x84a9ef[_0x250356(0x28a)]>0x0?(_0x5b8060={'\x75\x73\x65\x72\x50\x61\x72\x74\x73':_0x84a9ef},_0x48d772=_0x84a9ef):(_0x5b8060={},_0x48d772=[]);if(_0x409014)_0x2cbe7d['\x70\x75\x73\x68'](_0x409014);}break;}case _0x250356(0x2aa):{if(!_0x5b8060)_0x5b8060={};const _0x1f9c5c=readAssistantText(_0x3c1bcd[_0x250356(0x34f)]);if(_0x1f9c5c)_0x5b8060[_0x250356(0x2b5)]=_0x1f9c5c;if(_0x3c1bcd['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73']&&_0x4db51d[_0x250356(0x2c8)](_0x3c1bcd['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x73']['\x6c\x65\x6e\x67\x74\x68'],0x0)){const _0x30bb8f=[];for(const _0x2f152d of _0x3c1bcd[_0x250356(0x320)]){if(_0x2f152d[_0x250356(0x350)]!==_0x4db51d[_0x250356(0x1cb)])continue;if(!_0x2f152d['\x69\x64']||!_0x2f152d[_0x250356(0x207)]?.[_0x250356(0x1d6)]||typeof _0x2f152d[_0x250356(0x207)][_0x250356(0x19d)]!==_0x4db51d[_0x250356(0x20b)])throw new Error(_0x250356(0x22b)+_0xa438bf);_0x30bb8f[_0x250356(0x195)]({'\x69\x64':_0x2f152d['\x69\x64'],'\x6e\x61\x6d\x65':_0x2f152d[_0x250356(0x207)][_0x250356(0x1d6)],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x2f152d[_0x250356(0x207)]['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73']});}if(_0x4db51d[_0x250356(0x2c8)](_0x30bb8f[_0x250356(0x28a)],0x0))_0x5b8060[_0x250356(0x2a0)]=_0x30bb8f;}if(_0x4db51d[_0x250356(0x2fe)](_0x48d772[_0x250356(0x28a)],0x0)&&!_0x5b8060['\x75\x73\x65\x72\x50\x61\x72\x74\x73'])_0x5b8060['\x75\x73\x65\x72\x50\x61\x72\x74\x73']=_0x48d772;break;}case _0x4db51d[_0x250356(0x336)]:{const _0x4ae35c={'\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x49\x64':_0x3c1bcd[_0x250356(0x1e8)],'\x63\x6f\x6e\x74\x65\x6e\x74':readToolContent(_0x3c1bcd['\x63\x6f\x6e\x74\x65\x6e\x74'])};let _0x463525=![];if(_0x5b8060?.[_0x250356(0x2a0)]?.[_0x250356(0x33d)](_0x3e361f=>_0x3e361f['\x69\x64']===_0x3c1bcd[_0x250356(0x1e8)])){if(!_0x5b8060[_0x250356(0x322)])_0x5b8060[_0x250356(0x322)]=[];_0x5b8060[_0x250356(0x322)]['\x70\x75\x73\x68'](_0x4ae35c),_0x463525=!![];}else for(let _0x1f0173=_0x3775cb[_0x250356(0x28a)]-0x1;_0x1f0173>=0x0;_0x1f0173--){const _0x4371be=_0x3775cb[_0x1f0173];if(_0x4371be[_0x250356(0x2a0)]?.[_0x250356(0x33d)](_0x33ac88=>_0x33ac88['\x69\x64']===_0x3c1bcd['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x5f\x69\x64'])){if(!_0x4371be['\x74\x6f\x6f\x6c\x52\x65\x73\x75\x6c\x74\x73'])_0x4371be[_0x250356(0x322)]=[];_0x4371be[_0x250356(0x322)][_0x250356(0x195)](_0x4ae35c),_0x463525=!![];break;}}if(!_0x463525)throw new Error(_0x250356(0x1e6)+_0x3c1bcd[_0x250356(0x1e8)]);break;}case _0x4db51d[_0x250356(0x1cb)]:break;}if(_0x4db51d[_0x250356(0x292)](_0xa438bf,_0x5c446d))_0x14cc36();}_0x14cc36();const _0x23f6dc={'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x2b7a36,'\x74\x61\x73\x6b':_0x2cbe7d[_0x250356(0x321)]('\x0a\x0a')};if(_0x29c572)_0x23f6dc[_0x250356(0x1fc)]=_0x29c572;const _0x81e7ee=_0x4435e4['\x6a\x6f\x69\x6e']('\x0a\x0a');if(_0x81e7ee)_0x23f6dc[_0x250356(0x1aa)]=_0x81e7ee;if(_0x114857[_0x250356(0x28a)]>0x0)_0x23f6dc['\x74\x61\x73\x6b\x50\x61\x72\x74\x73']=_0x114857;if(_0x4db51d[_0x250356(0x2ba)](_0x3775cb[_0x250356(0x28a)],0x0))_0x23f6dc[_0x250356(0x291)]=_0x3775cb;const _0x1922a4=convertTools(_0x1c8f3d);if(_0x1922a4)_0x23f6dc[_0x250356(0x201)]=_0x1922a4;if(_0x35f706)_0x23f6dc[_0x250356(0x2cd)]=!![];return _0x23f6dc;}async function resolvePreviousResponseId(_0x2f011a,_0x59d154){const _0x1f8f92=a0_0x4409d1;if(!_0x2f011a)return{'\x70\x72\x69\x6f\x72\x54\x75\x72\x6e\x73':[]};const _0x361aa7=await _0x59d154[_0x1f8f92(0x246)](_0x2f011a);if(_0x361aa7===null)throw new Error(_0x1f8f92(0x2ec)+_0x2f011a);return{'\x70\x72\x69\x6f\x72\x54\x75\x72\x6e\x73':_0x361aa7};}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(_0x3c8f72){const _0x3d37d6=a0_0x4409d1,_0x244a39={'\x56\x6e\x74\x73\x53':function(_0x228c30,_0xa72452){return _0x228c30(_0xa72452);},'\x56\x73\x59\x70\x79':function(_0x1f56c5,_0x39c674){return _0x1f56c5===_0x39c674;},'\x70\x68\x4b\x65\x54':function(_0x65f8ec,_0x2e3298){return _0x65f8ec in _0x2e3298;},'\x46\x6a\x4a\x43\x65':'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73','\x67\x74\x4f\x72\x4d':function(_0x2ab133,_0x375e9e){return _0x2ab133+_0x375e9e;},'\x52\x71\x55\x4c\x45':function(_0x5c6c71,_0x2f3a27){return _0x5c6c71(_0x2f3a27);}},_0x118dc6=_0x3c8f72[_0x3d37d6(0x269)]??_0x3c8f72,_0x11b34f=_0x244a39[_0x3d37d6(0x27c)](Number,_0x118dc6['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']??_0x118dc6[_0x3d37d6(0x2b9)]??_0x118dc6['\x69\x6e\x70\x75\x74\x54\x6f\x6b\x65\x6e\x73']??0x0),_0xa695d0=Number(_0x118dc6[_0x3d37d6(0x1d9)]??_0x118dc6[_0x3d37d6(0x206)]??_0x118dc6[_0x3d37d6(0x2df)]??0x0);if(_0x244a39[_0x3d37d6(0x2bc)](_0x11b34f,0x0)&&_0xa695d0===0x0&&!_0x244a39['\x70\x68\x4b\x65\x54'](_0x244a39[_0x3d37d6(0x193)],_0x118dc6))return null;const _0x43b488=Number(_0x118dc6[_0x3d37d6(0x1d8)]??_0x244a39['\x67\x74\x4f\x72\x4d'](_0x11b34f,_0xa695d0)),_0x393c79=_0x244a39['\x56\x6e\x74\x73\x53'](Number,_0x118dc6[_0x3d37d6(0x315)]?.[_0x3d37d6(0x293)]??_0x118dc6['\x63\x61\x63\x68\x65\x64\x5f\x74\x6f\x6b\x65\x6e\x73']??0x0),_0x4a7c5e=_0x244a39['\x52\x71\x55\x4c\x45'](Number,_0x118dc6[_0x3d37d6(0x310)]?.[_0x3d37d6(0x1f4)]??_0x118dc6[_0x3d37d6(0x1f4)]??0x0);return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x11b34f,'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0xa695d0,'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x43b488,'\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':_0x393c79},'\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':_0x4a7c5e}};}function readToolInvocationFromRaw(_0x1aaac7){const _0x71cef9=a0_0x4409d1,_0x28eb6e={'\x68\x62\x50\x76\x59':function(_0x473675,_0x115ba0){return _0x473675!==_0x115ba0;},'\x4e\x67\x53\x50\x48':function(_0x357009,_0x564af2){return _0x357009===_0x564af2;},'\x76\x73\x64\x4c\x66':_0x71cef9(0x33c),'\x6b\x5a\x66\x4c\x72':_0x71cef9(0x275),'\x64\x5a\x56\x4c\x57':_0x71cef9(0x2cb),'\x47\x58\x47\x54\x4d':_0x71cef9(0x1d2),'\x76\x4b\x6c\x57\x66':function(_0x2ba394,_0x2de1ca){return _0x2ba394===_0x2de1ca;},'\x77\x49\x6a\x73\x67':function(_0xc30e64,_0x400f6b){return _0xc30e64||_0x400f6b;}};if(_0x28eb6e[_0x71cef9(0x33f)](_0x1aaac7['\x74\x79\x70\x65'],_0x71cef9(0x365)))return null;const _0x2c726f=_0x1aaac7[_0x71cef9(0x358)]??_0x1aaac7,_0x3d0a22=_0x28eb6e['\x4e\x67\x53\x50\x48'](typeof _0x2c726f[_0x71cef9(0x350)],_0x28eb6e[_0x71cef9(0x343)])?_0x2c726f[_0x71cef9(0x350)]:'',_0x2e8285=_0x28eb6e[_0x71cef9(0x28c)](_0x3d0a22,_0x28eb6e[_0x71cef9(0x1a8)])||_0x3d0a22===_0x71cef9(0x2b0)||typeof _0x2c726f[_0x71cef9(0x367)]===_0x28eb6e['\x64\x5a\x56\x4c\x57']||typeof _0x2c726f['\x63\x6f\x6d\x70\x75\x74\x65\x72\x5f\x75\x73\x65']===_0x28eb6e[_0x71cef9(0x2e6)];if(!(_0x3d0a22===_0x71cef9(0x2e4)||_0x3d0a22===_0x28eb6e[_0x71cef9(0x35e)]||typeof _0x2c726f[_0x71cef9(0x196)]==='\x6f\x62\x6a\x65\x63\x74'||typeof _0x2c726f[_0x71cef9(0x25c)]===_0x71cef9(0x2cb))&&!_0x2e8285)return null;const _0x2e0ed2=_0x2c726f['\x74\x6f\x6f\x6c\x49\x6e\x76\x6f\x63\x61\x74\x69\x6f\x6e']??_0x2c726f[_0x71cef9(0x25c)]??_0x2c726f[_0x71cef9(0x367)]??_0x2c726f['\x63\x6f\x6d\x70\x75\x74\x65\x72\x5f\x75\x73\x65']??_0x2c726f,_0x33a484=_0x28eb6e['\x76\x4b\x6c\x57\x66'](typeof _0x2e0ed2[_0x71cef9(0x1c2)],_0x28eb6e[_0x71cef9(0x343)])?_0x2e0ed2[_0x71cef9(0x1c2)]:typeof _0x2e0ed2[_0x71cef9(0x1e8)]==='\x73\x74\x72\x69\x6e\x67'?_0x2e0ed2['\x74\x6f\x6f\x6c\x5f\x63\x61\x6c\x6c\x5f\x69\x64']:typeof _0x2e0ed2['\x69\x64']===_0x28eb6e[_0x71cef9(0x343)]?_0x2e0ed2['\x69\x64']:_0x28eb6e[_0x71cef9(0x308)](typeof _0x2e0ed2[_0x71cef9(0x254)],_0x71cef9(0x33c))?_0x2e0ed2[_0x71cef9(0x254)]:'',_0x11e3c3=_0x2e8285?_0x71cef9(0x279):_0x28eb6e['\x76\x4b\x6c\x57\x66'](typeof _0x2e0ed2[_0x71cef9(0x1c1)],_0x71cef9(0x33c))?_0x2e0ed2['\x74\x6f\x6f\x6c\x4e\x61\x6d\x65']:typeof _0x2e0ed2[_0x71cef9(0x223)]==='\x73\x74\x72\x69\x6e\x67'?_0x2e0ed2[_0x71cef9(0x223)]:typeof _0x2e0ed2[_0x71cef9(0x1d6)]==='\x73\x74\x72\x69\x6e\x67'?_0x2e0ed2[_0x71cef9(0x1d6)]:'',_0x32ab4d=_0x2e0ed2[_0x71cef9(0x1d0)]??_0x2e0ed2[_0x71cef9(0x19d)]??_0x2e0ed2['\x69\x6e\x70\x75\x74']??{};if(_0x28eb6e[_0x71cef9(0x255)](!_0x33a484,!_0x11e3c3))return null;return{'\x69\x64':_0x33a484,'\x6e\x61\x6d\x65':_0x11e3c3,'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':typeof _0x32ab4d===_0x71cef9(0x33c)?_0x32ab4d:JSON['\x73\x74\x72\x69\x6e\x67\x69\x66\x79'](_0x32ab4d),'\x69\x73\x43\x6f\x6d\x70\x75\x74\x65\x72\x55\x73\x65':_0x2e8285,'\x63\x6f\x6d\x70\x75\x74\x65\x72\x41\x63\x74\x69\x6f\x6e':_0x2e8285?_0x2e0ed2['\x61\x63\x74\x69\x6f\x6e']??void 0x0:void 0x0};}function readReasoningFromPart(_0x5c57b0){const _0x3076d8=a0_0x4409d1,_0x339bd0={'\x49\x43\x6b\x77\x57':_0x3076d8(0x266),'\x66\x71\x43\x73\x66':function(_0x41e728,_0x5a5520){return _0x41e728!==_0x5a5520;},'\x65\x47\x55\x68\x70':_0x3076d8(0x216)};if(_0x5c57b0[_0x3076d8(0x350)]!==_0x339bd0['\x49\x43\x6b\x77\x57'])return null;const _0x37e7ef=_0x5c57b0['\x70\x61\x72\x74']??_0x5c57b0;if(_0x339bd0[_0x3076d8(0x2a1)](_0x37e7ef[_0x3076d8(0x350)],_0x339bd0[_0x3076d8(0x2eb)])&&_0x37e7ef['\x74\x79\x70\x65']!==_0x3076d8(0x239))return null;if(typeof _0x37e7ef['\x74\x65\x78\x74']===_0x3076d8(0x33c))return _0x37e7ef[_0x3076d8(0x244)];if(typeof _0x37e7ef[_0x3076d8(0x34f)]===_0x3076d8(0x33c))return _0x37e7ef[_0x3076d8(0x34f)];return null;}function assembleResponseOutput(_0x2b204a){const _0x1ce96a=a0_0x4409d1,_0x2eb61b={'\x6e\x6b\x4f\x69\x75':function(_0x23d326,_0x29b143){return _0x23d326===_0x29b143;},'\x64\x70\x61\x55\x77':function(_0x23f4fa,_0x2e97bf){return _0x23f4fa(_0x2e97bf);},'\x43\x70\x6c\x51\x45':_0x1ce96a(0x2b0),'\x65\x63\x44\x67\x58':_0x1ce96a(0x227),'\x6d\x55\x62\x6e\x46':_0x1ce96a(0x2c6),'\x44\x73\x50\x46\x6c':_0x1ce96a(0x266),'\x4a\x44\x69\x71\x52':_0x1ce96a(0x247),'\x70\x65\x68\x73\x4b':'\x72\x73\x5f\x30','\x6c\x52\x69\x68\x53':_0x1ce96a(0x30a)},_0x2298b7={'\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':emptyUsage(),'\x68\x61\x73\x55\x73\x61\x67\x65':![]};for(const _0x73ff0b of _0x2b204a)switch(_0x73ff0b[_0x1ce96a(0x350)]){case _0x1ce96a(0x317):{const _0x69ea97=_0x2eb61b[_0x1ce96a(0x271)](typeof _0x73ff0b[_0x1ce96a(0x29d)],_0x1ce96a(0x33c))&&_0x73ff0b[_0x1ce96a(0x29d)]||typeof _0x73ff0b[_0x1ce96a(0x244)]===_0x1ce96a(0x33c)&&_0x73ff0b[_0x1ce96a(0x244)]||typeof _0x73ff0b['\x74\x6f\x6b\x65\x6e']==='\x73\x74\x72\x69\x6e\x67'&&_0x73ff0b['\x74\x6f\x6b\x65\x6e']||'';if(_0x69ea97)_0x2298b7['\x74\x65\x78\x74\x50\x69\x65\x63\x65\x73'][_0x1ce96a(0x195)](_0x69ea97);break;}case _0x1ce96a(0x365):{const _0x2cd0d2=_0x2eb61b[_0x1ce96a(0x1c9)](readToolInvocationFromRaw,_0x73ff0b);if(!_0x2cd0d2)break;if(_0x2cd0d2[_0x1ce96a(0x2dc)])_0x2298b7[_0x1ce96a(0x1b0)]['\x70\x75\x73\x68']({'\x74\x79\x70\x65':_0x2eb61b[_0x1ce96a(0x32b)],'\x69\x64':_0x1ce96a(0x329)+_0x2cd0d2['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0x2cd0d2['\x69\x64'],'\x73\x74\x61\x74\x75\x73':_0x2eb61b[_0x1ce96a(0x2d6)],'\x70\x65\x6e\x64\x69\x6e\x67\x5f\x73\x61\x66\x65\x74\x79\x5f\x63\x68\x65\x63\x6b\x73':[],..._0x2cd0d2[_0x1ce96a(0x1e2)]?{'\x61\x63\x74\x69\x6f\x6e':_0x2cd0d2[_0x1ce96a(0x1e2)]}:{}});else{if(!_0x2298b7['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x73'][_0x1ce96a(0x20e)](_0x2cd0d2['\x69\x64']))_0x2298b7[_0x1ce96a(0x2b8)][_0x1ce96a(0x195)](_0x2cd0d2['\x69\x64']);_0x2298b7[_0x1ce96a(0x2a0)][_0x1ce96a(0x2b1)](_0x2cd0d2['\x69\x64'],{'\x74\x79\x70\x65':_0x2eb61b[_0x1ce96a(0x198)],'\x69\x64':'\x66\x63\x5f'+_0x2cd0d2['\x69\x64'],'\x63\x61\x6c\x6c\x5f\x69\x64':_0x2cd0d2['\x69\x64'],'\x6e\x61\x6d\x65':_0x2cd0d2['\x6e\x61\x6d\x65'],'\x61\x72\x67\x75\x6d\x65\x6e\x74\x73':_0x2cd0d2['\x61\x72\x67\x75\x6d\x65\x6e\x74\x73'],'\x73\x74\x61\x74\x75\x73':'\x63\x6f\x6d\x70\x6c\x65\x74\x65\x64'});}break;}case _0x2eb61b[_0x1ce96a(0x301)]:{const _0x4c0b86=readReasoningFromPart(_0x73ff0b);if(_0x4c0b86)_0x2298b7[_0x1ce96a(0x1bf)][_0x1ce96a(0x195)](_0x4c0b86);break;}case _0x2eb61b[_0x1ce96a(0x22d)]:{const _0x945fe2=readUsageFromEvent(_0x73ff0b);_0x945fe2&&(_0x2298b7[_0x1ce96a(0x269)]=foldUsage(_0x2298b7['\x75\x73\x61\x67\x65'],_0x945fe2),_0x2298b7[_0x1ce96a(0x2b4)]=!![]);break;}}const _0x87f6df=[];if(_0x2298b7[_0x1ce96a(0x1bf)]['\x6c\x65\x6e\x67\x74\x68']>0x0){const _0x3f0214={'\x74\x79\x70\x65':_0x1ce96a(0x216),'\x69\x64':_0x2eb61b['\x70\x65\x68\x73\x4b'],'\x73\x75\x6d\x6d\x61\x72\x79':[],'\x63\x6f\x6e\x74\x65\x6e\x74':_0x2298b7[_0x1ce96a(0x1bf)]['\x6d\x61\x70'](_0x4af37b=>({'\x74\x79\x70\x65':_0x1ce96a(0x19e),'\x74\x65\x78\x74':_0x4af37b})),'\x73\x74\x61\x74\x75\x73':_0x1ce96a(0x227)};_0x87f6df[_0x1ce96a(0x195)](_0x3f0214);}if(_0x2298b7['\x74\x65\x78\x74\x50\x69\x65\x63\x65\x73'][_0x1ce96a(0x28a)]>0x0){const _0x5b19ed={'\x74\x79\x70\x65':_0x2eb61b[_0x1ce96a(0x202)],'\x69\x64':_0x1ce96a(0x2fa),'\x72\x6f\x6c\x65':_0x1ce96a(0x2aa),'\x73\x74\x61\x74\x75\x73':_0x2eb61b['\x65\x63\x44\x67\x58'],'\x63\x6f\x6e\x74\x65\x6e\x74':[{'\x74\x79\x70\x65':_0x1ce96a(0x229),'\x74\x65\x78\x74':_0x2298b7[_0x1ce96a(0x341)][_0x1ce96a(0x321)](''),'\x61\x6e\x6e\x6f\x74\x61\x74\x69\x6f\x6e\x73':[]}]};_0x87f6df[_0x1ce96a(0x195)](_0x5b19ed);}for(const _0x282f5f of _0x2298b7['\x74\x6f\x6f\x6c\x43\x61\x6c\x6c\x4f\x72\x64\x65\x72']){const _0x1195df=_0x2298b7[_0x1ce96a(0x2a0)][_0x1ce96a(0x25b)](_0x282f5f);if(_0x1195df)_0x87f6df[_0x1ce96a(0x195)](_0x1195df);}for(const _0x26b35 of _0x2298b7[_0x1ce96a(0x1b0)])_0x87f6df[_0x1ce96a(0x195)](_0x26b35);return{'\x6f\x75\x74\x70\x75\x74':_0x87f6df,'\x75\x73\x61\x67\x65':_0x2298b7[_0x1ce96a(0x269)]};}function foldUsage(_0x48bda7,_0x1ec406){const _0x119a46=a0_0x4409d1,_0x29fbc1={'\x6b\x7a\x72\x45\x69':function(_0x563a98,_0x4d0707){return _0x563a98+_0x4d0707;}};return{'\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x29fbc1['\x6b\x7a\x72\x45\x69'](_0x48bda7[_0x119a46(0x1b6)],_0x1ec406['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']),'\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73':_0x48bda7['\x6f\x75\x74\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73']+_0x1ec406[_0x119a46(0x1d9)],'\x74\x6f\x74\x61\x6c\x5f\x74\x6f\x6b\x65\x6e\x73':_0x48bda7[_0x119a46(0x1d8)]+_0x1ec406[_0x119a46(0x1d8)],'\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':_0x48bda7[_0x119a46(0x315)][_0x119a46(0x293)]+_0x1ec406['\x69\x6e\x70\x75\x74\x5f\x74\x6f\x6b\x65\x6e\x73\x5f\x64\x65\x74\x61\x69\x6c\x73'][_0x119a46(0x293)]},'\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':_0x48bda7[_0x119a46(0x310)][_0x119a46(0x1f4)]+_0x1ec406[_0x119a46(0x310)][_0x119a46(0x1f4)]}};}function usageFromEvents(_0x44a68f){const _0x777dfb=a0_0x4409d1,_0x58d616={'\x72\x6e\x73\x67\x68':function(_0x2a70cd){return _0x2a70cd();},'\x51\x77\x72\x69\x63':function(_0x1a9d5b,_0x5391ee){return _0x1a9d5b(_0x5391ee);}};let _0x34f547=_0x58d616[_0x777dfb(0x21e)](emptyUsage);for(const _0x5384fd of _0x44a68f){if(_0x5384fd[_0x777dfb(0x350)]!==_0x777dfb(0x247))continue;const _0x162686=_0x58d616['\x51\x77\x72\x69\x63'](readUsageFromEvent,_0x5384fd);if(_0x162686)_0x34f547=foldUsage(_0x34f547,_0x162686);}return _0x34f547;}const SUPPORTED_TOOL_TYPES=new Set(['\x66\x75\x6e\x63\x74\x69\x6f\x6e',a0_0x4409d1(0x354),a0_0x4409d1(0x33b),a0_0x4409d1(0x200),a0_0x4409d1(0x18e),a0_0x4409d1(0x256)]),REJECTED_TOOL_TYPES=new Set([a0_0x4409d1(0x29b)]);var ResponsesValidationError=class extends Error{[a0_0x4409d1(0x350)]=a0_0x4409d1(0x2f4);[a0_0x4409d1(0x1f6)];[a0_0x4409d1(0x263)];constructor(_0xadae11,_0x5dd0aa,_0x24c36b){const _0x40ea2f=a0_0x4409d1,_0x271f94={'\x4c\x69\x47\x4c\x61':'\x52\x65\x73\x70\x6f\x6e\x73\x65\x73\x56\x61\x6c\x69\x64\x61\x74\x69\x6f\x6e\x45\x72\x72\x6f\x72'};super(_0xadae11),this['\x6e\x61\x6d\x65']=_0x271f94[_0x40ea2f(0x2d9)],this['\x63\x6f\x64\x65']=_0x5dd0aa,this['\x70\x61\x72\x61\x6d']=_0x24c36b;}};function validateResponsesRequest(_0x13c77a){const _0xb0fb81=a0_0x4409d1,_0x360971={'\x66\x6f\x77\x47\x66':function(_0xc2551a,_0x2e6990){return _0xc2551a===_0x2e6990;},'\x6a\x78\x56\x46\x4c':function(_0x317d0a,_0x2bc476){return _0x317d0a<_0x2bc476;},'\x6a\x78\x52\x4f\x72':function(_0x1587f3,_0x2cf345){return _0x1587f3!==_0x2cf345;},'\x49\x6b\x6b\x48\x45':'\x69\x6e\x76\x61\x6c\x69\x64\x5f\x74\x6f\x6f\x6c','\x4f\x4d\x4d\x6a\x7a':_0xb0fb81(0x211)},_0x35a9a8=_0x13c77a[_0xb0fb81(0x201)];if(!_0x35a9a8||_0x360971[_0xb0fb81(0x23c)](_0x35a9a8['\x6c\x65\x6e\x67\x74\x68'],0x0))return;for(let _0x4fdad8=0x0;_0x360971['\x6a\x78\x56\x46\x4c'](_0x4fdad8,_0x35a9a8['\x6c\x65\x6e\x67\x74\x68']);_0x4fdad8++){const _0x1d2139=_0x35a9a8[_0x4fdad8]['\x74\x79\x70\x65'];if(_0x360971[_0xb0fb81(0x1fb)](typeof _0x1d2139,_0xb0fb81(0x33c)))throw new ResponsesValidationError(_0xb0fb81(0x2f6)+_0x4fdad8+'\x5d\x20\x69\x73\x20\x6d\x69\x73\x73\x69\x6e\x67\x20\x61\x20\x74\x79\x70\x65\x20\x64\x69\x73\x63\x72\x69\x6d\x69\x6e\x61\x74\x6f\x72',_0x360971['\x49\x6b\x6b\x48\x45'],_0xb0fb81(0x2f6)+_0x4fdad8+_0xb0fb81(0x297));if(REJECTED_TOOL_TYPES['\x68\x61\x73'](_0x1d2139))throw new ResponsesValidationError(_0xb0fb81(0x1bb)+_0x1d2139+_0xb0fb81(0x2db),_0xb0fb81(0x211),'\x74\x6f\x6f\x6c\x73\x5b'+_0x4fdad8+_0xb0fb81(0x297));if(!SUPPORTED_TOOL_TYPES[_0xb0fb81(0x20e)](_0x1d2139))throw new ResponsesValidationError(_0xb0fb81(0x1bb)+_0x1d2139+_0xb0fb81(0x2af),_0x360971[_0xb0fb81(0x1c8)],_0xb0fb81(0x2f6)+_0x4fdad8+'\x5d\x2e\x74\x79\x70\x65');}}function normalizeResponsesWebSearchForTangleRouter(_0x401146,_0x2491bf={}){const _0x144bd9=a0_0x4409d1,_0xf58fc5={'\x70\x6b\x71\x48\x78':function(_0x4e2784,_0x3a1400){return _0x4e2784!==_0x3a1400;},'\x41\x42\x4d\x59\x52':_0x144bd9(0x18e),'\x47\x74\x61\x78\x50':'\x6f\x70\x65\x6e\x72\x6f\x75\x74\x65\x72\x3a\x77\x65\x62\x5f\x73\x65\x61\x72\x63\x68'},_0x623eb8=Array[_0x144bd9(0x1cf)](_0x401146[_0x144bd9(0x201)])?_0x401146[_0x144bd9(0x201)]:void 0x0;if(!_0x623eb8)return _0x401146;let _0x140b81=![];const _0x1cbc84=_0x623eb8[_0x144bd9(0x1b9)](_0x41b57a=>{const _0x3d5b27=_0x144bd9;if(!_0x41b57a||typeof _0x41b57a!==_0x3d5b27(0x2cb))return _0x41b57a;const _0x3f737b=_0x41b57a[_0x3d5b27(0x350)];if(_0x3f737b!==_0x3d5b27(0x200)&&_0xf58fc5['\x70\x6b\x71\x48\x78'](_0x3f737b,_0xf58fc5[_0x3d5b27(0x262)]))return _0x41b57a;return _0x140b81=!![],{'\x74\x79\x70\x65':_0xf58fc5[_0x3d5b27(0x272)],'\x70\x61\x72\x61\x6d\x65\x74\x65\x72\x73':{...readNativeWebSearchParameters(_0x41b57a),..._0x2491bf['\x70\x72\x6f\x76\x69\x64\x65\x72']?{'\x70\x72\x6f\x76\x69\x64\x65\x72':_0x2491bf[_0x3d5b27(0x238)]}:{},..._0x2491bf[_0x3d5b27(0x2ed)]?{'\x6d\x61\x78\x5f\x72\x65\x73\x75\x6c\x74\x73':_0x2491bf[_0x3d5b27(0x2ed)]}:{},..._0x2491bf['\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':_0x2491bf['\x6d\x61\x78\x54\x6f\x74\x61\x6c\x52\x65\x73\x75\x6c\x74\x73']}:{},..._0x2491bf[_0x3d5b27(0x1a9)]?{'\x73\x65\x61\x72\x63\x68\x5f\x63\x6f\x6e\x74\x65\x78\x74\x5f\x73\x69\x7a\x65':_0x2491bf[_0x3d5b27(0x1a9)]}:{}}};});return _0x140b81?{..._0x401146,'\x74\x6f\x6f\x6c\x73':_0x1cbc84}:_0x401146;}function readNativeWebSearchParameters(_0x503c2b){const _0x4c4a8b=a0_0x4409d1,_0x3f25ef={'\x42\x61\x48\x57\x71':function(_0xc1e7e1,_0x169435){return _0xc1e7e1===_0x169435;},'\x6b\x68\x7a\x59\x57':_0x4c4a8b(0x219)},_0x308b19=_0x503c2b,_0x391be7={},_0x291d9e=_0x308b19[_0x4c4a8b(0x363)]??_0x308b19[_0x4c4a8b(0x1a9)];if(_0x3f25ef[_0x4c4a8b(0x1b4)](_0x291d9e,'\x6c\x6f\x77')||_0x3f25ef['\x42\x61\x48\x57\x71'](_0x291d9e,_0x3f25ef['\x6b\x68\x7a\x59\x57'])||_0x291d9e==='\x68\x69\x67\x68')_0x391be7[_0x4c4a8b(0x363)]=_0x291d9e;const _0x187f4d=_0x308b19[_0x4c4a8b(0x31e)]??_0x308b19[_0x4c4a8b(0x1ac)];if(_0x187f4d&&typeof _0x187f4d===_0x4c4a8b(0x2cb))_0x391be7[_0x4c4a8b(0x31e)]=_0x187f4d;return _0x391be7;}function buildResponseShell(_0xa6cf83){const _0x21ee34=a0_0x4409d1,_0x384153={'\x6c\x57\x55\x7a\x67':_0x21ee34(0x2e1)},_0x395c9b=_0xa6cf83[_0x21ee34(0x236)][_0x21ee34(0x197)](_0x4a9dd2=>_0x4a9dd2['\x74\x79\x70\x65']==='\x6d\x65\x73\x73\x61\x67\x65')[_0x21ee34(0x31f)](_0x4b8362=>_0x4b8362[_0x21ee34(0x34f)])[_0x21ee34(0x197)](_0x18d2d6=>_0x18d2d6[_0x21ee34(0x350)]===_0x21ee34(0x229))[_0x21ee34(0x1b9)](_0x5e4286=>_0x5e4286[_0x21ee34(0x244)])[_0x21ee34(0x321)]('');return{'\x69\x64':_0xa6cf83['\x69\x64'],'\x6f\x62\x6a\x65\x63\x74':_0x384153[_0x21ee34(0x1eb)],'\x63\x72\x65\x61\x74\x65\x64\x5f\x61\x74':_0xa6cf83['\x63\x72\x65\x61\x74\x65\x64\x41\x74'],'\x6f\x75\x74\x70\x75\x74\x5f\x74\x65\x78\x74':_0x395c9b,'\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':_0xa6cf83['\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':_0xa6cf83[_0x21ee34(0x1ca)],'\x6f\x75\x74\x70\x75\x74':_0xa6cf83['\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':_0x21ee34(0x305),'\x74\x6f\x6f\x6c\x73':[],'\x74\x6f\x70\x5f\x70':null,'\x73\x74\x61\x74\x75\x73':_0x21ee34(0x227),'\x75\x73\x61\x67\x65':_0xa6cf83['\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':_0xa6cf83['\x70\x72\x65\x76\x69\x6f\x75\x73\x52\x65\x73\x70\x6f\x6e\x73\x65\x49\x64']??null};}function createTranslatorContext(_0x128324){const _0x55f36b=a0_0x4409d1,_0x2f6ef1={'\x54\x7a\x41\x61\x65':function(_0x443df1,_0x569ae7){return _0x443df1/_0x569ae7;}};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[_0x55f36b(0x1e4)](_0x2f6ef1[_0x55f36b(0x25d)](Date[_0x55f36b(0x250)](),0x3e8)),..._0x128324};}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 };
|