@treasuredata/tdx 0.2.2 → 0.2.3

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.
Files changed (85) hide show
  1. package/dist/build-info.json +2 -2
  2. package/dist/cli.js +1 -1
  3. package/dist/client/cdp-client.js +1 -1
  4. package/dist/client/http-client.js +1 -1
  5. package/dist/client/llm-client.js +1 -1
  6. package/dist/client/rate-limiter.js +1 -1
  7. package/dist/client/td-client.js +1 -1
  8. package/dist/client/trino-client.js +1 -1
  9. package/dist/client/workflow-client.js +1 -1
  10. package/dist/commands/activations.js +1 -1
  11. package/dist/commands/api-command.js +1 -1
  12. package/dist/commands/chat-command.js +1 -1
  13. package/dist/commands/claude-command.js +1 -1
  14. package/dist/commands/command.js +1 -1
  15. package/dist/commands/context-command.js +1 -1
  16. package/dist/commands/databases.js +1 -1
  17. package/dist/commands/describe.js +1 -1
  18. package/dist/commands/job-command.js +1 -1
  19. package/dist/commands/llm-command.js +1 -1
  20. package/dist/commands/llm-proxy.js +1 -1
  21. package/dist/commands/parent-segment-command.js +1 -1
  22. package/dist/commands/profiles-command.js +1 -1
  23. package/dist/commands/query-command.js +1 -1
  24. package/dist/commands/segment-command.js +1 -1
  25. package/dist/commands/segment-create-command.js +1 -1
  26. package/dist/commands/segment-fields-command.js +1 -1
  27. package/dist/commands/segment-pwd-command.js +1 -1
  28. package/dist/commands/segment-update-command.js +1 -1
  29. package/dist/commands/segment-use-command.js +1 -1
  30. package/dist/commands/segments.js +1 -1
  31. package/dist/commands/show.js +1 -1
  32. package/dist/commands/tables.js +1 -1
  33. package/dist/commands/use-command.js +1 -1
  34. package/dist/commands/workflow-command.js +1 -1
  35. package/dist/core/auth.js +1 -1
  36. package/dist/core/config.js +1 -1
  37. package/dist/core/global-context.js +1 -1
  38. package/dist/core/profile.js +1 -1
  39. package/dist/core/project-config.js +1 -1
  40. package/dist/core/session.js +1 -1
  41. package/dist/index.js +1 -1
  42. package/dist/proxy/anthropic-adapter.d.ts +8 -0
  43. package/dist/proxy/anthropic-adapter.d.ts.map +1 -1
  44. package/dist/proxy/anthropic-adapter.js +1 -1
  45. package/dist/proxy/anthropic-adapter.js.map +1 -1
  46. package/dist/proxy/server.js +1 -1
  47. package/dist/proxy/session-cache.js +1 -1
  48. package/dist/sdk/api.js +1 -1
  49. package/dist/sdk/database.js +1 -1
  50. package/dist/sdk/errors.js +1 -1
  51. package/dist/sdk/index.js +1 -1
  52. package/dist/sdk/job.js +1 -1
  53. package/dist/sdk/llm.js +1 -1
  54. package/dist/sdk/query.js +1 -1
  55. package/dist/sdk/segment.js +1 -1
  56. package/dist/sdk/table.js +1 -1
  57. package/dist/sdk/workflow.js +1 -1
  58. package/dist/types/endpoints.js +1 -1
  59. package/dist/types/index.js +1 -1
  60. package/dist/utils/agent-ref-parser.js +1 -1
  61. package/dist/utils/chat-cache.js +1 -1
  62. package/dist/utils/colors.js +1 -1
  63. package/dist/utils/command-output.js +1 -1
  64. package/dist/utils/constants.js +1 -1
  65. package/dist/utils/file-permissions.js +1 -1
  66. package/dist/utils/format-detector.js +1 -1
  67. package/dist/utils/formatters.js +1 -1
  68. package/dist/utils/json-loader.js +1 -1
  69. package/dist/utils/model-aliases.js +1 -1
  70. package/dist/utils/option-validation.js +1 -1
  71. package/dist/utils/port.js +1 -1
  72. package/dist/utils/process.js +1 -1
  73. package/dist/utils/prompt.js +1 -1
  74. package/dist/utils/segment-path-parser.js +1 -1
  75. package/dist/utils/segment-ref-parser.js +1 -1
  76. package/dist/utils/spinner.js +1 -1
  77. package/dist/utils/sql-parser.js +1 -1
  78. package/dist/utils/sse-parser.js +1 -1
  79. package/dist/utils/string-utils.js +1 -1
  80. package/dist/utils/table-ref-parser.js +1 -1
  81. package/dist/utils/tdx-logger.js +1 -1
  82. package/dist/utils/tree-formatter.js +1 -1
  83. package/dist/utils/version-check.js +1 -1
  84. package/dist/utils/workflow-utils.js +1 -1
  85. package/package.json +1 -1
@@ -1 +1 @@
1
- const a41_0x1b1a7b=a41_0x1430;(function(_0x66a754,_0xd152d1){const _0x2bef67=a41_0x1430,_0xb66cd=_0x66a754();while(!![]){try{const _0x127d87=-parseInt(_0x2bef67(0x25f))/0x1*(-parseInt(_0x2bef67(0x1ee))/0x2)+-parseInt(_0x2bef67(0x233))/0x3+parseInt(_0x2bef67(0x214))/0x4+parseInt(_0x2bef67(0x26c))/0x5*(parseInt(_0x2bef67(0x1d5))/0x6)+-parseInt(_0x2bef67(0x1ef))/0x7*(-parseInt(_0x2bef67(0x1db))/0x8)+-parseInt(_0x2bef67(0x1e0))/0x9+-parseInt(_0x2bef67(0x200))/0xa;if(_0x127d87===_0xd152d1)break;else _0xb66cd['push'](_0xb66cd['shift']());}catch(_0x38270f){_0xb66cd['push'](_0xb66cd['shift']());}}}(a41_0x1f5b,0xcd1e7));import a41_0x191c51 from'fastify';import a41_0x5c5ff8 from'@fastify/cors';function a41_0x1430(_0x28d4db,_0x46aa49){const _0x1f5b50=a41_0x1f5b();return a41_0x1430=function(_0x143023,_0x16a192){_0x143023=_0x143023-0x1be;let _0x437f7a=_0x1f5b50[_0x143023];return _0x437f7a;},a41_0x1430(_0x28d4db,_0x46aa49);}import{createHash}from'crypto';import{transformTDStreamWithToolDetection,formatAnthropicSSE,generateMessageId,generateToolPrompt,extractToolResults,estimateInputTokensFromRequest}from'./anthropic-adapter.js';import{colorizeJSON,colorizeJSONCompact}from'../utils/colors.js';import{extractModelAlias,resolveModelAlias}from'../utils/model-aliases.js';import{SessionCache}from'./session-cache.js';function formatConversationHistory(_0x183c14){const _0x542f3a=a41_0x1430;if(!_0x183c14||!Array[_0x542f3a(0x249)](_0x183c14))return'';return _0x183c14[_0x542f3a(0x1c4)](_0x35e4c9=>_0x35e4c9!=null)[_0x542f3a(0x213)](_0x4c1569=>{const _0x4cb439=_0x542f3a,_0x3c3ad1=_0x4c1569[_0x4cb439(0x1ea)]!=null&&Array[_0x4cb439(0x249)](_0x4c1569[_0x4cb439(0x1ea)])?_0x4c1569[_0x4cb439(0x1ea)][_0x4cb439(0x1c4)](_0x20f4a3=>_0x20f4a3&&_0x20f4a3[_0x4cb439(0x25c)]==='text')[_0x4cb439(0x213)](_0x4c26fd=>_0x4c26fd[_0x4cb439(0x1d2)])[_0x4cb439(0x223)]('\x0a'):_0x4c1569['content']||'',_0x27e12d=_0x4c1569[_0x4cb439(0x251)]===_0x4cb439(0x252)?'User':_0x4cb439(0x1d6);return _0x27e12d+':\x20'+_0x3c3ad1;})[_0x542f3a(0x223)]('\x0a\x0a');}function calculateContextSignature(_0x120f6e,_0x35d18d,_0x41351f){const _0x145b66=a41_0x1430,_0x3e904d=extractModelAlias(_0x120f6e),_0x201733=resolveModelAlias(_0x3e904d),_0x28b3a1=[..._0x35d18d||[]][_0x145b66(0x1df)](),_0x3dd784=(_0x41351f||[])[_0x145b66(0x1c4)](_0x4de78b=>_0x4de78b!=null)[_0x145b66(0x213)](_0x1f369f=>({'name':_0x1f369f['name'],'params':Object[_0x145b66(0x228)](_0x1f369f[_0x145b66(0x24a)]?.[_0x145b66(0x232)]||{})[_0x145b66(0x1df)](),'required':(_0x1f369f[_0x145b66(0x24a)]?.[_0x145b66(0x263)]||[])[_0x145b66(0x1df)]()}))[_0x145b66(0x1df)]((_0x423c63,_0x4339e6)=>_0x423c63['name']['localeCompare'](_0x4339e6[_0x145b66(0x246)])),_0x4739ef=JSON[_0x145b66(0x25a)]({'model':_0x201733,'prompts':_0x28b3a1,'tools':_0x3dd784});return createHash(_0x145b66(0x25e))[_0x145b66(0x248)](_0x4739ef)[_0x145b66(0x1c1)](_0x145b66(0x1fa))[_0x145b66(0x1fc)](0x0,0x10);}const MAX_CHATS_PER_SESSION=0xa,CACHE_EXPIRATION_MS=0xa*0x3c*0x3e8,CLEANUP_INTERVAL_MS=0x3c*0x3e8;function a41_0x1f5b(){const _0x34ae89=['\x20for\x20context:\x20','end','projectId','string','address','[PROXY\x20ERROR]\x20Validation\x20failed:\x20messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','method','text','\x20system\x20prompts,\x20','POST','216XSMjQW','Assistant','default','tools','sessionCache','Chat\x20creation\x20failed,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','2936mGdvEh','embeddedSystemPrompts','Agent\x20cached:\x20',',\x20model=','sort','3500640uIOaQx','push','event','llm','Created\x20a\x20new\x20chat\x20id:\x20','added\x20tools:','messageHistory','listen','New\x20context\x20-\x20including\x20full\x20context','register','content','\x0a---\x0a\x0a','add','Reset\x20chat\x20state\x20to\x20recover\x20on\x20next\x20request','875054oIkSkX','3290pxQJMH','Unknown\x20error','url','\x20SSE\x20events.','Started\x20cache\x20cleanup\x20interval\x20(runs\x20every\x20','delete','invalid_request_error','[Previous\x20conversation]\x0a\x0a<conversation>\x0a','info','new\x20system\x20prompt(s)','body','hex','\x20|\x20','substring','getOrCreateSession','debug','getAgentForModel','18224960XgKSBZ','Debug\x20info:','Added\x20system\x20prompt\x20previews:','api_error','startChat','cleanupExpiredChats','Failed\x20to\x20reconstruct\x20message\x20-\x20all\x20parts\x20are\x20empty,\x20using\x20fallback','warn','message','[PROXY\x20ERROR]\x20Streaming\x20error:','new\x20tool(s)','chatId','stop','[PROXY\x20ERROR]\x20Chat\x20stream\x20is\x20undefined','/health','post','Created\x20new\x20chat:\x20','Authorization','getOrCreateDefaultAgent','map','4624184cjFKMq','send','Model\x20normalization:\x20','clear','size','metadata','system','chats','Model:','raw','Failed\x20to\x20initialize\x20chat\x20stream.\x20Please\x20try\x20again.',':\x20messages=','attributes','Including\x20tool\x20results','OPTIONS','join','now',':\x20estimated\x20input_tokens=','trim','slice','keys','has','length','code','agentId','chat','handleCountTokens','get','Project\x20ID\x20must\x20be\x20configured','Final\x20message\x20reconstructed\x20after\x20context\x20reset:','properties','1055700ohvmCg','messages',')\x20to\x20stay\x20under\x20','server','port','pop','Using\x20agent:\x20','Creating/looking\x20up\x20agent\x20for:\x20','Added\x20system\x20prompts:','error','model','[PROXY\x20ERROR]\x20Uncaught\x20error\x20in\x20','[PROXY\x20ERROR]\x20Validation\x20failed:\x20message.content\x20must\x20be\x20a\x20string\x20or\x20array,\x20got:','handleRouteError','handleMessages','write','setupRoutes','[PROXY\x20ERROR]\x20Configuration\x20error:\x20Project\x20ID\x20must\x20be\x20configured','start','name','set','update','isArray','input_schema','[PROXY\x20ERROR]\x20Validation\x20failed:\x20tools\x20must\x20be\x20an\x20array\x20if\x20provided','Session\x20ID:','\x20->\x20','writeHead','data','Context:','role','user','catch','cleanupInterval','Session:','0.0.0.0','config','GET','[Current\x20message]\x0a\x0a','stringify','\x20(model:\x20','type','sent','sha256','1qjuoii','/v1/messages','not_supported_error','no-cache','required','continue','embeddedToolsByName','message.content\x20must\x20be\x20a\x20string\x20or\x20array','trace','setErrorHandler','logger','x-api-key','agentCache','227425AiQuYu','tools:','Context\x20signature:','text/event-stream','tools\x20must\x20be\x20an\x20array\x20if\x20provided','No\x20user\x20message\x20found\x20in\x20request','digest','http://localhost:','header:\x20','filter','/v1/messages/count_tokens','Failed\x20to\x20extract\x20tool\x20results:','\x0a</conversation>','tdx','http://','lastUsedAt'];a41_0x1f5b=function(){return _0x34ae89;};return a41_0x1f5b();}export class ProxyServer{[a41_0x1b1a7b(0x236)];[a41_0x1b1a7b(0x1d9)];[a41_0x1b1a7b(0x26b)];[a41_0x1b1a7b(0x257)];[a41_0x1b1a7b(0x254)];['logger'];constructor(_0x2df400){const _0x2b64da=a41_0x1b1a7b;this[_0x2b64da(0x269)]=_0x2df400[_0x2b64da(0x269)],this[_0x2b64da(0x257)]=_0x2df400,this[_0x2b64da(0x1d9)]=new SessionCache({'maxChatsPerSession':MAX_CHATS_PER_SESSION,'cacheExpirationMs':CACHE_EXPIRATION_MS}),this[_0x2b64da(0x26b)]=new Map(),this[_0x2b64da(0x236)]=a41_0x191c51({'logger':![],'bodyLimit':0x40*0x400*0x400}),this['setupMiddleware'](),this[_0x2b64da(0x243)]();}async[a41_0x1b1a7b(0x1ff)](_0x22a5fe){const _0x24e211=a41_0x1b1a7b,_0x1e3a5a=extractModelAlias(_0x22a5fe),_0x4a869f=resolveModelAlias(_0x1e3a5a);let _0x1e6b8e=this['agentCache'][_0x24e211(0x22f)](_0x4a869f);if(!_0x1e6b8e){this[_0x24e211(0x269)][_0x24e211(0x1fe)](_0x24e211(0x216)+_0x22a5fe+_0x24e211(0x24d)+_0x1e3a5a+_0x24e211(0x24d)+_0x4a869f),this['logger'][_0x24e211(0x1fe)](_0x24e211(0x23a)+_0x4a869f);const _0x4d7bb7=await this[_0x24e211(0x257)][_0x24e211(0x1c8)]['llm'][_0x24e211(0x212)](_0x4a869f);_0x1e6b8e=_0x4d7bb7['id'],this[_0x24e211(0x26b)][_0x24e211(0x247)](_0x4a869f,_0x1e6b8e),this[_0x24e211(0x269)][_0x24e211(0x1fe)](_0x24e211(0x1dd)+_0x4a869f+_0x24e211(0x24d)+_0x1e6b8e+'\x20('+_0x4d7bb7[_0x24e211(0x220)][_0x24e211(0x246)]+')');}return _0x1e6b8e;}[a41_0x1b1a7b(0x205)](){const _0x5e73d0=a41_0x1b1a7b;this[_0x5e73d0(0x1d9)][_0x5e73d0(0x205)]();}['setupMiddleware'](){const _0x28cad3=a41_0x1b1a7b;this[_0x28cad3(0x236)][_0x28cad3(0x1e9)](a41_0x5c5ff8,{'origin':!![],'methods':[_0x28cad3(0x258),_0x28cad3(0x1d4),_0x28cad3(0x222)],'allowedHeaders':['Content-Type',_0x28cad3(0x211),'anthropic-version',_0x28cad3(0x26a)]}),this[_0x28cad3(0x236)][_0x28cad3(0x268)]((_0x10db25,_0x5a8a32,_0x234bbe)=>{const _0xf5294e=_0x28cad3,_0xefb4a5=_0x10db25 instanceof Error?_0x10db25[_0xf5294e(0x208)]:'Unknown\x20error';this[_0xf5294e(0x269)][_0xf5294e(0x23c)]('[PROXY\x20ERROR]\x20Unhandled\x20error\x20in\x20'+_0x5a8a32[_0xf5294e(0x1d1)]+'\x20'+_0x5a8a32[_0xf5294e(0x1f1)]+':',_0x10db25),_0x234bbe['code'](0x1f4)['send']({'type':_0xf5294e(0x23c),'error':{'type':'api_error','message':_0xefb4a5}});});}[a41_0x1b1a7b(0x240)](_0x11d0c2,_0x34bebd,_0x1d1199){const _0x2919cf=a41_0x1b1a7b,_0x237241=_0x34bebd instanceof Error?_0x34bebd[_0x2919cf(0x208)]:_0x2919cf(0x1f0);this[_0x2919cf(0x269)]['error'](_0x2919cf(0x23e)+_0x11d0c2+':',_0x34bebd),!_0x1d1199[_0x2919cf(0x25d)]&&_0x1d1199[_0x2919cf(0x22b)](0x1f4)[_0x2919cf(0x215)]({'type':_0x2919cf(0x23c),'error':{'type':_0x2919cf(0x203),'message':_0x237241}});}[a41_0x1b1a7b(0x243)](){const _0x38dfa4=a41_0x1b1a7b;this[_0x38dfa4(0x236)][_0x38dfa4(0x22f)](_0x38dfa4(0x20e),async()=>{return{'status':'ok','message':'TD\x20LLM\x20Proxy\x20Server'};}),this['server'][_0x38dfa4(0x20f)](_0x38dfa4(0x260),async(_0x366dd5,_0x10feb6)=>{const _0x9d35c9=_0x38dfa4;return this[_0x9d35c9(0x241)](_0x366dd5,_0x10feb6)[_0x9d35c9(0x253)](_0x1edfa4=>{const _0x2965e3=_0x9d35c9;this['handleRouteError'](_0x2965e3(0x260),_0x1edfa4,_0x10feb6);});}),this['server']['post'](_0x38dfa4(0x1c5),async(_0x401aba,_0x3815dc)=>{const _0x4fc122=_0x38dfa4;return this[_0x4fc122(0x22e)](_0x401aba)[_0x4fc122(0x253)](_0x5e7ee0=>{this['handleRouteError']('/v1/messages/count_tokens',_0x5e7ee0,_0x3815dc);});});}async[a41_0x1b1a7b(0x241)](_0x412a29,_0x5ba7b1){const _0x4e0306=a41_0x1b1a7b,_0x13c1c1=_0x412a29[_0x4e0306(0x1f9)];if(!_0x13c1c1[_0x4e0306(0x234)]||!Array[_0x4e0306(0x249)](_0x13c1c1[_0x4e0306(0x234)])||_0x13c1c1['messages']['length']===0x0){this['logger'][_0x4e0306(0x23c)](_0x4e0306(0x1d0)),_0x5ba7b1[_0x4e0306(0x22b)](0x190)[_0x4e0306(0x215)]({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x1f5),'message':'messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty'}});return;}if(_0x13c1c1[_0x4e0306(0x1d8)]&&!Array[_0x4e0306(0x249)](_0x13c1c1[_0x4e0306(0x1d8)])){this['logger'][_0x4e0306(0x23c)](_0x4e0306(0x24b)),_0x5ba7b1[_0x4e0306(0x22b)](0x190)['send']({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x1f5),'message':_0x4e0306(0x1bf)}});return;}const _0x5d1e36=_0x13c1c1['messages']?.[_0x4e0306(0x22a)]??0x0,_0x386d2f=_0x13c1c1['model']||'unknown';this[_0x4e0306(0x269)]['info'](_0x412a29[_0x4e0306(0x1d1)]+'\x20'+_0x412a29[_0x4e0306(0x1f1)]+_0x4e0306(0x21f)+_0x5d1e36+_0x4e0306(0x1de)+_0x386d2f),this['logger'][_0x4e0306(0x1fe)](_0x4e0306(0x1c3)+colorizeJSONCompact(_0x412a29['headers']));this[_0x4e0306(0x269)]['trace']&&this[_0x4e0306(0x269)][_0x4e0306(0x267)](colorizeJSON(_0x13c1c1,{'color':!![]}));const _0x5077d6=_0x13c1c1[_0x4e0306(0x219)]?.['user_id']||_0x4e0306(0x1d7);this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x24c),_0x5077d6);const _0x1316fa=this[_0x4e0306(0x257)][_0x4e0306(0x1cd)];if(!_0x1316fa){this[_0x4e0306(0x269)]['error'](_0x4e0306(0x244)),_0x5ba7b1[_0x4e0306(0x22b)](0x1f4)[_0x4e0306(0x215)]({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x203),'message':_0x4e0306(0x230)}});return;}const _0x746613=this[_0x4e0306(0x1d9)][_0x4e0306(0x1fd)](_0x5077d6,_0x1316fa),_0x3d87ac=_0x746613[_0x4e0306(0x1e6)]['length'],_0x5d0dd2=_0x13c1c1['messages'][_0x4e0306(0x227)](_0x3d87ac);let _0x10a209=_0x5d0dd2[_0x4e0306(0x1c4)](_0x19fe53=>_0x19fe53[_0x4e0306(0x251)]===_0x4e0306(0x252))[_0x4e0306(0x238)]();if(!_0x10a209){_0x10a209=_0x13c1c1['messages'][_0x4e0306(0x1c4)](_0x4e49bd=>_0x4e49bd[_0x4e0306(0x251)]==='user')[_0x4e0306(0x238)]();if(!_0x10a209){this['logger'][_0x4e0306(0x23c)]('[PROXY\x20ERROR]\x20Validation\x20failed:\x20No\x20user\x20message\x20found\x20in\x20request'),_0x5ba7b1[_0x4e0306(0x22b)](0x190)[_0x4e0306(0x215)]({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x1f5),'message':_0x4e0306(0x1c0)}});return;}}let _0x50f743;if(typeof _0x10a209['content']===_0x4e0306(0x1ce))_0x50f743=_0x10a209[_0x4e0306(0x1ea)];else{if(_0x10a209[_0x4e0306(0x1ea)]!=null&&Array['isArray'](_0x10a209[_0x4e0306(0x1ea)]))_0x50f743=_0x10a209['content'][_0x4e0306(0x1c4)](_0x157720=>_0x157720&&_0x157720[_0x4e0306(0x25c)]===_0x4e0306(0x1d2)&&_0x157720[_0x4e0306(0x1d2)])['map'](_0x31d123=>_0x31d123[_0x4e0306(0x1d2)])[_0x4e0306(0x223)]('\x0a');else{this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x23f),typeof _0x10a209['content'],_0x10a209['content']),_0x5ba7b1[_0x4e0306(0x22b)](0x190)['send']({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x1f5),'message':_0x4e0306(0x266)}});return;}}const _0x1c1c3e=[];if(_0x13c1c1['system']){if(typeof _0x13c1c1[_0x4e0306(0x21a)]===_0x4e0306(0x1ce))_0x1c1c3e[_0x4e0306(0x1e1)](_0x13c1c1['system']);else{if(Array[_0x4e0306(0x249)](_0x13c1c1[_0x4e0306(0x21a)]))for(const _0x3193f0 of _0x13c1c1[_0x4e0306(0x21a)]){_0x3193f0[_0x4e0306(0x25c)]===_0x4e0306(0x1d2)&&_0x3193f0[_0x4e0306(0x1d2)]&&_0x1c1c3e[_0x4e0306(0x1e1)](_0x3193f0[_0x4e0306(0x1d2)]);}}}const _0x8f85d0=_0x13c1c1['tools']||[],_0x313e6e=calculateContextSignature(_0x13c1c1[_0x4e0306(0x23d)],_0x1c1c3e,_0x8f85d0);let _0x5c929c=_0x746613['chats'][_0x4e0306(0x22f)](_0x313e6e);const _0x378845=!_0x5c929c;if(!_0x5c929c){const _0x417136=await this['getAgentForModel'](_0x13c1c1[_0x4e0306(0x23d)]);_0x5c929c={'chatId':'','agentId':_0x417136,'contextSignature':_0x313e6e,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'lastUsedAt':Date[_0x4e0306(0x224)]()},_0x746613['chats'][_0x4e0306(0x247)](_0x313e6e,_0x5c929c);if(_0x746613[_0x4e0306(0x21b)]['size']>MAX_CHATS_PER_SESSION){let _0x50afde=null,_0xf4a6c8=Date[_0x4e0306(0x224)]();for(const [_0x1ffacd,_0x4b60a2]of _0x746613['chats']){_0x4b60a2[_0x4e0306(0x1ca)]<_0xf4a6c8&&(_0xf4a6c8=_0x4b60a2[_0x4e0306(0x1ca)],_0x50afde=_0x1ffacd);}_0x50afde&&(_0x746613['chats'][_0x4e0306(0x1f4)](_0x50afde),this['logger']['debug']('Evicted\x20oldest\x20chat\x20(signature:\x20'+_0x50afde+_0x4e0306(0x235)+MAX_CHATS_PER_SESSION+'\x20limit'));}}else _0x5c929c[_0x4e0306(0x1ca)]=Date[_0x4e0306(0x224)]();if(!_0x5c929c['chatId'])try{const _0xe67fb9=await this['config'][_0x4e0306(0x1c8)][_0x4e0306(0x1e3)][_0x4e0306(0x204)](_0x5c929c[_0x4e0306(0x22c)]);_0x5c929c[_0x4e0306(0x20b)]=_0xe67fb9['id'],this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x210)+_0xe67fb9['id']+_0x4e0306(0x1cb)+_0x313e6e),this[_0x4e0306(0x269)]['debug'](_0x4e0306(0x239)+_0x5c929c['agentId']+_0x4e0306(0x25b)+_0x13c1c1[_0x4e0306(0x23d)]+')');}catch(_0x471f27){this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x1da),_0x471f27);}const _0x572390=_0x1c1c3e[_0x4e0306(0x1c4)](_0x26ddff=>!_0x5c929c['embeddedSystemPrompts'][_0x4e0306(0x229)](_0x26ddff)),_0x3f0f49=_0x8f85d0['filter'](_0x41d0d3=>!_0x5c929c['embeddedToolsByName'][_0x4e0306(0x229)](_0x41d0d3[_0x4e0306(0x246)]));this[_0x4e0306(0x269)]['debug'](_0x4e0306(0x255),_0x5077d6),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x21c),_0x13c1c1[_0x4e0306(0x23d)]),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x26e),_0x313e6e),this['logger']['debug']('Is\x20new\x20context:',_0x378845),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)]('Chat\x20ID:',_0x5c929c[_0x4e0306(0x20b)]),this['logger']['debug']('Current\x20request\x20-\x20system\x20prompts:',_0x1c1c3e['length'],_0x4e0306(0x26d),_0x8f85d0['length']),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)]('Embedded\x20in\x20chat\x20-\x20system\x20prompts:',_0x5c929c[_0x4e0306(0x1dc)][_0x4e0306(0x218)],'tools:',_0x5c929c[_0x4e0306(0x265)]['size']),this['logger'][_0x4e0306(0x1fe)](_0x4e0306(0x23b),_0x572390[_0x4e0306(0x22a)],_0x4e0306(0x1e5),_0x3f0f49[_0x4e0306(0x22a)]);_0x572390['length']>0x0&&this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x202),_0x572390[_0x4e0306(0x213)](_0x4b0000=>_0x4b0000[_0x4e0306(0x1fc)](0x0,0x32)+'...')[_0x4e0306(0x223)](_0x4e0306(0x1fb)));_0x3f0f49['length']>0x0&&this[_0x4e0306(0x269)][_0x4e0306(0x1fe)]('Added\x20tool\x20names:',_0x3f0f49[_0x4e0306(0x213)](_0xde64fb=>_0xde64fb[_0x4e0306(0x246)])[_0x4e0306(0x223)](',\x20'));_0x378845&&this[_0x4e0306(0x269)][_0x4e0306(0x1f7)](_0x4e0306(0x1e4)+_0x5c929c['chatId']+_0x4e0306(0x1de)+_0x13c1c1[_0x4e0306(0x23d)]+',\x20'+_0x1c1c3e['length']+_0x4e0306(0x1d3)+_0x8f85d0[_0x4e0306(0x22a)]+'\x20tools');const _0x44cd4e=()=>{const _0x5c085a=_0x4e0306,_0x1d4164=[];_0x1c1c3e[_0x5c085a(0x22a)]>0x0&&_0x1d4164[_0x5c085a(0x1e1)](_0x1c1c3e[_0x5c085a(0x223)]('\x0a\x0a'));_0x8f85d0[_0x5c085a(0x22a)]>0x0&&_0x1d4164[_0x5c085a(0x1e1)](generateToolPrompt(_0x8f85d0));if(_0x13c1c1[_0x5c085a(0x234)]&&_0x13c1c1[_0x5c085a(0x234)][_0x5c085a(0x22a)]>0x1){const _0x475230=formatConversationHistory(_0x13c1c1[_0x5c085a(0x234)]);_0x475230&&_0x1d4164[_0x5c085a(0x1e1)](_0x5c085a(0x1f6)+_0x475230+_0x5c085a(0x1c7));}return _0x1d4164[_0x5c085a(0x1e1)](_0x5c085a(0x259)+_0x50f743),_0x1d4164[_0x5c085a(0x223)](_0x5c085a(0x1eb));};let _0x2d2776;if(_0x378845)this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x1e8)),_0x2d2776=_0x44cd4e();else{const _0x2c0e08=[];_0x572390[_0x4e0306(0x22a)]>0x0&&(_0x2c0e08[_0x4e0306(0x1e1)](_0x572390['join']('\x0a\x0a')),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)]('Embedding',_0x572390[_0x4e0306(0x22a)],_0x4e0306(0x1f8)));if(_0x3f0f49[_0x4e0306(0x22a)]>0x0)try{_0x2c0e08[_0x4e0306(0x1e1)](generateToolPrompt(_0x3f0f49)),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)]('Embedding',_0x3f0f49[_0x4e0306(0x22a)],_0x4e0306(0x20a));}catch(_0x59306d){this[_0x4e0306(0x269)]['error']('Failed\x20to\x20generate\x20tool\x20prompt:',_0x59306d);}try{const _0x3c3762=extractToolResults(_0x5d0dd2);_0x3c3762&&(_0x2c0e08[_0x4e0306(0x1e1)](_0x3c3762),this[_0x4e0306(0x269)][_0x4e0306(0x1fe)](_0x4e0306(0x221)));}catch(_0x495e13){this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x1c6),_0x495e13);}_0x2c0e08['push'](_0x50f743),_0x2d2776=_0x2c0e08['length']>0x1?_0x2c0e08[_0x4e0306(0x223)]('\x0a---\x0a\x0a'):_0x50f743;for(const _0xf8da37 of _0x572390){_0x5c929c[_0x4e0306(0x1dc)]['add'](_0xf8da37);}for(const _0x50f8c0 of _0x3f0f49){_0x5c929c[_0x4e0306(0x265)][_0x4e0306(0x247)](_0x50f8c0[_0x4e0306(0x246)],_0x50f8c0);}}let _0x5c0425=![];(!_0x2d2776||!_0x2d2776[_0x4e0306(0x226)]())&&(this['logger']['warn']('Final\x20message\x20is\x20empty\x20after\x20construction\x20-\x20starting\x20fresh\x20conversation'),this[_0x4e0306(0x269)]['warn']('Context:',{'isNewContext':_0x378845,'userMessageLength':_0x50f743?.[_0x4e0306(0x22a)]||0x0,'systemPromptsCount':_0x1c1c3e['length'],'toolsCount':_0x8f85d0['length'],'messagesCount':_0x13c1c1[_0x4e0306(0x234)]?.['length']||0x0,'newMessagesCount':_0x5d0dd2[_0x4e0306(0x22a)]}),_0x5c929c[_0x4e0306(0x20b)]='',_0x5c929c['embeddedSystemPrompts'][_0x4e0306(0x217)](),_0x5c929c['embeddedToolsByName'][_0x4e0306(0x217)](),_0x5c0425=!![],_0x2d2776=_0x44cd4e(),(!_0x2d2776||!_0x2d2776[_0x4e0306(0x226)]())&&(this['logger'][_0x4e0306(0x23c)](_0x4e0306(0x206)),this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x201),{'systemPromptsCount':_0x1c1c3e[_0x4e0306(0x22a)],'toolsCount':_0x8f85d0[_0x4e0306(0x22a)],'messagesCount':_0x13c1c1[_0x4e0306(0x234)]?.[_0x4e0306(0x22a)]||0x0,'userMessageLength':_0x50f743?.[_0x4e0306(0x22a)]||0x0}),_0x2d2776=_0x4e0306(0x264)),this[_0x4e0306(0x269)][_0x4e0306(0x1f7)](_0x4e0306(0x231),_0x2d2776['substring'](0x0,0x64)+'...'));const _0x52c66c=_0x13c1c1['stream']!==![];if(_0x52c66c){_0x5ba7b1[_0x4e0306(0x21d)][_0x4e0306(0x24e)](0xc8,{'Content-Type':_0x4e0306(0x1be),'Cache-Control':_0x4e0306(0x262),'Connection':'keep-alive','X-Accel-Buffering':'no'});const _0x58240a=generateMessageId();try{const _0x30d5f2=this[_0x4e0306(0x257)]['tdx']['llm'][_0x4e0306(0x22d)](_0x2d2776,{'chatId':_0x5c929c[_0x4e0306(0x20b)]||undefined,'agentId':_0x5c929c[_0x4e0306(0x20b)]?undefined:_0x5c929c[_0x4e0306(0x22c)]});if(!_0x30d5f2){this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x20d)),this[_0x4e0306(0x269)][_0x4e0306(0x23c)]('Context:',JSON[_0x4e0306(0x25a)]({'chatId':_0x5c929c[_0x4e0306(0x20b)],'agentId':_0x5c929c[_0x4e0306(0x22c)],'model':_0x13c1c1[_0x4e0306(0x23d)],'sessionId':_0x5077d6,'contextSignature':_0x313e6e})),_0x5c929c[_0x4e0306(0x20b)]='',this[_0x4e0306(0x269)][_0x4e0306(0x207)]('Reset\x20chat\x20state\x20to\x20recover\x20on\x20next\x20request');const _0x16206f=formatAnthropicSSE({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x203),'message':_0x4e0306(0x21e)},'request_id':_0x58240a});_0x5ba7b1[_0x4e0306(0x21d)][_0x4e0306(0x242)](_0x16206f),_0x5ba7b1['raw']['end']();return;}_0x746613[_0x4e0306(0x1e6)]=_0x13c1c1[_0x4e0306(0x234)];const _0x41415a=_0x5c929c,_0x413bfc=_0x378845||_0x5c0425;async function*_0x390ba9(_0x557498){const _0x4f7b10=_0x4e0306;for await(const _0x25a60e of _0x557498){if(_0x25a60e[_0x4f7b10(0x25c)]===_0x4f7b10(0x219)){if(_0x25a60e['data'][_0x4f7b10(0x20b)]&&!_0x41415a[_0x4f7b10(0x20b)]){_0x41415a['chatId']=_0x25a60e[_0x4f7b10(0x24f)][_0x4f7b10(0x20b)];if(_0x413bfc){for(const _0xee42ba of _0x1c1c3e){_0x41415a[_0x4f7b10(0x1dc)][_0x4f7b10(0x1ec)](_0xee42ba);}for(const _0x115571 of _0x8f85d0){_0x41415a[_0x4f7b10(0x265)]['set'](_0x115571[_0x4f7b10(0x246)],_0x115571);}}}}else _0x25a60e[_0x4f7b10(0x25c)]===_0x4f7b10(0x1e2)&&(yield _0x25a60e[_0x4f7b10(0x24f)]);}}const _0xb50bb4=_0x390ba9(_0x30d5f2),_0x1f6e9b=estimateInputTokensFromRequest(_0x13c1c1),_0x490b2d=transformTDStreamWithToolDetection(_0xb50bb4,_0x58240a,_0x13c1c1[_0x4e0306(0x23d)],this[_0x4e0306(0x269)],_0x50f743,_0x1f6e9b);let _0x5199a7=0x0;for await(const _0x5c3539 of _0x490b2d){const _0x142d09=formatAnthropicSSE(_0x5c3539);_0x5199a7++,this[_0x4e0306(0x269)]['debug'](colorizeJSONCompact(_0x5c3539,{'color':!![]})),_0x5ba7b1[_0x4e0306(0x21d)][_0x4e0306(0x242)](_0x142d09);}this['logger'][_0x4e0306(0x1fe)]('Stream\x20complete.\x20Sent\x20'+_0x5199a7+_0x4e0306(0x1f2)),_0x5ba7b1[_0x4e0306(0x21d)]['end']();}catch(_0x5bd441){const _0x1dfec1=_0x5bd441 instanceof Error?_0x5bd441[_0x4e0306(0x208)]:_0x4e0306(0x1f0);this[_0x4e0306(0x269)][_0x4e0306(0x23c)](_0x4e0306(0x209),_0x5bd441),this['logger']['error'](_0x4e0306(0x250),JSON[_0x4e0306(0x25a)]({'chatId':_0x5c929c[_0x4e0306(0x20b)],'agentId':_0x5c929c['agentId'],'model':_0x13c1c1[_0x4e0306(0x23d)],'sessionId':_0x5077d6,'contextSignature':_0x313e6e})),_0x5c929c['chatId']='',this['logger'][_0x4e0306(0x207)](_0x4e0306(0x1ed));const _0x5af240=formatAnthropicSSE({'type':'error','error':{'type':'api_error','message':_0x1dfec1},'request_id':_0x58240a});_0x5ba7b1[_0x4e0306(0x21d)][_0x4e0306(0x242)](_0x5af240),_0x5ba7b1[_0x4e0306(0x21d)][_0x4e0306(0x1cc)]();}}else this[_0x4e0306(0x269)][_0x4e0306(0x23c)]('[PROXY\x20ERROR]\x20Non-streaming\x20responses\x20are\x20not\x20yet\x20supported'),_0x5ba7b1[_0x4e0306(0x22b)](0x1f5)['send']({'type':_0x4e0306(0x23c),'error':{'type':_0x4e0306(0x261),'message':'Non-streaming\x20responses\x20are\x20not\x20yet\x20supported'}});}async['handleCountTokens'](_0x441044){const _0x52a04d=a41_0x1b1a7b,_0x455114=_0x441044[_0x52a04d(0x1f9)],_0x478b40=estimateInputTokensFromRequest(_0x455114);return this[_0x52a04d(0x269)]['info'](_0x441044[_0x52a04d(0x1d1)]+'\x20'+_0x441044[_0x52a04d(0x1f1)]+_0x52a04d(0x225)+_0x478b40),{'input_tokens':_0x478b40};}async[a41_0x1b1a7b(0x245)](){const _0x1b58a3=a41_0x1b1a7b;try{await this[_0x1b58a3(0x236)][_0x1b58a3(0x1e7)]({'port':this[_0x1b58a3(0x257)][_0x1b58a3(0x237)],'host':_0x1b58a3(0x256)}),this[_0x1b58a3(0x254)]=setInterval(()=>{const _0x531bac=_0x1b58a3;this[_0x531bac(0x205)]();},CLEANUP_INTERVAL_MS),this[_0x1b58a3(0x269)]['debug'](_0x1b58a3(0x1f3)+CLEANUP_INTERVAL_MS/0x3e8+'s,\x20expires\x20after\x20'+CACHE_EXPIRATION_MS/0x3e8+'s)');}catch(_0x1b98ff){const _0x5b2ebb=_0x1b98ff instanceof Error?_0x1b98ff['message']:_0x1b58a3(0x1f0);throw new Error('Failed\x20to\x20start\x20proxy\x20server:\x20'+_0x5b2ebb);}}async[a41_0x1b1a7b(0x20c)](){const _0x5270e5=a41_0x1b1a7b;this['cleanupInterval']&&(clearInterval(this[_0x5270e5(0x254)]),this['cleanupInterval']=undefined),await this[_0x5270e5(0x236)]['close']();}['getAddress'](){const _0x214df9=a41_0x1b1a7b,_0x1324e1=this['server'][_0x214df9(0x236)][_0x214df9(0x1cf)]();if(typeof _0x1324e1===_0x214df9(0x1ce))return _0x1324e1;if(_0x1324e1)return _0x214df9(0x1c9)+_0x1324e1[_0x214df9(0x1cf)]+':'+_0x1324e1[_0x214df9(0x237)];return _0x214df9(0x1c2)+this['config'][_0x214df9(0x237)];}}
1
+ const a41_0x7f4cac=a41_0x480d;(function(_0x4c5435,_0x521a43){const _0x12b26d=a41_0x480d,_0x42a7ea=_0x4c5435();while(!![]){try{const _0x525609=parseInt(_0x12b26d(0x20c))/0x1*(parseInt(_0x12b26d(0x255))/0x2)+parseInt(_0x12b26d(0x258))/0x3+-parseInt(_0x12b26d(0x1d5))/0x4*(-parseInt(_0x12b26d(0x248))/0x5)+-parseInt(_0x12b26d(0x23e))/0x6*(parseInt(_0x12b26d(0x22e))/0x7)+parseInt(_0x12b26d(0x1cc))/0x8*(-parseInt(_0x12b26d(0x1c5))/0x9)+-parseInt(_0x12b26d(0x1da))/0xa+-parseInt(_0x12b26d(0x1f2))/0xb*(parseInt(_0x12b26d(0x25e))/0xc);if(_0x525609===_0x521a43)break;else _0x42a7ea['push'](_0x42a7ea['shift']());}catch(_0x36eccb){_0x42a7ea['push'](_0x42a7ea['shift']());}}}(a41_0x3735,0x915ca));import a41_0x237442 from'fastify';import a41_0x129646 from'@fastify/cors';function a41_0x3735(){const _0x202b29=['User','post','Failed\x20to\x20reconstruct\x20message\x20-\x20all\x20parts\x20are\x20empty,\x20using\x20fallback','text/event-stream','invalid_request_error','stream','update','0.0.0.0',':\x20messages=','not_supported_error','close','No\x20user\x20message\x20found\x20in\x20request','content','header:\x20','type','message','digest','TD\x20LLM\x20Proxy\x20Server','code','tdx','new\x20system\x20prompt(s)','system','Context\x20signature:','2519958kbFPEi','Project\x20ID\x20must\x20be\x20configured','lastUsedAt','Using\x20agent:\x20','s,\x20expires\x20after\x20','name','default','url','Assistant','string','role','cleanupInterval','handleRouteError','Evicted\x20oldest\x20chat\x20(signature:\x20',',\x20model=','Agent\x20cached:\x20','6eqVtwT','http://','isArray','[PROXY\x20ERROR]\x20Validation\x20failed:\x20tools\x20must\x20be\x20an\x20array\x20if\x20provided','tools','now','trace','info','getOrCreateDefaultAgent','clear','5afgPST','server','Added\x20system\x20prompts:','Authorization','set','embeddedSystemPrompts','\x20->\x20','[PROXY\x20ERROR]\x20Unhandled\x20error\x20in\x20','join','register',':\x20estimated\x20input_tokens=','Failed\x20to\x20start\x20proxy\x20server:\x20','getOrCreateSession','14046IApaSU','[PROXY\x20ERROR]\x20Streaming\x20error:','sessionCache','2637813OfLVet','Session:','config','model','\x0a---\x0a\x0a','address','12uTafHA','http://localhost:','[PROXY\x20ERROR]\x20Validation\x20failed:\x20messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','sort','Final\x20message\x20is\x20empty\x20after\x20construction\x20-\x20starting\x20fresh\x20conversation','data','[PROXY\x20ERROR]\x20Validation\x20failed:\x20No\x20user\x20message\x20found\x20in\x20request','write','\x20for\x20context:\x20','new\x20tool(s)','[Previous\x20conversation]\x0a\x0a<conversation>\x0a','...','get','add','anthropic-version','Reset\x20chat\x20state\x20to\x20recover\x20on\x20next\x20request','slice','added\x20tools:','end','push','chat','Added\x20system\x20prompt\x20previews:','Model:','Started\x20cache\x20cleanup\x20interval\x20(runs\x20every\x20','llm','handleCountTokens','Chat\x20creation\x20failed,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','metadata','Session\x20ID:','send','1945233HVFRqS','/health','input_schema','headers','cleanupExpiredChats','[PROXY\x20ERROR]\x20Configuration\x20error:\x20Project\x20ID\x20must\x20be\x20configured','user_id','8gWqfvi','\x20limit','no-cache','body','port','listen','OPTIONS','[PROXY\x20ERROR]\x20Non-streaming\x20responses\x20are\x20not\x20yet\x20supported','text','4756580WKXrjA','chats','POST','agentCache','messageHistory','8942030haFvSR','stop','Chat\x20ID:','New\x20context\x20-\x20including\x20full\x20context','Created\x20a\x20new\x20chat\x20id:\x20','stringify','agentId','[PROXY\x20ERROR]\x20Chat\x20stream\x20is\x20undefined','required','Stream\x20complete.\x20Sent\x20','messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','setupRoutes','error','raw','trim','Embedded\x20in\x20chat\x20-\x20system\x20prompts:','[Current\x20message]\x0a\x0a','tools\x20must\x20be\x20an\x20array\x20if\x20provided','debug','messages','Including\x20tool\x20results','Failed\x20to\x20initialize\x20chat\x20stream.\x20Please\x20try\x20again.','handleMessages','keep-alive','10304129mAhGiB','pop','Debug\x20info:','start','catch','map','filter','startChat','has','setupMiddleware','Unknown\x20error','getAddress','Current\x20request\x20-\x20system\x20prompts:','logger','\x20tools','embeddedToolsByName','getAgentForModel','chatId','substring','method','Content-Type','[PROXY\x20ERROR]\x20Uncaught\x20error\x20in\x20','x-api-key','writeHead','/v1/messages/count_tokens','\x20SSE\x20events.','133mVwvDx','attributes','/v1/messages','\x0a</conversation>','api_error','tools:','Created\x20new\x20chat:\x20','Context:','length','warn','localeCompare'];a41_0x3735=function(){return _0x202b29;};return a41_0x3735();}import{createHash}from'crypto';import{transformTDStreamWithToolDetection,formatAnthropicSSE,generateMessageId,generateToolPrompt,extractToolResults,estimateInputTokensFromRequest}from'./anthropic-adapter.js';import{colorizeJSON,colorizeJSONCompact}from'../utils/colors.js';import{extractModelAlias,resolveModelAlias}from'../utils/model-aliases.js';import{SessionCache}from'./session-cache.js';function a41_0x480d(_0x338ef0,_0x5914ac){const _0x3735a2=a41_0x3735();return a41_0x480d=function(_0x480d43,_0x8d908f){_0x480d43=_0x480d43-0x1c2;let _0x69316d=_0x3735a2[_0x480d43];return _0x69316d;},a41_0x480d(_0x338ef0,_0x5914ac);}function formatConversationHistory(_0x4c0279){const _0x3106ab=a41_0x480d;if(!_0x4c0279||!Array[_0x3106ab(0x240)](_0x4c0279))return'';return _0x4c0279['filter'](_0x5c1e5b=>_0x5c1e5b!=null)[_0x3106ab(0x1f7)](_0x2fb4cd=>{const _0x5c175d=_0x3106ab,_0x1e0acc=_0x2fb4cd['content']!=null&&Array[_0x5c175d(0x240)](_0x2fb4cd[_0x5c175d(0x223)])?_0x2fb4cd['content'][_0x5c175d(0x1f8)](_0x49bf36=>_0x49bf36&&_0x49bf36['type']===_0x5c175d(0x1d4))[_0x5c175d(0x1f7)](_0x89b9dc=>_0x89b9dc[_0x5c175d(0x1d4)])[_0x5c175d(0x250)]('\x0a'):_0x2fb4cd['content']||'',_0x75923e=_0x2fb4cd[_0x5c175d(0x238)]==='user'?_0x5c175d(0x217):_0x5c175d(0x236);return _0x75923e+':\x20'+_0x1e0acc;})[_0x3106ab(0x250)]('\x0a\x0a');}function calculateContextSignature(_0xcf6855,_0x2f740f,_0x1faab1){const _0x4d80cf=a41_0x480d,_0x37aca2=extractModelAlias(_0xcf6855),_0x477a40=resolveModelAlias(_0x37aca2),_0x27781c=[..._0x2f740f||[]][_0x4d80cf(0x261)](),_0x58c82b=(_0x1faab1||[])[_0x4d80cf(0x1f8)](_0x5049a8=>_0x5049a8!=null)['map'](_0x1e4d1e=>({'name':_0x1e4d1e['name'],'params':Object['keys'](_0x1e4d1e['input_schema']?.['properties']||{})[_0x4d80cf(0x261)](),'required':(_0x1e4d1e[_0x4d80cf(0x1c7)]?.[_0x4d80cf(0x1e2)]||[])['sort']()}))[_0x4d80cf(0x261)]((_0x49ea48,_0x37bd35)=>_0x49ea48[_0x4d80cf(0x233)][_0x4d80cf(0x216)](_0x37bd35[_0x4d80cf(0x233)])),_0x2e2d85=JSON[_0x4d80cf(0x1df)]({'model':_0x477a40,'prompts':_0x27781c,'tools':_0x58c82b});return createHash('sha256')[_0x4d80cf(0x21d)](_0x2e2d85)[_0x4d80cf(0x227)]('hex')[_0x4d80cf(0x204)](0x0,0x10);}const MAX_CHATS_PER_SESSION=0xa,CACHE_EXPIRATION_MS=0xa*0x3c*0x3e8,CLEANUP_INTERVAL_MS=0x3c*0x3e8;export class ProxyServer{['server'];[a41_0x7f4cac(0x257)];[a41_0x7f4cac(0x1d8)];['config'];['cleanupInterval'];[a41_0x7f4cac(0x1ff)];constructor(_0x11c056){const _0x1121ad=a41_0x7f4cac;this[_0x1121ad(0x1ff)]=_0x11c056['logger'],this[_0x1121ad(0x25a)]=_0x11c056,this[_0x1121ad(0x257)]=new SessionCache({'maxChatsPerSession':MAX_CHATS_PER_SESSION,'cacheExpirationMs':CACHE_EXPIRATION_MS}),this[_0x1121ad(0x1d8)]=new Map(),this[_0x1121ad(0x249)]=a41_0x237442({'logger':![],'bodyLimit':0x40*0x400*0x400}),this[_0x1121ad(0x1fb)](),this['setupRoutes']();}async['getAgentForModel'](_0x1b1b54){const _0x55ab91=a41_0x7f4cac,_0x30af2e=extractModelAlias(_0x1b1b54),_0x32c35c=resolveModelAlias(_0x30af2e);let _0x37ef02=this[_0x55ab91(0x1d8)][_0x55ab91(0x26a)](_0x32c35c);if(!_0x37ef02){this[_0x55ab91(0x1ff)][_0x55ab91(0x1ec)]('Model\x20normalization:\x20'+_0x1b1b54+_0x55ab91(0x24e)+_0x30af2e+'\x20->\x20'+_0x32c35c),this[_0x55ab91(0x1ff)][_0x55ab91(0x1ec)]('Creating/looking\x20up\x20agent\x20for:\x20'+_0x32c35c);const _0x2472fd=await this[_0x55ab91(0x25a)]['tdx'][_0x55ab91(0x276)][_0x55ab91(0x246)](_0x32c35c);_0x37ef02=_0x2472fd['id'],this[_0x55ab91(0x1d8)][_0x55ab91(0x24c)](_0x32c35c,_0x37ef02),this[_0x55ab91(0x1ff)][_0x55ab91(0x1ec)](_0x55ab91(0x23d)+_0x32c35c+_0x55ab91(0x24e)+_0x37ef02+'\x20('+_0x2472fd[_0x55ab91(0x20d)][_0x55ab91(0x233)]+')');}return _0x37ef02;}['cleanupExpiredChats'](){const _0x171dcb=a41_0x7f4cac;this[_0x171dcb(0x257)][_0x171dcb(0x1c9)]();}[a41_0x7f4cac(0x1fb)](){const _0x119fb0=a41_0x7f4cac;this[_0x119fb0(0x249)][_0x119fb0(0x251)](a41_0x129646,{'origin':!![],'methods':['GET',_0x119fb0(0x1d7),_0x119fb0(0x1d2)],'allowedHeaders':[_0x119fb0(0x206),_0x119fb0(0x24b),_0x119fb0(0x26c),_0x119fb0(0x208)]}),this['server']['setErrorHandler']((_0x4d36e2,_0x39c1ba,_0x205643)=>{const _0x460a3d=_0x119fb0,_0x123dc8=_0x4d36e2 instanceof Error?_0x4d36e2[_0x460a3d(0x226)]:_0x460a3d(0x1fc);this[_0x460a3d(0x1ff)][_0x460a3d(0x1e6)](_0x460a3d(0x24f)+_0x39c1ba[_0x460a3d(0x205)]+'\x20'+_0x39c1ba[_0x460a3d(0x235)]+':',_0x4d36e2),_0x205643[_0x460a3d(0x229)](0x1f4)[_0x460a3d(0x1c4)]({'type':_0x460a3d(0x1e6),'error':{'type':_0x460a3d(0x210),'message':_0x123dc8}});});}[a41_0x7f4cac(0x23a)](_0x2d2217,_0x3d33f1,_0x3ccd33){const _0x2b94e4=a41_0x7f4cac,_0x4e7c9b=_0x3d33f1 instanceof Error?_0x3d33f1[_0x2b94e4(0x226)]:_0x2b94e4(0x1fc);this[_0x2b94e4(0x1ff)][_0x2b94e4(0x1e6)](_0x2b94e4(0x207)+_0x2d2217+':',_0x3d33f1),!_0x3ccd33['sent']&&_0x3ccd33['code'](0x1f4)['send']({'type':_0x2b94e4(0x1e6),'error':{'type':'api_error','message':_0x4e7c9b}});}[a41_0x7f4cac(0x1e5)](){const _0x4a2feb=a41_0x7f4cac;this[_0x4a2feb(0x249)][_0x4a2feb(0x26a)](_0x4a2feb(0x1c6),async()=>{const _0x352123=_0x4a2feb;return{'status':'ok','message':_0x352123(0x228)};}),this['server'][_0x4a2feb(0x218)](_0x4a2feb(0x20e),async(_0x44dd2d,_0xb7eed8)=>{return this['handleMessages'](_0x44dd2d,_0xb7eed8)['catch'](_0x42fd21=>{const _0x4cd903=a41_0x480d;this[_0x4cd903(0x23a)](_0x4cd903(0x20e),_0x42fd21,_0xb7eed8);});}),this[_0x4a2feb(0x249)][_0x4a2feb(0x218)](_0x4a2feb(0x20a),async(_0x47e655,_0x5f2f99)=>{const _0x33800c=_0x4a2feb;return this['handleCountTokens'](_0x47e655)[_0x33800c(0x1f6)](_0x2721bd=>{const _0x54a86e=_0x33800c;this[_0x54a86e(0x23a)]('/v1/messages/count_tokens',_0x2721bd,_0x5f2f99);});});}async[a41_0x7f4cac(0x1f0)](_0x525348,_0xba749d){const _0x429afe=a41_0x7f4cac,_0x5e4a7e=_0x525348['body'];if(!_0x5e4a7e[_0x429afe(0x1ed)]||!Array[_0x429afe(0x240)](_0x5e4a7e[_0x429afe(0x1ed)])||_0x5e4a7e[_0x429afe(0x1ed)]['length']===0x0){this[_0x429afe(0x1ff)]['error'](_0x429afe(0x260)),_0xba749d[_0x429afe(0x229)](0x190)[_0x429afe(0x1c4)]({'type':'error','error':{'type':_0x429afe(0x21b),'message':_0x429afe(0x1e4)}});return;}if(_0x5e4a7e[_0x429afe(0x242)]&&!Array[_0x429afe(0x240)](_0x5e4a7e[_0x429afe(0x242)])){this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x241)),_0xba749d['code'](0x190)[_0x429afe(0x1c4)]({'type':_0x429afe(0x1e6),'error':{'type':_0x429afe(0x21b),'message':_0x429afe(0x1eb)}});return;}const _0x77e086=_0x5e4a7e[_0x429afe(0x1ed)]?.[_0x429afe(0x214)]??0x0,_0x44395b=_0x5e4a7e[_0x429afe(0x25b)]||'unknown';this[_0x429afe(0x1ff)][_0x429afe(0x245)](_0x525348[_0x429afe(0x205)]+'\x20'+_0x525348['url']+_0x429afe(0x21f)+_0x77e086+',\x20model='+_0x44395b),this['logger'][_0x429afe(0x1ec)](_0x429afe(0x224)+colorizeJSONCompact(_0x525348[_0x429afe(0x1c8)]));this['logger'][_0x429afe(0x244)]&&this['logger'][_0x429afe(0x244)](colorizeJSON(_0x5e4a7e,{'color':!![]}));const _0x12e019=_0x5e4a7e[_0x429afe(0x1c2)]?.[_0x429afe(0x1cb)]||_0x429afe(0x234);this['logger']['debug'](_0x429afe(0x1c3),_0x12e019);const _0x3a5cdf=this[_0x429afe(0x25a)]['projectId'];if(!_0x3a5cdf){this['logger'][_0x429afe(0x1e6)](_0x429afe(0x1ca)),_0xba749d['code'](0x1f4)[_0x429afe(0x1c4)]({'type':_0x429afe(0x1e6),'error':{'type':_0x429afe(0x210),'message':_0x429afe(0x22f)}});return;}const _0x1664f7=this[_0x429afe(0x257)][_0x429afe(0x254)](_0x12e019,_0x3a5cdf),_0x584163=_0x1664f7[_0x429afe(0x1d9)]['length'],_0x37490a=_0x5e4a7e['messages'][_0x429afe(0x26e)](_0x584163);let _0x4aa8b5=_0x37490a[_0x429afe(0x1f8)](_0x4a996e=>_0x4a996e[_0x429afe(0x238)]==='user')[_0x429afe(0x1f3)]();if(!_0x4aa8b5){_0x4aa8b5=_0x5e4a7e[_0x429afe(0x1ed)][_0x429afe(0x1f8)](_0x556347=>_0x556347['role']==='user')['pop']();if(!_0x4aa8b5){this['logger'][_0x429afe(0x1e6)](_0x429afe(0x264)),_0xba749d[_0x429afe(0x229)](0x190)[_0x429afe(0x1c4)]({'type':'error','error':{'type':_0x429afe(0x21b),'message':_0x429afe(0x222)}});return;}}let _0x50e347;if(typeof _0x4aa8b5[_0x429afe(0x223)]===_0x429afe(0x237))_0x50e347=_0x4aa8b5[_0x429afe(0x223)];else{if(_0x4aa8b5[_0x429afe(0x223)]!=null&&Array['isArray'](_0x4aa8b5['content']))_0x50e347=_0x4aa8b5[_0x429afe(0x223)]['filter'](_0x42e261=>_0x42e261&&_0x42e261[_0x429afe(0x225)]===_0x429afe(0x1d4)&&_0x42e261[_0x429afe(0x1d4)])[_0x429afe(0x1f7)](_0x53f129=>_0x53f129[_0x429afe(0x1d4)])[_0x429afe(0x250)]('\x0a');else{this[_0x429afe(0x1ff)][_0x429afe(0x1e6)]('[PROXY\x20ERROR]\x20Validation\x20failed:\x20message.content\x20must\x20be\x20a\x20string\x20or\x20array,\x20got:',typeof _0x4aa8b5[_0x429afe(0x223)],_0x4aa8b5[_0x429afe(0x223)]),_0xba749d[_0x429afe(0x229)](0x190)[_0x429afe(0x1c4)]({'type':'error','error':{'type':_0x429afe(0x21b),'message':'message.content\x20must\x20be\x20a\x20string\x20or\x20array'}});return;}}const _0x4c0fb2=[];if(_0x5e4a7e['system']){if(typeof _0x5e4a7e[_0x429afe(0x22c)]===_0x429afe(0x237))_0x4c0fb2['push'](_0x5e4a7e[_0x429afe(0x22c)]);else{if(Array['isArray'](_0x5e4a7e[_0x429afe(0x22c)]))for(const _0x24c331 of _0x5e4a7e[_0x429afe(0x22c)]){_0x24c331[_0x429afe(0x225)]===_0x429afe(0x1d4)&&_0x24c331[_0x429afe(0x1d4)]&&_0x4c0fb2['push'](_0x24c331[_0x429afe(0x1d4)]);}}}const _0x1aaa67=_0x5e4a7e['tools']||[],_0x27f890=calculateContextSignature(_0x5e4a7e['model'],_0x4c0fb2,_0x1aaa67);let _0x12c787=_0x1664f7[_0x429afe(0x1d6)][_0x429afe(0x26a)](_0x27f890);const _0x1de621=!_0x12c787;if(!_0x12c787){const _0x2975b0=await this[_0x429afe(0x202)](_0x5e4a7e[_0x429afe(0x25b)]);_0x12c787={'chatId':'','agentId':_0x2975b0,'contextSignature':_0x27f890,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'lastUsedAt':Date[_0x429afe(0x243)]()},_0x1664f7[_0x429afe(0x1d6)][_0x429afe(0x24c)](_0x27f890,_0x12c787);if(_0x1664f7['chats']['size']>MAX_CHATS_PER_SESSION){let _0x4fe457=null,_0x23272b=Date[_0x429afe(0x243)]();for(const [_0x1e8f12,_0xb14684]of _0x1664f7[_0x429afe(0x1d6)]){_0xb14684['lastUsedAt']<_0x23272b&&(_0x23272b=_0xb14684[_0x429afe(0x230)],_0x4fe457=_0x1e8f12);}_0x4fe457&&(_0x1664f7[_0x429afe(0x1d6)]['delete'](_0x4fe457),this[_0x429afe(0x1ff)]['debug'](_0x429afe(0x23b)+_0x4fe457+')\x20to\x20stay\x20under\x20'+MAX_CHATS_PER_SESSION+_0x429afe(0x1cd)));}}else _0x12c787[_0x429afe(0x230)]=Date['now']();if(!_0x12c787[_0x429afe(0x203)])try{const _0x371e9e=await this[_0x429afe(0x25a)][_0x429afe(0x22a)][_0x429afe(0x276)][_0x429afe(0x1f9)](_0x12c787[_0x429afe(0x1e0)]);_0x12c787['chatId']=_0x371e9e['id'],this['logger']['debug'](_0x429afe(0x212)+_0x371e9e['id']+_0x429afe(0x266)+_0x27f890),this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x231)+_0x12c787[_0x429afe(0x1e0)]+'\x20(model:\x20'+_0x5e4a7e[_0x429afe(0x25b)]+')');}catch(_0x326f1f){this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x278),_0x326f1f);}const _0x30b58b=_0x4c0fb2[_0x429afe(0x1f8)](_0x2056b1=>!_0x12c787[_0x429afe(0x24d)][_0x429afe(0x1fa)](_0x2056b1)),_0xc0c153=_0x1aaa67[_0x429afe(0x1f8)](_0x33e2c7=>!_0x12c787['embeddedToolsByName']['has'](_0x33e2c7[_0x429afe(0x233)]));this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x259),_0x12e019),this[_0x429afe(0x1ff)]['debug'](_0x429afe(0x274),_0x5e4a7e[_0x429afe(0x25b)]),this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x22d),_0x27f890),this['logger'][_0x429afe(0x1ec)]('Is\x20new\x20context:',_0x1de621),this[_0x429afe(0x1ff)]['debug'](_0x429afe(0x1dc),_0x12c787[_0x429afe(0x203)]),this['logger'][_0x429afe(0x1ec)](_0x429afe(0x1fe),_0x4c0fb2[_0x429afe(0x214)],_0x429afe(0x211),_0x1aaa67[_0x429afe(0x214)]),this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x1e9),_0x12c787[_0x429afe(0x24d)]['size'],_0x429afe(0x211),_0x12c787['embeddedToolsByName']['size']),this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x24a),_0x30b58b['length'],_0x429afe(0x26f),_0xc0c153[_0x429afe(0x214)]);_0x30b58b['length']>0x0&&this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x273),_0x30b58b[_0x429afe(0x1f7)](_0x2feee9=>_0x2feee9[_0x429afe(0x204)](0x0,0x32)+_0x429afe(0x269))[_0x429afe(0x250)]('\x20|\x20'));_0xc0c153[_0x429afe(0x214)]>0x0&&this[_0x429afe(0x1ff)][_0x429afe(0x1ec)]('Added\x20tool\x20names:',_0xc0c153['map'](_0x18854b=>_0x18854b['name'])['join'](',\x20'));_0x1de621&&this[_0x429afe(0x1ff)][_0x429afe(0x245)](_0x429afe(0x1de)+_0x12c787[_0x429afe(0x203)]+_0x429afe(0x23c)+_0x5e4a7e[_0x429afe(0x25b)]+',\x20'+_0x4c0fb2['length']+'\x20system\x20prompts,\x20'+_0x1aaa67[_0x429afe(0x214)]+_0x429afe(0x200));const _0x44bd90=()=>{const _0x7ab1a9=_0x429afe,_0x418534=[];_0x4c0fb2['length']>0x0&&_0x418534[_0x7ab1a9(0x271)](_0x4c0fb2[_0x7ab1a9(0x250)]('\x0a\x0a'));_0x1aaa67[_0x7ab1a9(0x214)]>0x0&&_0x418534[_0x7ab1a9(0x271)](generateToolPrompt(_0x1aaa67));if(_0x5e4a7e[_0x7ab1a9(0x1ed)]&&_0x5e4a7e[_0x7ab1a9(0x1ed)]['length']>0x1){const _0x4bce3f=formatConversationHistory(_0x5e4a7e[_0x7ab1a9(0x1ed)]);_0x4bce3f&&_0x418534['push'](_0x7ab1a9(0x268)+_0x4bce3f+_0x7ab1a9(0x20f));}return _0x418534[_0x7ab1a9(0x271)](_0x7ab1a9(0x1ea)+_0x50e347),_0x418534[_0x7ab1a9(0x250)](_0x7ab1a9(0x25c));};let _0x3159e2;if(_0x1de621)this['logger'][_0x429afe(0x1ec)](_0x429afe(0x1dd)),_0x3159e2=_0x44bd90();else{const _0x247fae=[];_0x30b58b[_0x429afe(0x214)]>0x0&&(_0x247fae[_0x429afe(0x271)](_0x30b58b[_0x429afe(0x250)]('\x0a\x0a')),this[_0x429afe(0x1ff)]['debug']('Embedding',_0x30b58b[_0x429afe(0x214)],_0x429afe(0x22b)));if(_0xc0c153[_0x429afe(0x214)]>0x0)try{_0x247fae[_0x429afe(0x271)](generateToolPrompt(_0xc0c153)),this[_0x429afe(0x1ff)]['debug']('Embedding',_0xc0c153[_0x429afe(0x214)],_0x429afe(0x267));}catch(_0x279ac1){this[_0x429afe(0x1ff)][_0x429afe(0x1e6)]('Failed\x20to\x20generate\x20tool\x20prompt:',_0x279ac1);}try{const _0x378a90=extractToolResults(_0x37490a);_0x378a90&&(_0x247fae['push'](_0x378a90),this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x1ee)));}catch(_0x3af262){this[_0x429afe(0x1ff)][_0x429afe(0x1e6)]('Failed\x20to\x20extract\x20tool\x20results:',_0x3af262);}_0x247fae[_0x429afe(0x271)](_0x50e347),_0x3159e2=_0x247fae[_0x429afe(0x214)]>0x1?_0x247fae['join'](_0x429afe(0x25c)):_0x50e347;for(const _0x5ba416 of _0x30b58b){_0x12c787[_0x429afe(0x24d)][_0x429afe(0x26b)](_0x5ba416);}for(const _0x2e034e of _0xc0c153){_0x12c787[_0x429afe(0x201)][_0x429afe(0x24c)](_0x2e034e[_0x429afe(0x233)],_0x2e034e);}}let _0x1d1cf7=![];(!_0x3159e2||!_0x3159e2[_0x429afe(0x1e8)]())&&(this[_0x429afe(0x1ff)]['warn'](_0x429afe(0x262)),this[_0x429afe(0x1ff)][_0x429afe(0x215)](_0x429afe(0x213),{'isNewContext':_0x1de621,'userMessageLength':_0x50e347?.[_0x429afe(0x214)]||0x0,'systemPromptsCount':_0x4c0fb2[_0x429afe(0x214)],'toolsCount':_0x1aaa67['length'],'messagesCount':_0x5e4a7e['messages']?.[_0x429afe(0x214)]||0x0,'newMessagesCount':_0x37490a[_0x429afe(0x214)]}),_0x12c787[_0x429afe(0x203)]='',_0x12c787[_0x429afe(0x24d)][_0x429afe(0x247)](),_0x12c787['embeddedToolsByName']['clear'](),_0x1d1cf7=!![],_0x3159e2=_0x44bd90(),(!_0x3159e2||!_0x3159e2['trim']())&&(this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x219)),this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x1f4),{'systemPromptsCount':_0x4c0fb2['length'],'toolsCount':_0x1aaa67[_0x429afe(0x214)],'messagesCount':_0x5e4a7e[_0x429afe(0x1ed)]?.['length']||0x0,'userMessageLength':_0x50e347?.['length']||0x0}),_0x3159e2='continue'),this[_0x429afe(0x1ff)]['info']('Final\x20message\x20reconstructed\x20after\x20context\x20reset:',_0x3159e2[_0x429afe(0x204)](0x0,0x64)+_0x429afe(0x269)));const _0x129c8e=_0x5e4a7e[_0x429afe(0x21c)]!==![];if(_0x129c8e){_0xba749d['raw'][_0x429afe(0x209)](0xc8,{'Content-Type':_0x429afe(0x21a),'Cache-Control':_0x429afe(0x1ce),'Connection':_0x429afe(0x1f1),'X-Accel-Buffering':'no'});const _0x22c6e6=generateMessageId();try{const _0xea802d=this[_0x429afe(0x25a)]['tdx']['llm'][_0x429afe(0x272)](_0x3159e2,{'chatId':_0x12c787[_0x429afe(0x203)]||undefined,'agentId':_0x12c787[_0x429afe(0x203)]?undefined:_0x12c787[_0x429afe(0x1e0)]});if(!_0xea802d){this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x1e1)),this['logger'][_0x429afe(0x1e6)]('Context:',JSON[_0x429afe(0x1df)]({'chatId':_0x12c787['chatId'],'agentId':_0x12c787[_0x429afe(0x1e0)],'model':_0x5e4a7e[_0x429afe(0x25b)],'sessionId':_0x12e019,'contextSignature':_0x27f890})),_0x12c787[_0x429afe(0x203)]='',this[_0x429afe(0x1ff)][_0x429afe(0x215)](_0x429afe(0x26d));const _0x5bab3d=formatAnthropicSSE({'type':_0x429afe(0x1e6),'error':{'type':_0x429afe(0x210),'message':_0x429afe(0x1ef)},'request_id':_0x22c6e6});_0xba749d['raw'][_0x429afe(0x265)](_0x5bab3d),_0xba749d[_0x429afe(0x1e7)][_0x429afe(0x270)]();return;}_0x1664f7[_0x429afe(0x1d9)]=_0x5e4a7e[_0x429afe(0x1ed)];const _0x428b21=_0x12c787,_0x440a5b=_0x1de621||_0x1d1cf7;async function*_0x27539f(_0x2f0f26){const _0x44dc65=_0x429afe;for await(const _0x1cdbde of _0x2f0f26){if(_0x1cdbde[_0x44dc65(0x225)]===_0x44dc65(0x1c2)){if(_0x1cdbde[_0x44dc65(0x263)][_0x44dc65(0x203)]&&!_0x428b21['chatId']){_0x428b21['chatId']=_0x1cdbde[_0x44dc65(0x263)][_0x44dc65(0x203)];if(_0x440a5b){for(const _0x2ee27f of _0x4c0fb2){_0x428b21[_0x44dc65(0x24d)][_0x44dc65(0x26b)](_0x2ee27f);}for(const _0x1e5d2c of _0x1aaa67){_0x428b21['embeddedToolsByName'][_0x44dc65(0x24c)](_0x1e5d2c[_0x44dc65(0x233)],_0x1e5d2c);}}}}else _0x1cdbde[_0x44dc65(0x225)]==='event'&&(yield _0x1cdbde[_0x44dc65(0x263)]);}}const _0x542996=_0x27539f(_0xea802d),_0x415cdc=estimateInputTokensFromRequest(_0x5e4a7e),_0x505d06=transformTDStreamWithToolDetection(_0x542996,_0x22c6e6,_0x5e4a7e['model'],this[_0x429afe(0x1ff)],_0x50e347,_0x415cdc);let _0x338366=0x0;for await(const _0x5797e9 of _0x505d06){const _0x51413e=formatAnthropicSSE(_0x5797e9);_0x338366++,this[_0x429afe(0x1ff)]['debug'](colorizeJSONCompact(_0x5797e9,{'color':!![]})),_0xba749d[_0x429afe(0x1e7)][_0x429afe(0x265)](_0x51413e);}this[_0x429afe(0x1ff)][_0x429afe(0x1ec)](_0x429afe(0x1e3)+_0x338366+_0x429afe(0x20b)),_0xba749d[_0x429afe(0x1e7)][_0x429afe(0x270)]();}catch(_0x35e224){const _0x4f9038=_0x35e224 instanceof Error?_0x35e224['message']:'Unknown\x20error';this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x256),_0x35e224),this[_0x429afe(0x1ff)]['error']('Context:',JSON[_0x429afe(0x1df)]({'chatId':_0x12c787[_0x429afe(0x203)],'agentId':_0x12c787[_0x429afe(0x1e0)],'model':_0x5e4a7e[_0x429afe(0x25b)],'sessionId':_0x12e019,'contextSignature':_0x27f890})),_0x12c787[_0x429afe(0x203)]='',this[_0x429afe(0x1ff)]['warn'](_0x429afe(0x26d));const _0x48fe76=formatAnthropicSSE({'type':_0x429afe(0x1e6),'error':{'type':_0x429afe(0x210),'message':_0x4f9038},'request_id':_0x22c6e6});_0xba749d[_0x429afe(0x1e7)][_0x429afe(0x265)](_0x48fe76),_0xba749d[_0x429afe(0x1e7)]['end']();}}else this[_0x429afe(0x1ff)][_0x429afe(0x1e6)](_0x429afe(0x1d3)),_0xba749d[_0x429afe(0x229)](0x1f5)[_0x429afe(0x1c4)]({'type':_0x429afe(0x1e6),'error':{'type':_0x429afe(0x220),'message':'Non-streaming\x20responses\x20are\x20not\x20yet\x20supported'}});}async[a41_0x7f4cac(0x277)](_0x3f202c){const _0x1ea3ab=a41_0x7f4cac,_0xbd89d=_0x3f202c[_0x1ea3ab(0x1cf)],_0x9e284f=estimateInputTokensFromRequest(_0xbd89d);return this[_0x1ea3ab(0x1ff)]['info'](_0x3f202c[_0x1ea3ab(0x205)]+'\x20'+_0x3f202c[_0x1ea3ab(0x235)]+_0x1ea3ab(0x252)+_0x9e284f),{'input_tokens':_0x9e284f};}async[a41_0x7f4cac(0x1f5)](){const _0x2ed50d=a41_0x7f4cac;try{await this[_0x2ed50d(0x249)][_0x2ed50d(0x1d1)]({'port':this[_0x2ed50d(0x25a)][_0x2ed50d(0x1d0)],'host':_0x2ed50d(0x21e)}),this[_0x2ed50d(0x239)]=setInterval(()=>{const _0x59769c=_0x2ed50d;this[_0x59769c(0x1c9)]();},CLEANUP_INTERVAL_MS),this['logger'][_0x2ed50d(0x1ec)](_0x2ed50d(0x275)+CLEANUP_INTERVAL_MS/0x3e8+_0x2ed50d(0x232)+CACHE_EXPIRATION_MS/0x3e8+'s)');}catch(_0xeddf83){const _0x402750=_0xeddf83 instanceof Error?_0xeddf83[_0x2ed50d(0x226)]:'Unknown\x20error';throw new Error(_0x2ed50d(0x253)+_0x402750);}}async[a41_0x7f4cac(0x1db)](){const _0x517af3=a41_0x7f4cac;this[_0x517af3(0x239)]&&(clearInterval(this[_0x517af3(0x239)]),this['cleanupInterval']=undefined),await this[_0x517af3(0x249)][_0x517af3(0x221)]();}[a41_0x7f4cac(0x1fd)](){const _0x1fe8f9=a41_0x7f4cac,_0xe865d8=this[_0x1fe8f9(0x249)][_0x1fe8f9(0x249)][_0x1fe8f9(0x25d)]();if(typeof _0xe865d8==='string')return _0xe865d8;if(_0xe865d8)return _0x1fe8f9(0x23f)+_0xe865d8['address']+':'+_0xe865d8[_0x1fe8f9(0x1d0)];return _0x1fe8f9(0x25f)+this[_0x1fe8f9(0x25a)][_0x1fe8f9(0x1d0)];}}
@@ -1 +1 @@
1
- const a42_0x2cc2d1=a42_0x5531;function a42_0x7caa(){const _0x49a80b=['config','getSession','1832838XoRdEn','2661712LRUMum','getSessionCount','1742100tdcQhz','getOrCreateSession','Session\x20','set','lastUsedAt','\x20not\x20found','values','chats','push','822696bGlrJy','delete','clear','get','45nyhbHr','size','now','26522ijKIlQ','10YXhmOy','99rdQATr','getOrCreateChat','4652994TxdwVw','11VbVvnx','3029210xRRjeH','sessions','getTotalChatCount'];a42_0x7caa=function(){return _0x49a80b;};return a42_0x7caa();}(function(_0x573a01,_0x2af207){const _0x1fdb96=a42_0x5531,_0x1378cd=_0x573a01();while(!![]){try{const _0x14c15e=parseInt(_0x1fdb96(0xf7))/0x1*(parseInt(_0x1fdb96(0xf5))/0x2)+-parseInt(_0x1fdb96(0x100))/0x3+parseInt(_0x1fdb96(0x103))/0x4*(-parseInt(_0x1fdb96(0xf6))/0x5)+-parseInt(_0x1fdb96(0xf9))/0x6+-parseInt(_0x1fdb96(0xee))/0x7+parseInt(_0x1fdb96(0x101))/0x8*(parseInt(_0x1fdb96(0xf2))/0x9)+-parseInt(_0x1fdb96(0xfb))/0xa*(-parseInt(_0x1fdb96(0xfa))/0xb);if(_0x14c15e===_0x2af207)break;else _0x1378cd['push'](_0x1378cd['shift']());}catch(_0x338d0c){_0x1378cd['push'](_0x1378cd['shift']());}}}(a42_0x7caa,0xdcc73));function a42_0x5531(_0x2b9d4f,_0x40c8f8){const _0x7caa71=a42_0x7caa();return a42_0x5531=function(_0x553142,_0x290fab){_0x553142=_0x553142-0xec;let _0x8b2ce6=_0x7caa71[_0x553142];return _0x8b2ce6;},a42_0x5531(_0x2b9d4f,_0x40c8f8);}export class SessionCache{[a42_0x2cc2d1(0xfc)];['config'];constructor(_0xb1d6d5){this['config']=_0xb1d6d5,this['sessions']=new Map();}[a42_0x2cc2d1(0x104)](_0x574deb,_0x31d696){const _0x3767e8=a42_0x2cc2d1;let _0x2c3921=this[_0x3767e8(0xfc)]['get'](_0x574deb);return!_0x2c3921&&(_0x2c3921={'projectId':_0x31d696,'messageHistory':[],'chats':new Map()},this[_0x3767e8(0xfc)][_0x3767e8(0x106)](_0x574deb,_0x2c3921)),_0x2c3921;}[a42_0x2cc2d1(0xff)](_0x44f83e){const _0x8fffe6=a42_0x2cc2d1;return this[_0x8fffe6(0xfc)][_0x8fffe6(0xf1)](_0x44f83e);}[a42_0x2cc2d1(0xf8)](_0x38df3e,_0x226c8c,_0x146676){const _0x394e1a=a42_0x2cc2d1,_0x5442fd=this[_0x394e1a(0xfc)][_0x394e1a(0xf1)](_0x38df3e);if(!_0x5442fd)throw new Error(_0x394e1a(0x105)+_0x38df3e+_0x394e1a(0x108));let _0xe76b79=_0x5442fd[_0x394e1a(0xec)]['get'](_0x226c8c);if(!_0xe76b79){_0xe76b79={'chatId':'','agentId':_0x146676,'contextSignature':_0x226c8c,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'lastUsedAt':Date[_0x394e1a(0xf4)]()},_0x5442fd[_0x394e1a(0xec)]['set'](_0x226c8c,_0xe76b79);if(_0x5442fd[_0x394e1a(0xec)][_0x394e1a(0xf3)]>this['config']['maxChatsPerSession']){let _0x1f574f=null,_0x2a0eb3=Date[_0x394e1a(0xf4)]();for(const [_0x280e08,_0x55ce5e]of _0x5442fd['chats']){_0x55ce5e[_0x394e1a(0x107)]<_0x2a0eb3&&(_0x2a0eb3=_0x55ce5e[_0x394e1a(0x107)],_0x1f574f=_0x280e08);}_0x1f574f&&_0x5442fd[_0x394e1a(0xec)][_0x394e1a(0xef)](_0x1f574f);}}else _0xe76b79[_0x394e1a(0x107)]=Date[_0x394e1a(0xf4)]();return _0xe76b79;}['cleanupExpiredChats'](){const _0x2491d7=a42_0x2cc2d1,_0x587ab3=Date[_0x2491d7(0xf4)]();let _0x551d06=0x0;for(const [_0x16f255,_0x5bb70f]of this[_0x2491d7(0xfc)]){const _0x4230f6=[];for(const [_0x1d7c51,_0x1ed654]of _0x5bb70f['chats']){_0x587ab3-_0x1ed654['lastUsedAt']>this[_0x2491d7(0xfe)]['cacheExpirationMs']&&_0x4230f6[_0x2491d7(0xed)](_0x1d7c51);}for(const _0x3a0fd4 of _0x4230f6){_0x5bb70f[_0x2491d7(0xec)][_0x2491d7(0xef)](_0x3a0fd4),_0x551d06++;}_0x5bb70f['chats']['size']===0x0&&this[_0x2491d7(0xfc)][_0x2491d7(0xef)](_0x16f255);}return _0x551d06;}[a42_0x2cc2d1(0x102)](){const _0x10ee97=a42_0x2cc2d1;return this['sessions'][_0x10ee97(0xf3)];}[a42_0x2cc2d1(0xfd)](){const _0x568d9d=a42_0x2cc2d1;let _0xa248b=0x0;for(const _0x40a232 of this[_0x568d9d(0xfc)][_0x568d9d(0x109)]()){_0xa248b+=_0x40a232['chats'][_0x568d9d(0xf3)];}return _0xa248b;}[a42_0x2cc2d1(0xf0)](){const _0x1df3db=a42_0x2cc2d1;this[_0x1df3db(0xfc)][_0x1df3db(0xf0)]();}}
1
+ function a42_0xaafb(){const _0x228ad5=['config','582675KoPEPU','6433452mNuUCs','631339vDyDVl','33560flmkoC','6727070UEnbSk','cleanupExpiredChats','Session\x20','size','getTotalChatCount','\x20not\x20found','2exHtde','lastUsedAt','delete','maxChatsPerSession','4755SJErNg','now','set','clear','sessions','chats','11wtSkki','1384OSqEmC','23846750RdaWGM','387fTlIDm','push','getSession','get'];a42_0xaafb=function(){return _0x228ad5;};return a42_0xaafb();}const a42_0x3bde6c=a42_0x57cd;function a42_0x57cd(_0x146e02,_0x1c25d0){const _0xaafb4f=a42_0xaafb();return a42_0x57cd=function(_0x57cd43,_0x2f3e82){_0x57cd43=_0x57cd43-0xd3;let _0x4af6d5=_0xaafb4f[_0x57cd43];return _0x4af6d5;},a42_0x57cd(_0x146e02,_0x1c25d0);}(function(_0x2844d9,_0x50e545){const _0x281614=a42_0x57cd,_0x5b53ad=_0x2844d9();while(!![]){try{const _0x2dbaa8=parseInt(_0x281614(0xeb))/0x1*(parseInt(_0x281614(0xd7))/0x2)+-parseInt(_0x281614(0xe9))/0x3+parseInt(_0x281614(0xe2))/0x4*(parseInt(_0x281614(0xdb))/0x5)+parseInt(_0x281614(0xea))/0x6+parseInt(_0x281614(0xed))/0x7+-parseInt(_0x281614(0xec))/0x8*(-parseInt(_0x281614(0xe4))/0x9)+-parseInt(_0x281614(0xe3))/0xa*(parseInt(_0x281614(0xe1))/0xb);if(_0x2dbaa8===_0x50e545)break;else _0x5b53ad['push'](_0x5b53ad['shift']());}catch(_0x2c86c6){_0x5b53ad['push'](_0x5b53ad['shift']());}}}(a42_0xaafb,0x914b2));export class SessionCache{[a42_0x3bde6c(0xdf)];[a42_0x3bde6c(0xe8)];constructor(_0x328f17){const _0x59aa5c=a42_0x3bde6c;this[_0x59aa5c(0xe8)]=_0x328f17,this['sessions']=new Map();}['getOrCreateSession'](_0x24952c,_0x205196){const _0x474bc6=a42_0x3bde6c;let _0x2f7469=this['sessions'][_0x474bc6(0xe7)](_0x24952c);return!_0x2f7469&&(_0x2f7469={'projectId':_0x205196,'messageHistory':[],'chats':new Map()},this[_0x474bc6(0xdf)][_0x474bc6(0xdd)](_0x24952c,_0x2f7469)),_0x2f7469;}[a42_0x3bde6c(0xe6)](_0x937f7b){const _0xeb60cb=a42_0x3bde6c;return this[_0xeb60cb(0xdf)][_0xeb60cb(0xe7)](_0x937f7b);}['getOrCreateChat'](_0x8da86c,_0x3d09b9,_0x45bf97){const _0x48ea81=a42_0x3bde6c,_0x1e96d7=this[_0x48ea81(0xdf)][_0x48ea81(0xe7)](_0x8da86c);if(!_0x1e96d7)throw new Error(_0x48ea81(0xd3)+_0x8da86c+_0x48ea81(0xd6));let _0x134af2=_0x1e96d7[_0x48ea81(0xe0)]['get'](_0x3d09b9);if(!_0x134af2){_0x134af2={'chatId':'','agentId':_0x45bf97,'contextSignature':_0x3d09b9,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'lastUsedAt':Date[_0x48ea81(0xdc)]()},_0x1e96d7[_0x48ea81(0xe0)][_0x48ea81(0xdd)](_0x3d09b9,_0x134af2);if(_0x1e96d7[_0x48ea81(0xe0)][_0x48ea81(0xd4)]>this['config'][_0x48ea81(0xda)]){let _0x9f3ebf=null,_0x2d4437=Date[_0x48ea81(0xdc)]();for(const [_0x3df33a,_0x2d9ff6]of _0x1e96d7['chats']){_0x2d9ff6['lastUsedAt']<_0x2d4437&&(_0x2d4437=_0x2d9ff6[_0x48ea81(0xd8)],_0x9f3ebf=_0x3df33a);}_0x9f3ebf&&_0x1e96d7[_0x48ea81(0xe0)][_0x48ea81(0xd9)](_0x9f3ebf);}}else _0x134af2[_0x48ea81(0xd8)]=Date[_0x48ea81(0xdc)]();return _0x134af2;}[a42_0x3bde6c(0xee)](){const _0xdc7e71=a42_0x3bde6c,_0x1219a6=Date[_0xdc7e71(0xdc)]();let _0xcf3d0f=0x0;for(const [_0x1eb318,_0x4104b3]of this[_0xdc7e71(0xdf)]){const _0x3762bf=[];for(const [_0x166dca,_0x3e7662]of _0x4104b3[_0xdc7e71(0xe0)]){_0x1219a6-_0x3e7662['lastUsedAt']>this[_0xdc7e71(0xe8)]['cacheExpirationMs']&&_0x3762bf[_0xdc7e71(0xe5)](_0x166dca);}for(const _0x4c6b3f of _0x3762bf){_0x4104b3[_0xdc7e71(0xe0)][_0xdc7e71(0xd9)](_0x4c6b3f),_0xcf3d0f++;}_0x4104b3[_0xdc7e71(0xe0)][_0xdc7e71(0xd4)]===0x0&&this[_0xdc7e71(0xdf)][_0xdc7e71(0xd9)](_0x1eb318);}return _0xcf3d0f;}['getSessionCount'](){const _0x821889=a42_0x3bde6c;return this[_0x821889(0xdf)][_0x821889(0xd4)];}[a42_0x3bde6c(0xd5)](){const _0x3f1a16=a42_0x3bde6c;let _0xf29b37=0x0;for(const _0x487703 of this['sessions']['values']()){_0xf29b37+=_0x487703['chats'][_0x3f1a16(0xd4)];}return _0xf29b37;}[a42_0x3bde6c(0xde)](){const _0x1ca65f=a42_0x3bde6c;this[_0x1ca65f(0xdf)][_0x1ca65f(0xde)]();}}
package/dist/sdk/api.js CHANGED
@@ -1 +1 @@
1
- const a43_0x1a7cf8=a43_0x3056;(function(_0x1d4acb,_0x4bf17d){const _0xf8be8d=a43_0x3056,_0x4e0729=_0x1d4acb();while(!![]){try{const _0x4a4b49=parseInt(_0xf8be8d(0x136))/0x1*(-parseInt(_0xf8be8d(0x146))/0x2)+parseInt(_0xf8be8d(0x140))/0x3+-parseInt(_0xf8be8d(0x13d))/0x4+parseInt(_0xf8be8d(0x12d))/0x5*(-parseInt(_0xf8be8d(0x145))/0x6)+parseInt(_0xf8be8d(0x143))/0x7+-parseInt(_0xf8be8d(0x132))/0x8*(parseInt(_0xf8be8d(0x142))/0x9)+parseInt(_0xf8be8d(0x148))/0xa;if(_0x4a4b49===_0x4bf17d)break;else _0x4e0729['push'](_0x4e0729['shift']());}catch(_0x2e6d94){_0x4e0729['push'](_0x4e0729['shift']());}}}(a43_0x5656,0xbae8b));function a43_0x5656(){const _0x2fc06c=['request','Endpoint\x20must\x20start\x20with\x20/:\x20','335507fHtarh','data','status','config','string','Content-Type','message','5920756FLOPXD','stringify','site','4338363cVVOGw','headers','18TUXTxa','870058lgkEwT','utf-8','7320354lHKlao','2cMztji','application/json','28691930JJKokz','5PWJCQJ','trino','Error:\x20','apiKey','logger','2553096mWDVyq','readBodyFromFile'];a43_0x5656=function(){return _0x2fc06c;};return a43_0x5656();}import{HTTPClient}from'../client/http-client.js';import{getEndpoint}from'../types/index.js';function a43_0x3056(_0x37af43,_0x47d067){const _0x56563e=a43_0x5656();return a43_0x3056=function(_0x30560b,_0x514dc4){_0x30560b=_0x30560b-0x12d;let _0x5589bc=_0x56563e[_0x30560b];return _0x5589bc;},a43_0x3056(_0x37af43,_0x47d067);}import{getAuthHeaders,getTrinoHeaders,toHeaderRecord}from'../core/auth.js';import{readFileSync}from'fs';export class RawAPI{['config'];[a43_0x1a7cf8(0x131)];constructor(_0x263a03,_0x49f5f0){const _0x797611=a43_0x1a7cf8;this[_0x797611(0x139)]=_0x263a03,this[_0x797611(0x131)]=_0x49f5f0;}async[a43_0x1a7cf8(0x134)](_0x49d2ee,_0x4e03d1={}){const _0x426fcf=a43_0x1a7cf8,{method:method='GET',body:_0x2a824a,headers:_0x40f266={},apiType:apiType='td',includeHeaders:includeHeaders=![]}=_0x4e03d1;if(!_0x49d2ee['startsWith']('/'))throw new Error(_0x426fcf(0x135)+_0x49d2ee);const _0x520b73=getEndpoint(this[_0x426fcf(0x139)][_0x426fcf(0x13f)],apiType);let _0x4affaa;if(apiType===_0x426fcf(0x12e)){const _0x1ccaf6=getTrinoHeaders(this[_0x426fcf(0x139)][_0x426fcf(0x13f)],this[_0x426fcf(0x139)][_0x426fcf(0x130)]);_0x4affaa={..._0x1ccaf6,..._0x40f266};}else{const _0x336a4c=getAuthHeaders(this[_0x426fcf(0x139)][_0x426fcf(0x13f)],this[_0x426fcf(0x139)][_0x426fcf(0x130)]);_0x4affaa={...toHeaderRecord(_0x336a4c),..._0x40f266};}const _0x790e1e=_0x4affaa;let _0x14427a;_0x2a824a!==undefined&&(_0x14427a=typeof _0x2a824a===_0x426fcf(0x13a)?_0x2a824a:JSON[_0x426fcf(0x13e)](_0x2a824a),!_0x790e1e[_0x426fcf(0x13b)]&&(_0x790e1e[_0x426fcf(0x13b)]=_0x426fcf(0x147)));const _0x46078e=new HTTPClient(_0x520b73,_0x790e1e,this['logger']),_0xc30864=await _0x46078e['request'](method,_0x49d2ee,{'body':_0x14427a,'includeHeaders':!![]});return includeHeaders?{'data':_0xc30864[_0x426fcf(0x137)],'status':_0xc30864[_0x426fcf(0x138)],'headers':_0xc30864[_0x426fcf(0x141)]}:{'data':_0xc30864[_0x426fcf(0x137)],'status':_0xc30864['status']};}static[a43_0x1a7cf8(0x133)](_0x1eba47){const _0x4e6c4b=a43_0x1a7cf8;try{return readFileSync(_0x1eba47,_0x4e6c4b(0x144));}catch(_0x35c756){throw new Error('Failed\x20to\x20read\x20request\x20body\x20from\x20file:\x20'+_0x1eba47+'.\x20'+(_0x4e6c4b(0x12f)+(_0x35c756 instanceof Error?_0x35c756[_0x4e6c4b(0x13c)]:String(_0x35c756))));}}}
1
+ const a43_0x4ba3d5=a43_0x19af;function a43_0x19af(_0x352f8e,_0x610d59){const _0x301e29=a43_0x301e();return a43_0x19af=function(_0x19af5b,_0x3bad44){_0x19af5b=_0x19af5b-0x1e8;let _0x45cd83=_0x301e29[_0x19af5b];return _0x45cd83;},a43_0x19af(_0x352f8e,_0x610d59);}(function(_0x42abc4,_0x1bf28e){const _0xc3da2c=a43_0x19af,_0xb45cee=_0x42abc4();while(!![]){try{const _0x114794=-parseInt(_0xc3da2c(0x1fc))/0x1*(-parseInt(_0xc3da2c(0x1e9))/0x2)+parseInt(_0xc3da2c(0x1f6))/0x3+parseInt(_0xc3da2c(0x1f7))/0x4+parseInt(_0xc3da2c(0x1ef))/0x5*(parseInt(_0xc3da2c(0x1f0))/0x6)+parseInt(_0xc3da2c(0x1fa))/0x7+-parseInt(_0xc3da2c(0x1ea))/0x8*(parseInt(_0xc3da2c(0x1f5))/0x9)+-parseInt(_0xc3da2c(0x1f4))/0xa;if(_0x114794===_0x1bf28e)break;else _0xb45cee['push'](_0xb45cee['shift']());}catch(_0x2a1739){_0xb45cee['push'](_0xb45cee['shift']());}}}(a43_0x301e,0x59caa));import{HTTPClient}from'../client/http-client.js';import{getEndpoint}from'../types/index.js';import{getAuthHeaders,getTrinoHeaders,toHeaderRecord}from'../core/auth.js';import{readFileSync}from'fs';export class RawAPI{['config'];['logger'];constructor(_0x5bd1fd,_0x40a76c){const _0x16ea94=a43_0x19af;this[_0x16ea94(0x202)]=_0x5bd1fd,this[_0x16ea94(0x201)]=_0x40a76c;}async['request'](_0x576de5,_0x2af98a={}){const _0x4e4c0c=a43_0x19af,{method:method='GET',body:_0x22f27a,headers:_0x10a70d={},apiType:apiType='td',includeHeaders:includeHeaders=![]}=_0x2af98a;if(!_0x576de5[_0x4e4c0c(0x200)]('/'))throw new Error('Endpoint\x20must\x20start\x20with\x20/:\x20'+_0x576de5);const _0x39ce3a=getEndpoint(this['config'][_0x4e4c0c(0x1fd)],apiType);let _0x1eae7b;if(apiType===_0x4e4c0c(0x1e8)){const _0x1c29da=getTrinoHeaders(this[_0x4e4c0c(0x202)][_0x4e4c0c(0x1fd)],this[_0x4e4c0c(0x202)][_0x4e4c0c(0x1f3)]);_0x1eae7b={..._0x1c29da,..._0x10a70d};}else{const _0xd44a58=getAuthHeaders(this[_0x4e4c0c(0x202)]['site'],this[_0x4e4c0c(0x202)]['apiKey']);_0x1eae7b={...toHeaderRecord(_0xd44a58),..._0x10a70d};}const _0x510a3a=_0x1eae7b;let _0x2129da;_0x22f27a!==undefined&&(_0x2129da=typeof _0x22f27a==='string'?_0x22f27a:JSON[_0x4e4c0c(0x1ed)](_0x22f27a),!_0x510a3a[_0x4e4c0c(0x1f9)]&&(_0x510a3a[_0x4e4c0c(0x1f9)]=_0x4e4c0c(0x1f2)));const _0x614c6b=new HTTPClient(_0x39ce3a,_0x510a3a,this[_0x4e4c0c(0x201)]),_0x2bcd92=await _0x614c6b[_0x4e4c0c(0x1ee)](method,_0x576de5,{'body':_0x2129da,'includeHeaders':!![]});return includeHeaders?{'data':_0x2bcd92[_0x4e4c0c(0x1fe)],'status':_0x2bcd92[_0x4e4c0c(0x1ec)],'headers':_0x2bcd92['headers']}:{'data':_0x2bcd92[_0x4e4c0c(0x1fe)],'status':_0x2bcd92[_0x4e4c0c(0x1ec)]};}static[a43_0x4ba3d5(0x1ff)](_0x391717){const _0x5aee5a=a43_0x4ba3d5;try{return readFileSync(_0x391717,_0x5aee5a(0x1fb));}catch(_0x4f7689){throw new Error(_0x5aee5a(0x1f8)+_0x391717+'.\x20'+(_0x5aee5a(0x1eb)+(_0x4f7689 instanceof Error?_0x4f7689[_0x5aee5a(0x1f1)]:String(_0x4f7689))));}}}function a43_0x301e(){const _0x4af955=['48432qazQzp','message','application/json','apiKey','15862310gvUeaa','1445607WPVDaE','1561461BJqBqg','1777412KfvTSC','Failed\x20to\x20read\x20request\x20body\x20from\x20file:\x20','Content-Type','3024966MSfkug','utf-8','233715HBgqMp','site','data','readBodyFromFile','startsWith','logger','config','trino','4hSTkqA','8kWGCbk','Error:\x20','status','stringify','request','155VZwMpu'];a43_0x301e=function(){return _0x4af955;};return a43_0x301e();}
@@ -1 +1 @@
1
- const a44_0x3febb7=a44_0x590c;(function(_0xb85507,_0x2f19a4){const _0x1e30b7=a44_0x590c,_0x55d633=_0xb85507();while(!![]){try{const _0xd350d9=parseInt(_0x1e30b7(0x1f5))/0x1+-parseInt(_0x1e30b7(0x1f9))/0x2+parseInt(_0x1e30b7(0x1fc))/0x3*(-parseInt(_0x1e30b7(0x200))/0x4)+parseInt(_0x1e30b7(0x1f6))/0x5*(parseInt(_0x1e30b7(0x205))/0x6)+-parseInt(_0x1e30b7(0x1fd))/0x7+parseInt(_0x1e30b7(0x1f7))/0x8*(parseInt(_0x1e30b7(0x1ff))/0x9)+parseInt(_0x1e30b7(0x1f3))/0xa;if(_0xd350d9===_0x2f19a4)break;else _0x55d633['push'](_0x55d633['shift']());}catch(_0x4831d0){_0x55d633['push'](_0x55d633['shift']());}}}(a44_0x1a77,0xbbabd));import{buildLikePattern}from'../utils/string-utils.js';import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';function a44_0x590c(_0x2fec3b,_0x382807){const _0x1a7784=a44_0x1a77();return a44_0x590c=function(_0x590c23,_0x49301c){_0x590c23=_0x590c23-0x1f0;let _0x3c459d=_0x1a7784[_0x590c23];return _0x3c459d;},a44_0x590c(_0x2fec3b,_0x382807);}function a44_0x1a77(){const _0x182362=['3183755nkweIt','3499160sZypap','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.','2606344oMNFmm','trim','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20schema_name\x20AS\x20database_name\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20','3roupah','7485485ovehsX','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','9EQeiYE','5329004OiwqiZ','\x0a\x20\x20AND\x20schema_name\x20LIKE\x20','data','length','INVALID_ARGUMENT','12YNJoix','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','Limit\x20must\x20be\x20a\x20positive\x20number','client','26442730JUHFLQ','\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20','118309NRvrFo'];a44_0x1a77=function(){return _0x182362;};return a44_0x1a77();}export class DatabaseAPI{[a44_0x3febb7(0x1f2)];constructor(_0x124c57){const _0x5e13b6=a44_0x3febb7;this[_0x5e13b6(0x1f2)]=_0x124c57;}async['list'](_0x58b1cf,_0x2ea14a=DEFAULT_LISTING_LIMIT){const _0x4295c0=a44_0x3febb7;if(_0x58b1cf!==undefined&&_0x58b1cf['trim']()[_0x4295c0(0x203)]===0x0)throw new SDKError(ErrorCode[_0x4295c0(0x204)],_0x4295c0(0x1fe),undefined,{'helpText':_0x4295c0(0x1f8)});if(_0x2ea14a<=0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x4295c0(0x1f1),undefined,{'helpText':_0x4295c0(0x1f0)});let _0x29f152=_0x4295c0(0x1fb);_0x58b1cf&&(_0x29f152+=_0x4295c0(0x201)+buildLikePattern(_0x58b1cf)+'\x20ESCAPE\x20\x27\x5c\x27');_0x29f152+=_0x4295c0(0x1f4)+_0x2ea14a;const _0x2d9fea=await this['client']['executeQuery'](_0x29f152[_0x4295c0(0x1fa)]());return _0x2d9fea[_0x4295c0(0x202)];}}
1
+ const a44_0x5ed466=a44_0x45d5;(function(_0x20e2a8,_0x402b13){const _0x83e6fb=a44_0x45d5,_0xd51e83=_0x20e2a8();while(!![]){try{const _0x5f5410=parseInt(_0x83e6fb(0x153))/0x1+-parseInt(_0x83e6fb(0x156))/0x2*(parseInt(_0x83e6fb(0x164))/0x3)+parseInt(_0x83e6fb(0x157))/0x4*(-parseInt(_0x83e6fb(0x158))/0x5)+parseInt(_0x83e6fb(0x15f))/0x6+-parseInt(_0x83e6fb(0x155))/0x7*(parseInt(_0x83e6fb(0x160))/0x8)+parseInt(_0x83e6fb(0x152))/0x9*(parseInt(_0x83e6fb(0x15c))/0xa)+parseInt(_0x83e6fb(0x15a))/0xb*(parseInt(_0x83e6fb(0x150))/0xc);if(_0x5f5410===_0x402b13)break;else _0xd51e83['push'](_0xd51e83['shift']());}catch(_0x1cd110){_0xd51e83['push'](_0xd51e83['shift']());}}}(a44_0x2ee9,0xe219b));function a44_0x45d5(_0x186b58,_0x26d49b){const _0x2ee941=a44_0x2ee9();return a44_0x45d5=function(_0x45d5cd,_0x1f6cbd){_0x45d5cd=_0x45d5cd-0x150;let _0x10d1c2=_0x2ee941[_0x45d5cd];return _0x10d1c2;},a44_0x45d5(_0x186b58,_0x26d49b);}function a44_0x2ee9(){const _0x36f60c=['21944Ertvud','\x0a\x20\x20\x20\x20\x20\x20SELECT\x20schema_name\x20AS\x20database_name\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20','executeQuery','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20the\x20pattern\x20to\x20list\x20all\x20databases.','81eFdyhK','1992YGwmyP','INVALID_ARGUMENT','99pxFdrb','134281GngunC','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','3997Huvrpx','34406wzKVDi','100004RmuKgS','245udRdUB','client','114521FoNuKA','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','1530610gbEIUQ','trim','\x0a\x20\x20AND\x20schema_name\x20LIKE\x20','3814272ieLUav'];a44_0x2ee9=function(){return _0x36f60c;};return a44_0x2ee9();}import{buildLikePattern}from'../utils/string-utils.js';import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';export class DatabaseAPI{[a44_0x5ed466(0x159)];constructor(_0x48e399){const _0x50602d=a44_0x5ed466;this[_0x50602d(0x159)]=_0x48e399;}async['list'](_0x141778,_0x2cd7e7=DEFAULT_LISTING_LIMIT){const _0x139f26=a44_0x5ed466;if(_0x141778!==undefined&&_0x141778[_0x139f26(0x15d)]()['length']===0x0)throw new SDKError(ErrorCode[_0x139f26(0x151)],_0x139f26(0x154),undefined,{'helpText':_0x139f26(0x163)});if(_0x2cd7e7<=0x0)throw new SDKError(ErrorCode[_0x139f26(0x151)],'Limit\x20must\x20be\x20a\x20positive\x20number',undefined,{'helpText':_0x139f26(0x15b)});let _0x3ceb25=_0x139f26(0x161);_0x141778&&(_0x3ceb25+=_0x139f26(0x15e)+buildLikePattern(_0x141778)+'\x20ESCAPE\x20\x27\x5c\x27');_0x3ceb25+='\x0aORDER\x20BY\x20database_name\x0aLIMIT\x20'+_0x2cd7e7;const _0x5e62d2=await this[_0x139f26(0x159)][_0x139f26(0x162)](_0x3ceb25[_0x139f26(0x15d)]());return _0x5e62d2['data'];}}
@@ -1 +1 @@
1
- const a45_0x229632=a45_0x1127;(function(_0x3393bd,_0x1007da){const _0x3facb0=a45_0x1127,_0x4f964c=_0x3393bd();while(!![]){try{const _0x2ef53e=-parseInt(_0x3facb0(0xb5))/0x1*(parseInt(_0x3facb0(0xb9))/0x2)+-parseInt(_0x3facb0(0xd0))/0x3*(-parseInt(_0x3facb0(0xc3))/0x4)+parseInt(_0x3facb0(0xad))/0x5*(-parseInt(_0x3facb0(0xb6))/0x6)+-parseInt(_0x3facb0(0xa9))/0x7+-parseInt(_0x3facb0(0xc0))/0x8+parseInt(_0x3facb0(0xc5))/0x9*(parseInt(_0x3facb0(0xb7))/0xa)+parseInt(_0x3facb0(0xc7))/0xb*(parseInt(_0x3facb0(0xa7))/0xc);if(_0x2ef53e===_0x1007da)break;else _0x4f964c['push'](_0x4f964c['shift']());}catch(_0x551da8){_0x4f964c['push'](_0x4f964c['shift']());}}}(a45_0x4d17,0x3b4c4));export var ErrorCategory;(function(_0x3d010c){const _0xadd7c5=a45_0x1127;_0x3d010c[_0xadd7c5(0xc8)]=_0xadd7c5(0xc8),_0x3d010c[_0xadd7c5(0xca)]=_0xadd7c5(0xca);}(ErrorCategory||(ErrorCategory={})));export var ErrorCode;function a45_0x4d17(){const _0x4ed070=['PERMISSION_DENIED','TABLE_NOT_FOUND','TRINO_SYNTAX_ERROR','LLM_CHAT_CREATION_FAILURE','code','DATABASE_NOT_FOUND','5nIxgRK','18FtHeem','326030jXzMUv','originalMessage','146792XTvlRT','helpText','UNAVAILABLE','ALREADY_EXISTS','TRINO_INSUFFICIENT_RESOURCES','CANCELLED','HTTP_REQUEST_FAILURE','2535400asnlcQ','TRINO_USER_CANCELLED','LLM_EMPTY_MESSAGE','12788VPOXxz','SDKError','108lhRUHb','TRINO_INVALID_ARGUMENT','6444449mKXDhe','USER_ERROR','TRINO_NOT_FOUND','INTERNAL_ERROR','stack','INVALID_ARGUMENT','AGENT_NOT_FOUND','INTERNAL','includes','78kIFfrg','cause','NOT_FOUND','message','UNAUTHENTICATED','CHAT_NOT_FOUND','LLM_MALFORMED_MESSAGE','COMMAND_NOT_FOUND','RATE_LIMITED','isRetryable','TIMEOUT','24dYFdFf','LLM_PROJECT_NOT_FOUND','2782486HjqVZo','MISSING_ARGUMENT','TRINO_INTERNAL_ERROR','WORKFLOW_PROJECT_NOT_FOUND','536315ojyJgg','LLM_STREAM_ERROR'];a45_0x4d17=function(){return _0x4ed070;};return a45_0x4d17();}(function(_0x2c9647){const _0x38fd3a=a45_0x1127;_0x2c9647['MISSING_ARGUMENT']=_0x38fd3a(0xaa),_0x2c9647[_0x38fd3a(0xcc)]=_0x38fd3a(0xcc),_0x2c9647[_0x38fd3a(0xd2)]=_0x38fd3a(0xd2),_0x2c9647[_0x38fd3a(0xb4)]=_0x38fd3a(0xb4),_0x2c9647[_0x38fd3a(0xb0)]=_0x38fd3a(0xb0),_0x2c9647[_0x38fd3a(0xa8)]=_0x38fd3a(0xa8),_0x2c9647['AGENT_NOT_FOUND']='AGENT_NOT_FOUND',_0x2c9647['WORKFLOW_PROJECT_NOT_FOUND']=_0x38fd3a(0xac),_0x2c9647[_0x38fd3a(0xd5)]=_0x38fd3a(0xd5),_0x2c9647[_0x38fd3a(0xc2)]='LLM_EMPTY_MESSAGE',_0x2c9647[_0x38fd3a(0xd7)]=_0x38fd3a(0xd7),_0x2c9647['PERMISSION_DENIED']='PERMISSION_DENIED',_0x2c9647[_0x38fd3a(0xd4)]=_0x38fd3a(0xd4),_0x2c9647['ALREADY_EXISTS']=_0x38fd3a(0xbc),_0x2c9647['CANCELLED']=_0x38fd3a(0xbe),_0x2c9647[_0x38fd3a(0xb1)]=_0x38fd3a(0xb1),_0x2c9647[_0x38fd3a(0xc9)]=_0x38fd3a(0xc9),_0x2c9647[_0x38fd3a(0xc6)]='TRINO_INVALID_ARGUMENT',_0x2c9647[_0x38fd3a(0xc1)]='TRINO_USER_CANCELLED',_0x2c9647['UNAVAILABLE']=_0x38fd3a(0xbb),_0x2c9647['TIMEOUT']=_0x38fd3a(0xa6),_0x2c9647[_0x38fd3a(0xbf)]=_0x38fd3a(0xbf),_0x2c9647[_0x38fd3a(0xce)]='INTERNAL',_0x2c9647[_0x38fd3a(0xa4)]=_0x38fd3a(0xa4),_0x2c9647['TRINO_INTERNAL_ERROR']='TRINO_INTERNAL_ERROR',_0x2c9647[_0x38fd3a(0xbd)]=_0x38fd3a(0xbd),_0x2c9647[_0x38fd3a(0xd6)]=_0x38fd3a(0xd6),_0x2c9647[_0x38fd3a(0xae)]=_0x38fd3a(0xae),_0x2c9647[_0x38fd3a(0xb2)]=_0x38fd3a(0xb2);}(ErrorCode||(ErrorCode={})));const ERROR_CODE_CATEGORY={[ErrorCode['MISSING_ARGUMENT']]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xcc)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xd2)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xb4)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xb0)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xa8)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xcd)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xac)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a45_0x229632(0xd5)]]:ErrorCategory['USER_ERROR'],[ErrorCode['LLM_EMPTY_MESSAGE']]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xd7)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xaf)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xd4)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a45_0x229632(0xbc)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xbe)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode['TRINO_SYNTAX_ERROR']]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xc9)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xc6)]]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode['TRINO_USER_CANCELLED']]:ErrorCategory[a45_0x229632(0xc8)],[ErrorCode[a45_0x229632(0xbb)]]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode['TIMEOUT']]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode['HTTP_REQUEST_FAILURE']]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a45_0x229632(0xce)]]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode[a45_0x229632(0xa4)]]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode[a45_0x229632(0xab)]]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode[a45_0x229632(0xbd)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a45_0x229632(0xd6)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a45_0x229632(0xae)]]:ErrorCategory[a45_0x229632(0xca)],[ErrorCode[a45_0x229632(0xb2)]]:ErrorCategory[a45_0x229632(0xca)]};export function getErrorCategory(_0x50abd7){return ERROR_CODE_CATEGORY[_0x50abd7];}export function isRetryableError(_0x24e1ae){const _0x4eb068=a45_0x229632;return getErrorCategory(_0x24e1ae)===ErrorCategory[_0x4eb068(0xca)];}function a45_0x1127(_0x1ba21d,_0xce85a7){const _0x4d1728=a45_0x4d17();return a45_0x1127=function(_0x11277f,_0x25a2f0){_0x11277f=_0x11277f-0xa4;let _0x20f5f9=_0x4d1728[_0x11277f];return _0x20f5f9;},a45_0x1127(_0x1ba21d,_0xce85a7);}export class SDKError extends Error{[a45_0x229632(0xb3)];[a45_0x229632(0xba)];[a45_0x229632(0xd1)];constructor(_0x1009f2,_0x23495e,_0x39ff2e,_0x440dc8){const _0x214433=a45_0x229632;super('['+_0x1009f2+']\x20'+_0x23495e),this['name']=_0x214433(0xc4),this[_0x214433(0xb3)]=_0x1009f2,this[_0x214433(0xba)]=_0x440dc8?.[_0x214433(0xba)],this[_0x214433(0xd1)]=_0x39ff2e,_0x39ff2e instanceof Error&&(this[_0x214433(0xcb)]=this[_0x214433(0xcb)]+'\x0aCaused\x20by:\x20'+_0x39ff2e[_0x214433(0xcb)]);}get['category'](){return getErrorCategory(this['code']);}[a45_0x229632(0xa5)](){return isRetryableError(this['code']);}get[a45_0x229632(0xb8)](){const _0x505b54=a45_0x229632;return this[_0x505b54(0xd3)]['replace'](/^\[.*?\]\s*/,'');}}export function errorContains(_0x4d0110,..._0x4dd1f4){const _0x3ae10a=a45_0x229632,_0x7e2786=_0x4d0110?.['message']||'',_0x2ecaa5=_0x4d0110?.[_0x3ae10a(0xd1)],_0x232d9c=_0x2ecaa5?.[_0x3ae10a(0xd3)]||'';return _0x4dd1f4['some'](_0x209626=>_0x7e2786['includes'](_0x209626)||_0x232d9c[_0x3ae10a(0xcf)](_0x209626));}
1
+ const a45_0x589923=a45_0x47c4;(function(_0x169468,_0x38bdb7){const _0x56f3cf=a45_0x47c4,_0x26329f=_0x169468();while(!![]){try{const _0x516141=parseInt(_0x56f3cf(0x111))/0x1*(parseInt(_0x56f3cf(0x110))/0x2)+-parseInt(_0x56f3cf(0x129))/0x3*(-parseInt(_0x56f3cf(0x131))/0x4)+parseInt(_0x56f3cf(0x12c))/0x5*(parseInt(_0x56f3cf(0x12a))/0x6)+-parseInt(_0x56f3cf(0x10d))/0x7*(parseInt(_0x56f3cf(0x117))/0x8)+-parseInt(_0x56f3cf(0x108))/0x9*(parseInt(_0x56f3cf(0x11f))/0xa)+-parseInt(_0x56f3cf(0x124))/0xb+parseInt(_0x56f3cf(0x11e))/0xc;if(_0x516141===_0x38bdb7)break;else _0x26329f['push'](_0x26329f['shift']());}catch(_0x36ab96){_0x26329f['push'](_0x26329f['shift']());}}}(a45_0x4208,0x87778));function a45_0x47c4(_0x3cda29,_0x5c97ec){const _0x4208b6=a45_0x4208();return a45_0x47c4=function(_0x47c4a8,_0x1ee05f){_0x47c4a8=_0x47c4a8-0x101;let _0x18d214=_0x4208b6[_0x47c4a8];return _0x18d214;},a45_0x47c4(_0x3cda29,_0x5c97ec);}function a45_0x4208(){const _0x53d214=['10889593XSLHBs','TRINO_INSUFFICIENT_RESOURCES','LLM_EMPTY_MESSAGE','some','includes','6495HGyyAm','60IBdXTA','CANCELLED','419530xLDNdZ','stack','USER_ERROR','TRINO_INVALID_ARGUMENT','TRINO_NOT_FOUND','1676lrKYDe','code','TRINO_SYNTAX_ERROR','DATABASE_NOT_FOUND','cause','TIMEOUT','INVALID_ARGUMENT','COMMAND_NOT_FOUND','RATE_LIMITED','MISSING_ARGUMENT','LLM_CHAT_CREATION_FAILURE','SDKError','2120751gjpxER','message','CHAT_NOT_FOUND','AGENT_NOT_FOUND','replace','427gRBzhR','helpText','TRINO_USER_CANCELLED','316978GwWXZG','5yEMRQB','LLM_PROJECT_NOT_FOUND','INTERNAL','UNAVAILABLE','TABLE_NOT_FOUND','name','126584RbPEaT','originalMessage','WORKFLOW_PROJECT_NOT_FOUND','PERMISSION_DENIED','ALREADY_EXISTS','LLM_MALFORMED_MESSAGE','HTTP_REQUEST_FAILURE','8139780qqKAOh','30LjODNo','INTERNAL_ERROR','TRINO_INTERNAL_ERROR','NOT_FOUND','LLM_STREAM_ERROR'];a45_0x4208=function(){return _0x53d214;};return a45_0x4208();}export var ErrorCategory;(function(_0x5cee4d){const _0x567323=a45_0x47c4;_0x5cee4d[_0x567323(0x12e)]='USER_ERROR',_0x5cee4d[_0x567323(0x120)]=_0x567323(0x120);}(ErrorCategory||(ErrorCategory={})));export var ErrorCode;(function(_0x440f3d){const _0x5ee070=a45_0x47c4;_0x440f3d[_0x5ee070(0x105)]=_0x5ee070(0x105),_0x440f3d[_0x5ee070(0x102)]=_0x5ee070(0x102),_0x440f3d[_0x5ee070(0x122)]=_0x5ee070(0x122),_0x440f3d[_0x5ee070(0x134)]='DATABASE_NOT_FOUND',_0x440f3d[_0x5ee070(0x115)]='TABLE_NOT_FOUND',_0x440f3d[_0x5ee070(0x112)]=_0x5ee070(0x112),_0x440f3d['AGENT_NOT_FOUND']=_0x5ee070(0x10b),_0x440f3d[_0x5ee070(0x119)]=_0x5ee070(0x119),_0x440f3d[_0x5ee070(0x10a)]='CHAT_NOT_FOUND',_0x440f3d[_0x5ee070(0x126)]=_0x5ee070(0x126),_0x440f3d[_0x5ee070(0x103)]=_0x5ee070(0x103),_0x440f3d[_0x5ee070(0x11a)]=_0x5ee070(0x11a),_0x440f3d['UNAUTHENTICATED']='UNAUTHENTICATED',_0x440f3d[_0x5ee070(0x11b)]=_0x5ee070(0x11b),_0x440f3d[_0x5ee070(0x12b)]=_0x5ee070(0x12b),_0x440f3d[_0x5ee070(0x133)]=_0x5ee070(0x133),_0x440f3d[_0x5ee070(0x130)]=_0x5ee070(0x130),_0x440f3d[_0x5ee070(0x12f)]=_0x5ee070(0x12f),_0x440f3d[_0x5ee070(0x10f)]=_0x5ee070(0x10f),_0x440f3d[_0x5ee070(0x114)]=_0x5ee070(0x114),_0x440f3d[_0x5ee070(0x101)]=_0x5ee070(0x101),_0x440f3d[_0x5ee070(0x11d)]='HTTP_REQUEST_FAILURE',_0x440f3d['INTERNAL']=_0x5ee070(0x113),_0x440f3d[_0x5ee070(0x104)]=_0x5ee070(0x104),_0x440f3d[_0x5ee070(0x121)]='TRINO_INTERNAL_ERROR',_0x440f3d[_0x5ee070(0x125)]='TRINO_INSUFFICIENT_RESOURCES',_0x440f3d['LLM_MALFORMED_MESSAGE']=_0x5ee070(0x11c),_0x440f3d[_0x5ee070(0x123)]=_0x5ee070(0x123),_0x440f3d['LLM_CHAT_CREATION_FAILURE']=_0x5ee070(0x106);}(ErrorCode||(ErrorCode={})));const ERROR_CODE_CATEGORY={[ErrorCode[a45_0x589923(0x105)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode['INVALID_ARGUMENT']]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x122)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x134)]]:ErrorCategory['USER_ERROR'],[ErrorCode['TABLE_NOT_FOUND']]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x112)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode['AGENT_NOT_FOUND']]:ErrorCategory['USER_ERROR'],[ErrorCode[a45_0x589923(0x119)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x10a)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x126)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x103)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x11a)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode['UNAUTHENTICATED']]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x11b)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x12b)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode['TRINO_SYNTAX_ERROR']]:ErrorCategory['USER_ERROR'],[ErrorCode[a45_0x589923(0x130)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x12f)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x10f)]]:ErrorCategory[a45_0x589923(0x12e)],[ErrorCode[a45_0x589923(0x114)]]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode[a45_0x589923(0x101)]]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode[a45_0x589923(0x11d)]]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode['INTERNAL']]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode[a45_0x589923(0x104)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a45_0x589923(0x121)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode['TRINO_INSUFFICIENT_RESOURCES']]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a45_0x589923(0x11c)]]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode['LLM_STREAM_ERROR']]:ErrorCategory[a45_0x589923(0x120)],[ErrorCode[a45_0x589923(0x106)]]:ErrorCategory['INTERNAL_ERROR']};export function getErrorCategory(_0x15742f){return ERROR_CODE_CATEGORY[_0x15742f];}export function isRetryableError(_0x33838c){const _0xcb452=a45_0x589923;return getErrorCategory(_0x33838c)===ErrorCategory[_0xcb452(0x120)];}export class SDKError extends Error{[a45_0x589923(0x132)];[a45_0x589923(0x10e)];[a45_0x589923(0x135)];constructor(_0x504d1f,_0x3c858f,_0xb2a43c,_0x1cdf01){const _0x4e37f6=a45_0x589923;super('['+_0x504d1f+']\x20'+_0x3c858f),this[_0x4e37f6(0x116)]=_0x4e37f6(0x107),this['code']=_0x504d1f,this['helpText']=_0x1cdf01?.[_0x4e37f6(0x10e)],this[_0x4e37f6(0x135)]=_0xb2a43c,_0xb2a43c instanceof Error&&(this[_0x4e37f6(0x12d)]=this[_0x4e37f6(0x12d)]+'\x0aCaused\x20by:\x20'+_0xb2a43c[_0x4e37f6(0x12d)]);}get['category'](){const _0x2aeeff=a45_0x589923;return getErrorCategory(this[_0x2aeeff(0x132)]);}['isRetryable'](){return isRetryableError(this['code']);}get[a45_0x589923(0x118)](){const _0x4a9636=a45_0x589923;return this[_0x4a9636(0x109)][_0x4a9636(0x10c)](/^\[.*?\]\s*/,'');}}export function errorContains(_0xf44f2a,..._0xdec6a5){const _0x330948=a45_0x589923,_0x58755e=_0xf44f2a?.[_0x330948(0x109)]||'',_0x4e59f2=_0xf44f2a?.[_0x330948(0x135)],_0x32c4a1=_0x4e59f2?.[_0x330948(0x109)]||'';return _0xdec6a5[_0x330948(0x127)](_0x3bfcb8=>_0x58755e['includes'](_0x3bfcb8)||_0x32c4a1[_0x330948(0x128)](_0x3bfcb8));}
package/dist/sdk/index.js CHANGED
@@ -1 +1 @@
1
- const a46_0x5b91fc=a46_0x5cbe;(function(_0x1c3b70,_0x3b6340){const _0x3134c3=a46_0x5cbe,_0x1606fe=_0x1c3b70();while(!![]){try{const _0x5e8ab1=-parseInt(_0x3134c3(0x162))/0x1+parseInt(_0x3134c3(0x165))/0x2+parseInt(_0x3134c3(0x15b))/0x3*(parseInt(_0x3134c3(0x16e))/0x4)+-parseInt(_0x3134c3(0x158))/0x5+parseInt(_0x3134c3(0x160))/0x6+-parseInt(_0x3134c3(0x163))/0x7*(parseInt(_0x3134c3(0x16f))/0x8)+-parseInt(_0x3134c3(0x167))/0x9*(-parseInt(_0x3134c3(0x169))/0xa);if(_0x5e8ab1===_0x3b6340)break;else _0x1606fe['push'](_0x1606fe['shift']());}catch(_0x1fcaa8){_0x1606fe['push'](_0x1606fe['shift']());}}}(a46_0xe194,0xa5867));import{TrinoClient}from'../client/trino-client.js';import{TDClient}from'../client/td-client.js';import{CDPClient}from'../client/cdp-client.js';import{WorkflowClient}from'../client/workflow-client.js';import{LLMClient}from'../client/llm-client.js';import{loadUserConfigOnce,getAPIKey}from'../core/config.js';import{DatabaseAPI}from'./database.js';import{TableAPI}from'./table.js';import{SegmentAPI}from'./segment.js';import{WorkflowAPI}from'./workflow.js';import{LLMAPI}from'./llm.js';import{JobAPI}from'./job.js';import{RawAPI}from'./api.js';import{executeQuery}from'./query.js';import{LogLevel,TDXLogger}from'../utils/tdx-logger.js';export*from'./errors.js';export*from'./database.js';export*from'./table.js';export*from'./segment.js';export*from'./workflow.js';export*from'./llm.js';export*from'./job.js';function a46_0xe194(){const _0x75c440=['catch','apiKey','8OTovcT','7952376IApGFR','database','logLevel','llm','logger','cdpClient','6649995AWfdiV','init','api','1635111BoWvxr','us01','client','jobs','table','7810122jpEUwv','tdClient','514438XtMsvK','7JFCGym','llmClient','304424PTpAFB','site','18tMmyJB','workflow','4862510QhoTLO','segment','workflowClient'];a46_0xe194=function(){return _0x75c440;};return a46_0xe194();}export*from'./api.js';export*from'./query.js';export function loadLocalSDKConfig(_0x388377={}){const _0x4564fe=a46_0x5cbe,_0xb2dc7=_0x388377[_0x4564fe(0x166)]||_0x4564fe(0x15c),_0x5f0c57=_0x388377[_0x4564fe(0x154)]??LogLevel['INFO'];if(_0x388377[_0x4564fe(0x16d)])return{'site':_0xb2dc7,'apiKey':_0x388377[_0x4564fe(0x16d)],'logLevel':_0x5f0c57};loadUserConfigOnce();const _0x579592=getAPIKey(_0xb2dc7);return{'site':_0xb2dc7,'apiKey':_0x579592,'logLevel':_0x5f0c57};}function a46_0x5cbe(_0x5d53f4,_0xc898ab){const _0xe194eb=a46_0xe194();return a46_0x5cbe=function(_0x5cbebc,_0x192ffa){_0x5cbebc=_0x5cbebc-0x154;let _0x348962=_0xe194eb[_0x5cbebc];return _0x348962;},a46_0x5cbe(_0x5d53f4,_0xc898ab);}export class TDX{[a46_0x5b91fc(0x156)];[a46_0x5b91fc(0x15d)];[a46_0x5b91fc(0x161)];[a46_0x5b91fc(0x157)];[a46_0x5b91fc(0x16b)];[a46_0x5b91fc(0x164)];['database'];[a46_0x5b91fc(0x15f)];['segment'];[a46_0x5b91fc(0x168)];[a46_0x5b91fc(0x155)];[a46_0x5b91fc(0x15e)];[a46_0x5b91fc(0x15a)];constructor(_0x1d3a5d){const _0x4ed230=a46_0x5b91fc;this[_0x4ed230(0x156)]=new TDXLogger(_0x1d3a5d[_0x4ed230(0x154)],!![]),this[_0x4ed230(0x156)][_0x4ed230(0x159)]()[_0x4ed230(0x16c)](()=>{}),this[_0x4ed230(0x15d)]=new TrinoClient(_0x1d3a5d,this['logger']),this[_0x4ed230(0x161)]=new TDClient(_0x1d3a5d,this[_0x4ed230(0x156)]),this['cdpClient']=new CDPClient(_0x1d3a5d,this[_0x4ed230(0x156)]),this[_0x4ed230(0x16b)]=new WorkflowClient(_0x1d3a5d,this[_0x4ed230(0x156)]),this[_0x4ed230(0x164)]=new LLMClient(_0x1d3a5d,this[_0x4ed230(0x156)]),this[_0x4ed230(0x170)]=new DatabaseAPI(this[_0x4ed230(0x15d)]),this['table']=new TableAPI(this['client']),this[_0x4ed230(0x16a)]=new SegmentAPI(this['cdpClient']),this['workflow']=new WorkflowAPI(this[_0x4ed230(0x16b)]),this[_0x4ed230(0x155)]=new LLMAPI(this[_0x4ed230(0x164)]),this[_0x4ed230(0x15e)]=new JobAPI(this[_0x4ed230(0x161)]),this['api']=new RawAPI(_0x1d3a5d,this[_0x4ed230(0x156)]);}async['query'](_0x45fa0b,_0xb1329d){const _0x338168=a46_0x5b91fc;return executeQuery(this[_0x338168(0x15d)],_0x45fa0b,_0xb1329d);}}
1
+ const a46_0x28a242=a46_0x5dad;(function(_0x108fe0,_0x4d77d3){const _0xd932fe=a46_0x5dad,_0x3adce1=_0x108fe0();while(!![]){try{const _0x140bf0=parseInt(_0xd932fe(0x20a))/0x1+parseInt(_0xd932fe(0x20d))/0x2*(parseInt(_0xd932fe(0x206))/0x3)+-parseInt(_0xd932fe(0x1f7))/0x4+-parseInt(_0xd932fe(0x1fc))/0x5+-parseInt(_0xd932fe(0x203))/0x6*(-parseInt(_0xd932fe(0x1f6))/0x7)+-parseInt(_0xd932fe(0x1f2))/0x8*(parseInt(_0xd932fe(0x1fa))/0x9)+parseInt(_0xd932fe(0x202))/0xa;if(_0x140bf0===_0x4d77d3)break;else _0x3adce1['push'](_0x3adce1['shift']());}catch(_0x2530e3){_0x3adce1['push'](_0x3adce1['shift']());}}}(a46_0x5868,0x4d52f));import{TrinoClient}from'../client/trino-client.js';import{TDClient}from'../client/td-client.js';import{CDPClient}from'../client/cdp-client.js';import{WorkflowClient}from'../client/workflow-client.js';import{LLMClient}from'../client/llm-client.js';import{loadUserConfigOnce,getAPIKey}from'../core/config.js';import{DatabaseAPI}from'./database.js';function a46_0x5868(){const _0x432eb1=['INFO','133476tGQwcQ','api','client','948548ukanwz','catch','83488EEYbRs','apiKey','us01','tdClient','14bgMTAV','1267080BALVtF','workflow','logLevel','369bEKoNW','cdpClient','2928115fMiaek','workflowClient','jobs','llm','query','table','5592460TtTANu','1439976hJNjPz','database','llmClient','3fYHSCg','init','logger'];a46_0x5868=function(){return _0x432eb1;};return a46_0x5868();}import{TableAPI}from'./table.js';import{SegmentAPI}from'./segment.js';import{WorkflowAPI}from'./workflow.js';import{LLMAPI}from'./llm.js';function a46_0x5dad(_0x3882ed,_0x232209){const _0x586870=a46_0x5868();return a46_0x5dad=function(_0x5dad0f,_0xfcafb0){_0x5dad0f=_0x5dad0f-0x1f1;let _0x3d04f1=_0x586870[_0x5dad0f];return _0x3d04f1;},a46_0x5dad(_0x3882ed,_0x232209);}import{JobAPI}from'./job.js';import{RawAPI}from'./api.js';import{executeQuery}from'./query.js';import{LogLevel,TDXLogger}from'../utils/tdx-logger.js';export*from'./errors.js';export*from'./database.js';export*from'./table.js';export*from'./segment.js';export*from'./workflow.js';export*from'./llm.js';export*from'./job.js';export*from'./api.js';export*from'./query.js';export function loadLocalSDKConfig(_0x4b5f70={}){const _0x1a2356=a46_0x5dad,_0x1fefa0=_0x4b5f70['site']||_0x1a2356(0x1f4),_0x5c63d1=_0x4b5f70[_0x1a2356(0x1f9)]??LogLevel[_0x1a2356(0x209)];if(_0x4b5f70['apiKey'])return{'site':_0x1fefa0,'apiKey':_0x4b5f70[_0x1a2356(0x1f3)],'logLevel':_0x5c63d1};loadUserConfigOnce();const _0xa03f1d=getAPIKey(_0x1fefa0);return{'site':_0x1fefa0,'apiKey':_0xa03f1d,'logLevel':_0x5c63d1};}export class TDX{[a46_0x28a242(0x208)];[a46_0x28a242(0x20c)];[a46_0x28a242(0x1f5)];['cdpClient'];['workflowClient'];[a46_0x28a242(0x205)];[a46_0x28a242(0x204)];[a46_0x28a242(0x201)];['segment'];[a46_0x28a242(0x1f8)];[a46_0x28a242(0x1ff)];[a46_0x28a242(0x1fe)];[a46_0x28a242(0x20b)];constructor(_0x4df1d1){const _0x2750d1=a46_0x28a242;this[_0x2750d1(0x208)]=new TDXLogger(_0x4df1d1[_0x2750d1(0x1f9)],!![]),this[_0x2750d1(0x208)][_0x2750d1(0x207)]()[_0x2750d1(0x1f1)](()=>{}),this['client']=new TrinoClient(_0x4df1d1,this[_0x2750d1(0x208)]),this['tdClient']=new TDClient(_0x4df1d1,this[_0x2750d1(0x208)]),this[_0x2750d1(0x1fb)]=new CDPClient(_0x4df1d1,this[_0x2750d1(0x208)]),this['workflowClient']=new WorkflowClient(_0x4df1d1,this['logger']),this[_0x2750d1(0x205)]=new LLMClient(_0x4df1d1,this[_0x2750d1(0x208)]),this[_0x2750d1(0x204)]=new DatabaseAPI(this['client']),this[_0x2750d1(0x201)]=new TableAPI(this[_0x2750d1(0x20c)]),this['segment']=new SegmentAPI(this[_0x2750d1(0x1fb)]),this[_0x2750d1(0x1f8)]=new WorkflowAPI(this[_0x2750d1(0x1fd)]),this[_0x2750d1(0x1ff)]=new LLMAPI(this[_0x2750d1(0x205)]),this[_0x2750d1(0x1fe)]=new JobAPI(this[_0x2750d1(0x1f5)]),this[_0x2750d1(0x20b)]=new RawAPI(_0x4df1d1,this[_0x2750d1(0x208)]);}async[a46_0x28a242(0x200)](_0x187d3c,_0x37cc32){const _0x54d598=a46_0x28a242;return executeQuery(this[_0x54d598(0x20c)],_0x187d3c,_0x37cc32);}}
package/dist/sdk/job.js CHANGED
@@ -1 +1 @@
1
- function a47_0x30fb(){const _0x12f02f=['927285RgGRjl','listJobs','result','kill','trino','created_at','5fylXsV','updated_at','2988360goekJG','getJobResult','submitHiveJob','576289mVsxWs','2781356mttCUs','\x20UTC','submitPrestoJob','end_at','698052KGNNbH','start_at','list','replace','3ppyUrY','showJob','11743938FDpBao','client','map','hive','1589734kmVlQu'];a47_0x30fb=function(){return _0x12f02f;};return a47_0x30fb();}const a47_0x50e51a=a47_0x3995;(function(_0x1aa4c2,_0x4daa97){const _0x360684=a47_0x3995,_0x5403dd=_0x1aa4c2();while(!![]){try{const _0x3bde22=parseInt(_0x360684(0xa2))/0x1+parseInt(_0x360684(0xa1))/0x2*(-parseInt(_0x360684(0x9b))/0x3)+parseInt(_0x360684(0x93))/0x4*(-parseInt(_0x360684(0x8d))/0x5)+parseInt(_0x360684(0x97))/0x6+parseInt(_0x360684(0x92))/0x7+-parseInt(_0x360684(0x8f))/0x8+parseInt(_0x360684(0x9d))/0x9;if(_0x3bde22===_0x4daa97)break;else _0x5403dd['push'](_0x5403dd['shift']());}catch(_0xbe0d52){_0x5403dd['push'](_0x5403dd['shift']());}}}(a47_0x30fb,0x8a72d));function normalizeTimestamp(_0x58abea){const _0x1e5c23=a47_0x3995;if(!_0x58abea)return undefined;if(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/['test'](_0x58abea))return _0x58abea;return _0x58abea[_0x1e5c23(0x9a)](_0x1e5c23(0x94),'Z')[_0x1e5c23(0x9a)]('\x20','T');}function a47_0x3995(_0x2151cf,_0x2e404f){const _0x30fb90=a47_0x30fb();return a47_0x3995=function(_0x3995e0,_0x2a6a2b){_0x3995e0=_0x3995e0-0x8b;let _0x9a6a81=_0x30fb90[_0x3995e0];return _0x9a6a81;},a47_0x3995(_0x2151cf,_0x2e404f);}export class JobAPI{[a47_0x50e51a(0x9e)];constructor(_0x117c66){this['client']=_0x117c66;}async[a47_0x50e51a(0x99)](_0xf85da5){const _0x51db81=a47_0x50e51a,_0x293e20=await this[_0x51db81(0x9e)][_0x51db81(0xa3)](_0xf85da5);return _0x293e20[_0x51db81(0x9f)](_0x212339=>({..._0x212339,'created_at':normalizeTimestamp(_0x212339[_0x51db81(0x8c)]),'updated_at':normalizeTimestamp(_0x212339[_0x51db81(0x8e)]),'start_at':normalizeTimestamp(_0x212339['start_at']),'end_at':normalizeTimestamp(_0x212339[_0x51db81(0x96)])}));}async['show'](_0x3d1ef6){const _0x49d939=a47_0x50e51a,_0x4c0694=await this[_0x49d939(0x9e)][_0x49d939(0x9c)](_0x3d1ef6);return{..._0x4c0694,'created_at':normalizeTimestamp(_0x4c0694[_0x49d939(0x8c)]),'updated_at':normalizeTimestamp(_0x4c0694[_0x49d939(0x8e)]),'start_at':normalizeTimestamp(_0x4c0694[_0x49d939(0x98)]),'end_at':normalizeTimestamp(_0x4c0694[_0x49d939(0x96)])};}async[a47_0x50e51a(0xa5)](_0x458e68){const _0x50d5b8=a47_0x50e51a;await this[_0x50d5b8(0x9e)]['cancelJob'](_0x458e68);}async['submit'](_0xfb50c9,_0x4d22e0,_0xf31d82=a47_0x50e51a(0x8b)){const _0x410823=a47_0x50e51a;return _0xf31d82===_0x410823(0xa0)?await this[_0x410823(0x9e)][_0x410823(0x91)](_0xfb50c9,_0x4d22e0):await this['client'][_0x410823(0x95)](_0xfb50c9,_0x4d22e0);}async[a47_0x50e51a(0xa4)](_0x5148cc){const _0x212e2b=a47_0x50e51a;return await this[_0x212e2b(0x9e)][_0x212e2b(0x90)](_0x5148cc);}}
1
+ function a47_0x4dff(_0x121103,_0x42784e){const _0x5a5a52=a47_0x5a5a();return a47_0x4dff=function(_0x4dff60,_0x47d55c){_0x4dff60=_0x4dff60-0x1a0;let _0x193463=_0x5a5a52[_0x4dff60];return _0x193463;},a47_0x4dff(_0x121103,_0x42784e);}const a47_0x3b488a=a47_0x4dff;(function(_0x4bd429,_0x1e6461){const _0x119903=a47_0x4dff,_0x73768f=_0x4bd429();while(!![]){try{const _0x4b3f2f=-parseInt(_0x119903(0x1b3))/0x1*(parseInt(_0x119903(0x1b0))/0x2)+parseInt(_0x119903(0x1a2))/0x3+parseInt(_0x119903(0x1a0))/0x4+parseInt(_0x119903(0x1bc))/0x5+-parseInt(_0x119903(0x1b2))/0x6*(parseInt(_0x119903(0x1b4))/0x7)+parseInt(_0x119903(0x1a3))/0x8*(-parseInt(_0x119903(0x1ac))/0x9)+-parseInt(_0x119903(0x1a4))/0xa*(-parseInt(_0x119903(0x1a8))/0xb);if(_0x4b3f2f===_0x1e6461)break;else _0x73768f['push'](_0x73768f['shift']());}catch(_0x251ae5){_0x73768f['push'](_0x73768f['shift']());}}}(a47_0x5a5a,0x91e04));function normalizeTimestamp(_0x20e337){const _0x1aac38=a47_0x4dff;if(!_0x20e337)return undefined;if(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/[_0x1aac38(0x1bd)](_0x20e337))return _0x20e337;return _0x20e337[_0x1aac38(0x1ae)]('\x20UTC','Z')[_0x1aac38(0x1ae)]('\x20','T');}function a47_0x5a5a(){const _0x77b23c=['cancelJob','updated_at','map','11AchFlJ','end_at','kill','submitHiveJob','90gfDlIg','submit','replace','trino','2cjXCBc','hive','156WONqHw','381572liaqvI','287266sMBYNy','client','getJobResult','show','submitPrestoJob','start_at','created_at','result','5419070HDryZb','test','showJob','list','4400936APGNzY','listJobs','1338315KvzsUE','603152oPbCRJ','1698550HPtLUE'];a47_0x5a5a=function(){return _0x77b23c;};return a47_0x5a5a();}export class JobAPI{['client'];constructor(_0x1a2d6b){this['client']=_0x1a2d6b;}async[a47_0x3b488a(0x1bf)](_0x1df1cf){const _0x2c2dc7=a47_0x3b488a,_0x1ccd3c=await this['client'][_0x2c2dc7(0x1a1)](_0x1df1cf);return _0x1ccd3c[_0x2c2dc7(0x1a7)](_0x465f7e=>({..._0x465f7e,'created_at':normalizeTimestamp(_0x465f7e['created_at']),'updated_at':normalizeTimestamp(_0x465f7e[_0x2c2dc7(0x1a6)]),'start_at':normalizeTimestamp(_0x465f7e[_0x2c2dc7(0x1b9)]),'end_at':normalizeTimestamp(_0x465f7e[_0x2c2dc7(0x1a9)])}));}async[a47_0x3b488a(0x1b7)](_0x378d1a){const _0x38dfae=a47_0x3b488a,_0x38f457=await this['client'][_0x38dfae(0x1be)](_0x378d1a);return{..._0x38f457,'created_at':normalizeTimestamp(_0x38f457[_0x38dfae(0x1ba)]),'updated_at':normalizeTimestamp(_0x38f457[_0x38dfae(0x1a6)]),'start_at':normalizeTimestamp(_0x38f457[_0x38dfae(0x1b9)]),'end_at':normalizeTimestamp(_0x38f457[_0x38dfae(0x1a9)])};}async[a47_0x3b488a(0x1aa)](_0x2c0a1d){const _0x240215=a47_0x3b488a;await this['client'][_0x240215(0x1a5)](_0x2c0a1d);}async[a47_0x3b488a(0x1ad)](_0x220f6d,_0x19f181,_0x3b4f08=a47_0x3b488a(0x1af)){const _0x3e390a=a47_0x3b488a;return _0x3b4f08===_0x3e390a(0x1b1)?await this[_0x3e390a(0x1b5)][_0x3e390a(0x1ab)](_0x220f6d,_0x19f181):await this['client'][_0x3e390a(0x1b8)](_0x220f6d,_0x19f181);}async[a47_0x3b488a(0x1bb)](_0x13726a){const _0x1c7471=a47_0x3b488a;return await this['client'][_0x1c7471(0x1b6)](_0x13726a);}}
package/dist/sdk/llm.js CHANGED
@@ -1 +1 @@
1
- function a48_0x2d81(_0x15c3dc,_0x75d0b8){const _0x57ab33=a48_0x57ab();return a48_0x2d81=function(_0x2d8169,_0x29095c){_0x2d8169=_0x2d8169-0x177;let _0x563fef=_0x57ab33[_0x2d8169];return _0x563fef;},a48_0x2d81(_0x15c3dc,_0x75d0b8);}const a48_0x2ef10d=a48_0x2d81;(function(_0x4b92ef,_0x24f53){const _0x5866ae=a48_0x2d81,_0x18d4ee=_0x4b92ef();while(!![]){try{const _0x4522ad=-parseInt(_0x5866ae(0x1b3))/0x1+parseInt(_0x5866ae(0x1bb))/0x2*(parseInt(_0x5866ae(0x1b7))/0x3)+parseInt(_0x5866ae(0x179))/0x4+parseInt(_0x5866ae(0x190))/0x5*(-parseInt(_0x5866ae(0x17b))/0x6)+parseInt(_0x5866ae(0x186))/0x7+parseInt(_0x5866ae(0x183))/0x8+-parseInt(_0x5866ae(0x1b0))/0x9*(-parseInt(_0x5866ae(0x17a))/0xa);if(_0x4522ad===_0x24f53)break;else _0x18d4ee['push'](_0x18d4ee['shift']());}catch(_0x5192f6){_0x18d4ee['push'](_0x18d4ee['shift']());}}}(a48_0x57ab,0x2e2ad));import{HTTPClientError}from'../client/http-client.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';import{getSanitizedUsername,generateRandomHex}from'../utils/string-utils.js';import{readCachedLLMProject,writeCachedLLMProject}from'../core/config.js';function a48_0x57ab(){const _0x2dafa9=['chat','chatId','INTERNAL','claude-4.5-sonnet','attributes','listChats','updateAgent','continueChat','projects','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','client','already\x20exists','Project\x20not\x20found\x20with\x20ID:\x20','getOrCreateDefaultAgent','AGENT_NOT_FOUND','2844927rYRrHC','availableModels','UNAUTHENTICATED','23148cByfMg','getOrCreateDefaultProject','chatInfo','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','442452EFwctR','duplicate','getUserSettings','isProjectId','2dENhzd','Multiple\x20agents\x20found\x20with\x20name\x20\x27','getChatHistory','tdx_','metadata','currentProjectId','event','Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.','63844MMjXWW','10HkvRHo','6toVIiO','agentId','createAgent','push','deleteAgent','\x20in\x20project\x20','agent','signal','241408WgBUcT','agents','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','13440oblPCm','listProjects','availableModelNames','getChatInfo','LLM_PROJECT_NOT_FOUND','tdx_default_','Project\x20not\x20found:\x20','listAgents','models','getDefaultProjectName','1496975JEyGmr','test','createProject','filter','displayName','setCurrentProject','resolveProjectId','find','name','ALREADY_EXISTS','status','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','history','deleteProject','Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.','startChat','length'];a48_0x57ab=function(){return _0x2dafa9;};return a48_0x57ab();}export class LLMAPI{[a48_0x2ef10d(0x1ab)];[a48_0x2ef10d(0x1c0)];constructor(_0x2a9ee3){this['client']=_0x2a9ee3;}[a48_0x2ef10d(0x18f)](){const _0x1b4dc5=a48_0x2ef10d,_0x381b2e=getSanitizedUsername();return _0x1b4dc5(0x18b)+_0x381b2e;}['isProjectId'](_0x5ec335){const _0x54bfe5=a48_0x2ef10d;return/^[a-zA-Z0-9]{8,}$/[_0x54bfe5(0x191)](_0x5ec335);}async[a48_0x2ef10d(0x195)](_0x2e1da6){const _0x5c99e8=a48_0x2ef10d;if(this[_0x5c99e8(0x1ba)](_0x2e1da6)){const _0x344f52=await this[_0x5c99e8(0x1ab)][_0x5c99e8(0x187)](),_0x50a7fa=_0x344f52[_0x5c99e8(0x197)](_0x17ab4b=>_0x17ab4b['id']===_0x2e1da6);if(!_0x50a7fa)throw new SDKError(ErrorCode[_0x5c99e8(0x18a)],_0x5c99e8(0x1ad)+_0x2e1da6,undefined,{'helpText':_0x5c99e8(0x185)});this[_0x5c99e8(0x1c0)]=_0x2e1da6;}else this[_0x5c99e8(0x1c0)]=await this[_0x5c99e8(0x196)](_0x2e1da6);}['getCurrentProject'](){const _0x4ad768=a48_0x2ef10d;return this[_0x4ad768(0x1c0)];}async[a48_0x2ef10d(0x18e)](){const _0x150c47=a48_0x2ef10d,_0x148e03=await this['client'][_0x150c47(0x1b9)](),_0x5168bb=[];for(const _0x102af7 of _0x148e03[_0x150c47(0x188)]){const _0x7407a5=_0x148e03[_0x150c47(0x1b1)][_0x102af7];_0x7407a5&&_0x5168bb[_0x150c47(0x17e)]({'name':_0x102af7,'displayName':_0x7407a5[_0x150c47(0x194)]});}return _0x5168bb;}async[a48_0x2ef10d(0x192)](_0x71ea93){const _0x1b2bd5=a48_0x2ef10d;return await this[_0x1b2bd5(0x1ab)][_0x1b2bd5(0x192)](_0x71ea93);}async[a48_0x2ef10d(0x19d)](_0x36afa5){const _0x2cc5b5=a48_0x2ef10d;let _0x362108;if(this[_0x2cc5b5(0x1ba)](_0x36afa5)){const _0x3963f9=await this['client'][_0x2cc5b5(0x187)](),_0x48e4e3=_0x3963f9[_0x2cc5b5(0x197)](_0x301107=>_0x301107['id']===_0x36afa5);if(!_0x48e4e3)throw new SDKError(ErrorCode[_0x2cc5b5(0x18a)],'Project\x20not\x20found\x20with\x20ID:\x20'+_0x36afa5,undefined,{'helpText':_0x2cc5b5(0x185)});_0x362108=_0x36afa5;}else _0x362108=await this['resolveProjectId'](_0x36afa5);await this['client']['deleteProject'](_0x362108);}async[a48_0x2ef10d(0x1a9)](_0x134225=0x32){return await this['client']['listProjects'](_0x134225);}async[a48_0x2ef10d(0x1b4)](_0x3fc125){const _0x15e26b=a48_0x2ef10d,_0xb88280=_0x3fc125||this['getDefaultProjectName'](),_0x297cf6=await this[_0x15e26b(0x1ab)][_0x15e26b(0x187)]();if(!_0x3fc125){const _0x2e5515=readCachedLLMProject();if(_0x2e5515){const _0x3d034f=_0x297cf6[_0x15e26b(0x197)](_0x37bbdb=>_0x37bbdb[_0x15e26b(0x1a5)][_0x15e26b(0x198)]===_0x2e5515);if(_0x3d034f)return _0x3d034f;}}const _0x5dd782=_0x297cf6[_0x15e26b(0x197)](_0x404276=>_0x404276[_0x15e26b(0x1a5)]['name']===_0xb88280);if(_0x5dd782)return!_0x3fc125&&writeCachedLLMProject(_0xb88280),_0x5dd782;const _0xd2db22=await this[_0x15e26b(0x1ab)][_0x15e26b(0x192)]({'name':_0xb88280,'description':_0x15e26b(0x1aa)+getSanitizedUsername()+')'});return!_0x3fc125&&writeCachedLLMProject(_0xb88280),_0xd2db22;}async['resolveProjectId'](_0x44524c){const _0x6df7f4=a48_0x2ef10d,_0x56f208=await this['client'][_0x6df7f4(0x187)](),_0x4b223e=_0x56f208[_0x6df7f4(0x193)](_0x498271=>_0x498271[_0x6df7f4(0x1a5)]['name']===_0x44524c);if(_0x4b223e[_0x6df7f4(0x1a0)]===0x0)throw new SDKError(ErrorCode[_0x6df7f4(0x18a)],_0x6df7f4(0x18c)+_0x44524c,undefined,{'helpText':_0x6df7f4(0x185)});if(_0x4b223e[_0x6df7f4(0x1a0)]>0x1)throw new SDKError(ErrorCode[_0x6df7f4(0x1a3)],'Multiple\x20projects\x20found\x20with\x20name\x20\x27'+_0x44524c+'\x27.\x20This\x20should\x20not\x20happen.');return _0x4b223e[0x0]['id'];}async[a48_0x2ef10d(0x1ae)](_0x454231=a48_0x2ef10d(0x1a4),_0xaddfd4){const _0xa57b04=a48_0x2ef10d,_0x4c04d3=0xa;let _0x306467=0x0,_0x3e0d97;while(_0x306467<_0x4c04d3){try{const _0x21c8b8=await this['getOrCreateDefaultProject'](_0x3e0d97),_0xa33a9d=_0x21c8b8['id'],_0x4dcee7=_0xa57b04(0x1be)+_0x454231,_0x1979d6=await this['client'][_0xa57b04(0x18d)](_0xa33a9d),_0x4f64ae=_0x1979d6[_0xa57b04(0x197)](_0x3737f4=>_0x3737f4[_0xa57b04(0x1a5)][_0xa57b04(0x198)]===_0x4dcee7);if(_0x4f64ae)return _0x4f64ae;return await this[_0xa57b04(0x1ab)][_0xa57b04(0x17d)]({'name':_0x4dcee7,'projectId':_0xa33a9d,'modelType':_0x454231,'systemPrompt':'','temperature':_0xaddfd4});}catch(_0x5de315){if(_0x5de315 instanceof HTTPClientError){const _0x106f96=_0x5de315[_0xa57b04(0x19a)];if(_0x106f96>=0x190&&_0x106f96<0x1f4){if(_0x106f96===0x191)throw new SDKError(ErrorCode[_0xa57b04(0x1b2)],_0xa57b04(0x19b),_0x5de315);else{if(_0x106f96===0x193)throw new SDKError(ErrorCode['PERMISSION_DENIED'],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x5de315);}throw _0x5de315;}}if(errorContains(_0x5de315,_0xa57b04(0x1ac),_0xa57b04(0x1b8),'conflict')){_0x306467++;if(_0x306467>=_0x4c04d3)throw new SDKError(ErrorCode[_0xa57b04(0x199)],'Unable\x20to\x20create\x20project\x20after\x20'+_0x4c04d3+'\x20attempts\x20due\x20to\x20name\x20conflicts.',_0x5de315);const _0x28e3e1=this[_0xa57b04(0x18f)]();_0x3e0d97=_0x28e3e1+'_'+generateRandomHex();continue;}throw _0x5de315;}}throw new SDKError(ErrorCode[_0xa57b04(0x1a3)],_0xa57b04(0x1b6));}async['resolveAgentId'](_0x8e1a1,_0x3905cd){const _0x22fc33=a48_0x2ef10d,_0x3afcf9=_0x3905cd||this[_0x22fc33(0x1c0)],_0x24593b=await this['client'][_0x22fc33(0x18d)](_0x3afcf9),_0xd7301a=_0x24593b['filter'](_0x555afe=>_0x555afe[_0x22fc33(0x1a5)][_0x22fc33(0x198)]===_0x8e1a1);if(_0xd7301a[_0x22fc33(0x1a0)]===0x0){const _0x2bfe33=_0x3afcf9?_0x22fc33(0x180)+_0x3afcf9:'';throw new SDKError(ErrorCode[_0x22fc33(0x1af)],'Agent\x20not\x20found:\x20'+_0x8e1a1+_0x2bfe33,undefined,{'helpText':_0x3afcf9?_0x22fc33(0x19e):_0x22fc33(0x178)});}if(_0xd7301a[_0x22fc33(0x1a0)]>0x1)throw new SDKError(ErrorCode[_0x22fc33(0x1a3)],_0x22fc33(0x1bc)+_0x8e1a1+'\x27.\x20This\x20should\x20not\x20happen.');return _0xd7301a[0x0]['id'];}async[a48_0x2ef10d(0x184)](_0x276aa9){const _0x35a9ef=a48_0x2ef10d,_0x4710cc=_0x276aa9||this[_0x35a9ef(0x1c0)];return await this['client'][_0x35a9ef(0x18d)](_0x4710cc);}async[a48_0x2ef10d(0x181)](_0x148655){const _0x59e2d4=a48_0x2ef10d;return await this[_0x59e2d4(0x1ab)]['getAgent'](_0x148655);}async[a48_0x2ef10d(0x17d)](_0x74dccf){const _0x1a02a3=a48_0x2ef10d;return await this[_0x1a02a3(0x1ab)][_0x1a02a3(0x17d)](_0x74dccf);}async[a48_0x2ef10d(0x1a7)](_0x462129,_0x219f4f){const _0x2e6c84=a48_0x2ef10d;return await this['client'][_0x2e6c84(0x1a7)](_0x462129,_0x219f4f);}async[a48_0x2ef10d(0x17f)](_0x4ea8eb){const _0x1588a2=a48_0x2ef10d;await this['client'][_0x1588a2(0x17f)](_0x4ea8eb);}async[a48_0x2ef10d(0x19f)](_0x353071){const _0x290e24=a48_0x2ef10d;return await this[_0x290e24(0x1ab)][_0x290e24(0x19f)]({'agentId':_0x353071});}async*[a48_0x2ef10d(0x1a1)](_0x427475,_0x1c921f){const _0x394ecc=a48_0x2ef10d;let _0x441d77=_0x1c921f?.[_0x394ecc(0x1a2)];const _0x50615d=_0x1c921f?.[_0x394ecc(0x17c)];if(!_0x441d77){if(!_0x50615d)throw new Error('agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat');const _0x1498ee=await this[_0x394ecc(0x1ab)][_0x394ecc(0x19f)]({'agentId':_0x50615d});_0x441d77=_0x1498ee['id'],yield{'type':_0x394ecc(0x1bf),'data':{'chatId':_0x441d77,'agentId':_0x50615d}};}for await(const _0x4856d0 of this[_0x394ecc(0x1ab)][_0x394ecc(0x1a8)](_0x441d77,_0x427475,_0x1c921f?.[_0x394ecc(0x182)])){yield{'type':_0x394ecc(0x177),'data':_0x4856d0};}}async['chats'](_0x5b4e94=0x32){const _0x38495f=a48_0x2ef10d;return await this[_0x38495f(0x1ab)][_0x38495f(0x1a6)](_0x5b4e94);}async[a48_0x2ef10d(0x19c)](_0x46305b){const _0x5011ef=a48_0x2ef10d;return await this[_0x5011ef(0x1ab)][_0x5011ef(0x1bd)](_0x46305b);}async[a48_0x2ef10d(0x1b5)](_0x21c6a1){const _0x1fdfc3=a48_0x2ef10d;return await this[_0x1fdfc3(0x1ab)][_0x1fdfc3(0x189)](_0x21c6a1);}}
1
+ const a48_0x329d75=a48_0xebef;(function(_0x4d09f1,_0x3f7da4){const _0x3d58e1=a48_0xebef,_0x3dabc1=_0x4d09f1();while(!![]){try{const _0x44d616=-parseInt(_0x3d58e1(0x9e))/0x1*(parseInt(_0x3d58e1(0x97))/0x2)+parseInt(_0x3d58e1(0x88))/0x3*(parseInt(_0x3d58e1(0x7e))/0x4)+-parseInt(_0x3d58e1(0x6c))/0x5+parseInt(_0x3d58e1(0xb4))/0x6*(parseInt(_0x3d58e1(0x85))/0x7)+-parseInt(_0x3d58e1(0x78))/0x8+-parseInt(_0x3d58e1(0x94))/0x9*(-parseInt(_0x3d58e1(0x81))/0xa)+parseInt(_0x3d58e1(0xa6))/0xb;if(_0x44d616===_0x3f7da4)break;else _0x3dabc1['push'](_0x3dabc1['shift']());}catch(_0x3f9de9){_0x3dabc1['push'](_0x3dabc1['shift']());}}}(a48_0x521d,0xb3156));function a48_0x521d(){const _0x11e8dc=['conflict','status','signal','2388MfhcfR','startChat','5334290tTsTCg','setCurrentProject','deleteAgent','chat','filter','\x20in\x20project\x20','Multiple\x20projects\x20found\x20with\x20name\x20\x27','Project\x20not\x20found:\x20','claude-4.5-sonnet','Authentication\x20failed.\x20Please\x20check\x20your\x20API\x20key\x20is\x20valid\x20and\x20not\x20expired.','history','getCurrentProject','1755224khiPMJ','Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.','find','resolveProjectId','listAgents','\x27.\x20This\x20should\x20not\x20happen.','1492GdRVcH','updateAgent','client','40saltlL','length','PERMISSION_DENIED','chats','14805Mivewi','LLM_PROJECT_NOT_FOUND','getOrCreateDefaultProject','4395zbfdmP','agentId\x20is\x20required\x20when\x20starting\x20a\x20new\x20chat','already\x20exists','deleteProject','isProjectId','getUserSettings','createProject','Failed\x20to\x20get\x20or\x20create\x20agent:\x20exceeded\x20maximum\x20attempts','duplicate','getDefaultProjectName','Agent\x20not\x20found:\x20','INTERNAL','2879433nZCIza','models','Project\x20not\x20found\x20with\x20ID:\x20','4442OlgaJQ','event','push','attributes','getChatHistory','displayName','listProjects','637pRbaEg','tdx_default_','metadata','agentId','name','Default\x20project\x20for\x20tdx\x20CLI\x20chat\x20(user:\x20','Use\x20\x22tdx\x20llm\x20use\x20<project>\x22\x20to\x20set\x20a\x20project\x20context\x20first,\x20or\x20use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20all\x20agents.','getChatInfo','8432611KOaIsa','\x20attempts\x20due\x20to\x20name\x20conflicts.','availableModelNames','chatId','tdx_','currentProjectId','chatInfo','projects','getAgent','createAgent','Unable\x20to\x20create\x20project\x20after\x20'];a48_0x521d=function(){return _0x11e8dc;};return a48_0x521d();}import{HTTPClientError}from'../client/http-client.js';import{SDKError,ErrorCode,errorContains}from'./errors.js';function a48_0xebef(_0x450d41,_0x5b9066){const _0x521df6=a48_0x521d();return a48_0xebef=function(_0xebefb8,_0x40b768){_0xebefb8=_0xebefb8-0x6c;let _0x55e8bc=_0x521df6[_0xebefb8];return _0x55e8bc;},a48_0xebef(_0x450d41,_0x5b9066);}import{getSanitizedUsername,generateRandomHex}from'../utils/string-utils.js';import{readCachedLLMProject,writeCachedLLMProject}from'../core/config.js';export class LLMAPI{['client'];[a48_0x329d75(0xab)];constructor(_0x2d6db1){const _0x4eb1a0=a48_0x329d75;this[_0x4eb1a0(0x80)]=_0x2d6db1;}['getDefaultProjectName'](){const _0x57d4be=a48_0x329d75,_0x26b88e=getSanitizedUsername();return _0x57d4be(0x9f)+_0x26b88e;}[a48_0x329d75(0x8c)](_0x639530){return/^[a-zA-Z0-9]{8,}$/['test'](_0x639530);}async[a48_0x329d75(0x6d)](_0x28d91f){const _0x4f584e=a48_0x329d75;if(this[_0x4f584e(0x8c)](_0x28d91f)){const _0x5ef0d1=await this[_0x4f584e(0x80)][_0x4f584e(0x9d)](),_0x12dc0f=_0x5ef0d1[_0x4f584e(0x7a)](_0x15ea53=>_0x15ea53['id']===_0x28d91f);if(!_0x12dc0f)throw new SDKError(ErrorCode[_0x4f584e(0x86)],_0x4f584e(0x96)+_0x28d91f,undefined,{'helpText':_0x4f584e(0x79)});this[_0x4f584e(0xab)]=_0x28d91f;}else this[_0x4f584e(0xab)]=await this[_0x4f584e(0x7b)](_0x28d91f);}[a48_0x329d75(0x77)](){const _0x423fc6=a48_0x329d75;return this[_0x423fc6(0xab)];}async[a48_0x329d75(0x95)](){const _0x4dc125=a48_0x329d75,_0x4a7281=await this[_0x4dc125(0x80)][_0x4dc125(0x8d)](),_0x43a322=[];for(const _0x21e6bb of _0x4a7281[_0x4dc125(0xa8)]){const _0x28886a=_0x4a7281['availableModels'][_0x21e6bb];_0x28886a&&_0x43a322[_0x4dc125(0x99)]({'name':_0x21e6bb,'displayName':_0x28886a[_0x4dc125(0x9c)]});}return _0x43a322;}async['createProject'](_0x321003){const _0x1d5d4b=a48_0x329d75;return await this[_0x1d5d4b(0x80)]['createProject'](_0x321003);}async['deleteProject'](_0x10cdcc){const _0x112e5c=a48_0x329d75;let _0x47558e;if(this[_0x112e5c(0x8c)](_0x10cdcc)){const _0x4e63ef=await this['client'][_0x112e5c(0x9d)](),_0x6c749e=_0x4e63ef['find'](_0x31e48c=>_0x31e48c['id']===_0x10cdcc);if(!_0x6c749e)throw new SDKError(ErrorCode[_0x112e5c(0x86)],_0x112e5c(0x96)+_0x10cdcc,undefined,{'helpText':_0x112e5c(0x79)});_0x47558e=_0x10cdcc;}else _0x47558e=await this[_0x112e5c(0x7b)](_0x10cdcc);await this[_0x112e5c(0x80)][_0x112e5c(0x8b)](_0x47558e);}async[a48_0x329d75(0xad)](_0x3b1d63=0x32){return await this['client']['listProjects'](_0x3b1d63);}async[a48_0x329d75(0x87)](_0x349f67){const _0x55afc4=a48_0x329d75,_0x2f0942=_0x349f67||this[_0x55afc4(0x91)](),_0x7cab1e=await this[_0x55afc4(0x80)][_0x55afc4(0x9d)]();if(!_0x349f67){const _0x2d7604=readCachedLLMProject();if(_0x2d7604){const _0x3db6d5=_0x7cab1e[_0x55afc4(0x7a)](_0x5acf68=>_0x5acf68[_0x55afc4(0x9a)][_0x55afc4(0xa2)]===_0x2d7604);if(_0x3db6d5)return _0x3db6d5;}}const _0x468d44=_0x7cab1e[_0x55afc4(0x7a)](_0xd451fa=>_0xd451fa['attributes'][_0x55afc4(0xa2)]===_0x2f0942);if(_0x468d44)return!_0x349f67&&writeCachedLLMProject(_0x2f0942),_0x468d44;const _0x4b6cb5=await this[_0x55afc4(0x80)][_0x55afc4(0x8e)]({'name':_0x2f0942,'description':_0x55afc4(0xa3)+getSanitizedUsername()+')'});return!_0x349f67&&writeCachedLLMProject(_0x2f0942),_0x4b6cb5;}async[a48_0x329d75(0x7b)](_0x9ae328){const _0x5cfc3a=a48_0x329d75,_0x1edebd=await this[_0x5cfc3a(0x80)]['listProjects'](),_0x403858=_0x1edebd[_0x5cfc3a(0x70)](_0x50854e=>_0x50854e['attributes'][_0x5cfc3a(0xa2)]===_0x9ae328);if(_0x403858[_0x5cfc3a(0x82)]===0x0)throw new SDKError(ErrorCode[_0x5cfc3a(0x86)],_0x5cfc3a(0x73)+_0x9ae328,undefined,{'helpText':'Use\x20\x22tdx\x20llm\x20projects\x22\x20to\x20list\x20available\x20projects.'});if(_0x403858['length']>0x1)throw new SDKError(ErrorCode[_0x5cfc3a(0x93)],_0x5cfc3a(0x72)+_0x9ae328+_0x5cfc3a(0x7d));return _0x403858[0x0]['id'];}async['getOrCreateDefaultAgent'](_0xa7193c=a48_0x329d75(0x74),_0x54c0db){const _0x5c18a7=a48_0x329d75,_0x54e1a3=0xa;let _0x4d438f=0x0,_0x29d5c0;while(_0x4d438f<_0x54e1a3){try{const _0x40480a=await this[_0x5c18a7(0x87)](_0x29d5c0),_0x15ac14=_0x40480a['id'],_0x18bcf9=_0x5c18a7(0xaa)+_0xa7193c,_0x317d14=await this[_0x5c18a7(0x80)]['listAgents'](_0x15ac14),_0x8f6602=_0x317d14[_0x5c18a7(0x7a)](_0x57d406=>_0x57d406[_0x5c18a7(0x9a)]['name']===_0x18bcf9);if(_0x8f6602)return _0x8f6602;return await this[_0x5c18a7(0x80)][_0x5c18a7(0xaf)]({'name':_0x18bcf9,'projectId':_0x15ac14,'modelType':_0xa7193c,'systemPrompt':'','temperature':_0x54c0db});}catch(_0x299ff6){if(_0x299ff6 instanceof HTTPClientError){const _0x28a809=_0x299ff6[_0x5c18a7(0xb2)];if(_0x28a809>=0x190&&_0x28a809<0x1f4){if(_0x28a809===0x191)throw new SDKError(ErrorCode['UNAUTHENTICATED'],_0x5c18a7(0x75),_0x299ff6);else{if(_0x28a809===0x193)throw new SDKError(ErrorCode[_0x5c18a7(0x83)],'Permission\x20denied.\x20Please\x20check\x20your\x20API\x20key\x20has\x20the\x20required\x20permissions\x20for\x20LLM\x20API\x20operations.',_0x299ff6);}throw _0x299ff6;}}if(errorContains(_0x299ff6,_0x5c18a7(0x8a),_0x5c18a7(0x90),_0x5c18a7(0xb1))){_0x4d438f++;if(_0x4d438f>=_0x54e1a3)throw new SDKError(ErrorCode['ALREADY_EXISTS'],_0x5c18a7(0xb0)+_0x54e1a3+_0x5c18a7(0xa7),_0x299ff6);const _0x308e67=this[_0x5c18a7(0x91)]();_0x29d5c0=_0x308e67+'_'+generateRandomHex();continue;}throw _0x299ff6;}}throw new SDKError(ErrorCode[_0x5c18a7(0x93)],_0x5c18a7(0x8f));}async['resolveAgentId'](_0x562408,_0x2f83c2){const _0x4eb127=a48_0x329d75,_0x47d100=_0x2f83c2||this['currentProjectId'],_0x26ca44=await this['client']['listAgents'](_0x47d100),_0x482b23=_0x26ca44[_0x4eb127(0x70)](_0x9e5952=>_0x9e5952[_0x4eb127(0x9a)][_0x4eb127(0xa2)]===_0x562408);if(_0x482b23[_0x4eb127(0x82)]===0x0){const _0x4094ee=_0x47d100?_0x4eb127(0x71)+_0x47d100:'';throw new SDKError(ErrorCode['AGENT_NOT_FOUND'],_0x4eb127(0x92)+_0x562408+_0x4094ee,undefined,{'helpText':_0x47d100?'Use\x20\x22tdx\x20llm\x20agents\x22\x20to\x20list\x20available\x20agents\x20in\x20the\x20current\x20project.':_0x4eb127(0xa4)});}if(_0x482b23['length']>0x1)throw new SDKError(ErrorCode[_0x4eb127(0x93)],'Multiple\x20agents\x20found\x20with\x20name\x20\x27'+_0x562408+_0x4eb127(0x7d));return _0x482b23[0x0]['id'];}async['agents'](_0x4d74ca){const _0x56e3da=a48_0x329d75,_0x3e98b5=_0x4d74ca||this[_0x56e3da(0xab)];return await this['client'][_0x56e3da(0x7c)](_0x3e98b5);}async['agent'](_0x27d41e){const _0x1fec0f=a48_0x329d75;return await this[_0x1fec0f(0x80)][_0x1fec0f(0xae)](_0x27d41e);}async[a48_0x329d75(0xaf)](_0x1600b3){const _0xf67e42=a48_0x329d75;return await this['client'][_0xf67e42(0xaf)](_0x1600b3);}async[a48_0x329d75(0x7f)](_0x1eebac,_0x24fb8c){const _0x2aac17=a48_0x329d75;return await this[_0x2aac17(0x80)]['updateAgent'](_0x1eebac,_0x24fb8c);}async['deleteAgent'](_0x5d4a09){const _0x112f3a=a48_0x329d75;await this[_0x112f3a(0x80)][_0x112f3a(0x6e)](_0x5d4a09);}async[a48_0x329d75(0xb5)](_0x4fcc00){const _0x39f069=a48_0x329d75;return await this['client'][_0x39f069(0xb5)]({'agentId':_0x4fcc00});}async*[a48_0x329d75(0x6f)](_0x3e351f,_0x3483fc){const _0x4216ad=a48_0x329d75;let _0x100e66=_0x3483fc?.[_0x4216ad(0xa9)];const _0x204488=_0x3483fc?.[_0x4216ad(0xa1)];if(!_0x100e66){if(!_0x204488)throw new Error(_0x4216ad(0x89));const _0x1672df=await this['client']['startChat']({'agentId':_0x204488});_0x100e66=_0x1672df['id'],yield{'type':_0x4216ad(0xa0),'data':{'chatId':_0x100e66,'agentId':_0x204488}};}for await(const _0x555109 of this[_0x4216ad(0x80)]['continueChat'](_0x100e66,_0x3e351f,_0x3483fc?.[_0x4216ad(0xb3)])){yield{'type':_0x4216ad(0x98),'data':_0x555109};}}async[a48_0x329d75(0x84)](_0x57d9b5=0x32){return await this['client']['listChats'](_0x57d9b5);}async[a48_0x329d75(0x76)](_0x389f92){const _0xc30e9d=a48_0x329d75;return await this[_0xc30e9d(0x80)][_0xc30e9d(0x9b)](_0x389f92);}async[a48_0x329d75(0xac)](_0x363042){const _0x282d75=a48_0x329d75;return await this[_0x282d75(0x80)][_0x282d75(0xa5)](_0x363042);}}
package/dist/sdk/query.js CHANGED
@@ -1 +1 @@
1
- function a49_0x37f5(_0x130839,_0x50f04f){var _0x126415=a49_0x1264();return a49_0x37f5=function(_0x37f527,_0x4c6259){_0x37f527=_0x37f527-0xb4;var _0x558db2=_0x126415[_0x37f527];return _0x558db2;},a49_0x37f5(_0x130839,_0x50f04f);}(function(_0xedd6cd,_0x5447f4){var _0x23dd38=a49_0x37f5,_0x483725=_0xedd6cd();while(!![]){try{var _0x3c0501=parseInt(_0x23dd38(0xba))/0x1+parseInt(_0x23dd38(0xb5))/0x2+-parseInt(_0x23dd38(0xbd))/0x3+-parseInt(_0x23dd38(0xb4))/0x4*(parseInt(_0x23dd38(0xb9))/0x5)+-parseInt(_0x23dd38(0xb6))/0x6*(parseInt(_0x23dd38(0xbf))/0x7)+-parseInt(_0x23dd38(0xb7))/0x8*(-parseInt(_0x23dd38(0xb8))/0x9)+parseInt(_0x23dd38(0xc3))/0xa*(parseInt(_0x23dd38(0xc2))/0xb);if(_0x3c0501===_0x5447f4)break;else _0x483725['push'](_0x483725['shift']());}catch(_0x1c6e8e){_0x483725['push'](_0x483725['shift']());}}}(a49_0x1264,0xb5837));import{SDKError,ErrorCode}from'./errors.js';export async function executeQuery(_0x21953c,_0x3b9869,_0x44996a){var _0x16cee1=a49_0x37f5;if(!_0x3b9869||_0x3b9869[_0x16cee1(0xc1)]()[_0x16cee1(0xbe)]===0x0)throw new SDKError(ErrorCode[_0x16cee1(0xbb)],'SQL\x20query\x20is\x20required',undefined,{'helpText':_0x16cee1(0xbc)});return await _0x21953c[_0x16cee1(0xc0)](_0x3b9869,_0x44996a);}function a49_0x1264(){var _0x409132=['57295PUeyhE','executeQuery','trim','517IrPvRq','59450CPcnfb','34216HnITbu','1940904jAoGWq','1050JvYLlB','358096lsVOGn','279DlHNYE','55jgKeNt','708156UYQnci','MISSING_ARGUMENT','Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.','3227091TkwSpZ','length'];a49_0x1264=function(){return _0x409132;};return a49_0x1264();}
1
+ (function(_0x3acf89,_0x325a7f){var _0x342c23=a49_0x3b3e,_0x5b946f=_0x3acf89();while(!![]){try{var _0x4bc2d1=-parseInt(_0x342c23(0x152))/0x1*(-parseInt(_0x342c23(0x157))/0x2)+parseInt(_0x342c23(0x14f))/0x3*(parseInt(_0x342c23(0x14c))/0x4)+-parseInt(_0x342c23(0x154))/0x5+-parseInt(_0x342c23(0x156))/0x6+-parseInt(_0x342c23(0x155))/0x7+parseInt(_0x342c23(0x15a))/0x8*(-parseInt(_0x342c23(0x14d))/0x9)+parseInt(_0x342c23(0x158))/0xa*(parseInt(_0x342c23(0x153))/0xb);if(_0x4bc2d1===_0x325a7f)break;else _0x5b946f['push'](_0x5b946f['shift']());}catch(_0x3c9845){_0x5b946f['push'](_0x5b946f['shift']());}}}(a49_0x2469,0x51019));import{SDKError,ErrorCode}from'./errors.js';function a49_0x3b3e(_0x43e415,_0x5d9704){var _0x246903=a49_0x2469();return a49_0x3b3e=function(_0x3b3e46,_0x4ea30d){_0x3b3e46=_0x3b3e46-0x14c;var _0x18a7bf=_0x246903[_0x3b3e46];return _0x18a7bf;},a49_0x3b3e(_0x43e415,_0x5d9704);}function a49_0x2469(){var _0x2a9f04=['2146170HyvVhk','2RjiCbu','2330OYfSjt','executeQuery','16qtsVKF','4StIRon','2446650sTmIgC','SQL\x20query\x20is\x20required','460422EzKksl','trim','Provide\x20SQL\x20via\x20argument\x20or\x20use\x20--file\x20option.','637866oGyfhq','74657fRwVOf','2694235iEoymn','4204676ocJkvP'];a49_0x2469=function(){return _0x2a9f04;};return a49_0x2469();}export async function executeQuery(_0xed719c,_0x8ea826,_0x23e406){var _0x26eb65=a49_0x3b3e;if(!_0x8ea826||_0x8ea826[_0x26eb65(0x150)]()['length']===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],_0x26eb65(0x14e),undefined,{'helpText':_0x26eb65(0x151)});return await _0xed719c[_0x26eb65(0x159)](_0x8ea826,_0x23e406);}
@@ -1 +1 @@
1
- function a50_0x5c97(_0xbd03d1,_0x20bfb2){const _0x207232=a50_0x2072();return a50_0x5c97=function(_0x5c9704,_0x463001){_0x5c9704=_0x5c9704-0x19d;let _0x2a73c2=_0x207232[_0x5c9704];return _0x2a73c2;},a50_0x5c97(_0xbd03d1,_0x20bfb2);}const a50_0x9202b7=a50_0x5c97;(function(_0x300400,_0x596cc5){const _0x560df1=a50_0x5c97,_0x2859ca=_0x300400();while(!![]){try{const _0x5ec97e=parseInt(_0x560df1(0x1c3))/0x1*(-parseInt(_0x560df1(0x1c5))/0x2)+parseInt(_0x560df1(0x1e1))/0x3+parseInt(_0x560df1(0x1f0))/0x4*(parseInt(_0x560df1(0x1a2))/0x5)+parseInt(_0x560df1(0x1cd))/0x6*(-parseInt(_0x560df1(0x1e2))/0x7)+parseInt(_0x560df1(0x1a9))/0x8*(parseInt(_0x560df1(0x1a0))/0x9)+parseInt(_0x560df1(0x1b6))/0xa+parseInt(_0x560df1(0x1b8))/0xb*(parseInt(_0x560df1(0x1f1))/0xc);if(_0x5ec97e===_0x596cc5)break;else _0x2859ca['push'](_0x2859ca['shift']());}catch(_0x1c2275){_0x2859ca['push'](_0x2859ca['shift']());}}}(a50_0x2072,0x5c61f));import{SDKError,ErrorCode}from'./errors.js';import{parsePath}from'../utils/segment-path-parser.js';export class SegmentAPI{[a50_0x9202b7(0x1a4)];constructor(_0x3df5c5){const _0x5a2c02=a50_0x9202b7;this[_0x5a2c02(0x1a4)]=_0x3df5c5;}async[a50_0x9202b7(0x1d5)](){return await this['client']['listParentSegments']();}async[a50_0x9202b7(0x1a8)](_0x3dfea8){const _0x2e6c68=a50_0x9202b7;return await this[_0x2e6c68(0x1a4)][_0x2e6c68(0x1eb)](_0x3dfea8);}async[a50_0x9202b7(0x19d)](_0x2f4641){const _0x490846=a50_0x9202b7;return await this[_0x490846(0x1a4)][_0x490846(0x19d)](_0x2f4641);}async[a50_0x9202b7(0x1e0)](_0x3e94e8,_0x1367c0){const _0x152d7a=a50_0x9202b7;return await this[_0x152d7a(0x1a4)][_0x152d7a(0x1e0)](_0x3e94e8,_0x1367c0);}async['listFolders'](_0x5c797f){const _0x5a3f41=a50_0x9202b7;return await this[_0x5a3f41(0x1a4)]['listSegmentFolders'](_0x5c797f);}async['getFolder'](_0x562e38){const _0x10c136=a50_0x9202b7;return await this[_0x10c136(0x1a4)][_0x10c136(0x1c1)](_0x562e38);}async[a50_0x9202b7(0x1d8)](_0x11c54b,_0x101137){const _0x2487d1=a50_0x9202b7;return await this[_0x2487d1(0x1a4)]['listActivations'](_0x11c54b,_0x101137);}async[a50_0x9202b7(0x1af)](_0xe623c6){const _0x3c5373=a50_0x9202b7;return await this[_0x3c5373(0x1a4)][_0x3c5373(0x1c7)](_0xe623c6);}async[a50_0x9202b7(0x1c4)](_0x270011,_0x4a3aa3){const _0x5171c3=a50_0x9202b7;return await this[_0x5171c3(0x1a4)][_0x5171c3(0x1c4)](_0x270011,_0x4a3aa3);}async['resolveParentId'](_0x14c153){const _0x473709=a50_0x9202b7,_0x29ae09=await this[_0x473709(0x1d5)](),_0x50e939=_0x29ae09[_0x473709(0x1b3)](_0x249625=>_0x249625['attributes']['name']===_0x14c153);if(!_0x50e939)throw new SDKError(ErrorCode['NOT_FOUND'],_0x473709(0x1ac)+_0x14c153);return _0x50e939['id'];}async[a50_0x9202b7(0x1a5)](_0x4c6a5d,_0x32728b){const _0x155e9a=a50_0x9202b7,_0x4d9067=await this[_0x155e9a(0x19d)](_0x4c6a5d),_0x4d0f94=_0x4d9067[_0x155e9a(0x1b3)](_0x4e37b5=>_0x4e37b5['name']===_0x32728b);if(!_0x4d0f94)throw new SDKError(ErrorCode[_0x155e9a(0x1dd)],_0x155e9a(0x1ef)+_0x32728b+_0x155e9a(0x19e)+_0x4c6a5d);return _0x4d0f94['id'];}async[a50_0x9202b7(0x1ad)](_0x49163d,_0x534afc){const _0x4b2621=a50_0x9202b7,_0x562852=await this[_0x4b2621(0x1d3)](_0x49163d),_0x316d05=_0x562852['find'](_0x35b027=>_0x35b027[_0x4b2621(0x19f)]===_0x534afc);if(!_0x316d05)throw new SDKError(ErrorCode[_0x4b2621(0x1dd)],_0x4b2621(0x1b1)+_0x534afc+_0x4b2621(0x19e)+_0x49163d);return _0x316d05['id'];}async[a50_0x9202b7(0x1d2)](_0x1ee1c5){const _0x4989ce=a50_0x9202b7,_0x3f8f73=await this[_0x4989ce(0x1f4)](_0x1ee1c5),_0x3ae374=await this[_0x4989ce(0x1a4)][_0x4989ce(0x1cb)](_0x3f8f73),_0x20fb4e=[];if(_0x3ae374['attributes']&&Array[_0x4989ce(0x1d6)](_0x3ae374['attributes']))for(const _0xac90d of _0x3ae374[_0x4989ce(0x1b2)]){const _0x3fc8ac=_0xac90d;_0x3fc8ac['name']&&_0x3fc8ac[_0x4989ce(0x1ca)]&&_0x20fb4e[_0x4989ce(0x1a3)]({'name':_0x3fc8ac['name'],'type':_0x3fc8ac[_0x4989ce(0x1ca)],'source':'attribute','parentDatabaseName':_0x3fc8ac[_0x4989ce(0x1d4)],'parentTableName':_0x3fc8ac[_0x4989ce(0x1d7)],'parentColumn':_0x3fc8ac[_0x4989ce(0x1bd)]});}if(_0x3ae374[_0x4989ce(0x1ba)]&&Array[_0x4989ce(0x1d6)](_0x3ae374[_0x4989ce(0x1ba)]))for(const _0xd4bbce of _0x3ae374[_0x4989ce(0x1ba)]){const _0x299430=_0xd4bbce,_0xda47d7=_0x299430[_0x4989ce(0x19f)];if(_0xda47d7&&_0x299430[_0x4989ce(0x1dc)]&&Array[_0x4989ce(0x1d6)](_0x299430['schema']))for(const _0x4be77d of _0x299430[_0x4989ce(0x1dc)]){_0x4be77d[_0x4989ce(0x19f)]&&_0x4be77d[_0x4989ce(0x1ca)]&&_0x20fb4e[_0x4989ce(0x1a3)]({'name':_0xda47d7+'.'+_0x4be77d[_0x4989ce(0x19f)],'type':_0x4be77d[_0x4989ce(0x1ca)],'source':_0x4989ce(0x1be),'behaviorName':_0xda47d7,'parentDatabaseName':_0x299430[_0x4989ce(0x1d4)],'parentTableName':_0x299430[_0x4989ce(0x1d7)],'parentColumn':_0x4be77d['parentColumn']});}}return _0x20fb4e;}async[a50_0x9202b7(0x1c0)](_0x2651af){const _0x588c71=a50_0x9202b7;return await this[_0x588c71(0x1a4)][_0x588c71(0x1f3)](_0x2651af);}async[a50_0x9202b7(0x1de)](_0x40e931,_0x82ac1c){const _0x339885=a50_0x9202b7,_0x5026b9=await this[_0x339885(0x1f4)](_0x40e931);return await this[_0x339885(0x1a4)][_0x339885(0x1a6)](_0x5026b9,_0x82ac1c);}async[a50_0x9202b7(0x1bc)](_0x10e538){const _0x3f2e97=a50_0x9202b7,_0x4ec161=await this[_0x3f2e97(0x1f4)](_0x10e538);return await this[_0x3f2e97(0x1a4)][_0x3f2e97(0x1cb)](_0x4ec161);}async[a50_0x9202b7(0x1b7)](_0x4e0b55,_0xe73743){const _0x387a59=a50_0x9202b7;return await this[_0x387a59(0x1a4)][_0x387a59(0x1b7)](_0x4e0b55,_0xe73743);}async[a50_0x9202b7(0x1b9)](_0x1c72f0,_0x766082,_0x115b8c){const _0x317131=a50_0x9202b7;return await this[_0x317131(0x1a4)]['updateSegment'](_0x1c72f0,_0x766082,_0x115b8c);}async[a50_0x9202b7(0x1e5)](_0x5344c7,_0x35f2c6){const _0x2d7459=a50_0x9202b7,_0x49db76=await this[_0x2d7459(0x1f4)](_0x5344c7);return await this['client'][_0x2d7459(0x1ec)](_0x49db76,_0x35f2c6);}async[a50_0x9202b7(0x1f4)](_0x1a9b04){const _0x4c7e15=a50_0x9202b7;if(/^\d+$/['test'](_0x1a9b04))return _0x1a9b04;return await this[_0x4c7e15(0x1f5)](_0x1a9b04);}async[a50_0x9202b7(0x1e3)](_0xcdee7b,_0x2481ae){const _0x41dc7e=a50_0x9202b7,[_0x12b42d,_0x44a54f]=await Promise[_0x41dc7e(0x1b4)]([this[_0x41dc7e(0x1ad)](_0xcdee7b,_0x2481ae)[_0x41dc7e(0x1da)](()=>!![])[_0x41dc7e(0x1b5)](()=>![]),this['resolveSegmentId'](_0xcdee7b,_0x2481ae)[_0x41dc7e(0x1da)](()=>!![])['catch'](()=>![])]);if(_0x12b42d&&_0x44a54f)return _0x41dc7e(0x1c9);else{if(_0x12b42d)return _0x41dc7e(0x1cf);else{if(_0x44a54f)return _0x41dc7e(0x1c8);}}throw new SDKError(ErrorCode[_0x41dc7e(0x1dd)],_0x41dc7e(0x1a1)+_0x2481ae+_0x41dc7e(0x1df));}async[a50_0x9202b7(0x1e9)](_0x4fcfdd,_0x8cc5ba,_0xd0f32c){const _0x5cee35=a50_0x9202b7,[_0x1255c9,_0x29a9ef]=await Promise[_0x5cee35(0x1b4)]([this[_0x5cee35(0x1d3)](_0x4fcfdd),this[_0x5cee35(0x19d)](_0x4fcfdd)]),_0xc29771=_0xd0f32c?_0x1255c9[_0x5cee35(0x1e4)](_0x5507a3=>_0x5507a3[_0x5cee35(0x1ea)]===_0xd0f32c):_0x1255c9[_0x5cee35(0x1e4)](_0x439450=>!_0x439450[_0x5cee35(0x1ea)]),_0x2af3bb=_0xd0f32c?_0x29a9ef[_0x5cee35(0x1e4)](_0x14a692=>_0x14a692[_0x5cee35(0x1d1)]===_0xd0f32c):_0x29a9ef[_0x5cee35(0x1e4)](_0x3e073b=>!_0x3e073b[_0x5cee35(0x1d1)]),_0x131f68=_0xc29771[_0x5cee35(0x1bb)](_0x4e4487=>_0x4e4487['name']===_0x8cc5ba),_0x2ff260=_0x2af3bb[_0x5cee35(0x1bb)](_0x17df02=>_0x17df02[_0x5cee35(0x19f)]===_0x8cc5ba);if(_0x131f68&&_0x2ff260)return _0x5cee35(0x1c9);else{if(_0x131f68)return _0x5cee35(0x1cf);else{if(_0x2ff260)return'segment';}}throw new SDKError(ErrorCode['NOT_FOUND'],_0x5cee35(0x1a1)+_0x8cc5ba+'\x27\x20not\x20found\x20in\x20'+(_0xd0f32c?_0x5cee35(0x1cf):_0x5cee35(0x1d0)));}async[a50_0x9202b7(0x1c2)](_0x2f228b){const _0x5dc751=a50_0x9202b7;if(_0x2f228b['length']===0x0)throw new SDKError(ErrorCode[_0x5dc751(0x1cc)],_0x5dc751(0x1c6));const _0x3bc12a=_0x2f228b[0x0],_0x4a27cb=await this[_0x5dc751(0x1f5)](_0x3bc12a);if(_0x2f228b[_0x5dc751(0x1ce)]===0x1)return{'parentId':_0x4a27cb,'parentName':_0x3bc12a,'type':_0x5dc751(0x1ed),'fullPath':_0x3bc12a};const _0x376218=await this[_0x5dc751(0x1bc)](_0x4a27cb),_0x14c25b=_0x376218[_0x5dc751(0x1ae)],_0xb86bcc=[];let _0x2b498e=_0x14c25b;for(let _0x39b381=0x1;_0x39b381<_0x2f228b['length']-0x1;_0x39b381++){const _0x484da9=_0x2f228b[_0x39b381],_0x3bd314=await this[_0x5dc751(0x1d3)](_0x4a27cb),_0xef4ecb=_0x2b498e?_0x3bd314['find'](_0x27bbb5=>_0x27bbb5['name']===_0x484da9&&_0x27bbb5['parentFolderId']===_0x2b498e):_0x3bd314['find'](_0x44b213=>_0x44b213['name']===_0x484da9&&!_0x44b213['parentFolderId']);if(!_0xef4ecb)throw new SDKError(ErrorCode['NOT_FOUND'],'Folder\x20\x27'+_0x484da9+_0x5dc751(0x1e6));_0xb86bcc[_0x5dc751(0x1a3)](_0x484da9),_0x2b498e=_0xef4ecb['id'];}const _0xf58f8=_0x2f228b[_0x2f228b[_0x5dc751(0x1ce)]-0x1],_0x13a87a=await this['detectResourceTypeInFolder'](_0x4a27cb,_0xf58f8,_0x2b498e);if(_0x13a87a===_0x5dc751(0x1c9))return{'parentId':_0x4a27cb,'parentName':_0x3bc12a,'folderId':_0x2b498e,'folderPath':_0xb86bcc[_0x5dc751(0x1ce)]>0x0?_0xb86bcc:undefined,'type':_0x5dc751(0x1cf),'fullPath':_0x2f228b['join']('/')};else{if(_0x13a87a===_0x5dc751(0x1cf)){const _0x5eee0f=await this[_0x5dc751(0x1d3)](_0x4a27cb),_0x31d45c=_0x2b498e?_0x5eee0f[_0x5dc751(0x1b3)](_0x1d54ff=>_0x1d54ff[_0x5dc751(0x19f)]===_0xf58f8&&_0x1d54ff[_0x5dc751(0x1ea)]===_0x2b498e):_0x5eee0f['find'](_0x5598be=>_0x5598be[_0x5dc751(0x19f)]===_0xf58f8&&!_0x5598be[_0x5dc751(0x1ea)]);if(!_0x31d45c)throw new SDKError(ErrorCode[_0x5dc751(0x1dd)],_0x5dc751(0x1e7)+_0xf58f8+_0x5dc751(0x1a7));return _0xb86bcc[_0x5dc751(0x1a3)](_0xf58f8),{'parentId':_0x4a27cb,'parentName':_0x3bc12a,'folderId':_0x31d45c['id'],'folderPath':_0xb86bcc,'type':_0x5dc751(0x1cf),'fullPath':_0x2f228b[_0x5dc751(0x1ab)]('/')};}else{const _0x14503d=await this['listSegments'](_0x4a27cb),_0x41c1fb=_0x2b498e?_0x14503d['find'](_0x30dfe6=>_0x30dfe6[_0x5dc751(0x19f)]===_0xf58f8&&_0x30dfe6[_0x5dc751(0x1d1)]===_0x2b498e):_0x14503d[_0x5dc751(0x1b3)](_0x1d7613=>_0x1d7613[_0x5dc751(0x19f)]===_0xf58f8&&!_0x1d7613[_0x5dc751(0x1d1)]);if(!_0x41c1fb)throw new SDKError(ErrorCode[_0x5dc751(0x1dd)],_0x5dc751(0x1e8)+_0xf58f8+_0x5dc751(0x1a7));return{'parentId':_0x4a27cb,'parentName':_0x3bc12a,'folderId':_0x2b498e,'folderPath':_0xb86bcc[_0x5dc751(0x1ce)]>0x0?_0xb86bcc:undefined,'segmentId':_0x41c1fb['id'],'segmentName':_0xf58f8,'type':'segment','fullPath':_0x2f228b[_0x5dc751(0x1ab)]('/')};}}}async[a50_0x9202b7(0x1aa)](_0x380d58){const _0x375148=a50_0x9202b7,_0x496346=parsePath(_0x380d58);if(!_0x496346[_0x375148(0x1db)])throw new SDKError(ErrorCode[_0x375148(0x1cc)],'Path\x20must\x20be\x20absolute\x20(cannot\x20start\x20with\x20.\x20or\x20..)');return await this[_0x375148(0x1c2)](_0x496346['segments']);}async['listUnified'](_0x462288,_0x467e05){const _0x1a903f=a50_0x9202b7,[_0x320d37,_0x57f4cf]=await Promise[_0x1a903f(0x1b4)]([this['listFolders'](_0x462288),this[_0x1a903f(0x19d)](_0x462288)]);if(_0x467e05){const _0x5b48e7=_0x320d37['filter'](_0x2c1ccf=>_0x2c1ccf[_0x1a903f(0x1ea)]===_0x467e05),_0x360459=_0x57f4cf[_0x1a903f(0x1e4)](_0x19bfdc=>_0x19bfdc[_0x1a903f(0x1d1)]===_0x467e05);return{'folders':_0x5b48e7,'segments':_0x360459};}const _0x59e71f=await this[_0x1a903f(0x1bc)](_0x462288),_0x35dee0=_0x59e71f['rootFolderId'];if(_0x35dee0){const _0x4e5610=_0x320d37[_0x1a903f(0x1e4)](_0x2677bf=>_0x2677bf[_0x1a903f(0x1ea)]===_0x35dee0),_0x13b2f6=_0x57f4cf[_0x1a903f(0x1e4)](_0x4543ec=>_0x4543ec[_0x1a903f(0x1d1)]===_0x35dee0);return{'folders':_0x4e5610,'segments':_0x13b2f6};}const _0x2fb2c4=_0x320d37['filter'](_0x5265d7=>!_0x5265d7[_0x1a903f(0x1ea)]),_0x58f5a6=_0x57f4cf[_0x1a903f(0x1e4)](_0x48574f=>!_0x48574f[_0x1a903f(0x1d1)]);return{'folders':_0x2fb2c4,'segments':_0x58f5a6};}async[a50_0x9202b7(0x1d9)](_0x5574c6,_0x1cd262,_0x1ad628=0x0,_0x274b13=0xa){const _0x5d15af=a50_0x9202b7;if(_0x1ad628>=_0x274b13)throw new SDKError(ErrorCode[_0x5d15af(0x1cc)],'Maximum\x20recursion\x20depth\x20('+_0x274b13+_0x5d15af(0x1f2));const {folders:_0x17f8c3,segments:_0x3e4f4d}=await this['listUnified'](_0x5574c6,_0x1cd262),_0x1e9198=[];for(const _0x11c00b of _0x17f8c3){const _0x5de7e3=await this[_0x5d15af(0x1d9)](_0x5574c6,_0x11c00b['id'],_0x1ad628+0x1,_0x274b13);_0x1e9198[_0x5d15af(0x1a3)]({'type':_0x5d15af(0x1cf),'id':_0x11c00b['id'],'name':_0x11c00b[_0x5d15af(0x19f)],'children':_0x5de7e3['length']>0x0?_0x5de7e3:undefined,'metadata':{'description':_0x11c00b[_0x5d15af(0x1ee)]||undefined,'folderCount':_0x5de7e3[_0x5d15af(0x1e4)](_0x37e93e=>_0x37e93e[_0x5d15af(0x1ca)]===_0x5d15af(0x1cf))['length'],'segmentCount':_0x5de7e3['filter'](_0x4ca1c4=>_0x4ca1c4['type']===_0x5d15af(0x1c8))[_0x5d15af(0x1ce)],'createdAt':_0x11c00b[_0x5d15af(0x1b0)],'updatedAt':_0x11c00b[_0x5d15af(0x1bf)]}});}for(const _0x539bc3 of _0x3e4f4d){_0x1e9198['push']({'type':_0x5d15af(0x1c8),'id':_0x539bc3['id'],'name':_0x539bc3['name'],'population':_0x539bc3['population'],'metadata':{'description':_0x539bc3[_0x5d15af(0x1ee)],'createdAt':_0x539bc3[_0x5d15af(0x1b0)],'updatedAt':_0x539bc3[_0x5d15af(0x1bf)]}});}return _0x1e9198;}}function a50_0x2072(){const _0x742a44=['isAbsolute','schema','NOT_FOUND','updateParent','\x27\x20not\x20found\x20in\x20parent\x20segment','getSegment','491814QPXVJs','63JXdzBF','detectResourceType','filter','createFolder','\x27\x20not\x20found\x20in\x20path','Folder\x20\x27','Segment\x20\x27','detectResourceTypeInFolder','parentFolderId','getParentSegment','createSegmentFolder','parent','description','Child\x20segment\x20not\x20found:\x20','963488YKwvwE','624AoZWJz',')\x20exceeded','createParentSegment','resolveParentIdOrName','resolveParentId','listSegments','\x20in\x20parent\x20','name','9mMdbjS','Resource\x20\x27','10csJEwA','push','client','resolveSegmentId','updateParentSegment','\x27\x20not\x20found','getParent','918616UQPCxf','resolvePathToResource','join','Parent\x20segment\x20not\x20found:\x20','resolveFolderId','rootFolderId','getParentSQL','createdAt','Folder\x20not\x20found:\x20','attributes','find','all','catch','1290810RDUJgV','createSegment','145475OuaAWA','updateSegmentById','behaviors','some','getParentFull','parentColumn','behavior','updatedAt','createParent','getSegmentFolder','traversePath','242465skEvhs','getSegmentSQL','4yznKle','Path\x20cannot\x20be\x20empty','getParentSegmentSQL','segment','ambiguous','type','getParentSegmentFull','INVALID_ARGUMENT','475974dsdNFI','length','folder','parent\x20segment','segmentFolderId','listFields','listFolders','parentDatabaseName','listParents','isArray','parentTableName','listActivations','listRecursive','then'];a50_0x2072=function(){return _0x742a44;};return a50_0x2072();}
1
+ const a50_0x147392=a50_0x5859;function a50_0x5859(_0x1bfeed,_0x19c0d0){const _0x4eec40=a50_0x4eec();return a50_0x5859=function(_0x585935,_0x2351d6){_0x585935=_0x585935-0x19b;let _0x588c22=_0x4eec40[_0x585935];return _0x588c22;},a50_0x5859(_0x1bfeed,_0x19c0d0);}(function(_0xc95058,_0x22c4d4){const _0x106167=a50_0x5859,_0x15a961=_0xc95058();while(!![]){try{const _0x3f5d7c=parseInt(_0x106167(0x1a6))/0x1*(parseInt(_0x106167(0x1ec))/0x2)+parseInt(_0x106167(0x1d1))/0x3*(parseInt(_0x106167(0x1b7))/0x4)+parseInt(_0x106167(0x1e0))/0x5*(parseInt(_0x106167(0x1b4))/0x6)+parseInt(_0x106167(0x1ea))/0x7+parseInt(_0x106167(0x1a5))/0x8+-parseInt(_0x106167(0x1ae))/0x9+-parseInt(_0x106167(0x1a1))/0xa;if(_0x3f5d7c===_0x22c4d4)break;else _0x15a961['push'](_0x15a961['shift']());}catch(_0x3accdb){_0x15a961['push'](_0x15a961['shift']());}}}(a50_0x4eec,0xe09b0));import{SDKError,ErrorCode}from'./errors.js';function a50_0x4eec(){const _0x11198a=['INVALID_ARGUMENT','createSegment','behaviors','\x27\x20not\x20found','createParentSegment','join','behavior','getParentSQL','listParentSegments','name','Path\x20cannot\x20be\x20empty','ambiguous','parentDatabaseName','population','listActivations','catch','Child\x20segment\x20not\x20found:\x20','\x27\x20not\x20found\x20in\x20path','getParent','resolveParentIdOrName','1540743aAEOpr','getParentSegment','listSegmentFolders','getFolder','test','detectResourceTypeInFolder','all','attribute','client','description','resolveFolderId','updatedAt','parent\x20segment','type','segmentFolderId','255mVSxsN','parent','Segment\x20\x27','resolveParentId','updateParent','listSegments','parentFolderId','rootFolderId','detectResourceType','\x20in\x20parent\x20','7609007HQXZqH','attributes','138STppuJ','find','folder','schema','getParentFull','getSegmentFolder','parentTableName','getSegment','listFolders','filter','updateParentSegment','resolveSegmentId','11578290DKnrXv','getParentSegmentFull','some','createParent','4622456qIrhwZ','3888zDkGeV','createdAt','then','updateSegment','Parent\x20segment\x20not\x20found:\x20','traversePath','listRecursive','segments','10657665snYEGI','createSegmentFolder','listUnified','push','NOT_FOUND','segment','95922pZPVoD','createFolder','parentColumn','4hbZgeO','listParents','isArray','updateSegmentById','length','\x27\x20not\x20found\x20in\x20'];a50_0x4eec=function(){return _0x11198a;};return a50_0x4eec();}import{parsePath}from'../utils/segment-path-parser.js';export class SegmentAPI{[a50_0x147392(0x1d9)];constructor(_0x56b9e8){const _0x3b4f07=a50_0x147392;this[_0x3b4f07(0x1d9)]=_0x56b9e8;}async[a50_0x147392(0x1b8)](){const _0x479351=a50_0x147392;return await this[_0x479351(0x1d9)][_0x479351(0x1c5)]();}async[a50_0x147392(0x1cf)](_0x5eb527){const _0xe35456=a50_0x147392;return await this[_0xe35456(0x1d9)][_0xe35456(0x1d2)](_0x5eb527);}async['listSegments'](_0x4a32a9){const _0x5b2236=a50_0x147392;return await this[_0x5b2236(0x1d9)][_0x5b2236(0x1e5)](_0x4a32a9);}async[a50_0x147392(0x19c)](_0x58843d,_0x4f40db){const _0x4888e3=a50_0x147392;return await this[_0x4888e3(0x1d9)]['getSegment'](_0x58843d,_0x4f40db);}async[a50_0x147392(0x19d)](_0x12674b){const _0x434765=a50_0x147392;return await this[_0x434765(0x1d9)][_0x434765(0x1d3)](_0x12674b);}async[a50_0x147392(0x1d4)](_0x2a01b5){const _0x461cdd=a50_0x147392;return await this[_0x461cdd(0x1d9)][_0x461cdd(0x1f1)](_0x2a01b5);}async[a50_0x147392(0x1cb)](_0x27ab3c,_0x5e902a){const _0x55c05a=a50_0x147392;return await this[_0x55c05a(0x1d9)][_0x55c05a(0x1cb)](_0x27ab3c,_0x5e902a);}async[a50_0x147392(0x1c4)](_0xecb3cc){return await this['client']['getParentSegmentSQL'](_0xecb3cc);}async['getSegmentSQL'](_0x45964f,_0x34761f){const _0x4ce53e=a50_0x147392;return await this[_0x4ce53e(0x1d9)]['getSegmentSQL'](_0x45964f,_0x34761f);}async[a50_0x147392(0x1e3)](_0x25f2c1){const _0x99e3f5=a50_0x147392,_0x3e8a0e=await this['listParents'](),_0x5eeeb3=_0x3e8a0e['find'](_0x3cc2e=>_0x3cc2e[_0x99e3f5(0x1eb)][_0x99e3f5(0x1c6)]===_0x25f2c1);if(!_0x5eeeb3)throw new SDKError(ErrorCode['NOT_FOUND'],_0x99e3f5(0x1aa)+_0x25f2c1);return _0x5eeeb3['id'];}async[a50_0x147392(0x1a0)](_0xf05965,_0x45e69c){const _0x1c5c88=a50_0x147392,_0x571742=await this[_0x1c5c88(0x1e5)](_0xf05965),_0x491b0e=_0x571742['find'](_0x5384cf=>_0x5384cf[_0x1c5c88(0x1c6)]===_0x45e69c);if(!_0x491b0e)throw new SDKError(ErrorCode[_0x1c5c88(0x1b2)],_0x1c5c88(0x1cd)+_0x45e69c+_0x1c5c88(0x1e9)+_0xf05965);return _0x491b0e['id'];}async[a50_0x147392(0x1db)](_0x306215,_0x526d57){const _0x4078bd=a50_0x147392,_0x2cbbc4=await this['listFolders'](_0x306215),_0x248d7c=_0x2cbbc4[_0x4078bd(0x1ed)](_0x41f468=>_0x41f468['name']===_0x526d57);if(!_0x248d7c)throw new SDKError(ErrorCode[_0x4078bd(0x1b2)],'Folder\x20not\x20found:\x20'+_0x526d57+_0x4078bd(0x1e9)+_0x306215);return _0x248d7c['id'];}async['listFields'](_0x174947){const _0x2ddf1c=a50_0x147392,_0xd63dd=await this[_0x2ddf1c(0x1d0)](_0x174947),_0x32e0fd=await this[_0x2ddf1c(0x1d9)]['getParentSegmentFull'](_0xd63dd),_0x32ad17=[];if(_0x32e0fd[_0x2ddf1c(0x1eb)]&&Array[_0x2ddf1c(0x1b9)](_0x32e0fd['attributes']))for(const _0x4df9b7 of _0x32e0fd[_0x2ddf1c(0x1eb)]){const _0x321ed7=_0x4df9b7;_0x321ed7[_0x2ddf1c(0x1c6)]&&_0x321ed7[_0x2ddf1c(0x1de)]&&_0x32ad17[_0x2ddf1c(0x1b1)]({'name':_0x321ed7[_0x2ddf1c(0x1c6)],'type':_0x321ed7['type'],'source':_0x2ddf1c(0x1d8),'parentDatabaseName':_0x321ed7[_0x2ddf1c(0x1c9)],'parentTableName':_0x321ed7[_0x2ddf1c(0x19b)],'parentColumn':_0x321ed7[_0x2ddf1c(0x1b6)]});}if(_0x32e0fd[_0x2ddf1c(0x1bf)]&&Array[_0x2ddf1c(0x1b9)](_0x32e0fd[_0x2ddf1c(0x1bf)]))for(const _0x430e29 of _0x32e0fd[_0x2ddf1c(0x1bf)]){const _0x49509a=_0x430e29,_0x3448e6=_0x49509a[_0x2ddf1c(0x1c6)];if(_0x3448e6&&_0x49509a['schema']&&Array['isArray'](_0x49509a[_0x2ddf1c(0x1ef)]))for(const _0x42b19d of _0x49509a[_0x2ddf1c(0x1ef)]){_0x42b19d[_0x2ddf1c(0x1c6)]&&_0x42b19d[_0x2ddf1c(0x1de)]&&_0x32ad17[_0x2ddf1c(0x1b1)]({'name':_0x3448e6+'.'+_0x42b19d[_0x2ddf1c(0x1c6)],'type':_0x42b19d[_0x2ddf1c(0x1de)],'source':_0x2ddf1c(0x1c3),'behaviorName':_0x3448e6,'parentDatabaseName':_0x49509a[_0x2ddf1c(0x1c9)],'parentTableName':_0x49509a['parentTableName'],'parentColumn':_0x42b19d[_0x2ddf1c(0x1b6)]});}}return _0x32ad17;}async[a50_0x147392(0x1a4)](_0x106c47){const _0xa5ff05=a50_0x147392;return await this[_0xa5ff05(0x1d9)][_0xa5ff05(0x1c1)](_0x106c47);}async[a50_0x147392(0x1e4)](_0x933e70,_0x3b35e4){const _0x5e19c8=a50_0x147392,_0x4a42ba=await this[_0x5e19c8(0x1d0)](_0x933e70);return await this[_0x5e19c8(0x1d9)][_0x5e19c8(0x19f)](_0x4a42ba,_0x3b35e4);}async[a50_0x147392(0x1f0)](_0x5ee7bc){const _0xcce7b1=a50_0x147392,_0x3e5aa8=await this[_0xcce7b1(0x1d0)](_0x5ee7bc);return await this[_0xcce7b1(0x1d9)][_0xcce7b1(0x1a2)](_0x3e5aa8);}async['createSegment'](_0x5afcb6,_0x49d608){const _0x229cce=a50_0x147392;return await this[_0x229cce(0x1d9)][_0x229cce(0x1be)](_0x5afcb6,_0x49d608);}async[a50_0x147392(0x1ba)](_0x139364,_0x3c1c8d,_0x31e3cb){const _0x4cfba2=a50_0x147392;return await this['client'][_0x4cfba2(0x1a9)](_0x139364,_0x3c1c8d,_0x31e3cb);}async[a50_0x147392(0x1b5)](_0x531e34,_0x2dcc65){const _0x4f6675=a50_0x147392,_0x4c7516=await this['resolveParentIdOrName'](_0x531e34);return await this[_0x4f6675(0x1d9)][_0x4f6675(0x1af)](_0x4c7516,_0x2dcc65);}async[a50_0x147392(0x1d0)](_0x5db417){const _0x1e0ffa=a50_0x147392;if(/^\d+$/[_0x1e0ffa(0x1d5)](_0x5db417))return _0x5db417;return await this[_0x1e0ffa(0x1e3)](_0x5db417);}async[a50_0x147392(0x1e8)](_0x5100c2,_0x5d7cc4){const _0x2f2afd=a50_0x147392,[_0x353ae2,_0x58c702]=await Promise[_0x2f2afd(0x1d7)]([this[_0x2f2afd(0x1db)](_0x5100c2,_0x5d7cc4)[_0x2f2afd(0x1a8)](()=>!![])['catch'](()=>![]),this[_0x2f2afd(0x1a0)](_0x5100c2,_0x5d7cc4)[_0x2f2afd(0x1a8)](()=>!![])[_0x2f2afd(0x1cc)](()=>![])]);if(_0x353ae2&&_0x58c702)return'ambiguous';else{if(_0x353ae2)return _0x2f2afd(0x1ee);else{if(_0x58c702)return _0x2f2afd(0x1b3);}}throw new SDKError(ErrorCode[_0x2f2afd(0x1b2)],'Resource\x20\x27'+_0x5d7cc4+'\x27\x20not\x20found\x20in\x20parent\x20segment');}async['detectResourceTypeInFolder'](_0x43d3e1,_0x2e6c47,_0x5297e4){const _0x2703d5=a50_0x147392,[_0x3642ad,_0x456803]=await Promise[_0x2703d5(0x1d7)]([this[_0x2703d5(0x19d)](_0x43d3e1),this[_0x2703d5(0x1e5)](_0x43d3e1)]),_0x25b916=_0x5297e4?_0x3642ad['filter'](_0x410994=>_0x410994[_0x2703d5(0x1e6)]===_0x5297e4):_0x3642ad[_0x2703d5(0x19e)](_0x5bae90=>!_0x5bae90[_0x2703d5(0x1e6)]),_0x3f2f1e=_0x5297e4?_0x456803[_0x2703d5(0x19e)](_0xd9ce3c=>_0xd9ce3c[_0x2703d5(0x1df)]===_0x5297e4):_0x456803[_0x2703d5(0x19e)](_0x5cedf4=>!_0x5cedf4[_0x2703d5(0x1df)]),_0x131a8c=_0x25b916['some'](_0x3fd074=>_0x3fd074[_0x2703d5(0x1c6)]===_0x2e6c47),_0x2f2be0=_0x3f2f1e[_0x2703d5(0x1a3)](_0xe1f2aa=>_0xe1f2aa[_0x2703d5(0x1c6)]===_0x2e6c47);if(_0x131a8c&&_0x2f2be0)return _0x2703d5(0x1c8);else{if(_0x131a8c)return _0x2703d5(0x1ee);else{if(_0x2f2be0)return _0x2703d5(0x1b3);}}throw new SDKError(ErrorCode[_0x2703d5(0x1b2)],'Resource\x20\x27'+_0x2e6c47+_0x2703d5(0x1bc)+(_0x5297e4?_0x2703d5(0x1ee):_0x2703d5(0x1dd)));}async[a50_0x147392(0x1ab)](_0x1c4b51){const _0x4d49b4=a50_0x147392;if(_0x1c4b51[_0x4d49b4(0x1bb)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x4d49b4(0x1c7));const _0x4fe68f=_0x1c4b51[0x0],_0x54a0ef=await this[_0x4d49b4(0x1e3)](_0x4fe68f);if(_0x1c4b51[_0x4d49b4(0x1bb)]===0x1)return{'parentId':_0x54a0ef,'parentName':_0x4fe68f,'type':_0x4d49b4(0x1e1),'fullPath':_0x4fe68f};const _0xc1d5bf=await this[_0x4d49b4(0x1f0)](_0x54a0ef),_0x160b15=_0xc1d5bf[_0x4d49b4(0x1e7)],_0xf4ca79=[];let _0x5248d2=_0x160b15;for(let _0xcf13b8=0x1;_0xcf13b8<_0x1c4b51['length']-0x1;_0xcf13b8++){const _0x5955f2=_0x1c4b51[_0xcf13b8],_0x3f1f4a=await this[_0x4d49b4(0x19d)](_0x54a0ef),_0x3fe3b7=_0x5248d2?_0x3f1f4a[_0x4d49b4(0x1ed)](_0x58ce96=>_0x58ce96['name']===_0x5955f2&&_0x58ce96[_0x4d49b4(0x1e6)]===_0x5248d2):_0x3f1f4a['find'](_0x332000=>_0x332000[_0x4d49b4(0x1c6)]===_0x5955f2&&!_0x332000[_0x4d49b4(0x1e6)]);if(!_0x3fe3b7)throw new SDKError(ErrorCode['NOT_FOUND'],'Folder\x20\x27'+_0x5955f2+_0x4d49b4(0x1ce));_0xf4ca79[_0x4d49b4(0x1b1)](_0x5955f2),_0x5248d2=_0x3fe3b7['id'];}const _0x1b3d3e=_0x1c4b51[_0x1c4b51[_0x4d49b4(0x1bb)]-0x1],_0x593454=await this[_0x4d49b4(0x1d6)](_0x54a0ef,_0x1b3d3e,_0x5248d2);if(_0x593454===_0x4d49b4(0x1c8))return{'parentId':_0x54a0ef,'parentName':_0x4fe68f,'folderId':_0x5248d2,'folderPath':_0xf4ca79[_0x4d49b4(0x1bb)]>0x0?_0xf4ca79:undefined,'type':_0x4d49b4(0x1ee),'fullPath':_0x1c4b51['join']('/')};else{if(_0x593454===_0x4d49b4(0x1ee)){const _0x543349=await this[_0x4d49b4(0x19d)](_0x54a0ef),_0x316868=_0x5248d2?_0x543349[_0x4d49b4(0x1ed)](_0x43f308=>_0x43f308[_0x4d49b4(0x1c6)]===_0x1b3d3e&&_0x43f308[_0x4d49b4(0x1e6)]===_0x5248d2):_0x543349[_0x4d49b4(0x1ed)](_0x430370=>_0x430370[_0x4d49b4(0x1c6)]===_0x1b3d3e&&!_0x430370['parentFolderId']);if(!_0x316868)throw new SDKError(ErrorCode[_0x4d49b4(0x1b2)],'Folder\x20\x27'+_0x1b3d3e+_0x4d49b4(0x1c0));return _0xf4ca79[_0x4d49b4(0x1b1)](_0x1b3d3e),{'parentId':_0x54a0ef,'parentName':_0x4fe68f,'folderId':_0x316868['id'],'folderPath':_0xf4ca79,'type':'folder','fullPath':_0x1c4b51[_0x4d49b4(0x1c2)]('/')};}else{const _0x2687b0=await this[_0x4d49b4(0x1e5)](_0x54a0ef),_0x1a2fb6=_0x5248d2?_0x2687b0[_0x4d49b4(0x1ed)](_0x2a559d=>_0x2a559d[_0x4d49b4(0x1c6)]===_0x1b3d3e&&_0x2a559d[_0x4d49b4(0x1df)]===_0x5248d2):_0x2687b0[_0x4d49b4(0x1ed)](_0x16a24c=>_0x16a24c[_0x4d49b4(0x1c6)]===_0x1b3d3e&&!_0x16a24c[_0x4d49b4(0x1df)]);if(!_0x1a2fb6)throw new SDKError(ErrorCode['NOT_FOUND'],_0x4d49b4(0x1e2)+_0x1b3d3e+_0x4d49b4(0x1c0));return{'parentId':_0x54a0ef,'parentName':_0x4fe68f,'folderId':_0x5248d2,'folderPath':_0xf4ca79[_0x4d49b4(0x1bb)]>0x0?_0xf4ca79:undefined,'segmentId':_0x1a2fb6['id'],'segmentName':_0x1b3d3e,'type':_0x4d49b4(0x1b3),'fullPath':_0x1c4b51[_0x4d49b4(0x1c2)]('/')};}}}async['resolvePathToResource'](_0x47d5cf){const _0x47c223=a50_0x147392,_0x47b86f=parsePath(_0x47d5cf);if(!_0x47b86f['isAbsolute'])throw new SDKError(ErrorCode[_0x47c223(0x1bd)],'Path\x20must\x20be\x20absolute\x20(cannot\x20start\x20with\x20.\x20or\x20..)');return await this[_0x47c223(0x1ab)](_0x47b86f[_0x47c223(0x1ad)]);}async[a50_0x147392(0x1b0)](_0xd23262,_0x3d1b0c){const _0x22723d=a50_0x147392,[_0x89312b,_0x187a81]=await Promise['all']([this[_0x22723d(0x19d)](_0xd23262),this[_0x22723d(0x1e5)](_0xd23262)]);if(_0x3d1b0c){const _0x194d97=_0x89312b[_0x22723d(0x19e)](_0x29eaa8=>_0x29eaa8[_0x22723d(0x1e6)]===_0x3d1b0c),_0x13265c=_0x187a81[_0x22723d(0x19e)](_0x2e539b=>_0x2e539b[_0x22723d(0x1df)]===_0x3d1b0c);return{'folders':_0x194d97,'segments':_0x13265c};}const _0x5bb79b=await this['getParentFull'](_0xd23262),_0x425379=_0x5bb79b['rootFolderId'];if(_0x425379){const _0x2aa7c4=_0x89312b[_0x22723d(0x19e)](_0x28875f=>_0x28875f[_0x22723d(0x1e6)]===_0x425379),_0x40e23e=_0x187a81['filter'](_0x25f2c4=>_0x25f2c4[_0x22723d(0x1df)]===_0x425379);return{'folders':_0x2aa7c4,'segments':_0x40e23e};}const _0x2c8dc6=_0x89312b[_0x22723d(0x19e)](_0x4a42fe=>!_0x4a42fe[_0x22723d(0x1e6)]),_0x33aeeb=_0x187a81[_0x22723d(0x19e)](_0xe35b1e=>!_0xe35b1e[_0x22723d(0x1df)]);return{'folders':_0x2c8dc6,'segments':_0x33aeeb};}async[a50_0x147392(0x1ac)](_0x31467a,_0x200f20,_0x44218a=0x0,_0x320b81=0xa){const _0x98e899=a50_0x147392;if(_0x44218a>=_0x320b81)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Maximum\x20recursion\x20depth\x20('+_0x320b81+')\x20exceeded');const {folders:_0x1fdaeb,segments:_0x328b75}=await this[_0x98e899(0x1b0)](_0x31467a,_0x200f20),_0x4c9a96=[];for(const _0x310a9b of _0x1fdaeb){const _0x1b4ff0=await this['listRecursive'](_0x31467a,_0x310a9b['id'],_0x44218a+0x1,_0x320b81);_0x4c9a96[_0x98e899(0x1b1)]({'type':_0x98e899(0x1ee),'id':_0x310a9b['id'],'name':_0x310a9b[_0x98e899(0x1c6)],'children':_0x1b4ff0[_0x98e899(0x1bb)]>0x0?_0x1b4ff0:undefined,'metadata':{'description':_0x310a9b['description']||undefined,'folderCount':_0x1b4ff0['filter'](_0x19809a=>_0x19809a['type']===_0x98e899(0x1ee))[_0x98e899(0x1bb)],'segmentCount':_0x1b4ff0[_0x98e899(0x19e)](_0x5d5d34=>_0x5d5d34['type']===_0x98e899(0x1b3))[_0x98e899(0x1bb)],'createdAt':_0x310a9b['createdAt'],'updatedAt':_0x310a9b[_0x98e899(0x1dc)]}});}for(const _0x35a5be of _0x328b75){_0x4c9a96[_0x98e899(0x1b1)]({'type':'segment','id':_0x35a5be['id'],'name':_0x35a5be[_0x98e899(0x1c6)],'population':_0x35a5be[_0x98e899(0x1ca)],'metadata':{'description':_0x35a5be[_0x98e899(0x1da)],'createdAt':_0x35a5be[_0x98e899(0x1a7)],'updatedAt':_0x35a5be[_0x98e899(0x1dc)]}});}return _0x4c9a96;}}
package/dist/sdk/table.js CHANGED
@@ -1 +1 @@
1
- const a51_0x495a2a=a51_0x1060;function a51_0xc0c1(){const _0x2c313f=['Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','16406310akVtSM','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20','9kEtbyr','data','isInteger','5651744ibYxXa','validateTable','2939278cjhwCY','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','Database\x20name\x20is\x20required','2503045hdEWsd','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','\x0a\x20\x20\x20\x20\x20\x20','3LXUBIc','length','140jQMxrN','INVALID_ARGUMENT','client','Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only','\x0a\x20\x20AND\x20table_schema\x20LIKE\x20','\x20ESCAPE\x20\x27\x5c\x27','113892goMBeN','MISSING_ARGUMENT','Usage:\x20tdx\x20describe\x20<database.table>','describe','523138FLqgFN','Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','4351288erudlx','validateDatabase','Limit\x20must\x20be\x20a\x20positive\x20integer','executeQuery','trim','\x0a\x20\x20\x20\x20','Table\x20name\x20is\x20required','Limit\x20must\x20be\x20a\x20positive\x20number','SELECT\x20*\x20FROM\x20','\x0a\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20column_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20data_type,\x0a\x20\x20\x20\x20\x20\x20\x20\x20is_nullable\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.columns\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','Usage:\x20tdx\x20show\x20<database.table>','\x20LIMIT\x20','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','slice','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20schema_name\x20=\x20','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','\x0a\x20\x20AND\x20table_name\x20LIKE\x20','list'];a51_0xc0c1=function(){return _0x2c313f;};return a51_0xc0c1();}(function(_0x36b9f1,_0x32154d){const _0x470211=a51_0x1060,_0x583141=_0x36b9f1();while(!![]){try{const _0x449b80=parseInt(_0x470211(0x19a))/0x1+parseInt(_0x470211(0x1ba))/0x2+parseInt(_0x470211(0x1c0))/0x3*(parseInt(_0x470211(0x19d))/0x4)+parseInt(_0x470211(0x1bd))/0x5+-parseInt(_0x470211(0x196))/0x6*(parseInt(_0x470211(0x1c2))/0x7)+-parseInt(_0x470211(0x1b8))/0x8+-parseInt(_0x470211(0x1b5))/0x9*(parseInt(_0x470211(0x1b3))/0xa);if(_0x449b80===_0x32154d)break;else _0x583141['push'](_0x583141['shift']());}catch(_0x509a52){_0x583141['push'](_0x583141['shift']());}}}(a51_0xc0c1,0xd09c5));import{escapeStringLiteral,buildLikePattern}from'../utils/string-utils.js';function a51_0x1060(_0x51a8ca,_0x18dac9){const _0xc0c1a3=a51_0xc0c1();return a51_0x1060=function(_0x10603a,_0x88e9){_0x10603a=_0x10603a-0x196;let _0x4f0691=_0xc0c1a3[_0x10603a];return _0x4f0691;},a51_0x1060(_0x51a8ca,_0x18dac9);}import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';export class TableAPI{[a51_0x495a2a(0x1c4)];constructor(_0x3a8b9e){const _0x5b8e67=a51_0x495a2a;this[_0x5b8e67(0x1c4)]=_0x3a8b9e;}async[a51_0x495a2a(0x1b0)](_0x213de0,_0x18279a,_0x401c4c,_0x233679=DEFAULT_LISTING_LIMIT){const _0x4b66dd=a51_0x495a2a;if(_0x213de0!==undefined&&_0x213de0['trim']()[_0x4b66dd(0x1c1)]===0x0)throw new SDKError(ErrorCode[_0x4b66dd(0x1c3)],_0x4b66dd(0x1c5),undefined,{'helpText':_0x4b66dd(0x1bb)});if(_0x18279a!==undefined&&_0x18279a['trim']()[_0x4b66dd(0x1c1)]===0x0)throw new SDKError(ErrorCode[_0x4b66dd(0x1c3)],_0x4b66dd(0x1ac),undefined,{'helpText':'Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.'});if(_0x401c4c!==undefined&&_0x401c4c[_0x4b66dd(0x1a1)]()[_0x4b66dd(0x1c1)]===0x0)throw new SDKError(ErrorCode[_0x4b66dd(0x1c3)],_0x4b66dd(0x1ad),undefined,{'helpText':_0x4b66dd(0x1b1)});if(_0x233679<=0x0)throw new SDKError(ErrorCode[_0x4b66dd(0x1c3)],_0x4b66dd(0x1a4),undefined,{'helpText':_0x4b66dd(0x1ae)});let _0x430974;_0x213de0?(_0x430974=_0x4b66dd(0x1a9)+escapeStringLiteral(_0x213de0)+_0x4b66dd(0x1bf),_0x18279a&&(_0x430974+=_0x4b66dd(0x1af)+buildLikePattern(_0x18279a)+_0x4b66dd(0x1c7)),_0x430974+=_0x4b66dd(0x1b4)+_0x233679):(_0x430974='\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_schema\x20AS\x20database_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20',_0x401c4c&&(_0x430974+=_0x4b66dd(0x1c6)+buildLikePattern(_0x401c4c)+_0x4b66dd(0x1c7)),_0x18279a&&(_0x430974+=_0x4b66dd(0x1af)+buildLikePattern(_0x18279a)+_0x4b66dd(0x1c7)),_0x430974+=_0x4b66dd(0x19c)+_0x233679);const _0x58ea81=await this[_0x4b66dd(0x1c4)][_0x4b66dd(0x1a0)](_0x430974[_0x4b66dd(0x1a1)]());return _0x58ea81[_0x4b66dd(0x1b6)];}async[a51_0x495a2a(0x19e)](_0x2e4874){const _0x569445=a51_0x495a2a,_0x48a7fd=(_0x569445(0x1ab)+escapeStringLiteral(_0x2e4874)+_0x569445(0x1a2))[_0x569445(0x1a1)](),_0x5dc5c0=await this[_0x569445(0x1c4)][_0x569445(0x1a0)](_0x48a7fd);return _0x5dc5c0[_0x569445(0x1b6)][_0x569445(0x1c1)]>0x0;}async[a51_0x495a2a(0x1b9)](_0x3c5621,_0xd1dd22){const _0x1fd780=a51_0x495a2a,_0x449d44=(_0x1fd780(0x1b2)+escapeStringLiteral(_0x3c5621)+_0x1fd780(0x1be)+escapeStringLiteral(_0xd1dd22)+'\x0a\x20\x20\x20\x20')[_0x1fd780(0x1a1)](),_0x16efcf=await this[_0x1fd780(0x1c4)][_0x1fd780(0x1a0)](_0x449d44);return _0x16efcf['data'][_0x1fd780(0x1c1)]>0x0;}async[a51_0x495a2a(0x199)](_0x37a705,_0x3bb21c){const _0x1bc2c9=a51_0x495a2a;if(!_0x37a705||_0x37a705[_0x1bc2c9(0x1a1)]()[_0x1bc2c9(0x1c1)]===0x0)throw new SDKError(ErrorCode[_0x1bc2c9(0x197)],_0x1bc2c9(0x1bc),undefined,{'helpText':_0x1bc2c9(0x198)});if(!_0x3bb21c||_0x3bb21c[_0x1bc2c9(0x1a1)]()['length']===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],_0x1bc2c9(0x1a3),undefined,{'helpText':'Usage:\x20tdx\x20describe\x20<database.table>'});const _0x1b6dec=(_0x1bc2c9(0x1a6)+escapeStringLiteral(_0x37a705)+_0x1bc2c9(0x1be)+escapeStringLiteral(_0x3bb21c)+'\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20')['trim'](),_0x510fc6=await this[_0x1bc2c9(0x1c4)]['executeQuery'](_0x1b6dec);return _0x510fc6['data'];}async['show'](_0x1f9822,_0x4416b7,_0x3f8850=0x28,_0x1e7e6f){const _0x59c334=a51_0x495a2a;try{if(!_0x1f9822||_0x1f9822['trim']()['length']===0x0)throw new SDKError(ErrorCode['MISSING_ARGUMENT'],_0x59c334(0x1bc),undefined,{'helpText':_0x59c334(0x1a7)});if(!_0x4416b7||_0x4416b7[_0x59c334(0x1a1)]()[_0x59c334(0x1c1)]===0x0)throw new SDKError(ErrorCode[_0x59c334(0x197)],'Table\x20name\x20is\x20required',undefined,{'helpText':_0x59c334(0x1a7)});if(!Number[_0x59c334(0x1b7)](_0x3f8850)||_0x3f8850<=0x0)throw new SDKError(ErrorCode[_0x59c334(0x1c3)],_0x59c334(0x19f),undefined,{'helpText':_0x59c334(0x19b)});const _0x2b3759=escapeStringLiteral(_0x1f9822)[_0x59c334(0x1aa)](0x1,-0x1)+'.'+escapeStringLiteral(_0x4416b7)[_0x59c334(0x1aa)](0x1,-0x1),_0x3375c8=_0x59c334(0x1a5)+_0x2b3759+_0x59c334(0x1a8)+_0x3f8850,_0x41f8b2=await this[_0x59c334(0x1c4)][_0x59c334(0x1a0)](_0x3375c8,{'catalog':_0x1e7e6f,'schema':_0x1f9822});return _0x41f8b2;}catch(_0x274c83){if(_0x274c83 instanceof SDKError)throw _0x274c83;throw _0x274c83;}}}
1
+ function a51_0x545c(){const _0x2b0b7c=['\x0a\x20\x20AND\x20table_name\x20LIKE\x20','59815bKZbEa','Pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only','\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_schema\x20AS\x20database_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20','Provide\x20a\x20positive\x20number\x20for\x20limit\x20(e.g.,\x20100).','1092346VUkMdy','6CDTbkI','\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_name\x20=\x20','describe','\x0aORDER\x20BY\x20database_name,\x20table_name\x0aLIMIT\x20','1216iotPkT','list','data','\x20ESCAPE\x20\x27\x5c\x27','isInteger','Limit\x20must\x20be\x20a\x20positive\x20integer','\x0a\x20\x20\x20\x20','1556313crqZqk','Limit\x20must\x20be\x20a\x20positive\x20number','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20','MISSING_ARGUMENT','show','14191803LpNGUx','3104024IEqOTH','SELECT\x20*\x20FROM\x20','INVALID_ARGUMENT','87196dNSGMT','Usage:\x20tdx\x20show\x20<database.table>','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22user_*\x22)\x20or\x20omit\x20to\x20list\x20all\x20tables.','validateTable','\x0aORDER\x20BY\x20table_name\x0aLIMIT\x20','Database\x20name\x20is\x20required','validateDatabase','\x0a\x20\x20\x20\x20\x20\x20ORDER\x20BY\x20ordinal_position\x0a\x20\x20\x20\x20','executeQuery','slice','Database\x20name\x20cannot\x20be\x20empty\x20or\x20whitespace-only','Usage:\x20tdx\x20describe\x20<database.table>','client','Table\x20name\x20is\x20required','Provide\x20a\x20valid\x20glob\x20pattern\x20(e.g.,\x20\x22prod_*\x22)\x20or\x20omit\x20to\x20search\x20all\x20databases.','length','\x0a\x20\x20\x20\x20\x20\x20','Provide\x20a\x20valid\x20database\x20name\x20or\x20omit\x20to\x20list\x20tables\x20from\x20all\x20databases.','trim','6663480KXXTua','\x0a\x20\x20\x20\x20\x20\x20SELECT\x201\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.schemata\x0a\x20\x20\x20\x20\x20\x20WHERE\x20catalog_name\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20schema_name\x20=\x20'];a51_0x545c=function(){return _0x2b0b7c;};return a51_0x545c();}const a51_0x467df8=a51_0x34c6;(function(_0x1650fc,_0x1fd8ff){const _0x387c7a=a51_0x34c6,_0x3c7c81=_0x1650fc();while(!![]){try{const _0x5ec4b9=-parseInt(_0x387c7a(0xba))/0x1+-parseInt(_0x387c7a(0xd4))/0x2+parseInt(_0x387c7a(0xb1))/0x3+-parseInt(_0x387c7a(0xb7))/0x4+parseInt(_0x387c7a(0xcd))/0x5*(parseInt(_0x387c7a(0xa6))/0x6)+parseInt(_0x387c7a(0xd0))/0x7*(-parseInt(_0x387c7a(0xaa))/0x8)+parseInt(_0x387c7a(0xb6))/0x9;if(_0x5ec4b9===_0x1fd8ff)break;else _0x3c7c81['push'](_0x3c7c81['shift']());}catch(_0x365c68){_0x3c7c81['push'](_0x3c7c81['shift']());}}}(a51_0x545c,0xafcf7));function a51_0x34c6(_0x1726d7,_0x4fdfec){const _0x545c2c=a51_0x545c();return a51_0x34c6=function(_0x34c62f,_0x599100){_0x34c62f=_0x34c62f-0xa6;let _0x2a4349=_0x545c2c[_0x34c62f];return _0x2a4349;},a51_0x34c6(_0x1726d7,_0x4fdfec);}import{escapeStringLiteral,buildLikePattern}from'../utils/string-utils.js';import{SDKError,ErrorCode}from'./errors.js';import{DEFAULT_LISTING_LIMIT}from'../utils/constants.js';export class TableAPI{[a51_0x467df8(0xc6)];constructor(_0x206caf){const _0x280366=a51_0x467df8;this[_0x280366(0xc6)]=_0x206caf;}async[a51_0x467df8(0xab)](_0x5c75cb,_0x2f40dc,_0x203cc4,_0x15fc72=DEFAULT_LISTING_LIMIT){const _0x29ca46=a51_0x467df8;if(_0x5c75cb!==undefined&&_0x5c75cb['trim']()[_0x29ca46(0xc9)]===0x0)throw new SDKError(ErrorCode[_0x29ca46(0xb9)],_0x29ca46(0xc4),undefined,{'helpText':_0x29ca46(0xcb)});if(_0x2f40dc!==undefined&&_0x2f40dc[_0x29ca46(0xcc)]()[_0x29ca46(0xc9)]===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],_0x29ca46(0xd1),undefined,{'helpText':_0x29ca46(0xbc)});if(_0x203cc4!==undefined&&_0x203cc4['trim']()['length']===0x0)throw new SDKError(ErrorCode['INVALID_ARGUMENT'],'Database\x20pattern\x20cannot\x20be\x20empty\x20or\x20whitespace-only',undefined,{'helpText':_0x29ca46(0xc8)});if(_0x15fc72<=0x0)throw new SDKError(ErrorCode[_0x29ca46(0xb9)],_0x29ca46(0xb2),undefined,{'helpText':_0x29ca46(0xd3)});let _0x2e01ca;_0x5c75cb?(_0x2e01ca='\x0a\x20\x20\x20\x20\x20\x20\x20\x20SELECT\x20table_name\x0a\x20\x20\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.tables\x0a\x20\x20\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20'+escapeStringLiteral(_0x5c75cb)+_0x29ca46(0xca),_0x2f40dc&&(_0x2e01ca+=_0x29ca46(0xcf)+buildLikePattern(_0x2f40dc)+_0x29ca46(0xad)),_0x2e01ca+=_0x29ca46(0xbe)+_0x15fc72):(_0x2e01ca=_0x29ca46(0xd2),_0x203cc4&&(_0x2e01ca+='\x0a\x20\x20AND\x20table_schema\x20LIKE\x20'+buildLikePattern(_0x203cc4)+_0x29ca46(0xad)),_0x2f40dc&&(_0x2e01ca+=_0x29ca46(0xcf)+buildLikePattern(_0x2f40dc)+'\x20ESCAPE\x20\x27\x5c\x27'),_0x2e01ca+=_0x29ca46(0xa9)+_0x15fc72);const _0xb02a47=await this[_0x29ca46(0xc6)]['executeQuery'](_0x2e01ca[_0x29ca46(0xcc)]());return _0xb02a47['data'];}async[a51_0x467df8(0xc0)](_0x241417){const _0x46aafe=a51_0x467df8,_0x1c97f9=(_0x46aafe(0xce)+escapeStringLiteral(_0x241417)+_0x46aafe(0xb0))[_0x46aafe(0xcc)](),_0x536a06=await this[_0x46aafe(0xc6)][_0x46aafe(0xc2)](_0x1c97f9);return _0x536a06[_0x46aafe(0xac)][_0x46aafe(0xc9)]>0x0;}async[a51_0x467df8(0xbd)](_0x15e545,_0x45f055){const _0xb88145=a51_0x467df8,_0x200719=(_0xb88145(0xb3)+escapeStringLiteral(_0x15e545)+_0xb88145(0xa7)+escapeStringLiteral(_0x45f055)+_0xb88145(0xb0))[_0xb88145(0xcc)](),_0x8917bc=await this[_0xb88145(0xc6)][_0xb88145(0xc2)](_0x200719);return _0x8917bc[_0xb88145(0xac)][_0xb88145(0xc9)]>0x0;}async[a51_0x467df8(0xa8)](_0x521192,_0x4e241e){const _0x24c21d=a51_0x467df8;if(!_0x521192||_0x521192['trim']()[_0x24c21d(0xc9)]===0x0)throw new SDKError(ErrorCode[_0x24c21d(0xb4)],_0x24c21d(0xbf),undefined,{'helpText':'Usage:\x20tdx\x20describe\x20<database.table>'});if(!_0x4e241e||_0x4e241e['trim']()[_0x24c21d(0xc9)]===0x0)throw new SDKError(ErrorCode[_0x24c21d(0xb4)],'Table\x20name\x20is\x20required',undefined,{'helpText':_0x24c21d(0xc5)});const _0x156336=('\x0a\x20\x20\x20\x20\x20\x20SELECT\x0a\x20\x20\x20\x20\x20\x20\x20\x20column_name,\x0a\x20\x20\x20\x20\x20\x20\x20\x20data_type,\x0a\x20\x20\x20\x20\x20\x20\x20\x20is_nullable\x0a\x20\x20\x20\x20\x20\x20FROM\x20td.information_schema.columns\x0a\x20\x20\x20\x20\x20\x20WHERE\x20table_catalog\x20=\x20\x27td\x27\x0a\x20\x20\x20\x20\x20\x20\x20\x20AND\x20table_schema\x20=\x20'+escapeStringLiteral(_0x521192)+_0x24c21d(0xa7)+escapeStringLiteral(_0x4e241e)+_0x24c21d(0xc1))[_0x24c21d(0xcc)](),_0x43c5e7=await this[_0x24c21d(0xc6)][_0x24c21d(0xc2)](_0x156336);return _0x43c5e7[_0x24c21d(0xac)];}async[a51_0x467df8(0xb5)](_0x48a61b,_0x529f7e,_0x4dc7e8=0x28,_0x388524){const _0x440220=a51_0x467df8;try{if(!_0x48a61b||_0x48a61b[_0x440220(0xcc)]()[_0x440220(0xc9)]===0x0)throw new SDKError(ErrorCode[_0x440220(0xb4)],'Database\x20name\x20is\x20required',undefined,{'helpText':'Usage:\x20tdx\x20show\x20<database.table>'});if(!_0x529f7e||_0x529f7e[_0x440220(0xcc)]()[_0x440220(0xc9)]===0x0)throw new SDKError(ErrorCode[_0x440220(0xb4)],_0x440220(0xc7),undefined,{'helpText':_0x440220(0xbb)});if(!Number[_0x440220(0xae)](_0x4dc7e8)||_0x4dc7e8<=0x0)throw new SDKError(ErrorCode[_0x440220(0xb9)],_0x440220(0xaf),undefined,{'helpText':'Use\x20--limit\x20<number>\x20to\x20specify\x20row\x20limit\x20(must\x20be\x20positive).'});const _0x497a17=escapeStringLiteral(_0x48a61b)['slice'](0x1,-0x1)+'.'+escapeStringLiteral(_0x529f7e)[_0x440220(0xc3)](0x1,-0x1),_0xcd135c=_0x440220(0xb8)+_0x497a17+'\x20LIMIT\x20'+_0x4dc7e8,_0x21defe=await this[_0x440220(0xc6)][_0x440220(0xc2)](_0xcd135c,{'catalog':_0x388524,'schema':_0x48a61b});return _0x21defe;}catch(_0x29b5df){if(_0x29b5df instanceof SDKError)throw _0x29b5df;throw _0x29b5df;}}}