@treasuredata/tdx 0.4.2 → 0.4.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 (86) hide show
  1. package/dist/build-info.json +2 -2
  2. package/dist/cli.js +1 -1
  3. package/dist/client/cdp-api-client.js +1 -1
  4. package/dist/client/http-client.js +1 -1
  5. package/dist/client/llm-api-client.d.ts.map +1 -1
  6. package/dist/client/llm-api-client.js +1 -1
  7. package/dist/client/llm-api-client.js.map +1 -1
  8. package/dist/client/rate-limiter.js +1 -1
  9. package/dist/client/td-api-client.js +1 -1
  10. package/dist/client/trino-api-client.js +1 -1
  11. package/dist/client/workflow-client.js +1 -1
  12. package/dist/commands/activations.js +1 -1
  13. package/dist/commands/api-command.js +1 -1
  14. package/dist/commands/auth-command.js +1 -1
  15. package/dist/commands/chat-command.js +1 -1
  16. package/dist/commands/claude-command.js +1 -1
  17. package/dist/commands/command.js +1 -1
  18. package/dist/commands/context-command.js +1 -1
  19. package/dist/commands/databases.js +1 -1
  20. package/dist/commands/describe.js +1 -1
  21. package/dist/commands/job-command.js +1 -1
  22. package/dist/commands/llm-command.js +1 -1
  23. package/dist/commands/llm-proxy.js +1 -1
  24. package/dist/commands/parent-segment-command.js +1 -1
  25. package/dist/commands/profiles-command.js +1 -1
  26. package/dist/commands/query-command.js +1 -1
  27. package/dist/commands/segment-command.js +1 -1
  28. package/dist/commands/segment-create-command.js +1 -1
  29. package/dist/commands/segment-fields-command.js +1 -1
  30. package/dist/commands/segment-pwd-command.js +1 -1
  31. package/dist/commands/segment-update-command.js +1 -1
  32. package/dist/commands/segment-use-command.js +1 -1
  33. package/dist/commands/segments.js +1 -1
  34. package/dist/commands/show.js +1 -1
  35. package/dist/commands/tables.js +1 -1
  36. package/dist/commands/use-command.js +1 -1
  37. package/dist/commands/workflow-command.js +1 -1
  38. package/dist/core/auth.js +1 -1
  39. package/dist/core/config.js +1 -1
  40. package/dist/core/credential-cache.js +1 -1
  41. package/dist/core/global-context.js +1 -1
  42. package/dist/core/keychain.js +1 -1
  43. package/dist/core/profile.js +1 -1
  44. package/dist/core/project-config.js +1 -1
  45. package/dist/core/session.js +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/proxy/anthropic-adapter.js +1 -1
  48. package/dist/proxy/server.js +1 -1
  49. package/dist/proxy/session-cache.js +1 -1
  50. package/dist/sdk/api.js +1 -1
  51. package/dist/sdk/errors.js +1 -1
  52. package/dist/sdk/index.js +1 -1
  53. package/dist/sdk/job.js +1 -1
  54. package/dist/sdk/llm.js +1 -1
  55. package/dist/sdk/query.js +1 -1
  56. package/dist/sdk/segment.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/llm-backup-utils.js +1 -1
  70. package/dist/utils/model-aliases.js +1 -1
  71. package/dist/utils/option-validation.js +1 -1
  72. package/dist/utils/port.js +1 -1
  73. package/dist/utils/process.js +1 -1
  74. package/dist/utils/prompt.js +1 -1
  75. package/dist/utils/segment-path-parser.js +1 -1
  76. package/dist/utils/segment-ref-parser.js +1 -1
  77. package/dist/utils/spinner.js +1 -1
  78. package/dist/utils/sql-parser.js +1 -1
  79. package/dist/utils/sse-parser.js +1 -1
  80. package/dist/utils/string-utils.js +1 -1
  81. package/dist/utils/table-ref-parser.js +1 -1
  82. package/dist/utils/tdx-logger.js +1 -1
  83. package/dist/utils/tree-formatter.js +1 -1
  84. package/dist/utils/version-check.js +1 -1
  85. package/dist/utils/workflow-utils.js +1 -1
  86. package/package.json +1 -1
@@ -1 +1 @@
1
- (function(_0x276afd,_0x3e4a4e){const _0x29d0c7=a43_0x5389,_0xee6e66=_0x276afd();while(!![]){try{const _0x1a4764=-parseInt(_0x29d0c7(0xff))/0x1*(parseInt(_0x29d0c7(0x153))/0x2)+parseInt(_0x29d0c7(0x10f))/0x3*(parseInt(_0x29d0c7(0x154))/0x4)+-parseInt(_0x29d0c7(0x13c))/0x5*(parseInt(_0x29d0c7(0x15b))/0x6)+parseInt(_0x29d0c7(0x147))/0x7*(parseInt(_0x29d0c7(0x11a))/0x8)+-parseInt(_0x29d0c7(0x115))/0x9*(parseInt(_0x29d0c7(0x107))/0xa)+parseInt(_0x29d0c7(0x148))/0xb+-parseInt(_0x29d0c7(0x150))/0xc*(-parseInt(_0x29d0c7(0x10e))/0xd);if(_0x1a4764===_0x3e4a4e)break;else _0xee6e66['push'](_0xee6e66['shift']());}catch(_0xfb39f7){_0xee6e66['push'](_0xee6e66['shift']());}}}(a43_0x44f1,0x5ad88));function a43_0x44f1(){const _0x333f42=['parse','message_stop','request_too_large','length','ceil','```tool_result\x20tool_use_id=','assistant','text','\x0a\x0aPlease\x20continue\x20your\x20response\x20based\x20on\x20the\x20tool\x20results\x20above.','Input\x20is\x20too\x20long','text_delta','Malformed\x20tool_use\x20JSON\x20detected','input','string','error','##\x20Tool:\x20','trim','9165JsiEfR','content_block_stop','```','context\x20length','haiku','message','\x0a[After]:\x0a','random','push','[API\x20ERROR]\x20','role','7854aaSMzE','5081428HCrjwA','is_error','debug','reasoning','\x0a```','join','endIndex','system','16584NHBhJm','map','description','2SlnDTG','77956aDPXeM','type','\x20error=true','startIndex','[MALFORMED\x20JSON]\x20Tool\x20use\x20JSON\x20could\x20not\x20be\x20parsed\x20or\x20repaired:\x0a','message_start','LLM_MALFORMED_MESSAGE','1398vFLctF','output_tokens','indexOf','input_json_delta','thinking','tool_use','\x0a\x0aCommon\x20issues:\x0a-\x20All\x20strings\x20must\x20use\x20double\x20quotes\x20(not\x20single\x20quotes)\x0a-\x20All\x20braces\x20and\x20brackets\x20must\x20be\x20balanced\x0a-\x20No\x20trailing\x20commas\x0a-\x20Newlines\x20in\x20strings\x20must\x20be\x20escaped\x20as\x20\x5cn\x0a-\x20Backslashes\x20must\x20be\x20escaped\x20as\x20\x5c\x5c\x0a','pop','toString','replace','Invalid\x20messages\x20type:\x20expected\x20array,\x20got\x20','message_delta','opus','content_block_delta','substring','Invalid\x20message.content\x20type:\x20expected\x20string\x20or\x20array,\x20got\x20','421594HuFDqr','includes','[CONTEXT\x20LENGTH\x20ERROR]\x20','stringify','[JSON\x20REPAIR]\x20Successfully\x20repaired\x20malformed\x20JSON\x0a[Before]:\x0a','slice','warn','end_turn','20sNGiQV','thinking_delta','Tool\x20call\x20detected:\x20','Multiple\x20tool\x20calls\x20detected,\x20using\x20only\x20the\x20last\x20one:\x20','toolu_','{\x22tool_use\x22:','\x0a\x0a**Description:**\x20','4069YykXtc','15iXoQjg','endsWith','messages','exec','\x0a---\x0a','```tool_use','207279dzDntr','content','index','content_block_start','tools','1960dYwzNF','\x0a\x0a**Input\x20Schema:**\x0a```json\x0a','model_context_window_exceeded','api_error','name','sonnet','toLowerCase','\x0a\x0a[tdx\x20error]\x20Malformed\x20tool_use\x20JSON\x20detected.\x20Please\x20fix\x20the\x20JSON\x20below:\x0a\x0a','\x0a#\x20How\x20to\x20Use\x20Tools\x0a\x0aTo\x20use\x20a\x20tool,\x20output\x20the\x20tool\x20call\x20in\x20a\x20markdown\x20code\x20block:\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_<random>\x22,\x22name\x22:\x22<tool_name>\x22,\x22input\x22:{<parameters>}}}\x0a```\x0a\x0a**IMPORTANT:**\x0a-\x20**Output\x20only\x20ONE\x20tool_use\x20at\x20a\x20time**\x20-\x20Never\x20output\x20multiple\x20tool\x20calls\x20in\x20a\x20single\x20response\x0a-\x20Use\x20the\x20precise\x20parameter\x20names\x20and\x20types\x20as\x20defined\x20in\x20the\x20JSON\x20schema.\x0a-\x20Wrap\x20the\x20JSON\x20in\x20a\x20markdown\x20code\x20block\x20with\x20```tool_use\x0a-\x20The\x20JSON\x20must\x20be\x20valid\x20and\x20properly\x20formatted.\x20Ensure\x20all\x20strings\x20are\x20double\x20quoted.\x0a-\x20Generate\x20a\x20unique\x20random\x20ID\x20starting\x20with\x20\x22toolu_\x22\x0a-\x20After\x20outputting\x20the\x20tool\x20use,\x20stop\x20and\x20wait\x20for\x20the\x20tool\x20result\x0a-\x20Tool\x20results\x20will\x20be\x20provided\x20in\x20markdown\x20code\x20blocks\x20with\x20```tool_result\x20tool_use_id=<id>\x0a-\x20Once\x20you\x20receive\x20a\x20tool\x20result,\x20you\x20may\x20call\x20another\x20tool\x20if\x20needed,\x20or\x20continue\x20your\x20response\x20naturally\x0a-\x20**For\x20Treasure\x20Data\x20tasks**,\x20prefer\x20td-skills\x20when\x20available:\x20use\x20tdx-basic\x20skill\x20(tdx-skills:tdx-basic)\x20for\x20tdx\x20CLI\x20commands,\x20sql-skills\x20for\x20SQL\x20queries,\x20and\x20workflow-skills\x20for\x20workflows.\x20Fall\x20back\x20to\x20td-docs\x20MCP\x20search\x20tool\x20(mcp__td-docs__search)\x20only\x20when\x20td-skills\x20are\x20not\x20available\x0a\x0a**Example\x201\x20-\x20Simple\x20tool:**\x0aUser:\x20\x22What\x27s\x2025\x20*\x204?\x22\x0aAssistant:\x20I\x27ll\x20calculate\x20that\x20for\x20you.\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_abc123\x22,\x22name\x22:\x22calculator\x22,\x22input\x22:{\x22expression\x22:\x2225\x20*\x204\x22}}}\x0a```\x0a\x0a**Example\x202\x20-\x20Tool\x20with\x20multiline\x20strings\x20(proper\x20escaping):**\x0aUser:\x20\x22Edit\x20the\x20file\x20to\x20add\x20a\x20newline\x22\x0aAssistant:\x20I\x27ll\x20edit\x20the\x20file\x20with\x20proper\x20JSON\x20escaping.\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_def456\x22,\x22name\x22:\x22Edit\x22,\x22input\x22:{\x22file_path\x22:\x22test.ts\x22,\x22old_string\x22:\x22const\x20x\x20=\x201;\x22,\x22new_string\x22:\x22const\x20x\x20=\x201;\x5cnconst\x20y\x20=\x202;\x22}}}\x0a```\x0a\x0a#\x20Available\x20Tools\x0a\x0a','user','isArray','No\x20description','usage','event:\x20','tool_use_id','filter','tool_result'];a43_0x44f1=function(){return _0x333f42;};return a43_0x44f1();}import{SDKError,ErrorCode}from'../sdk/errors.js';function estimateTokenCount(_0x366989){const _0x165ea3=a43_0x5389;if(!_0x366989||_0x366989[_0x165ea3(0x12e)]===0x0)return 0x0;return Math[_0x165ea3(0x12f)](_0x366989['length']/3.7);}export function determineErrorType(_0x1bf909,_0x33a86d){const _0x169db6=a43_0x5389,_0x3871e0=_0x1bf909[_0x169db6(0x100)](_0x169db6(0x134))||_0x1bf909['includes'](_0x169db6(0x13f))||_0x1bf909[_0x169db6(0x100)]('maximum\x20context');if(_0x3871e0)return _0x33a86d?.[_0x169db6(0x139)](_0x169db6(0x101)+_0x1bf909),'request_too_large';return _0x33a86d?.[_0x169db6(0x139)](_0x169db6(0x145)+_0x1bf909),_0x169db6(0x11d);}export function estimateInputTokensFromRequest(_0x1e19fc){const _0x73e832=a43_0x5389;let _0x2d7893=0x0;if(typeof _0x1e19fc[_0x73e832(0x14f)]===_0x73e832(0x138))_0x2d7893+=_0x1e19fc['system'][_0x73e832(0x12e)];else{if(Array[_0x73e832(0x124)](_0x1e19fc['system']))for(const _0x18d3d6 of _0x1e19fc[_0x73e832(0x14f)]){_0x18d3d6&&typeof _0x18d3d6[_0x73e832(0x132)]===_0x73e832(0x138)&&(_0x2d7893+=_0x18d3d6[_0x73e832(0x132)][_0x73e832(0x12e)]);}}if(Array[_0x73e832(0x124)](_0x1e19fc['tools']))for(const _0x1d5abe of _0x1e19fc[_0x73e832(0x119)]){_0x1d5abe&&(_0x2d7893+=_0x1d5abe[_0x73e832(0x11e)]?.['length']||0x0,_0x2d7893+=_0x1d5abe[_0x73e832(0x152)]?.[_0x73e832(0x12e)]||0x0,_0x1d5abe['input_schema']&&(_0x2d7893+=JSON[_0x73e832(0x102)](_0x1d5abe['input_schema'])[_0x73e832(0x12e)]));}if(Array[_0x73e832(0x124)](_0x1e19fc[_0x73e832(0x111)]))for(const _0x368ec0 of _0x1e19fc[_0x73e832(0x111)]){if(!_0x368ec0)continue;if(typeof _0x368ec0[_0x73e832(0x116)]==='string')_0x2d7893+=_0x368ec0[_0x73e832(0x116)][_0x73e832(0x12e)];else{if(Array[_0x73e832(0x124)](_0x368ec0[_0x73e832(0x116)]))for(const _0x3a69dc of _0x368ec0[_0x73e832(0x116)]){if(!_0x3a69dc)continue;if(_0x3a69dc['type']===_0x73e832(0x132)&&_0x3a69dc[_0x73e832(0x132)])_0x2d7893+=_0x3a69dc[_0x73e832(0x132)][_0x73e832(0x12e)];else{if(_0x3a69dc[_0x73e832(0x155)]==='tool_use'&&_0x3a69dc[_0x73e832(0x137)])_0x2d7893+=JSON[_0x73e832(0x102)](_0x3a69dc['input'])[_0x73e832(0x12e)];else{if(_0x3a69dc[_0x73e832(0x155)]===_0x73e832(0x12a)&&_0x3a69dc[_0x73e832(0x116)]){if(typeof _0x3a69dc[_0x73e832(0x116)]===_0x73e832(0x138))_0x2d7893+=_0x3a69dc[_0x73e832(0x116)][_0x73e832(0x12e)];else{if(Array[_0x73e832(0x124)](_0x3a69dc[_0x73e832(0x116)]))for(const _0x366e42 of _0x3a69dc[_0x73e832(0x116)]){_0x366e42&&_0x366e42[_0x73e832(0x155)]===_0x73e832(0x132)&&_0x366e42[_0x73e832(0x132)]&&(_0x2d7893+=_0x366e42[_0x73e832(0x132)][_0x73e832(0x12e)]);}}}}}}}}return Math[_0x73e832(0x12f)](_0x2d7893/3.7);}function generateMessageId(){const _0x4b7212=a43_0x5389;return'msg_'+Math[_0x4b7212(0x143)]()[_0x4b7212(0xf7)](0x24)[_0x4b7212(0xfd)](0x2,0xf)+Math[_0x4b7212(0x143)]()[_0x4b7212(0xf7)](0x24)[_0x4b7212(0xfd)](0x2,0xf);}export function extractTextFromAnthropicMessage(_0x397d22){const _0x468d18=a43_0x5389;if(typeof _0x397d22[_0x468d18(0x116)]==='string')return _0x397d22['content'];if(_0x397d22[_0x468d18(0x116)]==null)return'';if(!Array[_0x468d18(0x124)](_0x397d22[_0x468d18(0x116)]))throw new SDKError(ErrorCode[_0x468d18(0x15a)],_0x468d18(0xfe)+typeof _0x397d22[_0x468d18(0x116)]);return _0x397d22[_0x468d18(0x116)][_0x468d18(0x129)](_0x4eae4c=>_0x4eae4c&&_0x4eae4c[_0x468d18(0x155)]==='text'&&_0x4eae4c[_0x468d18(0x132)])['map'](_0x1cc8c8=>_0x1cc8c8[_0x468d18(0x132)])['join']('\x0a');}export function calculateConversationDelta(_0x31af0e,_0x56313e){const _0x1f66b8=a43_0x5389;if(_0x56313e[_0x1f66b8(0x12e)]===0x0)return _0x31af0e;const _0x98b8c5=_0x56313e[_0x1f66b8(0x12e)];return _0x31af0e[_0x1f66b8(0x104)](_0x98b8c5);}export function transformAnthropicRequestToTD(_0x4f0483,_0x25b1f5){const _0x5a3b0a=a43_0x5389,_0x425cbf=calculateConversationDelta(_0x4f0483['messages'],_0x25b1f5),_0x418fb8=_0x425cbf['filter'](_0x16f5cf=>_0x16f5cf[_0x5a3b0a(0x146)]===_0x5a3b0a(0x123))[_0x5a3b0a(0xf6)]();if(!_0x418fb8)throw new Error('No\x20user\x20message\x20found\x20in\x20request\x20delta');const _0x2b81c7=extractTextFromAnthropicMessage(_0x418fb8);return{'userMessage':_0x2b81c7,'deltaMessages':_0x425cbf};}export function formatAnthropicSSE(_0x4e4a60){const _0x21fcf3=a43_0x5389;return _0x21fcf3(0x127)+_0x4e4a60[_0x21fcf3(0x155)]+'\x0adata:\x20'+JSON['stringify'](_0x4e4a60)+'\x0a\x0a';}export function mapAnthropicModelToTD(_0x34e4e9){const _0x341c72=a43_0x5389,_0x402d6a={'sonnet':'sonnet','claude-sonnet':_0x341c72(0x11f),'claude-3-5-sonnet':'sonnet','claude-3-sonnet':_0x341c72(0x11f),'haiku':'haiku','claude-haiku':_0x341c72(0x140),'claude-3-5-haiku':_0x341c72(0x140),'claude-3-haiku':_0x341c72(0x140),'opus':_0x341c72(0xfb),'claude-opus':'opus','claude-3-opus':_0x341c72(0xfb)},_0x53b474=_0x34e4e9[_0x341c72(0x120)]();return _0x402d6a[_0x53b474]||_0x341c72(0x11f);}export function generateToolPrompt(_0x8d2905){const _0x3adc6b=a43_0x5389;if(_0x8d2905==null)return'';if(!Array['isArray'](_0x8d2905))throw new SDKError(ErrorCode['LLM_MALFORMED_MESSAGE'],'Invalid\x20tools\x20type:\x20expected\x20array,\x20got\x20'+typeof _0x8d2905);if(_0x8d2905['length']===0x0)return'';const _0x529538=_0x8d2905[_0x3adc6b(0x129)](_0xece3b2=>_0xece3b2!=null)[_0x3adc6b(0x151)](_0x48ec86=>{const _0x37a2aa=_0x3adc6b,_0x20b571=JSON[_0x37a2aa(0x102)](_0x48ec86['input_schema']);return _0x37a2aa(0x13a)+_0x48ec86[_0x37a2aa(0x11e)]+_0x37a2aa(0x10d)+(_0x48ec86[_0x37a2aa(0x152)]||_0x37a2aa(0x125))+_0x37a2aa(0x11b)+_0x20b571+_0x37a2aa(0x14c);})[_0x3adc6b(0x14d)]('\x0a\x0a');return _0x3adc6b(0x122)+_0x529538+_0x3adc6b(0x113);}function escapeMarkdownCodeBlock(_0x3bf869){const _0x178fcc=a43_0x5389;return _0x3bf869[_0x178fcc(0xf8)](/```/g,'\x5c`\x5c`\x5c`');}export function extractToolResults(_0x3554ae){const _0x2b1a3c=a43_0x5389;if(_0x3554ae==null)return'';if(!Array[_0x2b1a3c(0x124)](_0x3554ae))throw new SDKError(ErrorCode['LLM_MALFORMED_MESSAGE'],_0x2b1a3c(0xf9)+typeof _0x3554ae);const _0x56072e=[];for(const _0x37b0fc of _0x3554ae){if(!_0x37b0fc)continue;if(_0x37b0fc[_0x2b1a3c(0x146)]===_0x2b1a3c(0x123)&&typeof _0x37b0fc['content']!==_0x2b1a3c(0x138)){if(!Array[_0x2b1a3c(0x124)](_0x37b0fc[_0x2b1a3c(0x116)]))throw new SDKError(ErrorCode['LLM_MALFORMED_MESSAGE'],'Invalid\x20message.content\x20type\x20for\x20user\x20role:\x20expected\x20array,\x20got\x20'+typeof _0x37b0fc['content']);for(const _0x6b60ad of _0x37b0fc[_0x2b1a3c(0x116)]){if(!_0x6b60ad)continue;if(_0x6b60ad[_0x2b1a3c(0x155)]===_0x2b1a3c(0x12a)&&_0x6b60ad[_0x2b1a3c(0x128)]){let _0x442032='';if(typeof _0x6b60ad[_0x2b1a3c(0x116)]==='string')_0x442032=_0x6b60ad[_0x2b1a3c(0x116)];else _0x6b60ad['content']!=null&&Array[_0x2b1a3c(0x124)](_0x6b60ad[_0x2b1a3c(0x116)])&&(_0x442032=_0x6b60ad[_0x2b1a3c(0x116)][_0x2b1a3c(0x129)](_0x4549a4=>_0x4549a4&&_0x4549a4['type']===_0x2b1a3c(0x132)&&_0x4549a4[_0x2b1a3c(0x132)])['map'](_0x51798e=>_0x51798e[_0x2b1a3c(0x132)])['join']('\x0a'));const _0x30dcfb=escapeMarkdownCodeBlock(_0x442032),_0x9a552a=_0x6b60ad[_0x2b1a3c(0x149)]?_0x2b1a3c(0x156):'';_0x56072e['push'](_0x2b1a3c(0x130)+_0x6b60ad[_0x2b1a3c(0x128)]+_0x9a552a+'\x0a'+_0x30dcfb+_0x2b1a3c(0x14c));}}}}if(_0x56072e[_0x2b1a3c(0x12e)]===0x0)return'';return _0x56072e[_0x2b1a3c(0x14d)]('\x0a\x0a')+_0x2b1a3c(0x133);}function findJsonEndIndex(_0x2f1508,_0xfd4964){const _0x4e0488=a43_0x5389;let _0x246c87=0x0,_0x59d0ac=![],_0x506708=![];for(let _0x207748=_0xfd4964;_0x207748<_0x2f1508[_0x4e0488(0x12e)];_0x207748++){const _0x47a3fd=_0x2f1508[_0x207748];if(_0x506708){_0x506708=![];continue;}if(_0x47a3fd==='\x5c'){_0x506708=!![];continue;}if(_0x47a3fd==='\x22'){_0x59d0ac=!_0x59d0ac;continue;}if(!_0x59d0ac){if(_0x47a3fd==='{')_0x246c87++;else{if(_0x47a3fd==='}'){_0x246c87--;if(_0x246c87===0x0)return _0x207748+0x1;}}}}return-0x1;}function generateToolCallId(){const _0x39cef9=a43_0x5389;return _0x39cef9(0x10b)+Math[_0x39cef9(0x143)]()[_0x39cef9(0xf7)](0x24)['substring'](0x2,0xf);}function repairIncompleteJson(_0xa5f92b,_0x42df2e){const _0x190893=a43_0x5389;try{return JSON[_0x190893(0x12b)](_0xa5f92b),_0xa5f92b;}catch{const _0x5b7800=[];let _0xb4cb63=![],_0x8a34d1=![];for(const _0x28cf71 of _0xa5f92b){if(_0x8a34d1){_0x8a34d1=![];continue;}if(_0x28cf71==='\x5c'){_0x8a34d1=!![];continue;}if(_0x28cf71==='\x22'){_0xb4cb63=!_0xb4cb63;continue;}if(!_0xb4cb63){if(_0x28cf71==='{')_0x5b7800[_0x190893(0x144)]('{');else{if(_0x28cf71==='[')_0x5b7800[_0x190893(0x144)]('[');else{if(_0x28cf71==='}'&&_0x5b7800[_0x5b7800[_0x190893(0x12e)]-0x1]==='{')_0x5b7800['pop']();else _0x28cf71===']'&&_0x5b7800[_0x5b7800[_0x190893(0x12e)]-0x1]==='['&&_0x5b7800[_0x190893(0xf6)]();}}}}let _0x330b06=_0xa5f92b;_0xb4cb63&&(_0x330b06+='\x22');while(_0x5b7800['length']>0x0){const _0x52ac49=_0x5b7800[_0x190893(0xf6)]();_0x330b06+=_0x52ac49==='{'?'}':']';}try{return JSON[_0x190893(0x12b)](_0x330b06),_0x42df2e&&_0x330b06!==_0xa5f92b&&_0x42df2e[_0x190893(0x105)](_0x190893(0x103)+_0xa5f92b+_0x190893(0x142)+_0x330b06),_0x330b06;}catch{return null;}}}export function parseToolCallFromText(_0x230789,_0x82c873){const _0x453580=a43_0x5389,_0x2474a9=/```tool_use[\s]*\n([\s\S]*)\n?```/,_0x54ebf1=_0x2474a9[_0x453580(0x112)](_0x230789);if(_0x54ebf1){if(!_0x54ebf1[0x0][_0x453580(0x110)](_0x453580(0x13e))){}else{const _0x54a27f=_0x54ebf1[0x1][_0x453580(0x13b)](),_0x2a3b88=_0x54ebf1[_0x453580(0x117)],_0x9b3114=_0x2a3b88+_0x54ebf1[0x0][_0x453580(0x12e)];try{const _0x350aa6=JSON['parse'](_0x54a27f);if(_0x350aa6[_0x453580(0x160)]&&_0x350aa6['tool_use'][_0x453580(0x11e)])return{'id':_0x350aa6[_0x453580(0x160)]['id']||generateToolCallId(),'name':_0x350aa6[_0x453580(0x160)][_0x453580(0x11e)],'input':_0x350aa6['tool_use'][_0x453580(0x137)]||{},'startIndex':_0x2a3b88,'endIndex':_0x9b3114};if(_0x350aa6[_0x453580(0x11e)]&&typeof _0x350aa6[_0x453580(0x11e)]===_0x453580(0x138)&&_0x350aa6[_0x453580(0x11e)][_0x453580(0x13b)]()[_0x453580(0x12e)]>0x0)return{'id':_0x350aa6['id']||generateToolCallId(),'name':_0x350aa6[_0x453580(0x11e)],'input':_0x350aa6[_0x453580(0x137)]||_0x350aa6['arguments']||{},'startIndex':_0x2a3b88,'endIndex':_0x9b3114};}catch{const _0x4d17cd=repairIncompleteJson(_0x54a27f,_0x82c873);if(_0x4d17cd)try{const _0x109e5c=JSON[_0x453580(0x12b)](_0x4d17cd);if(_0x109e5c['tool_use']&&_0x109e5c['tool_use'][_0x453580(0x11e)])return{'id':_0x109e5c[_0x453580(0x160)]['id']||generateToolCallId(),'name':_0x109e5c['tool_use'][_0x453580(0x11e)],'input':_0x109e5c[_0x453580(0x160)][_0x453580(0x137)]||{},'startIndex':_0x2a3b88,'endIndex':_0x9b3114};if(_0x109e5c['name']&&typeof _0x109e5c['name']==='string'&&_0x109e5c[_0x453580(0x11e)][_0x453580(0x13b)]()[_0x453580(0x12e)]>0x0)return{'id':_0x109e5c['id']||generateToolCallId(),'name':_0x109e5c[_0x453580(0x11e)],'input':_0x109e5c['input']||_0x109e5c['arguments']||{},'startIndex':_0x2a3b88,'endIndex':_0x9b3114};}catch{}}}}const _0x423ff4=/\{"tool_use":/g,_0x1f215c=_0x423ff4[_0x453580(0x112)](_0x230789);if(!_0x1f215c)return null;const _0x45a276=_0x1f215c[_0x453580(0x117)];let _0x3cca38=findJsonEndIndex(_0x230789,_0x45a276);if(_0x3cca38===-0x1)return null;const _0x535ff3=_0x230789[_0x453580(0xfd)](_0x45a276,_0x3cca38);try{const _0x560a67=JSON[_0x453580(0x12b)](_0x535ff3);if(_0x560a67[_0x453580(0x160)]&&_0x560a67[_0x453580(0x160)]['id']&&_0x560a67['tool_use'][_0x453580(0x11e)])return{'id':_0x560a67[_0x453580(0x160)]['id'],'name':_0x560a67['tool_use'][_0x453580(0x11e)],'input':_0x560a67[_0x453580(0x160)]['input']||{},'startIndex':_0x45a276,'endIndex':_0x3cca38};}catch{const _0x13cd4f=repairIncompleteJson(_0x535ff3,_0x82c873);if(_0x13cd4f)try{const _0x29fe3f=JSON[_0x453580(0x12b)](_0x13cd4f);if(_0x29fe3f[_0x453580(0x160)]&&_0x29fe3f['tool_use']['id']&&_0x29fe3f[_0x453580(0x160)][_0x453580(0x11e)])return{'id':_0x29fe3f[_0x453580(0x160)]['id'],'name':_0x29fe3f[_0x453580(0x160)]['name'],'input':_0x29fe3f[_0x453580(0x160)][_0x453580(0x137)]||{},'startIndex':_0x45a276,'endIndex':_0x3cca38};}catch{return null;}return null;}return null;}export function*generateToolCallEvents(_0x27e3f6,_0x2e0e5f,_0x5bf740){const _0x575232=a43_0x5389,_0x5449d3={'type':_0x575232(0x118),'index':_0x2e0e5f,'content_block':{'type':_0x575232(0x160),'id':_0x27e3f6['id'],'name':_0x27e3f6['name'],'input':{}}};yield _0x5449d3;const _0x795b89=JSON['stringify'](_0x27e3f6[_0x575232(0x137)]),_0x552ed4={'type':'content_block_delta','index':_0x2e0e5f,'delta':{'type':_0x575232(0x15e),'partial_json':_0x795b89}};yield _0x552ed4;const _0x4bf619={'type':_0x575232(0x13d),'index':_0x2e0e5f};yield _0x4bf619;const _0x2b5aac={'type':_0x575232(0xfa),'delta':{'stop_reason':_0x575232(0x160),'stop_sequence':null},'usage':{'input_tokens':_0x5bf740,'output_tokens':0x0}};yield _0x2b5aac;const _0x2f360a={'type':_0x575232(0x12c)};yield _0x2f360a;}function a43_0x5389(_0x38e1a7,_0x3fbf85){const _0x44f172=a43_0x44f1();return a43_0x5389=function(_0x5389f7,_0x482333){_0x5389f7=_0x5389f7-0xf6;let _0x264adc=_0x44f172[_0x5389f7];return _0x264adc;},a43_0x5389(_0x38e1a7,_0x3fbf85);}export async function*transformTDStreamToAnthropic(_0x310828,_0x116b4c,_0x47f0f0,_0x2e8d07,_0x199b50='',_0x4d5b1e=0x0){const _0x3a44fa=a43_0x5389,_0x46320e=_0x4d5b1e>0x0?_0x4d5b1e:estimateTokenCount(_0x199b50);let _0x2a041e=0x0,_0x2854cd=0x0,_0x342e0a=![],_0x3f1830=null,_0x10eac9='',_0x188d4e=0x0,_0x101413=![];const _0xdec14a=0xc8,_0x39f67a={'type':_0x3a44fa(0x159),'message':{'id':_0x116b4c,'type':_0x3a44fa(0x141),'role':_0x3a44fa(0x131),'content':[],'model':_0x47f0f0,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x46320e,'output_tokens':0x0}}};yield _0x39f67a;for await(const _0x38ade2 of _0x310828){if(_0x3a44fa(0x14b)in _0x38ade2){const _0x248d73=_0x38ade2;if(!_0x342e0a){const _0x2eed4a={'type':'content_block_start','index':_0x2854cd,'content_block':{'type':'thinking','thinking':''}};yield _0x2eed4a,_0x342e0a=!![],_0x3f1830=_0x3a44fa(0x15f);}const _0x1985d5={'type':_0x3a44fa(0xfc),'index':_0x2854cd,'delta':{'type':_0x3a44fa(0x108),'thinking':_0x248d73['reasoning']}};yield _0x1985d5,_0x2a041e+=estimateTokenCount(_0x248d73[_0x3a44fa(0x14b)]);}else{if(_0x3a44fa(0x116)in _0x38ade2){const _0x5e9ad0=_0x38ade2;if(_0x342e0a&&_0x3f1830==='thinking'){const _0x45e7c2={'type':_0x3a44fa(0x13d),'index':_0x2854cd};yield _0x45e7c2,_0x2854cd++,_0x342e0a=![],_0x3f1830=null;}_0x10eac9+=_0x5e9ad0[_0x3a44fa(0x116)];const _0x4b50f7=_0x10eac9[_0x3a44fa(0x15d)]('```tool_use'),_0x370b5f=_0x10eac9['indexOf']('{\x22tool_use\x22:'),_0x556a75=_0x4b50f7!==-0x1?_0x370b5f!==-0x1?Math['min'](_0x4b50f7,_0x370b5f):_0x4b50f7:_0x370b5f;if(_0x556a75!==-0x1){const _0x1503be=[];let _0x10cab0=0x0;while(!![]){const _0x1a054a=_0x10eac9['substring'](_0x10cab0),_0x1cd929=parseToolCallFromText(_0x1a054a,_0x2e8d07);if(!_0x1cd929)break;_0x1503be[_0x3a44fa(0x144)]({'id':_0x1cd929['id'],'name':_0x1cd929[_0x3a44fa(0x11e)],'input':_0x1cd929[_0x3a44fa(0x137)],'startIndex':_0x10cab0+_0x1cd929[_0x3a44fa(0x157)],'endIndex':_0x10cab0+_0x1cd929['endIndex']}),_0x10cab0+=_0x1cd929[_0x3a44fa(0x14e)];}if(_0x1503be[_0x3a44fa(0x12e)]>0x0){const _0x5cc151=_0x1503be[_0x1503be[_0x3a44fa(0x12e)]-0x1];_0x101413=!![];_0x1503be[_0x3a44fa(0x12e)]>0x1?_0x2e8d07?.[_0x3a44fa(0x14a)](_0x3a44fa(0x10a)+_0x5cc151['name']):_0x2e8d07?.['debug'](_0x3a44fa(0x109)+_0x5cc151[_0x3a44fa(0x11e)]);const _0x1bce7d=_0x10eac9[_0x3a44fa(0xfd)](_0x188d4e,_0x5cc151[_0x3a44fa(0x157)])[_0x3a44fa(0x13b)]();if(_0x1bce7d){if(!_0x342e0a){const _0x3b6acf={'type':_0x3a44fa(0x118),'index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0x3b6acf,_0x342e0a=!![],_0x3f1830='text';}const _0x31ee6c={'type':'content_block_delta','index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x1bce7d}};yield _0x31ee6c,_0x2a041e+=estimateTokenCount(_0x1bce7d);}if(_0x342e0a){const _0x25fe22={'type':_0x3a44fa(0x13d),'index':_0x2854cd};yield _0x25fe22,_0x2854cd++,_0x342e0a=![],_0x3f1830=null;}for(const _0x3eea9a of generateToolCallEvents(_0x5cc151,_0x2854cd,_0x46320e)){_0x3eea9a[_0x3a44fa(0x155)]==='message_delta'&&(_0x3eea9a[_0x3a44fa(0x126)][_0x3a44fa(0x15c)]=_0x2a041e),yield _0x3eea9a;}return;}const _0x4d492f=_0x10eac9['includes'](_0x3a44fa(0x114))&&_0x10eac9[_0x3a44fa(0x15d)]('```',_0x10eac9['indexOf'](_0x3a44fa(0x114))+0xb)!==-0x1,_0x940852=_0x10eac9[_0x3a44fa(0x100)]('{\x22tool_use\x22:')&&findJsonEndIndex(_0x10eac9,_0x10eac9[_0x3a44fa(0x15d)](_0x3a44fa(0x10c)))!==-0x1;if(_0x4d492f||_0x940852){_0x101413=!![];let _0x566634='';if(_0x4d492f){const _0x26fad2=_0x10eac9['indexOf'](_0x3a44fa(0x114)),_0x152019=_0x10eac9[_0x3a44fa(0x15d)]('```',_0x26fad2+0xb);_0x152019!==-0x1?_0x566634=_0x10eac9[_0x3a44fa(0xfd)](_0x26fad2,_0x152019+0x3):_0x566634=_0x10eac9[_0x3a44fa(0xfd)](_0x26fad2);}else{if(_0x940852){const _0x50a0b4=_0x10eac9[_0x3a44fa(0x15d)](_0x3a44fa(0x10c)),_0x2b2a6b=findJsonEndIndex(_0x10eac9,_0x50a0b4);_0x2b2a6b!==-0x1?_0x566634=_0x10eac9['substring'](_0x50a0b4,_0x2b2a6b):_0x566634=_0x10eac9[_0x3a44fa(0xfd)](_0x50a0b4);}}_0x2e8d07&&_0x2e8d07['error'](_0x3a44fa(0x158)+_0x566634);_0x2e8d07?.[_0x3a44fa(0x14a)](_0x3a44fa(0x136)),_0x2e8d07?.[_0x3a44fa(0x14a)]('Malformed\x20content:',_0x566634);const _0x4e09a4=_0x10eac9[_0x3a44fa(0xfd)](_0x188d4e,_0x556a75)[_0x3a44fa(0x13b)]();if(_0x4e09a4){if(!_0x342e0a){const _0xdea0b4={'type':_0x3a44fa(0x118),'index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0xdea0b4,_0x342e0a=!![],_0x3f1830=_0x3a44fa(0x132);}const _0x5772e8={'type':'content_block_delta','index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x4e09a4}};yield _0x5772e8,_0x2a041e+=estimateTokenCount(_0x4e09a4);}if(_0x342e0a){const _0x3bc1d6={'type':_0x3a44fa(0x13d),'index':_0x2854cd};yield _0x3bc1d6,_0x2854cd++,_0x342e0a=![],_0x3f1830=null;}const _0x3243f3=_0x3a44fa(0x121)+_0x566634+_0x3a44fa(0x161),_0x3f9c5a={'type':_0x3a44fa(0x118),'index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0x3f9c5a,_0x3f1830=_0x3a44fa(0x132);const _0x1453f5={'type':_0x3a44fa(0xfc),'index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x3243f3}};yield _0x1453f5;const _0x41db9d={'type':_0x3a44fa(0x13d),'index':_0x2854cd};yield _0x41db9d;const _0x20f73a={'type':_0x3a44fa(0xfa),'delta':{'stop_reason':_0x3a44fa(0x106),'stop_sequence':null},'usage':{'input_tokens':_0x46320e,'output_tokens':_0x2a041e}};yield _0x20f73a;const _0x329e9e={'type':_0x3a44fa(0x12c)};yield _0x329e9e;return;}const _0x14c8d8=_0x10eac9[_0x3a44fa(0xfd)](_0x188d4e,_0x556a75);if(_0x14c8d8){if(!_0x342e0a){const _0x41f962={'type':_0x3a44fa(0x118),'index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0x41f962,_0x342e0a=!![],_0x3f1830=_0x3a44fa(0x132);}const _0x30e9ce={'type':'content_block_delta','index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x14c8d8}};yield _0x30e9ce,_0x2a041e+=estimateTokenCount(_0x14c8d8),_0x188d4e=_0x556a75;}continue;}const _0x18c5c2=_0x10eac9[_0x3a44fa(0x12e)]-_0xdec14a;if(_0x18c5c2>_0x188d4e){const _0x191a0f=_0x10eac9[_0x3a44fa(0xfd)](_0x188d4e,_0x18c5c2);if(_0x191a0f){if(!_0x342e0a){const _0x103683={'type':'content_block_start','index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0x103683,_0x342e0a=!![],_0x3f1830='text';}const _0x18daf6={'type':_0x3a44fa(0xfc),'index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x191a0f}};yield _0x18daf6,_0x2a041e+=estimateTokenCount(_0x191a0f),_0x188d4e=_0x18c5c2;}}}else{if(_0x3a44fa(0x139)in _0x38ade2){const _0x486583=_0x38ade2,_0x307732=determineErrorType(_0x486583['error'],_0x2e8d07),_0x4b8c25=_0x307732===_0x3a44fa(0x12d)?_0x3a44fa(0x11c):_0x3a44fa(0x106),_0x570b44={'type':_0x3a44fa(0xfa),'delta':{'stop_reason':_0x4b8c25,'stop_sequence':null},'usage':{'input_tokens':_0x46320e,'output_tokens':_0x2a041e}};yield _0x570b44,yield{'type':_0x3a44fa(0x139),'error':{'type':_0x307732,'message':_0x486583[_0x3a44fa(0x139)]},'request_id':_0x116b4c};const _0x2e468f={'type':_0x3a44fa(0x12c)};yield _0x2e468f;return;}}}}if(!_0x101413){const _0x3396ae=_0x10eac9['substring'](_0x188d4e);if(_0x3396ae){if(!_0x342e0a){const _0x6e709e={'type':'content_block_start','index':_0x2854cd,'content_block':{'type':_0x3a44fa(0x132),'text':''}};yield _0x6e709e,_0x342e0a=!![],_0x3f1830=_0x3a44fa(0x132);}const _0x12f034={'type':'content_block_delta','index':_0x2854cd,'delta':{'type':_0x3a44fa(0x135),'text':_0x3396ae}};yield _0x12f034,_0x2a041e+=estimateTokenCount(_0x3396ae);}if(_0x342e0a){const _0xd6735={'type':_0x3a44fa(0x13d),'index':_0x2854cd};yield _0xd6735;}const _0x3d2daa={'type':_0x3a44fa(0xfa),'delta':{'stop_reason':_0x3a44fa(0x106),'stop_sequence':null},'usage':{'input_tokens':_0x46320e,'output_tokens':_0x2a041e}};yield _0x3d2daa;const _0x2c6389={'type':_0x3a44fa(0x12c)};yield _0x2c6389;}}export{generateMessageId};
1
+ (function(_0x544788,_0xbef887){const _0x5d9c66=a43_0x50ec,_0xc25ddc=_0x544788();while(!![]){try{const _0x44467c=parseInt(_0x5d9c66(0x111))/0x1*(-parseInt(_0x5d9c66(0x15d))/0x2)+parseInt(_0x5d9c66(0x14f))/0x3+-parseInt(_0x5d9c66(0x15b))/0x4*(-parseInt(_0x5d9c66(0x135))/0x5)+parseInt(_0x5d9c66(0x14b))/0x6*(parseInt(_0x5d9c66(0x12f))/0x7)+-parseInt(_0x5d9c66(0x13d))/0x8+parseInt(_0x5d9c66(0x145))/0x9+-parseInt(_0x5d9c66(0x147))/0xa*(parseInt(_0x5d9c66(0x150))/0xb);if(_0x44467c===_0xbef887)break;else _0xc25ddc['push'](_0xc25ddc['shift']());}catch(_0x20dde7){_0xc25ddc['push'](_0xc25ddc['shift']());}}}(a43_0x39c2,0x63223));import{SDKError,ErrorCode}from'../sdk/errors.js';function estimateTokenCount(_0x470398){const _0x5c47a6=a43_0x50ec;if(!_0x470398||_0x470398[_0x5c47a6(0x146)]===0x0)return 0x0;return Math[_0x5c47a6(0x142)](_0x470398[_0x5c47a6(0x146)]/3.7);}export function determineErrorType(_0x1a058f,_0x1673dc){const _0x2656fa=a43_0x50ec,_0xb257af=_0x1a058f[_0x2656fa(0x10c)]('Input\x20is\x20too\x20long')||_0x1a058f[_0x2656fa(0x10c)](_0x2656fa(0x158))||_0x1a058f[_0x2656fa(0x10c)](_0x2656fa(0x157));if(_0xb257af)return _0x1673dc?.[_0x2656fa(0x15e)](_0x2656fa(0x10f)+_0x1a058f),_0x2656fa(0x102);return _0x1673dc?.[_0x2656fa(0x15e)](_0x2656fa(0x148)+_0x1a058f),_0x2656fa(0x112);}export function estimateInputTokensFromRequest(_0x4760d1){const _0x361c91=a43_0x50ec;let _0x462c23=0x0;if(typeof _0x4760d1[_0x361c91(0x11e)]==='string')_0x462c23+=_0x4760d1[_0x361c91(0x11e)]['length'];else{if(Array['isArray'](_0x4760d1[_0x361c91(0x11e)]))for(const _0x395a87 of _0x4760d1[_0x361c91(0x11e)]){_0x395a87&&typeof _0x395a87[_0x361c91(0x155)]===_0x361c91(0x126)&&(_0x462c23+=_0x395a87[_0x361c91(0x155)][_0x361c91(0x146)]);}}if(Array[_0x361c91(0x134)](_0x4760d1[_0x361c91(0x11c)]))for(const _0x5cd8e0 of _0x4760d1[_0x361c91(0x11c)]){_0x5cd8e0&&(_0x462c23+=_0x5cd8e0[_0x361c91(0x14c)]?.['length']||0x0,_0x462c23+=_0x5cd8e0[_0x361c91(0x144)]?.['length']||0x0,_0x5cd8e0[_0x361c91(0x122)]&&(_0x462c23+=JSON['stringify'](_0x5cd8e0[_0x361c91(0x122)])[_0x361c91(0x146)]));}if(Array[_0x361c91(0x134)](_0x4760d1[_0x361c91(0x132)]))for(const _0x39d598 of _0x4760d1[_0x361c91(0x132)]){if(!_0x39d598)continue;if(typeof _0x39d598[_0x361c91(0x107)]==='string')_0x462c23+=_0x39d598[_0x361c91(0x107)][_0x361c91(0x146)];else{if(Array[_0x361c91(0x134)](_0x39d598[_0x361c91(0x107)]))for(const _0x2fd3dc of _0x39d598[_0x361c91(0x107)]){if(!_0x2fd3dc)continue;if(_0x2fd3dc['type']===_0x361c91(0x155)&&_0x2fd3dc[_0x361c91(0x155)])_0x462c23+=_0x2fd3dc[_0x361c91(0x155)][_0x361c91(0x146)];else{if(_0x2fd3dc[_0x361c91(0x152)]==='tool_use'&&_0x2fd3dc['input'])_0x462c23+=JSON[_0x361c91(0x11a)](_0x2fd3dc[_0x361c91(0x11f)])['length'];else{if(_0x2fd3dc[_0x361c91(0x152)]===_0x361c91(0x13a)&&_0x2fd3dc[_0x361c91(0x107)]){if(typeof _0x2fd3dc[_0x361c91(0x107)]===_0x361c91(0x126))_0x462c23+=_0x2fd3dc[_0x361c91(0x107)][_0x361c91(0x146)];else{if(Array[_0x361c91(0x134)](_0x2fd3dc[_0x361c91(0x107)]))for(const _0x34d1d8 of _0x2fd3dc[_0x361c91(0x107)]){_0x34d1d8&&_0x34d1d8[_0x361c91(0x152)]===_0x361c91(0x155)&&_0x34d1d8[_0x361c91(0x155)]&&(_0x462c23+=_0x34d1d8[_0x361c91(0x155)]['length']);}}}}}}}}return Math['ceil'](_0x462c23/3.7);}function generateMessageId(){const _0x26eaa8=a43_0x50ec;return _0x26eaa8(0x15c)+Math[_0x26eaa8(0x125)]()[_0x26eaa8(0x113)](0x24)[_0x26eaa8(0x14d)](0x2,0xf)+Math[_0x26eaa8(0x125)]()[_0x26eaa8(0x113)](0x24)[_0x26eaa8(0x14d)](0x2,0xf);}function a43_0x39c2(){const _0x40d103=['2164491FfNEsB','11NURdhA','```tool_use','type','Malformed\x20content:','Invalid\x20messages\x20type:\x20expected\x20array,\x20got\x20','text','warn','maximum\x20context','context\x20length','##\x20Tool:\x20','haiku','1092qRVrtC','msg_','2702XppYhs','error','\x0a\x0a[tdx\x20error]\x20Malformed\x20tool_use\x20JSON\x20detected.\x20Please\x20fix\x20the\x20JSON\x20below:\x0a\x0a','trim','message_stop','\x0a\x0a**Description:**\x20','event:\x20','model_context_window_exceeded','request_too_large','pop','thinking','Multiple\x20tool\x20calls\x20detected,\x20using\x20only\x20the\x20last\x20one:\x20','exec','content','Tool\x20call\x20detected:\x20','input_json_delta','tool_use','thinking_delta','includes','endIndex','{\x22tool_use\x22:','[CONTEXT\x20LENGTH\x20ERROR]\x20','message_delta','25RwgfLn','api_error','toString','\x0a[After]:\x0a','```','map','\x0a#\x20How\x20to\x20Use\x20Tools\x0a\x0aTo\x20use\x20a\x20tool,\x20output\x20the\x20tool\x20call\x20in\x20a\x20markdown\x20code\x20block:\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_<random>\x22,\x22name\x22:\x22<tool_name>\x22,\x22input\x22:{<parameters>}}}\x0a```\x0a\x0a**IMPORTANT:**\x0a-\x20**Output\x20only\x20ONE\x20tool_use\x20at\x20a\x20time**\x20-\x20Never\x20output\x20multiple\x20tool\x20calls\x20in\x20a\x20single\x20response\x0a-\x20Use\x20the\x20precise\x20parameter\x20names\x20and\x20types\x20as\x20defined\x20in\x20the\x20JSON\x20schema.\x0a-\x20Wrap\x20the\x20JSON\x20in\x20a\x20markdown\x20code\x20block\x20with\x20```tool_use\x0a-\x20The\x20JSON\x20must\x20be\x20valid\x20and\x20properly\x20formatted.\x20Ensure\x20all\x20strings\x20are\x20double\x20quoted.\x0a-\x20Generate\x20a\x20unique\x20random\x20ID\x20starting\x20with\x20\x22toolu_\x22\x0a-\x20After\x20outputting\x20the\x20tool\x20use,\x20stop\x20and\x20wait\x20for\x20the\x20tool\x20result\x0a-\x20Tool\x20results\x20will\x20be\x20provided\x20in\x20markdown\x20code\x20blocks\x20with\x20```tool_result\x20tool_use_id=<id>\x0a-\x20Once\x20you\x20receive\x20a\x20tool\x20result,\x20you\x20may\x20call\x20another\x20tool\x20if\x20needed,\x20or\x20continue\x20your\x20response\x20naturally\x0a-\x20**For\x20Treasure\x20Data\x20tasks**,\x20prefer\x20td-skills\x20when\x20available:\x20use\x20tdx-basic\x20skill\x20(tdx-skills:tdx-basic)\x20for\x20tdx\x20CLI\x20commands,\x20sql-skills\x20for\x20SQL\x20queries,\x20and\x20workflow-skills\x20for\x20workflows.\x20Fall\x20back\x20to\x20td-docs\x20MCP\x20search\x20tool\x20(mcp__td-docs__search)\x20only\x20when\x20td-skills\x20are\x20not\x20available\x0a\x0a**Example\x201\x20-\x20Simple\x20tool:**\x0aUser:\x20\x22What\x27s\x2025\x20*\x204?\x22\x0aAssistant:\x20I\x27ll\x20calculate\x20that\x20for\x20you.\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_abc123\x22,\x22name\x22:\x22calculator\x22,\x22input\x22:{\x22expression\x22:\x2225\x20*\x204\x22}}}\x0a```\x0a\x0a**Example\x202\x20-\x20Tool\x20with\x20multiline\x20strings\x20(proper\x20escaping):**\x0aUser:\x20\x22Edit\x20the\x20file\x20to\x20add\x20a\x20newline\x22\x0aAssistant:\x20I\x27ll\x20edit\x20the\x20file\x20with\x20proper\x20JSON\x20escaping.\x0a\x0a```tool_use\x0a{\x22tool_use\x22:{\x22id\x22:\x22toolu_def456\x22,\x22name\x22:\x22Edit\x22,\x22input\x22:{\x22file_path\x22:\x22test.ts\x22,\x22old_string\x22:\x22const\x20x\x20=\x201;\x22,\x22new_string\x22:\x22const\x20x\x20=\x201;\x5cnconst\x20y\x20=\x202;\x22}}}\x0a```\x0a\x0a#\x20Available\x20Tools\x0a\x0a','reasoning','LLM_MALFORMED_MESSAGE','stringify','Invalid\x20tools\x20type:\x20expected\x20array,\x20got\x20','tools','filter','system','input','join','push','input_schema','content_block_stop','\x0adata:\x20','random','string','role','opus','\x0a\x0aCommon\x20issues:\x0a-\x20All\x20strings\x20must\x20use\x20double\x20quotes\x20(not\x20single\x20quotes)\x0a-\x20All\x20braces\x20and\x20brackets\x20must\x20be\x20balanced\x0a-\x20No\x20trailing\x20commas\x0a-\x20Newlines\x20in\x20strings\x20must\x20be\x20escaped\x20as\x20\x5cn\x0a-\x20Backslashes\x20must\x20be\x20escaped\x20as\x20\x5c\x5c\x0a','content_block_delta','usage','Invalid\x20message.content\x20type\x20for\x20user\x20role:\x20expected\x20array,\x20got\x20','parse','\x0a```','41699kQJEMb','No\x20description','toLowerCase','messages','```tool_result\x20tool_use_id=','isArray','2705bSIfrb','Invalid\x20message.content\x20type:\x20expected\x20string\x20or\x20array,\x20got\x20','\x5c`\x5c`\x5c`','arguments','message','tool_result','text_delta','end_turn','2109768goLbvJ','content_block_start','\x0a\x0aPlease\x20continue\x20your\x20response\x20based\x20on\x20the\x20tool\x20results\x20above.','assistant','\x0a\x0a**Input\x20Schema:**\x0a```json\x0a','ceil','user','description','3495960WYXGTI','length','6910940aAyRrb','[API\x20ERROR]\x20','debug','sonnet','138UEpMKi','name','substring','indexOf'];a43_0x39c2=function(){return _0x40d103;};return a43_0x39c2();}export function extractTextFromAnthropicMessage(_0x327bd4){const _0x1112de=a43_0x50ec;if(typeof _0x327bd4['content']===_0x1112de(0x126))return _0x327bd4[_0x1112de(0x107)];if(_0x327bd4[_0x1112de(0x107)]==null)return'';if(!Array[_0x1112de(0x134)](_0x327bd4[_0x1112de(0x107)]))throw new SDKError(ErrorCode[_0x1112de(0x119)],_0x1112de(0x136)+typeof _0x327bd4[_0x1112de(0x107)]);return _0x327bd4[_0x1112de(0x107)][_0x1112de(0x11d)](_0x1b612d=>_0x1b612d&&_0x1b612d['type']==='text'&&_0x1b612d[_0x1112de(0x155)])['map'](_0x28e3f9=>_0x28e3f9[_0x1112de(0x155)])[_0x1112de(0x120)]('\x0a');}export function calculateConversationDelta(_0x2bdcd6,_0x4c1393){if(_0x4c1393['length']===0x0)return _0x2bdcd6;const _0x35d66b=_0x4c1393['length'];return _0x2bdcd6['slice'](_0x35d66b);}export function transformAnthropicRequestToTD(_0x4e1483,_0x3f38df){const _0x213a75=a43_0x50ec,_0x1da78f=calculateConversationDelta(_0x4e1483[_0x213a75(0x132)],_0x3f38df),_0x4b9684=_0x1da78f[_0x213a75(0x11d)](_0x587c13=>_0x587c13[_0x213a75(0x127)]===_0x213a75(0x143))['pop']();if(!_0x4b9684)throw new Error('No\x20user\x20message\x20found\x20in\x20request\x20delta');const _0xf8f7a1=extractTextFromAnthropicMessage(_0x4b9684);return{'userMessage':_0xf8f7a1,'deltaMessages':_0x1da78f};}export function formatAnthropicSSE(_0x225e84){const _0x32b1e6=a43_0x50ec;return _0x32b1e6(0x100)+_0x225e84[_0x32b1e6(0x152)]+_0x32b1e6(0x124)+JSON[_0x32b1e6(0x11a)](_0x225e84)+'\x0a\x0a';}export function mapAnthropicModelToTD(_0xd31aa8){const _0x7fe7ac=a43_0x50ec,_0x12f683={'sonnet':'sonnet','claude-sonnet':'sonnet','claude-3-5-sonnet':_0x7fe7ac(0x14a),'claude-3-sonnet':_0x7fe7ac(0x14a),'haiku':_0x7fe7ac(0x15a),'claude-haiku':_0x7fe7ac(0x15a),'claude-3-5-haiku':'haiku','claude-3-haiku':_0x7fe7ac(0x15a),'opus':'opus','claude-opus':_0x7fe7ac(0x128),'claude-3-opus':_0x7fe7ac(0x128)},_0x5d6d8a=_0xd31aa8[_0x7fe7ac(0x131)]();return _0x12f683[_0x5d6d8a]||_0x7fe7ac(0x14a);}export function generateToolPrompt(_0x200663){const _0x4a9125=a43_0x50ec;if(_0x200663==null)return'';if(!Array['isArray'](_0x200663))throw new SDKError(ErrorCode[_0x4a9125(0x119)],_0x4a9125(0x11b)+typeof _0x200663);if(_0x200663[_0x4a9125(0x146)]===0x0)return'';const _0x20fc81=_0x200663[_0x4a9125(0x11d)](_0x5cd620=>_0x5cd620!=null)[_0x4a9125(0x116)](_0x26c8e4=>{const _0x593677=_0x4a9125,_0x481578=JSON[_0x593677(0x11a)](_0x26c8e4['input_schema']);return _0x593677(0x159)+_0x26c8e4['name']+_0x593677(0xff)+(_0x26c8e4[_0x593677(0x144)]||_0x593677(0x130))+_0x593677(0x141)+_0x481578+_0x593677(0x12e);})['join']('\x0a\x0a');return _0x4a9125(0x117)+_0x20fc81+'\x0a---\x0a';}function escapeMarkdownCodeBlock(_0x2a6fd0){const _0x2994ab=a43_0x50ec;return _0x2a6fd0['replace'](/```/g,_0x2994ab(0x137));}export function extractToolResults(_0x53ff43){const _0x252a6d=a43_0x50ec;if(_0x53ff43==null)return'';if(!Array[_0x252a6d(0x134)](_0x53ff43))throw new SDKError(ErrorCode[_0x252a6d(0x119)],_0x252a6d(0x154)+typeof _0x53ff43);const _0x47817e=[];for(const _0x54beab of _0x53ff43){if(!_0x54beab)continue;if(_0x54beab['role']===_0x252a6d(0x143)&&typeof _0x54beab['content']!==_0x252a6d(0x126)){if(!Array[_0x252a6d(0x134)](_0x54beab[_0x252a6d(0x107)]))throw new SDKError(ErrorCode[_0x252a6d(0x119)],_0x252a6d(0x12c)+typeof _0x54beab[_0x252a6d(0x107)]);for(const _0x287f0f of _0x54beab[_0x252a6d(0x107)]){if(!_0x287f0f)continue;if(_0x287f0f[_0x252a6d(0x152)]===_0x252a6d(0x13a)&&_0x287f0f['tool_use_id']){let _0xae7040='';if(typeof _0x287f0f[_0x252a6d(0x107)]===_0x252a6d(0x126))_0xae7040=_0x287f0f[_0x252a6d(0x107)];else _0x287f0f[_0x252a6d(0x107)]!=null&&Array[_0x252a6d(0x134)](_0x287f0f['content'])&&(_0xae7040=_0x287f0f[_0x252a6d(0x107)][_0x252a6d(0x11d)](_0x3152ff=>_0x3152ff&&_0x3152ff[_0x252a6d(0x152)]==='text'&&_0x3152ff[_0x252a6d(0x155)])[_0x252a6d(0x116)](_0xb8b711=>_0xb8b711[_0x252a6d(0x155)])['join']('\x0a'));const _0x3af62d=escapeMarkdownCodeBlock(_0xae7040),_0x16771c=_0x287f0f['is_error']?'\x20error=true':'';_0x47817e['push'](_0x252a6d(0x133)+_0x287f0f['tool_use_id']+_0x16771c+'\x0a'+_0x3af62d+_0x252a6d(0x12e));}}}}if(_0x47817e[_0x252a6d(0x146)]===0x0)return'';return _0x47817e[_0x252a6d(0x120)]('\x0a\x0a')+_0x252a6d(0x13f);}function a43_0x50ec(_0x161212,_0x279196){const _0x39c2bd=a43_0x39c2();return a43_0x50ec=function(_0x50ec3c,_0x18b16a){_0x50ec3c=_0x50ec3c-0xfc;let _0x29dadd=_0x39c2bd[_0x50ec3c];return _0x29dadd;},a43_0x50ec(_0x161212,_0x279196);}function findJsonEndIndex(_0x58c51a,_0x194d4b){const _0x5e2676=a43_0x50ec;let _0x3de5f5=0x0,_0x52a92f=![],_0x3830bb=![];for(let _0x231177=_0x194d4b;_0x231177<_0x58c51a[_0x5e2676(0x146)];_0x231177++){const _0x2910b8=_0x58c51a[_0x231177];if(_0x3830bb){_0x3830bb=![];continue;}if(_0x2910b8==='\x5c'){_0x3830bb=!![];continue;}if(_0x2910b8==='\x22'){_0x52a92f=!_0x52a92f;continue;}if(!_0x52a92f){if(_0x2910b8==='{')_0x3de5f5++;else{if(_0x2910b8==='}'){_0x3de5f5--;if(_0x3de5f5===0x0)return _0x231177+0x1;}}}}return-0x1;}function generateToolCallId(){const _0x4d6cf3=a43_0x50ec;return'toolu_'+Math['random']()[_0x4d6cf3(0x113)](0x24)['substring'](0x2,0xf);}function repairIncompleteJson(_0x531403,_0x5a2c7b){const _0x58014e=a43_0x50ec;try{return JSON[_0x58014e(0x12d)](_0x531403),_0x531403;}catch{const _0x96160c=[];let _0x433dc5=![],_0x12bc53=![];for(const _0x32095e of _0x531403){if(_0x12bc53){_0x12bc53=![];continue;}if(_0x32095e==='\x5c'){_0x12bc53=!![];continue;}if(_0x32095e==='\x22'){_0x433dc5=!_0x433dc5;continue;}if(!_0x433dc5){if(_0x32095e==='{')_0x96160c[_0x58014e(0x121)]('{');else{if(_0x32095e==='[')_0x96160c[_0x58014e(0x121)]('[');else{if(_0x32095e==='}'&&_0x96160c[_0x96160c[_0x58014e(0x146)]-0x1]==='{')_0x96160c[_0x58014e(0x103)]();else _0x32095e===']'&&_0x96160c[_0x96160c[_0x58014e(0x146)]-0x1]==='['&&_0x96160c[_0x58014e(0x103)]();}}}}let _0x3cefe7=_0x531403;_0x433dc5&&(_0x3cefe7+='\x22');while(_0x96160c[_0x58014e(0x146)]>0x0){const _0x432452=_0x96160c[_0x58014e(0x103)]();_0x3cefe7+=_0x432452==='{'?'}':']';}try{return JSON[_0x58014e(0x12d)](_0x3cefe7),_0x5a2c7b&&_0x3cefe7!==_0x531403&&_0x5a2c7b[_0x58014e(0x156)]('[JSON\x20REPAIR]\x20Successfully\x20repaired\x20malformed\x20JSON\x0a[Before]:\x0a'+_0x531403+_0x58014e(0x114)+_0x3cefe7),_0x3cefe7;}catch{return null;}}}export function parseToolCallFromText(_0x3413f3,_0x4baf7f){const _0x21f2a9=a43_0x50ec,_0x18066d=/```tool_use[\s]*\n([\s\S]*)\n?```/,_0x106c98=_0x18066d[_0x21f2a9(0x106)](_0x3413f3);if(_0x106c98){if(!_0x106c98[0x0]['endsWith']('```')){}else{const _0x3c0d3a=_0x106c98[0x1][_0x21f2a9(0xfd)](),_0x54b517=_0x106c98['index'],_0x231259=_0x54b517+_0x106c98[0x0][_0x21f2a9(0x146)];try{const _0x5937fe=JSON[_0x21f2a9(0x12d)](_0x3c0d3a);if(_0x5937fe[_0x21f2a9(0x10a)]&&_0x5937fe[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)])return{'id':_0x5937fe[_0x21f2a9(0x10a)]['id']||generateToolCallId(),'name':_0x5937fe[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)],'input':_0x5937fe[_0x21f2a9(0x10a)][_0x21f2a9(0x11f)]||{},'startIndex':_0x54b517,'endIndex':_0x231259};if(_0x5937fe[_0x21f2a9(0x14c)]&&typeof _0x5937fe['name']===_0x21f2a9(0x126)&&_0x5937fe[_0x21f2a9(0x14c)][_0x21f2a9(0xfd)]()['length']>0x0)return{'id':_0x5937fe['id']||generateToolCallId(),'name':_0x5937fe[_0x21f2a9(0x14c)],'input':_0x5937fe[_0x21f2a9(0x11f)]||_0x5937fe[_0x21f2a9(0x138)]||{},'startIndex':_0x54b517,'endIndex':_0x231259};}catch{const _0x10a5c5=repairIncompleteJson(_0x3c0d3a,_0x4baf7f);if(_0x10a5c5)try{const _0x5b4e29=JSON[_0x21f2a9(0x12d)](_0x10a5c5);if(_0x5b4e29['tool_use']&&_0x5b4e29[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)])return{'id':_0x5b4e29['tool_use']['id']||generateToolCallId(),'name':_0x5b4e29[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)],'input':_0x5b4e29[_0x21f2a9(0x10a)][_0x21f2a9(0x11f)]||{},'startIndex':_0x54b517,'endIndex':_0x231259};if(_0x5b4e29[_0x21f2a9(0x14c)]&&typeof _0x5b4e29[_0x21f2a9(0x14c)]===_0x21f2a9(0x126)&&_0x5b4e29[_0x21f2a9(0x14c)][_0x21f2a9(0xfd)]()[_0x21f2a9(0x146)]>0x0)return{'id':_0x5b4e29['id']||generateToolCallId(),'name':_0x5b4e29[_0x21f2a9(0x14c)],'input':_0x5b4e29[_0x21f2a9(0x11f)]||_0x5b4e29[_0x21f2a9(0x138)]||{},'startIndex':_0x54b517,'endIndex':_0x231259};}catch{}}}}const _0x5ac1fa=/\{"tool_use":/g,_0x348ae3=_0x5ac1fa[_0x21f2a9(0x106)](_0x3413f3);if(!_0x348ae3)return null;const _0x36378c=_0x348ae3['index'];let _0x3b0bd4=findJsonEndIndex(_0x3413f3,_0x36378c);if(_0x3b0bd4===-0x1)return null;const _0x34c56f=_0x3413f3[_0x21f2a9(0x14d)](_0x36378c,_0x3b0bd4);try{const _0x23e41a=JSON['parse'](_0x34c56f);if(_0x23e41a['tool_use']&&_0x23e41a[_0x21f2a9(0x10a)]['id']&&_0x23e41a[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)])return{'id':_0x23e41a[_0x21f2a9(0x10a)]['id'],'name':_0x23e41a[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)],'input':_0x23e41a[_0x21f2a9(0x10a)][_0x21f2a9(0x11f)]||{},'startIndex':_0x36378c,'endIndex':_0x3b0bd4};}catch{const _0x2627b6=repairIncompleteJson(_0x34c56f,_0x4baf7f);if(_0x2627b6)try{const _0x37493c=JSON['parse'](_0x2627b6);if(_0x37493c[_0x21f2a9(0x10a)]&&_0x37493c['tool_use']['id']&&_0x37493c[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)])return{'id':_0x37493c[_0x21f2a9(0x10a)]['id'],'name':_0x37493c[_0x21f2a9(0x10a)][_0x21f2a9(0x14c)],'input':_0x37493c[_0x21f2a9(0x10a)][_0x21f2a9(0x11f)]||{},'startIndex':_0x36378c,'endIndex':_0x3b0bd4};}catch{return null;}return null;}return null;}export function*generateToolCallEvents(_0x2e4eff,_0x4b9903,_0x5a5db0){const _0x3ce1de=a43_0x50ec,_0x281493={'type':_0x3ce1de(0x13e),'index':_0x4b9903,'content_block':{'type':_0x3ce1de(0x10a),'id':_0x2e4eff['id'],'name':_0x2e4eff[_0x3ce1de(0x14c)],'input':{}}};yield _0x281493;const _0xf41198=JSON['stringify'](_0x2e4eff[_0x3ce1de(0x11f)]),_0x235f45={'type':_0x3ce1de(0x12a),'index':_0x4b9903,'delta':{'type':_0x3ce1de(0x109),'partial_json':_0xf41198}};yield _0x235f45;const _0x479588={'type':_0x3ce1de(0x123),'index':_0x4b9903};yield _0x479588;const _0x4c7d97={'type':_0x3ce1de(0x110),'delta':{'stop_reason':_0x3ce1de(0x10a),'stop_sequence':null},'usage':{'input_tokens':_0x5a5db0,'output_tokens':0x0}};yield _0x4c7d97;const _0x50d62f={'type':'message_stop'};yield _0x50d62f;}export async function*transformTDStreamToAnthropic(_0x53ab56,_0x3f45c4,_0x23864b,_0x18f75c,_0x34054d='',_0x160a74=0x0){const _0x5753ab=a43_0x50ec,_0x294912=_0x160a74>0x0?_0x160a74:estimateTokenCount(_0x34054d);let _0x396c56=0x0,_0x4d0665=0x0,_0x4831e7=![],_0x1e8efe=null,_0x3bd550='',_0x3d5927=0x0,_0x2e297e=![];const _0x387d41=0xc8,_0x26b917={'type':'message_start','message':{'id':_0x3f45c4,'type':_0x5753ab(0x139),'role':_0x5753ab(0x140),'content':[],'model':_0x23864b,'stop_reason':null,'stop_sequence':null,'usage':{'input_tokens':_0x294912,'output_tokens':0x0}}};yield _0x26b917;for await(const _0xe87916 of _0x53ab56){if(_0x5753ab(0x118)in _0xe87916){const _0x2ccfc1=_0xe87916;if(!_0x4831e7){const _0x44fd4f={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x104),'thinking':''}};yield _0x44fd4f,_0x4831e7=!![],_0x1e8efe=_0x5753ab(0x104);}const _0x3485fd={'type':_0x5753ab(0x12a),'index':_0x4d0665,'delta':{'type':_0x5753ab(0x10b),'thinking':_0x2ccfc1['reasoning']}};yield _0x3485fd,_0x396c56+=estimateTokenCount(_0x2ccfc1[_0x5753ab(0x118)]);}else{if('content'in _0xe87916){const _0x5e522c=_0xe87916;if(_0x4831e7&&_0x1e8efe===_0x5753ab(0x104)){const _0x18f9a8={'type':_0x5753ab(0x123),'index':_0x4d0665};yield _0x18f9a8,_0x4d0665++,_0x4831e7=![],_0x1e8efe=null;}_0x3bd550+=_0x5e522c[_0x5753ab(0x107)];const _0x32a6ba=_0x3bd550[_0x5753ab(0x14e)](_0x5753ab(0x151)),_0x390fd3=_0x3bd550[_0x5753ab(0x14e)](_0x5753ab(0x10e)),_0xa66cff=_0x32a6ba!==-0x1?_0x390fd3!==-0x1?Math['min'](_0x32a6ba,_0x390fd3):_0x32a6ba:_0x390fd3;if(_0xa66cff!==-0x1){const _0x6cfe7d=[];let _0x489816=0x0;while(!![]){const _0x1f66cd=_0x3bd550['substring'](_0x489816),_0x57af37=parseToolCallFromText(_0x1f66cd,_0x18f75c);if(!_0x57af37)break;_0x6cfe7d[_0x5753ab(0x121)]({'id':_0x57af37['id'],'name':_0x57af37[_0x5753ab(0x14c)],'input':_0x57af37[_0x5753ab(0x11f)],'startIndex':_0x489816+_0x57af37['startIndex'],'endIndex':_0x489816+_0x57af37[_0x5753ab(0x10d)]}),_0x489816+=_0x57af37[_0x5753ab(0x10d)];}if(_0x6cfe7d['length']>0x0){const _0x661b66=_0x6cfe7d[_0x6cfe7d[_0x5753ab(0x146)]-0x1];_0x2e297e=!![];_0x6cfe7d[_0x5753ab(0x146)]>0x1?_0x18f75c?.[_0x5753ab(0x149)](_0x5753ab(0x105)+_0x661b66['name']):_0x18f75c?.[_0x5753ab(0x149)](_0x5753ab(0x108)+_0x661b66[_0x5753ab(0x14c)]);const _0x54a42c=_0x3bd550[_0x5753ab(0x14d)](_0x3d5927,_0x661b66['startIndex'])[_0x5753ab(0xfd)]();if(_0x54a42c){if(!_0x4831e7){const _0x573a46={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x155),'text':''}};yield _0x573a46,_0x4831e7=!![],_0x1e8efe='text';}const _0x45dff2={'type':_0x5753ab(0x12a),'index':_0x4d0665,'delta':{'type':_0x5753ab(0x13b),'text':_0x54a42c}};yield _0x45dff2,_0x396c56+=estimateTokenCount(_0x54a42c);}if(_0x4831e7){const _0x18554d={'type':_0x5753ab(0x123),'index':_0x4d0665};yield _0x18554d,_0x4d0665++,_0x4831e7=![],_0x1e8efe=null;}for(const _0x1fa5d1 of generateToolCallEvents(_0x661b66,_0x4d0665,_0x294912)){_0x1fa5d1['type']===_0x5753ab(0x110)&&(_0x1fa5d1[_0x5753ab(0x12b)]['output_tokens']=_0x396c56),yield _0x1fa5d1;}return;}const _0x58775a=_0x3bd550['includes'](_0x5753ab(0x151))&&_0x3bd550[_0x5753ab(0x14e)](_0x5753ab(0x115),_0x3bd550[_0x5753ab(0x14e)](_0x5753ab(0x151))+0xb)!==-0x1,_0x456d00=_0x3bd550[_0x5753ab(0x10c)](_0x5753ab(0x10e))&&findJsonEndIndex(_0x3bd550,_0x3bd550['indexOf'](_0x5753ab(0x10e)))!==-0x1;if(_0x58775a||_0x456d00){_0x2e297e=!![];let _0x27fe20='';if(_0x58775a){const _0x29e52f=_0x3bd550['indexOf'](_0x5753ab(0x151)),_0x1481bc=_0x3bd550['indexOf']('```',_0x29e52f+0xb);_0x1481bc!==-0x1?_0x27fe20=_0x3bd550[_0x5753ab(0x14d)](_0x29e52f,_0x1481bc+0x3):_0x27fe20=_0x3bd550[_0x5753ab(0x14d)](_0x29e52f);}else{if(_0x456d00){const _0x53beb6=_0x3bd550[_0x5753ab(0x14e)](_0x5753ab(0x10e)),_0x2d3f8d=findJsonEndIndex(_0x3bd550,_0x53beb6);_0x2d3f8d!==-0x1?_0x27fe20=_0x3bd550['substring'](_0x53beb6,_0x2d3f8d):_0x27fe20=_0x3bd550['substring'](_0x53beb6);}}_0x18f75c&&_0x18f75c[_0x5753ab(0x15e)]('[MALFORMED\x20JSON]\x20Tool\x20use\x20JSON\x20could\x20not\x20be\x20parsed\x20or\x20repaired:\x0a'+_0x27fe20);_0x18f75c?.[_0x5753ab(0x149)]('Malformed\x20tool_use\x20JSON\x20detected'),_0x18f75c?.[_0x5753ab(0x149)](_0x5753ab(0x153),_0x27fe20);const _0x3969fb=_0x3bd550[_0x5753ab(0x14d)](_0x3d5927,_0xa66cff)[_0x5753ab(0xfd)]();if(_0x3969fb){if(!_0x4831e7){const _0x1e477d={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x155),'text':''}};yield _0x1e477d,_0x4831e7=!![],_0x1e8efe=_0x5753ab(0x155);}const _0x3cde7f={'type':_0x5753ab(0x12a),'index':_0x4d0665,'delta':{'type':_0x5753ab(0x13b),'text':_0x3969fb}};yield _0x3cde7f,_0x396c56+=estimateTokenCount(_0x3969fb);}if(_0x4831e7){const _0x5cca14={'type':_0x5753ab(0x123),'index':_0x4d0665};yield _0x5cca14,_0x4d0665++,_0x4831e7=![],_0x1e8efe=null;}const _0x4b0cbd=_0x5753ab(0xfc)+_0x27fe20+_0x5753ab(0x129),_0x152b7f={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x155),'text':''}};yield _0x152b7f,_0x1e8efe=_0x5753ab(0x155);const _0x275b13={'type':'content_block_delta','index':_0x4d0665,'delta':{'type':'text_delta','text':_0x4b0cbd}};yield _0x275b13;const _0x407761={'type':_0x5753ab(0x123),'index':_0x4d0665};yield _0x407761;const _0x30c6be={'type':'message_delta','delta':{'stop_reason':_0x5753ab(0x13c),'stop_sequence':null},'usage':{'input_tokens':_0x294912,'output_tokens':_0x396c56}};yield _0x30c6be;const _0x314740={'type':_0x5753ab(0xfe)};yield _0x314740;return;}const _0x2c7d35=_0x3bd550['substring'](_0x3d5927,_0xa66cff);if(_0x2c7d35){if(!_0x4831e7){const _0x45039a={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x155),'text':''}};yield _0x45039a,_0x4831e7=!![],_0x1e8efe=_0x5753ab(0x155);}const _0x557517={'type':'content_block_delta','index':_0x4d0665,'delta':{'type':'text_delta','text':_0x2c7d35}};yield _0x557517,_0x396c56+=estimateTokenCount(_0x2c7d35),_0x3d5927=_0xa66cff;}continue;}const _0x1da400=_0x3bd550[_0x5753ab(0x146)]-_0x387d41;if(_0x1da400>_0x3d5927){const _0x57c96c=_0x3bd550['substring'](_0x3d5927,_0x1da400);if(_0x57c96c){if(!_0x4831e7){const _0xb7f1c0={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':'text','text':''}};yield _0xb7f1c0,_0x4831e7=!![],_0x1e8efe=_0x5753ab(0x155);}const _0x446313={'type':_0x5753ab(0x12a),'index':_0x4d0665,'delta':{'type':_0x5753ab(0x13b),'text':_0x57c96c}};yield _0x446313,_0x396c56+=estimateTokenCount(_0x57c96c),_0x3d5927=_0x1da400;}}}else{if('error'in _0xe87916){const _0x3c42cc=_0xe87916,_0x3158f5=determineErrorType(_0x3c42cc[_0x5753ab(0x15e)],_0x18f75c),_0x43afbe=_0x3158f5===_0x5753ab(0x102)?_0x5753ab(0x101):_0x5753ab(0x13c),_0x571aa6={'type':_0x5753ab(0x110),'delta':{'stop_reason':_0x43afbe,'stop_sequence':null},'usage':{'input_tokens':_0x294912,'output_tokens':_0x396c56}};yield _0x571aa6,yield{'type':_0x5753ab(0x15e),'error':{'type':_0x3158f5,'message':_0x3c42cc[_0x5753ab(0x15e)]},'request_id':_0x3f45c4};const _0x1a7d39={'type':'message_stop'};yield _0x1a7d39;return;}}}}if(!_0x2e297e){const _0x1dbf35=_0x3bd550[_0x5753ab(0x14d)](_0x3d5927);if(_0x1dbf35){if(!_0x4831e7){const _0x10695f={'type':_0x5753ab(0x13e),'index':_0x4d0665,'content_block':{'type':_0x5753ab(0x155),'text':''}};yield _0x10695f,_0x4831e7=!![],_0x1e8efe='text';}const _0x51d3b1={'type':'content_block_delta','index':_0x4d0665,'delta':{'type':_0x5753ab(0x13b),'text':_0x1dbf35}};yield _0x51d3b1,_0x396c56+=estimateTokenCount(_0x1dbf35);}if(_0x4831e7){const _0x5cc219={'type':_0x5753ab(0x123),'index':_0x4d0665};yield _0x5cc219;}const _0x4be867={'type':_0x5753ab(0x110),'delta':{'stop_reason':'end_turn','stop_sequence':null},'usage':{'input_tokens':_0x294912,'output_tokens':_0x396c56}};yield _0x4be867;const _0x149ac7={'type':_0x5753ab(0xfe)};yield _0x149ac7;}}export{generateMessageId};
@@ -1 +1 @@
1
- const a44_0xa20526=a44_0x56cb;(function(_0x470d6f,_0x55020a){const _0x31f4d7=a44_0x56cb,_0x4d52ec=_0x470d6f();while(!![]){try{const _0x58af65=parseInt(_0x31f4d7(0x18b))/0x1*(parseInt(_0x31f4d7(0x207))/0x2)+parseInt(_0x31f4d7(0x19c))/0x3*(-parseInt(_0x31f4d7(0x21d))/0x4)+-parseInt(_0x31f4d7(0x1f2))/0x5*(parseInt(_0x31f4d7(0x1e5))/0x6)+parseInt(_0x31f4d7(0x1c1))/0x7*(parseInt(_0x31f4d7(0x161))/0x8)+-parseInt(_0x31f4d7(0x16e))/0x9+parseInt(_0x31f4d7(0x1be))/0xa+-parseInt(_0x31f4d7(0x20f))/0xb;if(_0x58af65===_0x55020a)break;else _0x4d52ec['push'](_0x4d52ec['shift']());}catch(_0x4a867a){_0x4d52ec['push'](_0x4d52ec['shift']());}}}(a44_0x383f,0x35eaf));import a44_0x2ac25e from'fastify';function a44_0x383f(){const _0x5e9bc2=['getOrCreateDefaultAgent','clear',']\x20model:\x20','Failed\x20to\x20extract\x20tool\x20results:','chatId','substring','embeddedSystemPrompts','metadata','getAgentForModel','port','[Previous\x20conversation]\x0a\x0a<conversation>\x0a','push','[PROXY\x20ERROR]\x20Non-streaming\x20responses\x20are\x20not\x20yet\x20supported','\x20|\x20','[PROXY\x20ERROR]\x20Unhandled\x20error\x20in\x20','data','System\x20prompts:\x20','3838150mhAmoU','raw','Reset\x20chat\x20ID\x20to\x20recover\x20on\x20next\x20request','9541VZNySg','agentId','string','register','map','pop','end','getOrCreateSession','content','name','Embedding','Assistant','request_too_large','invalid_request_error','catch','model',',\x20model=','headers','sent',',\x20\x22','isArray','\x20->\x20','\x20Input\x20size:\x20','filter','site',',\x20tools=','Final\x20message\x20is\x20empty\x20after\x20construction\x20-\x20starting\x20fresh\x20conversation','/v1/messages/count_tokens','lastUsedAt','message','address','budget_tokens','messages',',\x20context:\x20','Embedded\x20in\x20chat\x20-\x20system\x20prompts:\x20','Added\x20system\x20prompt\x20previews:','12FTiZDU','text/event-stream','Failed\x20to\x20generate\x20tool\x20prompt:','\x20messages,\x20','url','Waiting\x20for\x20concurrent\x20chat\x20creation\x20for\x20context:\x20','text','cleanupInterval','error','handleCountTokens','writeHead','no-cache',']\x20Created\x20new\x20chat\x20for\x20model\x20','284390PNHnrR',',\x20is\x20new\x20context:\x20','header:\x20','sort','No\x20user\x20message\x20found\x20in\x20request','Including\x20tool\x20results','post','digest','info','body','trace',',\x20context=','hex','Unknown\x20error',']\x20Building\x20a\x20new\x20context\x20for\x20model\x20','stringify','Reset\x20chat\x20state\x20to\x20recover\x20on\x20next\x20request','GET','\x20chars.\x20Cleared\x20chat\x20state\x20for\x20session\x20','event','update','665090FBJjik','\x20tools,\x20message_size=','chats','projectId','embeddedToolsByName','now','\x0a---\x0a\x0a','startChat','648285BdoWxq','dev-us01',',\x20system_prompts=','\x20(reasoning:\x20','Context:','keys','[CONTEXT\x20LENGTH\x20ERROR]\x20','Stream\x20complete.\x20Sent\x20','write','start','replace','getAddress','Failed\x20to\x20create\x20chat,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','get','44940plygPV','api_error','attributes',')\x20to\x20stay\x20under\x20',',\x20tools:\x20','stream','[PROXY\x20ERROR]\x20Streaming\x20error:','1848EeOtUN','input_schema','New\x20-\x20system\x20prompts:\x20','user','slice','Agent\x20cached:\x20',',\x20tool_names=[','localeCompare','agentCache','x-api-key','[PROXY\x20ERROR]\x20Uncaught\x20error\x20in\x20','sha256','join','3110085xdjfaj','[PROXY\x20ERROR]\x20Validation\x20failed:\x20message.content\x20must\x20be\x20a\x20string\x20or\x20array,\x20got:','sessionCache','server','Debug\x20info:','setupRoutes','role',']\x20Continue\x20chat\x20for\x20model\x20','Started\x20cache\x20cleanup\x20interval\x20(runs\x20every\x20','trim','Model\x20normalization:\x20','Project\x20ID\x20must\x20be\x20configured','Creating/looking\x20up\x20agent\x20for:\x20','Proxy\x20server\x20started\x20at\x20localhost:','length',':\x20messages=',':\x20estimated\x20input_tokens=','tools','cleanupExpiredChats','Chat\x20ID:\x20','messageHistory','delete','Concurrent\x20chat\x20creation\x20failed,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','/v1/messages','messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','Failed\x20to\x20initialize\x20chat\x20stream.\x20Please\x20try\x20again.','\x20SSE\x20events.','handleMessages','warn','1CVxMXF','chat','Authorization','/health','config','type','setupMiddleware','logger','system','tools\x20must\x20be\x20an\x20array\x20if\x20provided','[PROXY\x20ERROR]\x20Chat\x20stream\x20is\x20undefined','[PROXY\x20ERROR]\x20Configuration\x20error:\x20Project\x20ID\x20must\x20be\x20configured','unknown','tdx','...\x22','has','code','78sKCBmJ','send','createPromise','add','OPTIONS',',\x20context\x20signature:\x20','debug','setErrorHandler','handleRouteError','default','set','llm','Content-Type','http://localhost:','continue','method','[Current\x20message]\x0a\x0a'];a44_0x383f=function(){return _0x5e9bc2;};return a44_0x383f();}import a44_0x1929df from'@fastify/cors';function a44_0x56cb(_0x1ce3d9,_0x25ff93){const _0x383fdb=a44_0x383f();return a44_0x56cb=function(_0x56cbb0,_0xd83431){_0x56cbb0=_0x56cbb0-0x160;let _0x25defc=_0x383fdb[_0x56cbb0];return _0x25defc;},a44_0x56cb(_0x1ce3d9,_0x25ff93);}import{createHash}from'crypto';import{transformTDStreamToAnthropic,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(_0x49bd40){const _0x367525=a44_0x56cb;if(!_0x49bd40||!Array['isArray'](_0x49bd40))return'';return _0x49bd40[_0x367525(0x1d8)](_0x5ab6e8=>_0x5ab6e8!=null)[_0x367525(0x1c5)](_0x63ac23=>{const _0x349f9e=_0x367525,_0x178b87=_0x63ac23[_0x349f9e(0x1c9)]!=null&&Array[_0x349f9e(0x1d5)](_0x63ac23[_0x349f9e(0x1c9)])?_0x63ac23[_0x349f9e(0x1c9)][_0x349f9e(0x1d8)](_0x3649e3=>_0x3649e3&&_0x3649e3[_0x349f9e(0x190)]===_0x349f9e(0x1eb))[_0x349f9e(0x1c5)](_0x1aeb46=>_0x1aeb46[_0x349f9e(0x1eb)])[_0x349f9e(0x16d)]('\x0a'):_0x63ac23['content']||'',_0x9687a0=_0x63ac23[_0x349f9e(0x174)]===_0x349f9e(0x164)?'User':_0x349f9e(0x1cc);return _0x9687a0+':\x20'+_0x178b87;})[_0x367525(0x16d)]('\x0a\x0a');}function calculateContextSignature(_0x30ec68,_0x2cf68e,_0x25bc99,_0x4afd8e){const _0x169a62=a44_0x56cb,_0x3f4bf7=extractModelAlias(_0x30ec68),_0x53faf8=resolveModelAlias(_0x3f4bf7),_0x154e89=[..._0x2cf68e||[]][_0x169a62(0x1f5)](),_0x3569e1=(_0x25bc99||[])['filter'](_0x22acd6=>_0x22acd6!=null)[_0x169a62(0x1c5)](_0x6b92ff=>({'name':_0x6b92ff[_0x169a62(0x1ca)],'params':Object[_0x169a62(0x214)](_0x6b92ff[_0x169a62(0x162)]?.['properties']||{})[_0x169a62(0x1f5)](),'required':(_0x6b92ff[_0x169a62(0x162)]?.['required']||[])['sort']()}))[_0x169a62(0x1f5)]((_0x44c518,_0x384380)=>_0x44c518[_0x169a62(0x1ca)][_0x169a62(0x168)](_0x384380['name'])),_0x3b67eb=JSON[_0x169a62(0x201)]({'model':_0x53faf8,'prompts':_0x154e89,'tools':_0x3569e1,'reasoning':_0x4afd8e});return createHash(_0x169a62(0x16c))[_0x169a62(0x206)](_0x3b67eb)[_0x169a62(0x1f9)](_0x169a62(0x1fe))['substring'](0x0,0x10);}function clearChatState(_0x516af1){const _0x687c59=a44_0x56cb;_0x516af1[_0x687c59(0x1b1)]='',_0x516af1[_0x687c59(0x1b3)][_0x687c59(0x1ae)](),_0x516af1[_0x687c59(0x20b)][_0x687c59(0x1ae)]();}function mapBudgetTokensToReasoningEffort(_0x25a488,_0x22e693){const _0x207202=a44_0x56cb;if(_0x22e693!==_0x207202(0x210))return 0x0;if(!_0x25a488||_0x25a488===0x0)return 0x0;if(_0x25a488<=0x400)return 0x1;if(_0x25a488<=0x800)return 0x2;if(_0x25a488<=0x1000)return 0x3;return 0x4;}const MAX_CHATS_PER_SESSION=0xa,CACHE_EXPIRATION_MS=0xa*0x3c*0x3e8,CLEANUP_INTERVAL_MS=0x3c*0x3e8;export class ProxyServer{[a44_0xa20526(0x171)];[a44_0xa20526(0x170)];[a44_0xa20526(0x169)];[a44_0xa20526(0x18f)];['cleanupInterval'];['logger'];constructor(_0x36ac4c){const _0x357776=a44_0xa20526;this[_0x357776(0x192)]=_0x36ac4c[_0x357776(0x192)],this[_0x357776(0x18f)]=_0x36ac4c,this[_0x357776(0x170)]=new SessionCache({'maxChatsPerSession':MAX_CHATS_PER_SESSION,'cacheExpirationMs':CACHE_EXPIRATION_MS}),this[_0x357776(0x169)]=new Map(),this['server']=a44_0x2ac25e({'logger':![],'bodyLimit':0x40*0x400*0x400}),this[_0x357776(0x191)](),this['setupRoutes']();}async['getAgentForModel'](_0x3cd3e5,_0x3bd863=0x0){const _0x45207c=a44_0xa20526,_0x16d2e9=extractModelAlias(_0x3cd3e5),_0x4ab5f3=resolveModelAlias(_0x16d2e9),_0x436705=_0x4ab5f3+'_'+_0x3bd863;let _0x4a8a3f=this[_0x45207c(0x169)][_0x45207c(0x21c)](_0x436705);if(!_0x4a8a3f){this[_0x45207c(0x192)]['debug'](_0x45207c(0x178)+_0x3cd3e5+_0x45207c(0x1d6)+_0x16d2e9+_0x45207c(0x1d6)+_0x4ab5f3),this['logger'][_0x45207c(0x1a2)](_0x45207c(0x17a)+_0x4ab5f3+_0x45207c(0x212)+_0x3bd863+')');const _0x2e0ac6=await this[_0x45207c(0x18f)][_0x45207c(0x198)][_0x45207c(0x1a7)][_0x45207c(0x1ad)](_0x4ab5f3,_0x3bd863);_0x4a8a3f=_0x2e0ac6['id'],this['agentCache'][_0x45207c(0x1a6)](_0x436705,_0x4a8a3f),this[_0x45207c(0x192)][_0x45207c(0x1a2)](_0x45207c(0x166)+_0x436705+_0x45207c(0x1d6)+_0x4a8a3f+'\x20('+_0x2e0ac6[_0x45207c(0x21f)][_0x45207c(0x1ca)]+')');}return _0x4a8a3f;}[a44_0xa20526(0x180)](){const _0x37604f=a44_0xa20526;this[_0x37604f(0x170)][_0x37604f(0x180)]();}[a44_0xa20526(0x191)](){const _0x172d8a=a44_0xa20526;this['server'][_0x172d8a(0x1c4)](a44_0x1929df,{'origin':!![],'methods':[_0x172d8a(0x203),'POST',_0x172d8a(0x1a0)],'allowedHeaders':[_0x172d8a(0x1a8),_0x172d8a(0x18d),'anthropic-version',_0x172d8a(0x16a)]}),this['server'][_0x172d8a(0x1a3)]((_0x2f259a,_0x15863a,_0x1c390e)=>{const _0xb51eb9=_0x172d8a,_0x4e40f8=_0x2f259a instanceof Error?_0x2f259a[_0xb51eb9(0x1de)]:_0xb51eb9(0x1ff);this[_0xb51eb9(0x192)]['error'](_0xb51eb9(0x1bb)+_0x15863a[_0xb51eb9(0x1ab)]+'\x20'+_0x15863a[_0xb51eb9(0x1e9)]+':',_0x2f259a),_0x1c390e[_0xb51eb9(0x19b)](0x1f4)[_0xb51eb9(0x19d)]({'type':_0xb51eb9(0x1ed),'error':{'type':_0xb51eb9(0x21e),'message':_0x4e40f8}});});}[a44_0xa20526(0x1a4)](_0x626e79,_0x1b0f71,_0x16a4b0){const _0xaa2cdf=a44_0xa20526,_0xb750f6=_0x1b0f71 instanceof Error?_0x1b0f71['message']:_0xaa2cdf(0x1ff);this['logger']['error'](_0xaa2cdf(0x16b)+_0x626e79+':',_0x1b0f71),!_0x16a4b0[_0xaa2cdf(0x1d3)]&&_0x16a4b0['code'](0x1f4)['send']({'type':_0xaa2cdf(0x1ed),'error':{'type':_0xaa2cdf(0x21e),'message':_0xb750f6}});}[a44_0xa20526(0x173)](){const _0x242c2c=a44_0xa20526;this[_0x242c2c(0x171)][_0x242c2c(0x21c)](_0x242c2c(0x18e),async()=>{return{'status':'ok','message':'TD\x20LLM\x20Proxy\x20Server'};}),this['server'][_0x242c2c(0x1f8)](_0x242c2c(0x185),async(_0x36d3d0,_0x3409de)=>{const _0x2f2f69=_0x242c2c;return this[_0x2f2f69(0x189)](_0x36d3d0,_0x3409de)[_0x2f2f69(0x1cf)](_0x2e66ed=>{const _0x147c66=_0x2f2f69;this[_0x147c66(0x1a4)](_0x147c66(0x185),_0x2e66ed,_0x3409de);});}),this[_0x242c2c(0x171)][_0x242c2c(0x1f8)](_0x242c2c(0x1dc),async(_0x2d6cc1,_0x405dfe)=>{const _0x321ec7=_0x242c2c;return this[_0x321ec7(0x1ee)](_0x2d6cc1)[_0x321ec7(0x1cf)](_0x5ba0b2=>{const _0x2ce0bb=_0x321ec7;this[_0x2ce0bb(0x1a4)](_0x2ce0bb(0x1dc),_0x5ba0b2,_0x405dfe);});});}async['handleMessages'](_0x521db3,_0x1642a7){const _0x1b66f5=a44_0xa20526,_0x5a8300=_0x521db3[_0x1b66f5(0x1fb)];if(!_0x5a8300[_0x1b66f5(0x1e1)]||!Array[_0x1b66f5(0x1d5)](_0x5a8300[_0x1b66f5(0x1e1)])||_0x5a8300[_0x1b66f5(0x1e1)][_0x1b66f5(0x17c)]===0x0){this[_0x1b66f5(0x192)]['error']('[PROXY\x20ERROR]\x20Validation\x20failed:\x20messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty'),_0x1642a7[_0x1b66f5(0x19b)](0x190)[_0x1b66f5(0x19d)]({'type':_0x1b66f5(0x1ed),'error':{'type':_0x1b66f5(0x1ce),'message':_0x1b66f5(0x186)}});return;}if(_0x5a8300[_0x1b66f5(0x17f)]&&!Array[_0x1b66f5(0x1d5)](_0x5a8300[_0x1b66f5(0x17f)])){this[_0x1b66f5(0x192)][_0x1b66f5(0x1ed)]('[PROXY\x20ERROR]\x20Validation\x20failed:\x20tools\x20must\x20be\x20an\x20array\x20if\x20provided'),_0x1642a7['code'](0x190)[_0x1b66f5(0x19d)]({'type':_0x1b66f5(0x1ed),'error':{'type':'invalid_request_error','message':_0x1b66f5(0x194)}});return;}const _0x281828=_0x5a8300[_0x1b66f5(0x1e1)]?.[_0x1b66f5(0x17c)]??0x0,_0x433724=_0x5a8300[_0x1b66f5(0x1d0)]||_0x1b66f5(0x197);this[_0x1b66f5(0x192)][_0x1b66f5(0x1fa)](_0x521db3[_0x1b66f5(0x1ab)]+'\x20'+_0x521db3[_0x1b66f5(0x1e9)]+_0x1b66f5(0x17d)+_0x281828+_0x1b66f5(0x1d1)+_0x433724),this[_0x1b66f5(0x192)]['debug'](_0x1b66f5(0x1f4)+colorizeJSONCompact(_0x521db3[_0x1b66f5(0x1d2)]));this[_0x1b66f5(0x192)][_0x1b66f5(0x1fc)]&&this[_0x1b66f5(0x192)]['trace'](colorizeJSON(_0x5a8300,{'color':!![]}));const _0x45257b=_0x5a8300['metadata']?.['user_id']||_0x1b66f5(0x1a5),_0x4f4bf1=this[_0x1b66f5(0x18f)][_0x1b66f5(0x20a)];if(!_0x4f4bf1){this[_0x1b66f5(0x192)]['error'](_0x1b66f5(0x196)),_0x1642a7[_0x1b66f5(0x19b)](0x1f4)[_0x1b66f5(0x19d)]({'type':_0x1b66f5(0x1ed),'error':{'type':'api_error','message':_0x1b66f5(0x179)}});return;}const _0x212d9=this['sessionCache'][_0x1b66f5(0x1c8)](_0x45257b,_0x4f4bf1),_0x27ac05=[];if(_0x5a8300[_0x1b66f5(0x193)]){if(typeof _0x5a8300[_0x1b66f5(0x193)]==='string')_0x27ac05['push'](_0x5a8300[_0x1b66f5(0x193)]);else{if(Array[_0x1b66f5(0x1d5)](_0x5a8300[_0x1b66f5(0x193)]))for(const _0x5c871c of _0x5a8300[_0x1b66f5(0x193)]){_0x5c871c['type']===_0x1b66f5(0x1eb)&&_0x5c871c[_0x1b66f5(0x1eb)]&&_0x27ac05[_0x1b66f5(0x1b8)](_0x5c871c[_0x1b66f5(0x1eb)]);}}}const _0x5f90dc=_0x5a8300[_0x1b66f5(0x17f)]||[],_0x46f8e0=_0x5a8300['thinking']?.[_0x1b66f5(0x1e0)],_0x516238=mapBudgetTokensToReasoningEffort(_0x46f8e0,this['config'][_0x1b66f5(0x1d9)]),_0x3d240a=calculateContextSignature(_0x5a8300[_0x1b66f5(0x1d0)],_0x27ac05,_0x5f90dc,_0x516238);let _0xd82fcf=_0x212d9[_0x1b66f5(0x209)][_0x1b66f5(0x21c)](_0x3d240a);const _0x5b051d=!_0xd82fcf;if(!_0xd82fcf){const _0x1d498a=await this[_0x1b66f5(0x1b5)](_0x5a8300[_0x1b66f5(0x1d0)],_0x516238);_0xd82fcf={'chatId':'','agentId':_0x1d498a,'contextSignature':_0x3d240a,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'messageHistory':[],'lastUsedAt':Date[_0x1b66f5(0x20c)]()},_0x212d9['chats']['set'](_0x3d240a,_0xd82fcf);if(_0x212d9[_0x1b66f5(0x209)]['size']>MAX_CHATS_PER_SESSION){let _0x275762=null,_0x59108e=Date[_0x1b66f5(0x20c)]();for(const [_0x5edeaf,_0x22e723]of _0x212d9[_0x1b66f5(0x209)]){_0x22e723[_0x1b66f5(0x1dd)]<_0x59108e&&(_0x59108e=_0x22e723[_0x1b66f5(0x1dd)],_0x275762=_0x5edeaf);}_0x275762&&(_0x212d9[_0x1b66f5(0x209)][_0x1b66f5(0x183)](_0x275762),this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)]('Evicted\x20oldest\x20chat\x20(signature:\x20'+_0x275762+_0x1b66f5(0x220)+MAX_CHATS_PER_SESSION+'\x20limit'));}}else _0xd82fcf[_0x1b66f5(0x1dd)]=Date['now']();if(!_0xd82fcf['chatId']){if(_0xd82fcf['creating']&&_0xd82fcf[_0x1b66f5(0x19e)]){this[_0x1b66f5(0x192)]['debug'](_0x1b66f5(0x1ea)+_0x3d240a);try{_0xd82fcf[_0x1b66f5(0x1b1)]=await _0xd82fcf[_0x1b66f5(0x19e)];}catch(_0x45869a){this['logger'][_0x1b66f5(0x1ed)](_0x1b66f5(0x184),_0x45869a);}}else{if(!_0xd82fcf['creating']){_0xd82fcf['creating']=!![],_0xd82fcf[_0x1b66f5(0x19e)]=((async()=>{const _0x362d81=_0x1b66f5;try{const _0x1312cb=await this[_0x362d81(0x18f)]['tdx'][_0x362d81(0x1a7)][_0x362d81(0x20e)](_0xd82fcf[_0x362d81(0x1c2)]);return this[_0x362d81(0x192)][_0x362d81(0x1fa)]('['+_0x1312cb['id']+_0x362d81(0x1f1)+_0x5a8300[_0x362d81(0x1d0)]+_0x362d81(0x1fd)+_0x3d240a),_0x1312cb['id'];}catch(_0x1d6bc0){this[_0x362d81(0x192)][_0x362d81(0x1ed)](_0x362d81(0x21b),_0x1d6bc0);throw _0x1d6bc0;}finally{_0xd82fcf['creating']=![],_0xd82fcf[_0x362d81(0x19e)]=undefined;}})());try{_0xd82fcf['chatId']=await _0xd82fcf[_0x1b66f5(0x19e)];}catch{}}}}const _0x8ea13=_0x27ac05[_0x1b66f5(0x1d8)](_0x3b1a12=>!_0xd82fcf[_0x1b66f5(0x1b3)][_0x1b66f5(0x19a)](_0x3b1a12)),_0x2bdf3c=_0x5f90dc[_0x1b66f5(0x1d8)](_0x27b9fe=>!_0xd82fcf['embeddedToolsByName'][_0x1b66f5(0x19a)](_0x27b9fe['name']));this['logger'][_0x1b66f5(0x1a2)]('[session:\x20'+_0x45257b+_0x1b66f5(0x1af)+_0x5a8300[_0x1b66f5(0x1d0)]+_0x1b66f5(0x1a1)+_0x3d240a+_0x1b66f5(0x1f3)+_0x5b051d),this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x181)+_0xd82fcf[_0x1b66f5(0x1b1)]),this['logger']['debug'](_0x1b66f5(0x1bd)+_0x27ac05['length']+',\x20tools:\x20'+_0x5f90dc['length']),this[_0x1b66f5(0x192)]['debug'](_0x1b66f5(0x1e3)+_0xd82fcf[_0x1b66f5(0x1b3)]['size']+',\x20tools:\x20'+_0xd82fcf[_0x1b66f5(0x20b)]['size']),this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x163)+_0x8ea13[_0x1b66f5(0x17c)]+_0x1b66f5(0x221)+_0x2bdf3c[_0x1b66f5(0x17c)]);_0x8ea13[_0x1b66f5(0x17c)]>0x0&&this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x1e4),_0x8ea13['map'](_0x5133ad=>_0x5133ad[_0x1b66f5(0x1b2)](0x0,0x32)+'...')['join'](_0x1b66f5(0x1ba)));_0x2bdf3c[_0x1b66f5(0x17c)]>0x0&&this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)]('Added\x20tool\x20names:',_0x2bdf3c[_0x1b66f5(0x1c5)](_0x505786=>_0x505786[_0x1b66f5(0x1ca)])[_0x1b66f5(0x16d)](',\x20'));const _0x3aeeae=_0xd82fcf['messageHistory'][_0x1b66f5(0x17c)],_0x566e98=_0x5a8300[_0x1b66f5(0x1e1)][_0x1b66f5(0x165)](_0x3aeeae);let _0x4a8820=_0x566e98[_0x1b66f5(0x1d8)](_0xddc9f5=>_0xddc9f5['role']==='user')[_0x1b66f5(0x1c6)]();if(!_0x4a8820){_0x4a8820=_0x5a8300['messages'][_0x1b66f5(0x1d8)](_0x1169d9=>_0x1169d9[_0x1b66f5(0x174)]==='user')['pop']();if(!_0x4a8820){this[_0x1b66f5(0x192)]['error']('[PROXY\x20ERROR]\x20Validation\x20failed:\x20No\x20user\x20message\x20found\x20in\x20request'),_0x1642a7[_0x1b66f5(0x19b)](0x190)[_0x1b66f5(0x19d)]({'type':_0x1b66f5(0x1ed),'error':{'type':_0x1b66f5(0x1ce),'message':_0x1b66f5(0x1f6)}});return;}}let _0x3bbc06;if(typeof _0x4a8820[_0x1b66f5(0x1c9)]===_0x1b66f5(0x1c3))_0x3bbc06=_0x4a8820[_0x1b66f5(0x1c9)];else{if(_0x4a8820[_0x1b66f5(0x1c9)]!=null&&Array['isArray'](_0x4a8820['content']))_0x3bbc06=_0x4a8820[_0x1b66f5(0x1c9)][_0x1b66f5(0x1d8)](_0x484236=>_0x484236&&_0x484236[_0x1b66f5(0x190)]===_0x1b66f5(0x1eb)&&_0x484236[_0x1b66f5(0x1eb)])[_0x1b66f5(0x1c5)](_0x14447b=>_0x14447b[_0x1b66f5(0x1eb)])[_0x1b66f5(0x16d)]('\x0a');else{this['logger'][_0x1b66f5(0x1ed)](_0x1b66f5(0x16f),typeof _0x4a8820[_0x1b66f5(0x1c9)],_0x4a8820[_0x1b66f5(0x1c9)]),_0x1642a7['code'](0x190)['send']({'type':_0x1b66f5(0x1ed),'error':{'type':_0x1b66f5(0x1ce),'message':'message.content\x20must\x20be\x20a\x20string\x20or\x20array'}});return;}}const _0x585b91=()=>{const _0x381e1d=_0x1b66f5,_0x435358=[];_0x27ac05[_0x381e1d(0x17c)]>0x0&&_0x435358[_0x381e1d(0x1b8)](_0x27ac05[_0x381e1d(0x16d)]('\x0a\x0a'));_0x5f90dc['length']>0x0&&_0x435358[_0x381e1d(0x1b8)](generateToolPrompt(_0x5f90dc));if(_0x5a8300[_0x381e1d(0x1e1)]&&_0x5a8300[_0x381e1d(0x1e1)][_0x381e1d(0x17c)]>0x1){const _0x44cb60=formatConversationHistory(_0x5a8300['messages']);_0x44cb60&&_0x435358[_0x381e1d(0x1b8)](_0x381e1d(0x1b7)+_0x44cb60+'\x0a</conversation>');}return _0x435358[_0x381e1d(0x1b8)](_0x381e1d(0x1ac)+_0x3bbc06),_0x435358[_0x381e1d(0x16d)](_0x381e1d(0x20d));};let _0x5521cb;if(_0x5b051d){this[_0x1b66f5(0x192)][_0x1b66f5(0x1fa)]('['+_0xd82fcf[_0x1b66f5(0x1b1)]+_0x1b66f5(0x200)+_0x5a8300[_0x1b66f5(0x1d0)]+_0x1b66f5(0x211)+_0x27ac05[_0x1b66f5(0x17c)]+_0x1b66f5(0x1da)+_0x5f90dc['length']+_0x1b66f5(0x167)+_0x5f90dc[_0x1b66f5(0x1c5)](_0x2b87d7=>_0x2b87d7['name'])[_0x1b66f5(0x16d)](',\x20')+']'),_0x5521cb=_0x585b91();for(const _0x28b81d of _0x27ac05){_0xd82fcf[_0x1b66f5(0x1b3)][_0x1b66f5(0x19f)](_0x28b81d);}for(const _0x2812e2 of _0x5f90dc){_0xd82fcf[_0x1b66f5(0x20b)][_0x1b66f5(0x1a6)](_0x2812e2[_0x1b66f5(0x1ca)],_0x2812e2);}}else{const _0x1c8a49=[];_0x8ea13[_0x1b66f5(0x17c)]>0x0&&(_0x1c8a49[_0x1b66f5(0x1b8)](_0x8ea13[_0x1b66f5(0x16d)]('\x0a\x0a')),this['logger'][_0x1b66f5(0x1a2)](_0x1b66f5(0x1cb),_0x8ea13['length'],'new\x20system\x20prompt(s)'));if(_0x2bdf3c[_0x1b66f5(0x17c)]>0x0)try{_0x1c8a49[_0x1b66f5(0x1b8)](generateToolPrompt(_0x2bdf3c)),this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x1cb),_0x2bdf3c[_0x1b66f5(0x17c)],'new\x20tool(s)');}catch(_0x4c82af){this[_0x1b66f5(0x192)][_0x1b66f5(0x1ed)](_0x1b66f5(0x1e7),_0x4c82af);}try{const _0x4204a5=extractToolResults(_0x566e98);_0x4204a5&&(_0x1c8a49[_0x1b66f5(0x1b8)](_0x4204a5),this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x1f7)));}catch(_0x3d6317){this[_0x1b66f5(0x192)][_0x1b66f5(0x1ed)](_0x1b66f5(0x1b0),_0x3d6317);}_0x1c8a49['push'](_0x3bbc06),_0x5521cb=_0x1c8a49[_0x1b66f5(0x17c)]>0x1?_0x1c8a49[_0x1b66f5(0x16d)](_0x1b66f5(0x20d)):_0x3bbc06;for(const _0x48fb9c of _0x8ea13){_0xd82fcf['embeddedSystemPrompts'][_0x1b66f5(0x19f)](_0x48fb9c);}for(const _0x1b6666 of _0x2bdf3c){_0xd82fcf[_0x1b66f5(0x20b)][_0x1b66f5(0x1a6)](_0x1b6666[_0x1b66f5(0x1ca)],_0x1b6666);}}(!_0x5521cb||!_0x5521cb[_0x1b66f5(0x177)]())&&(this[_0x1b66f5(0x192)][_0x1b66f5(0x18a)](_0x1b66f5(0x1db)),this[_0x1b66f5(0x192)][_0x1b66f5(0x18a)]('Context:',{'isNewContext':_0x5b051d,'userMessageLength':_0x3bbc06?.[_0x1b66f5(0x17c)]||0x0,'systemPromptsCount':_0x27ac05[_0x1b66f5(0x17c)],'toolsCount':_0x5f90dc['length'],'messagesCount':_0x5a8300[_0x1b66f5(0x1e1)]?.[_0x1b66f5(0x17c)]||0x0,'newMessagesCount':_0x566e98[_0x1b66f5(0x17c)]}),clearChatState(_0xd82fcf),_0x5521cb=_0x585b91(),(!_0x5521cb||!_0x5521cb[_0x1b66f5(0x177)]())&&(this[_0x1b66f5(0x192)][_0x1b66f5(0x1ed)]('Failed\x20to\x20reconstruct\x20message\x20-\x20all\x20parts\x20are\x20empty,\x20using\x20fallback'),this[_0x1b66f5(0x192)]['error'](_0x1b66f5(0x172),{'systemPromptsCount':_0x27ac05[_0x1b66f5(0x17c)],'toolsCount':_0x5f90dc['length'],'messagesCount':_0x5a8300['messages']?.[_0x1b66f5(0x17c)]||0x0,'userMessageLength':_0x3bbc06?.[_0x1b66f5(0x17c)]||0x0}),_0x5521cb=_0x1b66f5(0x1aa)),this[_0x1b66f5(0x192)][_0x1b66f5(0x1fa)]('Final\x20message\x20reconstructed\x20after\x20context\x20reset:',_0x5521cb[_0x1b66f5(0x1b2)](0x0,0x64)+'...'));const _0x43f0a5=_0x5a8300[_0x1b66f5(0x222)]!==![];if(_0x43f0a5){_0x1642a7[_0x1b66f5(0x1bf)][_0x1b66f5(0x1ef)](0xc8,{'Content-Type':_0x1b66f5(0x1e6),'Cache-Control':_0x1b66f5(0x1f0),'Connection':'keep-alive','X-Accel-Buffering':'no'});const _0x300b12=generateMessageId();try{if(_0xd82fcf['chatId']){const _0x1de763=_0x5521cb[_0x1b66f5(0x1b2)](0x0,0x32)[_0x1b66f5(0x219)](/\n/g,'\x20');this['logger'][_0x1b66f5(0x1fa)]('['+_0xd82fcf[_0x1b66f5(0x1b1)]+_0x1b66f5(0x175)+_0x5a8300[_0x1b66f5(0x1d0)]+',\x20context='+_0x3d240a+',\x20'+_0x5a8300[_0x1b66f5(0x1e1)]['length']+_0x1b66f5(0x1e8)+_0x27ac05[_0x1b66f5(0x17c)]+'\x20system\x20prompts,\x20'+_0x5f90dc[_0x1b66f5(0x17c)]+_0x1b66f5(0x208)+_0x5521cb[_0x1b66f5(0x17c)]+_0x1b66f5(0x1d4)+_0x1de763+_0x1b66f5(0x199));}const _0x5c7e88=this['config'][_0x1b66f5(0x198)]['llm'][_0x1b66f5(0x18c)](_0x5521cb,{'chatId':_0xd82fcf[_0x1b66f5(0x1b1)]||undefined,'agentId':_0xd82fcf[_0x1b66f5(0x1b1)]?undefined:_0xd82fcf[_0x1b66f5(0x1c2)]});if(!_0x5c7e88){this['logger'][_0x1b66f5(0x1ed)](_0x1b66f5(0x195)),this['logger'][_0x1b66f5(0x1ed)]('Context:',JSON[_0x1b66f5(0x201)]({'chatId':_0xd82fcf[_0x1b66f5(0x1b1)],'agentId':_0xd82fcf[_0x1b66f5(0x1c2)],'model':_0x5a8300[_0x1b66f5(0x1d0)],'sessionId':_0x45257b,'contextSignature':_0x3d240a})),_0xd82fcf['chatId']='',this[_0x1b66f5(0x192)][_0x1b66f5(0x18a)](_0x1b66f5(0x1c0));const _0x9b1305=formatAnthropicSSE({'type':_0x1b66f5(0x1ed),'error':{'type':_0x1b66f5(0x21e),'message':_0x1b66f5(0x187)},'request_id':_0x300b12});_0x1642a7[_0x1b66f5(0x1bf)]['write'](_0x9b1305),_0x1642a7[_0x1b66f5(0x1bf)][_0x1b66f5(0x1c7)]();return;}_0xd82fcf[_0x1b66f5(0x182)]=_0x5a8300[_0x1b66f5(0x1e1)];const _0x41ec45=_0xd82fcf;async function*_0x34750a(_0x52fccc){const _0x11a63f=_0x1b66f5;for await(const _0x1b2ead of _0x52fccc){if(_0x1b2ead[_0x11a63f(0x190)]===_0x11a63f(0x1b4))_0x1b2ead[_0x11a63f(0x1bc)][_0x11a63f(0x1b1)]&&!_0x41ec45[_0x11a63f(0x1b1)]&&(_0x41ec45[_0x11a63f(0x1b1)]=_0x1b2ead[_0x11a63f(0x1bc)][_0x11a63f(0x1b1)]);else _0x1b2ead[_0x11a63f(0x190)]===_0x11a63f(0x205)&&(yield _0x1b2ead[_0x11a63f(0x1bc)]);}}const _0x94522=_0x34750a(_0x5c7e88),_0xd93a21=estimateInputTokensFromRequest(_0x5a8300),_0x5a88b4=transformTDStreamToAnthropic(_0x94522,_0x300b12,_0x5a8300[_0x1b66f5(0x1d0)],this['logger'],_0x3bbc06,_0xd93a21),_0x35e065=_0x5521cb[_0x1b66f5(0x17c)];let _0x5451ab=0x0;for await(const _0x575614 of _0x5a88b4){const _0x2f53cb=formatAnthropicSSE(_0x575614);_0x5451ab++,this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](colorizeJSONCompact(_0x575614,{'color':!![]})),_0x575614[_0x1b66f5(0x190)]===_0x1b66f5(0x1ed)&&_0x575614[_0x1b66f5(0x1ed)][_0x1b66f5(0x190)]===_0x1b66f5(0x1cd)&&(clearChatState(_0xd82fcf),this[_0x1b66f5(0x192)]['warn'](_0x1b66f5(0x215)+_0x575614[_0x1b66f5(0x1ed)][_0x1b66f5(0x1de)]+_0x1b66f5(0x1d7)+_0x35e065+_0x1b66f5(0x204)+_0x45257b+_0x1b66f5(0x1e2)+_0x3d240a)),_0x1642a7['raw']['write'](_0x2f53cb);}this[_0x1b66f5(0x192)][_0x1b66f5(0x1a2)](_0x1b66f5(0x216)+_0x5451ab+_0x1b66f5(0x188)),_0x1642a7['raw']['end']();}catch(_0x80351){const _0x5cb0b9=_0x80351 instanceof Error?_0x80351[_0x1b66f5(0x1de)]:_0x1b66f5(0x1ff);this['logger'][_0x1b66f5(0x1ed)](_0x1b66f5(0x160),_0x80351),this[_0x1b66f5(0x192)]['error'](_0x1b66f5(0x213),JSON[_0x1b66f5(0x201)]({'chatId':_0xd82fcf[_0x1b66f5(0x1b1)],'agentId':_0xd82fcf[_0x1b66f5(0x1c2)],'model':_0x5a8300[_0x1b66f5(0x1d0)],'sessionId':_0x45257b,'contextSignature':_0x3d240a})),_0xd82fcf[_0x1b66f5(0x1b1)]='',this[_0x1b66f5(0x192)]['warn'](_0x1b66f5(0x202));const _0x3e1702=formatAnthropicSSE({'type':_0x1b66f5(0x1ed),'error':{'type':'api_error','message':_0x5cb0b9},'request_id':_0x300b12});_0x1642a7['raw'][_0x1b66f5(0x217)](_0x3e1702),_0x1642a7[_0x1b66f5(0x1bf)][_0x1b66f5(0x1c7)]();}}else this[_0x1b66f5(0x192)][_0x1b66f5(0x1ed)](_0x1b66f5(0x1b9)),_0x1642a7[_0x1b66f5(0x19b)](0x1f5)[_0x1b66f5(0x19d)]({'type':_0x1b66f5(0x1ed),'error':{'type':'not_supported_error','message':'Non-streaming\x20responses\x20are\x20not\x20yet\x20supported'}});}async[a44_0xa20526(0x1ee)](_0x3daf67){const _0x428c01=a44_0xa20526,_0x46a946=_0x3daf67[_0x428c01(0x1fb)],_0x5d96a5=estimateInputTokensFromRequest(_0x46a946);return this[_0x428c01(0x192)][_0x428c01(0x1fa)](_0x3daf67[_0x428c01(0x1ab)]+'\x20'+_0x3daf67['url']+_0x428c01(0x17e)+_0x5d96a5),{'input_tokens':_0x5d96a5};}async[a44_0xa20526(0x218)](){const _0x5c76c8=a44_0xa20526;try{await this[_0x5c76c8(0x171)]['listen']({'port':this['config']['port'],'host':'0.0.0.0'}),this[_0x5c76c8(0x192)][_0x5c76c8(0x1fa)](_0x5c76c8(0x17b)+this[_0x5c76c8(0x18f)][_0x5c76c8(0x1b6)]),this[_0x5c76c8(0x1ec)]=setInterval(()=>{const _0x4c37a4=_0x5c76c8;this[_0x4c37a4(0x180)]();},CLEANUP_INTERVAL_MS),this[_0x5c76c8(0x192)]['debug'](_0x5c76c8(0x176)+CLEANUP_INTERVAL_MS/0x3e8+'s,\x20expires\x20after\x20'+CACHE_EXPIRATION_MS/0x3e8+'s)');}catch(_0x4c2b78){const _0x12dc7b=_0x4c2b78 instanceof Error?_0x4c2b78['message']:_0x5c76c8(0x1ff);throw new Error('Failed\x20to\x20start\x20proxy\x20server:\x20'+_0x12dc7b);}}async['stop'](){const _0x191256=a44_0xa20526;this[_0x191256(0x1ec)]&&(clearInterval(this[_0x191256(0x1ec)]),this[_0x191256(0x1ec)]=undefined),await this[_0x191256(0x171)]['close']();}[a44_0xa20526(0x21a)](){const _0x3e3501=a44_0xa20526,_0x31d636=this['server']['server'][_0x3e3501(0x1df)]();if(typeof _0x31d636===_0x3e3501(0x1c3))return _0x31d636;if(_0x31d636)return'http://'+_0x31d636[_0x3e3501(0x1df)]+':'+_0x31d636['port'];return _0x3e3501(0x1a9)+this[_0x3e3501(0x18f)][_0x3e3501(0x1b6)];}}
1
+ const a44_0x5bf55d=a44_0x4737;(function(_0x2396e0,_0x292fc0){const _0x1e1b90=a44_0x4737,_0x4f9513=_0x2396e0();while(!![]){try{const _0x1cca98=parseInt(_0x1e1b90(0x22e))/0x1+parseInt(_0x1e1b90(0x203))/0x2*(parseInt(_0x1e1b90(0x1db))/0x3)+-parseInt(_0x1e1b90(0x267))/0x4*(-parseInt(_0x1e1b90(0x1e2))/0x5)+parseInt(_0x1e1b90(0x221))/0x6*(parseInt(_0x1e1b90(0x263))/0x7)+-parseInt(_0x1e1b90(0x1b8))/0x8+-parseInt(_0x1e1b90(0x257))/0x9*(parseInt(_0x1e1b90(0x1de))/0xa)+-parseInt(_0x1e1b90(0x208))/0xb;if(_0x1cca98===_0x292fc0)break;else _0x4f9513['push'](_0x4f9513['shift']());}catch(_0x56567c){_0x4f9513['push'](_0x4f9513['shift']());}}}(a44_0x3694,0x8fe7f));import a44_0x3ecde8 from'fastify';import a44_0x2c1c2d from'@fastify/cors';import{createHash}from'crypto';function a44_0x3694(){const _0xb178e4=['embeddedSystemPrompts','setupRoutes','site','config','getAgentForModel','input_schema','invalid_request_error','stringify','api_error','171llwCcn','\x20SSE\x20events.','push','Final\x20message\x20is\x20empty\x20after\x20construction\x20-\x20starting\x20fresh\x20conversation','getOrCreateSession','cleanupExpiredChats','[PROXY\x20ERROR]\x20Validation\x20failed:\x20No\x20user\x20message\x20found\x20in\x20request','length','\x20Input\x20size:\x20','warn','properties','[PROXY\x20ERROR]\x20Uncaught\x20error\x20in\x20','70jvTQiP',',\x20tools:\x20','Waiting\x20for\x20concurrent\x20chat\x20creation\x20for\x20context:\x20','role','4XZmgLo','url','Agent\x20cached:\x20','raw','agentId','POST','\x20->\x20','Context:','Including\x20tool\x20results','\x20limit',']\x20model:\x20','/v1/messages/count_tokens','method','error','slice','[PROXY\x20ERROR]\x20Streaming\x20error:','[PROXY\x20ERROR]\x20Configuration\x20error:\x20Project\x20ID\x20must\x20be\x20configured','post','Creating/looking\x20up\x20agent\x20for:\x20','type','sessionCache','attributes','9359056BJQrxM','pop','messageHistory','Added\x20tool\x20names:','tools\x20must\x20be\x20an\x20array\x20if\x20provided','/health','Reset\x20chat\x20ID\x20to\x20recover\x20on\x20next\x20request','end','[PROXY\x20ERROR]\x20Chat\x20stream\x20is\x20undefined','sha256','set','chat','map','sent','stop','OPTIONS','\x20chars.\x20Cleared\x20chat\x20state\x20for\x20session\x20','Chat\x20ID:\x20','handleRouteError','TD\x20LLM\x20Proxy\x20Server','Concurrent\x20chat\x20creation\x20failed,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','Failed\x20to\x20initialize\x20chat\x20stream.\x20Please\x20try\x20again.','http://localhost:',']\x20Created\x20new\x20chat\x20for\x20model\x20','body','System\x20prompts:\x20','stream','Failed\x20to\x20create\x20chat,\x20will\x20fall\x20back\x20to\x20lazy\x20creation:','Added\x20system\x20prompt\x20previews:','unknown','header:\x20','[session:\x20','handleCountTokens','...\x22','join','2928rANogk','new\x20system\x20prompt(s)','messages','266000ZhupRC',',\x20tool_names=[','no-cache','code','2096665OKLVeF','\x20messages,\x20','[PROXY\x20ERROR]\x20Validation\x20failed:\x20message.content\x20must\x20be\x20a\x20string\x20or\x20array,\x20got:','http://','llm','now','chats','not_supported_error','Project\x20ID\x20must\x20be\x20configured','Non-streaming\x20responses\x20are\x20not\x20yet\x20supported','Embedding','cleanupInterval','chatId','GET','add','tdx',']\x20Building\x20a\x20new\x20context\x20for\x20model\x20','setupMiddleware','data','Unknown\x20error','address','register','[CONTEXT\x20LENGTH\x20ERROR]\x20','close','info','embeddedToolsByName','lastUsedAt','x-api-key','user_id','\x20system\x20prompts,\x20',',\x20model=','logger','catch','1186ZWTfMh','string','Embedded\x20in\x20chat\x20-\x20system\x20prompts:\x20',',\x20context=','trim','612711maVavP','isArray','server','handleMessages','size','agentCache','clear','Final\x20message\x20reconstructed\x20after\x20context\x20reset:','\x20|\x20','anthropic-version','tools','message','text','projectId','[Previous\x20conversation]\x0a\x0a<conversation>\x0a','/v1/messages','[PROXY\x20ERROR]\x20Non-streaming\x20responses\x20are\x20not\x20yet\x20supported','No\x20user\x20message\x20found\x20in\x20request','headers','send',',\x20tools=','keep-alive','continue','writeHead',',\x20is\x20new\x20context:\x20','499722zSxYxo','model','Failed\x20to\x20extract\x20tool\x20results:','keys','getAddress','[PROXY\x20ERROR]\x20Validation\x20failed:\x20tools\x20must\x20be\x20an\x20array\x20if\x20provided','\x0a---\x0a\x0a','dev-us01','0.0.0.0','New\x20-\x20system\x20prompts:\x20','messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','message.content\x20must\x20be\x20a\x20string\x20or\x20array','trace','489451FWBGsW','Failed\x20to\x20generate\x20tool\x20prompt:','debug','system','required','setErrorHandler','text/event-stream','metadata','Reset\x20chat\x20state\x20to\x20recover\x20on\x20next\x20request','User','sort','port',':\x20messages=','listen','name','localeCompare','filter','substring','getOrCreateDefaultAgent','has','createPromise','\x20(reasoning:\x20','creating','...','default','event','write','\x20tools,\x20message_size=','content','[PROXY\x20ERROR]\x20Validation\x20failed:\x20messages\x20array\x20is\x20required\x20and\x20must\x20not\x20be\x20empty','Debug\x20info:','[Current\x20message]\x0a\x0a'];a44_0x3694=function(){return _0xb178e4;};return a44_0x3694();}import{transformTDStreamToAnthropic,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(_0x2ecf7d){const _0x541392=a44_0x4737;if(!_0x2ecf7d||!Array[_0x541392(0x209)](_0x2ecf7d))return'';return _0x2ecf7d[_0x541392(0x23e)](_0x506e2e=>_0x506e2e!=null)['map'](_0x4832ce=>{const _0x5c5cb1=_0x541392,_0x4701de=_0x4832ce[_0x5c5cb1(0x24a)]!=null&&Array['isArray'](_0x4832ce[_0x5c5cb1(0x24a)])?_0x4832ce[_0x5c5cb1(0x24a)][_0x5c5cb1(0x23e)](_0x56dd73=>_0x56dd73&&_0x56dd73[_0x5c5cb1(0x1b5)]==='text')['map'](_0x36a5ce=>_0x36a5ce[_0x5c5cb1(0x214)])['join']('\x0a'):_0x4832ce['content']||'',_0x3f16d0=_0x4832ce[_0x5c5cb1(0x266)]==='user'?_0x5c5cb1(0x237):'Assistant';return _0x3f16d0+':\x20'+_0x4701de;})[_0x541392(0x1da)]('\x0a\x0a');}function calculateContextSignature(_0x270541,_0x1dc370,_0x202a28,_0x55c6da){const _0x4631ac=a44_0x4737,_0x10a2c0=extractModelAlias(_0x270541),_0x5b9cdb=resolveModelAlias(_0x10a2c0),_0x4933c2=[..._0x1dc370||[]][_0x4631ac(0x238)](),_0x110a67=(_0x202a28||[])[_0x4631ac(0x23e)](_0x2612a3=>_0x2612a3!=null)[_0x4631ac(0x1c4)](_0x39f2df=>({'name':_0x39f2df[_0x4631ac(0x23c)],'params':Object[_0x4631ac(0x224)](_0x39f2df[_0x4631ac(0x253)]?.[_0x4631ac(0x261)]||{})[_0x4631ac(0x238)](),'required':(_0x39f2df[_0x4631ac(0x253)]?.[_0x4631ac(0x232)]||[])[_0x4631ac(0x238)]()}))['sort']((_0x12e8bd,_0x1ba018)=>_0x12e8bd[_0x4631ac(0x23c)][_0x4631ac(0x23d)](_0x1ba018[_0x4631ac(0x23c)])),_0x564142=JSON['stringify']({'model':_0x5b9cdb,'prompts':_0x4933c2,'tools':_0x110a67,'reasoning':_0x55c6da});return createHash(_0x4631ac(0x1c1))['update'](_0x564142)['digest']('hex')[_0x4631ac(0x23f)](0x0,0x10);}function a44_0x4737(_0x5d6e2a,_0x4ba18b){const _0x3694e5=a44_0x3694();return a44_0x4737=function(_0x4737f4,_0x1d3a9b){_0x4737f4=_0x4737f4-0x1a5;let _0x2453a3=_0x3694e5[_0x4737f4];return _0x2453a3;},a44_0x4737(_0x5d6e2a,_0x4ba18b);}function clearChatState(_0x3792bc){const _0x5cde92=a44_0x4737;_0x3792bc[_0x5cde92(0x1ee)]='',_0x3792bc[_0x5cde92(0x24e)][_0x5cde92(0x20e)](),_0x3792bc['embeddedToolsByName'][_0x5cde92(0x20e)]();}function mapBudgetTokensToReasoningEffort(_0x348c84,_0x309559){const _0x1c92c2=a44_0x4737;if(_0x309559!==_0x1c92c2(0x228))return 0x0;if(!_0x348c84||_0x348c84===0x0)return 0x0;if(_0x348c84<=0x400)return 0x1;if(_0x348c84<=0x800)return 0x2;if(_0x348c84<=0x1000)return 0x3;return 0x4;}const MAX_CHATS_PER_SESSION=0xa,CACHE_EXPIRATION_MS=0xa*0x3c*0x3e8,CLEANUP_INTERVAL_MS=0x3c*0x3e8;export class ProxyServer{['server'];[a44_0x5bf55d(0x1b6)];[a44_0x5bf55d(0x20d)];[a44_0x5bf55d(0x251)];[a44_0x5bf55d(0x1ed)];['logger'];constructor(_0xc3c7bb){const _0x540fbb=a44_0x5bf55d;this[_0x540fbb(0x201)]=_0xc3c7bb[_0x540fbb(0x201)],this['config']=_0xc3c7bb,this['sessionCache']=new SessionCache({'maxChatsPerSession':MAX_CHATS_PER_SESSION,'cacheExpirationMs':CACHE_EXPIRATION_MS}),this[_0x540fbb(0x20d)]=new Map(),this[_0x540fbb(0x20a)]=a44_0x3ecde8({'logger':![],'bodyLimit':0x40*0x400*0x400}),this[_0x540fbb(0x1f3)](),this[_0x540fbb(0x24f)]();}async[a44_0x5bf55d(0x252)](_0x1b72fd,_0x1af8fc=0x0){const _0x5ee546=a44_0x5bf55d,_0x2805f5=extractModelAlias(_0x1b72fd),_0xee5b02=resolveModelAlias(_0x2805f5),_0x4a37a8=_0xee5b02+'_'+_0x1af8fc;let _0x1d05c8=this[_0x5ee546(0x20d)]['get'](_0x4a37a8);if(!_0x1d05c8){this[_0x5ee546(0x201)]['debug']('Model\x20normalization:\x20'+_0x1b72fd+_0x5ee546(0x1a8)+_0x2805f5+_0x5ee546(0x1a8)+_0xee5b02),this[_0x5ee546(0x201)]['debug'](_0x5ee546(0x1b4)+_0xee5b02+_0x5ee546(0x243)+_0x1af8fc+')');const _0xfeb24b=await this[_0x5ee546(0x251)][_0x5ee546(0x1f1)][_0x5ee546(0x1e6)][_0x5ee546(0x240)](_0xee5b02,_0x1af8fc);_0x1d05c8=_0xfeb24b['id'],this[_0x5ee546(0x20d)]['set'](_0x4a37a8,_0x1d05c8),this['logger']['debug'](_0x5ee546(0x269)+_0x4a37a8+_0x5ee546(0x1a8)+_0x1d05c8+'\x20('+_0xfeb24b[_0x5ee546(0x1b7)][_0x5ee546(0x23c)]+')');}return _0x1d05c8;}[a44_0x5bf55d(0x25c)](){const _0x48a507=a44_0x5bf55d;this['sessionCache'][_0x48a507(0x25c)]();}[a44_0x5bf55d(0x1f3)](){const _0x3af429=a44_0x5bf55d;this[_0x3af429(0x20a)][_0x3af429(0x1f7)](a44_0x2c1c2d,{'origin':!![],'methods':[_0x3af429(0x1ef),_0x3af429(0x1a7),_0x3af429(0x1c7)],'allowedHeaders':['Content-Type','Authorization',_0x3af429(0x211),_0x3af429(0x1fd)]}),this['server'][_0x3af429(0x233)]((_0x2211e8,_0x58a0d9,_0x3d3d87)=>{const _0x2e7e83=_0x3af429,_0x10db87=_0x2211e8 instanceof Error?_0x2211e8['message']:'Unknown\x20error';this[_0x2e7e83(0x201)][_0x2e7e83(0x1af)]('[PROXY\x20ERROR]\x20Unhandled\x20error\x20in\x20'+_0x58a0d9[_0x2e7e83(0x1ae)]+'\x20'+_0x58a0d9[_0x2e7e83(0x268)]+':',_0x2211e8),_0x3d3d87[_0x2e7e83(0x1e1)](0x1f4)[_0x2e7e83(0x21b)]({'type':_0x2e7e83(0x1af),'error':{'type':_0x2e7e83(0x256),'message':_0x10db87}});});}[a44_0x5bf55d(0x1ca)](_0x1683f1,_0x26b4ba,_0x29cb31){const _0x18c8a3=a44_0x5bf55d,_0x492643=_0x26b4ba instanceof Error?_0x26b4ba[_0x18c8a3(0x213)]:_0x18c8a3(0x1f5);this[_0x18c8a3(0x201)]['error'](_0x18c8a3(0x262)+_0x1683f1+':',_0x26b4ba),!_0x29cb31[_0x18c8a3(0x1c5)]&&_0x29cb31[_0x18c8a3(0x1e1)](0x1f4)['send']({'type':'error','error':{'type':_0x18c8a3(0x256),'message':_0x492643}});}[a44_0x5bf55d(0x24f)](){const _0x2eaa85=a44_0x5bf55d;this[_0x2eaa85(0x20a)]['get'](_0x2eaa85(0x1bd),async()=>{const _0x2a00dc=_0x2eaa85;return{'status':'ok','message':_0x2a00dc(0x1cb)};}),this[_0x2eaa85(0x20a)][_0x2eaa85(0x1b3)]('/v1/messages',async(_0x4d8ab1,_0x933889)=>{const _0x1309a8=_0x2eaa85;return this[_0x1309a8(0x20b)](_0x4d8ab1,_0x933889)[_0x1309a8(0x202)](_0xc0e42c=>{const _0x5635c=_0x1309a8;this['handleRouteError'](_0x5635c(0x217),_0xc0e42c,_0x933889);});}),this['server']['post'](_0x2eaa85(0x1ad),async(_0x3b0d04,_0x51a77b)=>{const _0x184b8e=_0x2eaa85;return this[_0x184b8e(0x1d8)](_0x3b0d04)[_0x184b8e(0x202)](_0x24a6f9=>{const _0x586a85=_0x184b8e;this[_0x586a85(0x1ca)](_0x586a85(0x1ad),_0x24a6f9,_0x51a77b);});});}async['handleMessages'](_0x56826b,_0x3a98f0){const _0x674f7=a44_0x5bf55d,_0x4db582=_0x56826b[_0x674f7(0x1d0)];if(!_0x4db582['messages']||!Array[_0x674f7(0x209)](_0x4db582[_0x674f7(0x1dd)])||_0x4db582['messages'][_0x674f7(0x25e)]===0x0){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x24b)),_0x3a98f0[_0x674f7(0x1e1)](0x190)['send']({'type':_0x674f7(0x1af),'error':{'type':_0x674f7(0x254),'message':_0x674f7(0x22b)}});return;}if(_0x4db582[_0x674f7(0x212)]&&!Array['isArray'](_0x4db582[_0x674f7(0x212)])){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x226)),_0x3a98f0[_0x674f7(0x1e1)](0x190)['send']({'type':_0x674f7(0x1af),'error':{'type':'invalid_request_error','message':_0x674f7(0x1bc)}});return;}const _0x2ffb49=_0x4db582[_0x674f7(0x1dd)]?.[_0x674f7(0x25e)]??0x0,_0x34bfc1=_0x4db582['model']||_0x674f7(0x1d5);this[_0x674f7(0x201)][_0x674f7(0x1fa)](_0x56826b[_0x674f7(0x1ae)]+'\x20'+_0x56826b[_0x674f7(0x268)]+_0x674f7(0x23a)+_0x2ffb49+_0x674f7(0x200)+_0x34bfc1),this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1d6)+colorizeJSONCompact(_0x56826b[_0x674f7(0x21a)]));this[_0x674f7(0x201)][_0x674f7(0x22d)]&&this[_0x674f7(0x201)]['trace'](colorizeJSON(_0x4db582,{'color':!![]}));const _0x2a25f9=_0x4db582['metadata']?.[_0x674f7(0x1fe)]||_0x674f7(0x246),_0x5ef9ff=this[_0x674f7(0x251)][_0x674f7(0x215)];if(!_0x5ef9ff){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x1b2)),_0x3a98f0[_0x674f7(0x1e1)](0x1f4)['send']({'type':_0x674f7(0x1af),'error':{'type':_0x674f7(0x256),'message':_0x674f7(0x1ea)}});return;}const _0x3674bd=this['sessionCache'][_0x674f7(0x25b)](_0x2a25f9,_0x5ef9ff),_0x4b40ef=[];if(_0x4db582['system']){if(typeof _0x4db582[_0x674f7(0x231)]==='string')_0x4b40ef['push'](_0x4db582[_0x674f7(0x231)]);else{if(Array['isArray'](_0x4db582[_0x674f7(0x231)]))for(const _0x2d1292 of _0x4db582['system']){_0x2d1292[_0x674f7(0x1b5)]==='text'&&_0x2d1292[_0x674f7(0x214)]&&_0x4b40ef[_0x674f7(0x259)](_0x2d1292[_0x674f7(0x214)]);}}}const _0x10b556=_0x4db582[_0x674f7(0x212)]||[],_0x4568df=_0x4db582['thinking']?.['budget_tokens'],_0x241f9a=mapBudgetTokensToReasoningEffort(_0x4568df,this['config'][_0x674f7(0x250)]),_0x3d2f23=calculateContextSignature(_0x4db582[_0x674f7(0x222)],_0x4b40ef,_0x10b556,_0x241f9a);let _0x2fc4e0=_0x3674bd[_0x674f7(0x1e8)]['get'](_0x3d2f23);const _0x2a201f=!_0x2fc4e0;if(!_0x2fc4e0){const _0x3367ee=await this[_0x674f7(0x252)](_0x4db582['model'],_0x241f9a);_0x2fc4e0={'chatId':'','agentId':_0x3367ee,'contextSignature':_0x3d2f23,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'messageHistory':[],'lastUsedAt':Date['now']()},_0x3674bd[_0x674f7(0x1e8)][_0x674f7(0x1c2)](_0x3d2f23,_0x2fc4e0);if(_0x3674bd[_0x674f7(0x1e8)]['size']>MAX_CHATS_PER_SESSION){let _0x3cb4a1=null,_0x5809f3=Date[_0x674f7(0x1e7)]();for(const [_0x245502,_0xe52457]of _0x3674bd[_0x674f7(0x1e8)]){_0xe52457[_0x674f7(0x1fc)]<_0x5809f3&&(_0x5809f3=_0xe52457[_0x674f7(0x1fc)],_0x3cb4a1=_0x245502);}_0x3cb4a1&&(_0x3674bd[_0x674f7(0x1e8)]['delete'](_0x3cb4a1),this[_0x674f7(0x201)][_0x674f7(0x230)]('Evicted\x20oldest\x20chat\x20(signature:\x20'+_0x3cb4a1+')\x20to\x20stay\x20under\x20'+MAX_CHATS_PER_SESSION+_0x674f7(0x1ab)));}}else _0x2fc4e0[_0x674f7(0x1fc)]=Date['now']();if(!_0x2fc4e0['chatId']){if(_0x2fc4e0[_0x674f7(0x244)]&&_0x2fc4e0[_0x674f7(0x242)]){this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x265)+_0x3d2f23);try{_0x2fc4e0[_0x674f7(0x1ee)]=await _0x2fc4e0[_0x674f7(0x242)];}catch(_0x5c7606){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x1cc),_0x5c7606);}}else{if(!_0x2fc4e0[_0x674f7(0x244)]){_0x2fc4e0[_0x674f7(0x244)]=!![],_0x2fc4e0['createPromise']=((async()=>{const _0x3ff489=_0x674f7;try{const _0x3a7de7=await this[_0x3ff489(0x251)][_0x3ff489(0x1f1)][_0x3ff489(0x1e6)]['startChat'](_0x2fc4e0[_0x3ff489(0x1a6)]);return this['logger'][_0x3ff489(0x1fa)]('['+_0x3a7de7['id']+_0x3ff489(0x1cf)+_0x4db582[_0x3ff489(0x222)]+_0x3ff489(0x206)+_0x3d2f23),_0x3a7de7['id'];}catch(_0x9d1603){this[_0x3ff489(0x201)][_0x3ff489(0x1af)](_0x3ff489(0x1d3),_0x9d1603);throw _0x9d1603;}finally{_0x2fc4e0[_0x3ff489(0x244)]=![],_0x2fc4e0[_0x3ff489(0x242)]=undefined;}})());try{_0x2fc4e0[_0x674f7(0x1ee)]=await _0x2fc4e0[_0x674f7(0x242)];}catch{}}}}const _0x1d9c0b=_0x4b40ef[_0x674f7(0x23e)](_0x25e3db=>!_0x2fc4e0[_0x674f7(0x24e)][_0x674f7(0x241)](_0x25e3db)),_0x4adec3=_0x10b556[_0x674f7(0x23e)](_0x174520=>!_0x2fc4e0[_0x674f7(0x1fb)][_0x674f7(0x241)](_0x174520[_0x674f7(0x23c)]));this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1d7)+_0x2a25f9+_0x674f7(0x1ac)+_0x4db582[_0x674f7(0x222)]+',\x20context\x20signature:\x20'+_0x3d2f23+_0x674f7(0x220)+_0x2a201f),this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1c9)+_0x2fc4e0[_0x674f7(0x1ee)]),this[_0x674f7(0x201)]['debug'](_0x674f7(0x1d1)+_0x4b40ef[_0x674f7(0x25e)]+_0x674f7(0x264)+_0x10b556['length']),this[_0x674f7(0x201)]['debug'](_0x674f7(0x205)+_0x2fc4e0['embeddedSystemPrompts']['size']+',\x20tools:\x20'+_0x2fc4e0[_0x674f7(0x1fb)][_0x674f7(0x20c)]),this['logger'][_0x674f7(0x230)](_0x674f7(0x22a)+_0x1d9c0b['length']+',\x20tools:\x20'+_0x4adec3[_0x674f7(0x25e)]);_0x1d9c0b[_0x674f7(0x25e)]>0x0&&this[_0x674f7(0x201)]['debug'](_0x674f7(0x1d4),_0x1d9c0b['map'](_0x62bb7=>_0x62bb7['substring'](0x0,0x32)+_0x674f7(0x245))[_0x674f7(0x1da)](_0x674f7(0x210)));_0x4adec3['length']>0x0&&this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1bb),_0x4adec3[_0x674f7(0x1c4)](_0x468cf8=>_0x468cf8[_0x674f7(0x23c)])[_0x674f7(0x1da)](',\x20'));const _0x5efe7f=_0x2fc4e0[_0x674f7(0x1ba)][_0x674f7(0x25e)],_0x468945=_0x4db582[_0x674f7(0x1dd)][_0x674f7(0x1b0)](_0x5efe7f);let _0x50cdf2=_0x468945['filter'](_0x440ada=>_0x440ada['role']==='user')[_0x674f7(0x1b9)]();if(!_0x50cdf2){_0x50cdf2=_0x4db582[_0x674f7(0x1dd)][_0x674f7(0x23e)](_0x4bc90b=>_0x4bc90b[_0x674f7(0x266)]==='user')[_0x674f7(0x1b9)]();if(!_0x50cdf2){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x25d)),_0x3a98f0[_0x674f7(0x1e1)](0x190)[_0x674f7(0x21b)]({'type':_0x674f7(0x1af),'error':{'type':_0x674f7(0x254),'message':_0x674f7(0x219)}});return;}}let _0x3557b5;if(typeof _0x50cdf2['content']==='string')_0x3557b5=_0x50cdf2[_0x674f7(0x24a)];else{if(_0x50cdf2[_0x674f7(0x24a)]!=null&&Array[_0x674f7(0x209)](_0x50cdf2[_0x674f7(0x24a)]))_0x3557b5=_0x50cdf2['content']['filter'](_0x1cd299=>_0x1cd299&&_0x1cd299[_0x674f7(0x1b5)]===_0x674f7(0x214)&&_0x1cd299['text'])[_0x674f7(0x1c4)](_0x534001=>_0x534001['text'])[_0x674f7(0x1da)]('\x0a');else{this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x1e4),typeof _0x50cdf2[_0x674f7(0x24a)],_0x50cdf2[_0x674f7(0x24a)]),_0x3a98f0['code'](0x190)[_0x674f7(0x21b)]({'type':_0x674f7(0x1af),'error':{'type':'invalid_request_error','message':_0x674f7(0x22c)}});return;}}const _0x16df08=()=>{const _0x4c69b2=_0x674f7,_0x3cac22=[];_0x4b40ef[_0x4c69b2(0x25e)]>0x0&&_0x3cac22[_0x4c69b2(0x259)](_0x4b40ef[_0x4c69b2(0x1da)]('\x0a\x0a'));_0x10b556[_0x4c69b2(0x25e)]>0x0&&_0x3cac22[_0x4c69b2(0x259)](generateToolPrompt(_0x10b556));if(_0x4db582[_0x4c69b2(0x1dd)]&&_0x4db582[_0x4c69b2(0x1dd)]['length']>0x1){const _0x51ea67=formatConversationHistory(_0x4db582[_0x4c69b2(0x1dd)]);_0x51ea67&&_0x3cac22['push'](_0x4c69b2(0x216)+_0x51ea67+'\x0a</conversation>');}return _0x3cac22['push'](_0x4c69b2(0x24d)+_0x3557b5),_0x3cac22[_0x4c69b2(0x1da)](_0x4c69b2(0x227));};let _0x137460;if(_0x2a201f){this[_0x674f7(0x201)][_0x674f7(0x1fa)]('['+_0x2fc4e0[_0x674f7(0x1ee)]+_0x674f7(0x1f2)+_0x4db582[_0x674f7(0x222)]+',\x20system_prompts='+_0x4b40ef[_0x674f7(0x25e)]+_0x674f7(0x21c)+_0x10b556[_0x674f7(0x25e)]+_0x674f7(0x1df)+_0x10b556[_0x674f7(0x1c4)](_0x5b86c3=>_0x5b86c3[_0x674f7(0x23c)])[_0x674f7(0x1da)](',\x20')+']'),_0x137460=_0x16df08();for(const _0x270e93 of _0x4b40ef){_0x2fc4e0[_0x674f7(0x24e)][_0x674f7(0x1f0)](_0x270e93);}for(const _0x1b02fd of _0x10b556){_0x2fc4e0['embeddedToolsByName'][_0x674f7(0x1c2)](_0x1b02fd['name'],_0x1b02fd);}}else{const _0x4dc2f0=[];_0x1d9c0b[_0x674f7(0x25e)]>0x0&&(_0x4dc2f0['push'](_0x1d9c0b[_0x674f7(0x1da)]('\x0a\x0a')),this[_0x674f7(0x201)][_0x674f7(0x230)]('Embedding',_0x1d9c0b['length'],_0x674f7(0x1dc)));if(_0x4adec3[_0x674f7(0x25e)]>0x0)try{_0x4dc2f0[_0x674f7(0x259)](generateToolPrompt(_0x4adec3)),this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1ec),_0x4adec3[_0x674f7(0x25e)],'new\x20tool(s)');}catch(_0x5edd78){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x22f),_0x5edd78);}try{const _0x3cf654=extractToolResults(_0x468945);_0x3cf654&&(_0x4dc2f0[_0x674f7(0x259)](_0x3cf654),this[_0x674f7(0x201)][_0x674f7(0x230)](_0x674f7(0x1aa)));}catch(_0x1b88d4){this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x223),_0x1b88d4);}_0x4dc2f0[_0x674f7(0x259)](_0x3557b5),_0x137460=_0x4dc2f0[_0x674f7(0x25e)]>0x1?_0x4dc2f0['join']('\x0a---\x0a\x0a'):_0x3557b5;for(const _0x339c64 of _0x1d9c0b){_0x2fc4e0['embeddedSystemPrompts'][_0x674f7(0x1f0)](_0x339c64);}for(const _0x53c469 of _0x4adec3){_0x2fc4e0[_0x674f7(0x1fb)]['set'](_0x53c469['name'],_0x53c469);}}(!_0x137460||!_0x137460['trim']())&&(this[_0x674f7(0x201)]['warn'](_0x674f7(0x25a)),this[_0x674f7(0x201)][_0x674f7(0x260)](_0x674f7(0x1a9),{'isNewContext':_0x2a201f,'userMessageLength':_0x3557b5?.[_0x674f7(0x25e)]||0x0,'systemPromptsCount':_0x4b40ef['length'],'toolsCount':_0x10b556[_0x674f7(0x25e)],'messagesCount':_0x4db582[_0x674f7(0x1dd)]?.[_0x674f7(0x25e)]||0x0,'newMessagesCount':_0x468945[_0x674f7(0x25e)]}),clearChatState(_0x2fc4e0),_0x137460=_0x16df08(),(!_0x137460||!_0x137460[_0x674f7(0x207)]())&&(this['logger']['error']('Failed\x20to\x20reconstruct\x20message\x20-\x20all\x20parts\x20are\x20empty,\x20using\x20fallback'),this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x24c),{'systemPromptsCount':_0x4b40ef[_0x674f7(0x25e)],'toolsCount':_0x10b556[_0x674f7(0x25e)],'messagesCount':_0x4db582[_0x674f7(0x1dd)]?.['length']||0x0,'userMessageLength':_0x3557b5?.['length']||0x0}),_0x137460=_0x674f7(0x21e)),this[_0x674f7(0x201)][_0x674f7(0x1fa)](_0x674f7(0x20f),_0x137460[_0x674f7(0x23f)](0x0,0x64)+_0x674f7(0x245)));const _0xbee72b=_0x4db582[_0x674f7(0x1d2)]!==![];if(_0xbee72b){_0x3a98f0['raw'][_0x674f7(0x21f)](0xc8,{'Content-Type':_0x674f7(0x234),'Cache-Control':_0x674f7(0x1e0),'Connection':_0x674f7(0x21d),'X-Accel-Buffering':'no'});const _0x3173ae=generateMessageId();try{if(_0x2fc4e0[_0x674f7(0x1ee)]){const _0x8d2be7=_0x137460['substring'](0x0,0x32)['replace'](/\n/g,'\x20');this[_0x674f7(0x201)][_0x674f7(0x1fa)]('['+_0x2fc4e0[_0x674f7(0x1ee)]+']\x20Continue\x20chat\x20for\x20model\x20'+_0x4db582[_0x674f7(0x222)]+_0x674f7(0x206)+_0x3d2f23+',\x20'+_0x4db582[_0x674f7(0x1dd)][_0x674f7(0x25e)]+_0x674f7(0x1e3)+_0x4b40ef[_0x674f7(0x25e)]+_0x674f7(0x1ff)+_0x10b556[_0x674f7(0x25e)]+_0x674f7(0x249)+_0x137460['length']+',\x20\x22'+_0x8d2be7+_0x674f7(0x1d9));}const _0x5c005f=this[_0x674f7(0x251)][_0x674f7(0x1f1)]['llm'][_0x674f7(0x1c3)](_0x137460,{'chatId':_0x2fc4e0['chatId']||undefined,'agentId':_0x2fc4e0[_0x674f7(0x1ee)]?undefined:_0x2fc4e0[_0x674f7(0x1a6)]});if(!_0x5c005f){this['logger'][_0x674f7(0x1af)](_0x674f7(0x1c0)),this['logger'][_0x674f7(0x1af)](_0x674f7(0x1a9),JSON['stringify']({'chatId':_0x2fc4e0['chatId'],'agentId':_0x2fc4e0['agentId'],'model':_0x4db582[_0x674f7(0x222)],'sessionId':_0x2a25f9,'contextSignature':_0x3d2f23})),_0x2fc4e0['chatId']='',this[_0x674f7(0x201)][_0x674f7(0x260)](_0x674f7(0x1be));const _0x2ef5fd=formatAnthropicSSE({'type':'error','error':{'type':_0x674f7(0x256),'message':_0x674f7(0x1cd)},'request_id':_0x3173ae});_0x3a98f0[_0x674f7(0x1a5)][_0x674f7(0x248)](_0x2ef5fd),_0x3a98f0[_0x674f7(0x1a5)][_0x674f7(0x1bf)]();return;}_0x2fc4e0[_0x674f7(0x1ba)]=_0x4db582[_0x674f7(0x1dd)];const _0x30f514=_0x2fc4e0;async function*_0x3d70ca(_0x4cd00b){const _0x19f827=_0x674f7;for await(const _0x2bccf9 of _0x4cd00b){if(_0x2bccf9['type']===_0x19f827(0x235))_0x2bccf9[_0x19f827(0x1f4)][_0x19f827(0x1ee)]&&!_0x30f514[_0x19f827(0x1ee)]&&(_0x30f514[_0x19f827(0x1ee)]=_0x2bccf9[_0x19f827(0x1f4)][_0x19f827(0x1ee)]);else _0x2bccf9['type']===_0x19f827(0x247)&&(yield _0x2bccf9['data']);}}const _0x3ad76a=_0x3d70ca(_0x5c005f),_0x37c687=estimateInputTokensFromRequest(_0x4db582),_0x29afa7=transformTDStreamToAnthropic(_0x3ad76a,_0x3173ae,_0x4db582[_0x674f7(0x222)],this[_0x674f7(0x201)],_0x3557b5,_0x37c687),_0x22786c=_0x137460[_0x674f7(0x25e)];let _0xca9c4b=0x0;for await(const _0x25d7bb of _0x29afa7){const _0x3ed08d=formatAnthropicSSE(_0x25d7bb);_0xca9c4b++,this[_0x674f7(0x201)][_0x674f7(0x230)](colorizeJSONCompact(_0x25d7bb,{'color':!![]})),_0x25d7bb[_0x674f7(0x1b5)]===_0x674f7(0x1af)&&_0x25d7bb[_0x674f7(0x1af)][_0x674f7(0x1b5)]==='request_too_large'&&(clearChatState(_0x2fc4e0),this['logger'][_0x674f7(0x260)](_0x674f7(0x1f8)+_0x25d7bb['error']['message']+_0x674f7(0x25f)+_0x22786c+_0x674f7(0x1c8)+_0x2a25f9+',\x20context:\x20'+_0x3d2f23)),_0x3a98f0[_0x674f7(0x1a5)]['write'](_0x3ed08d);}this[_0x674f7(0x201)][_0x674f7(0x230)]('Stream\x20complete.\x20Sent\x20'+_0xca9c4b+_0x674f7(0x258)),_0x3a98f0[_0x674f7(0x1a5)]['end']();}catch(_0x57bee1){const _0x1d3c16=_0x57bee1 instanceof Error?_0x57bee1[_0x674f7(0x213)]:_0x674f7(0x1f5);this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x1b1),_0x57bee1),this[_0x674f7(0x201)]['error'](_0x674f7(0x1a9),JSON[_0x674f7(0x255)]({'chatId':_0x2fc4e0[_0x674f7(0x1ee)],'agentId':_0x2fc4e0['agentId'],'model':_0x4db582[_0x674f7(0x222)],'sessionId':_0x2a25f9,'contextSignature':_0x3d2f23})),_0x2fc4e0[_0x674f7(0x1ee)]='',this[_0x674f7(0x201)][_0x674f7(0x260)](_0x674f7(0x236));const _0x964e68=formatAnthropicSSE({'type':'error','error':{'type':_0x674f7(0x256),'message':_0x1d3c16},'request_id':_0x3173ae});_0x3a98f0[_0x674f7(0x1a5)][_0x674f7(0x248)](_0x964e68),_0x3a98f0[_0x674f7(0x1a5)][_0x674f7(0x1bf)]();}}else this[_0x674f7(0x201)][_0x674f7(0x1af)](_0x674f7(0x218)),_0x3a98f0[_0x674f7(0x1e1)](0x1f5)[_0x674f7(0x21b)]({'type':_0x674f7(0x1af),'error':{'type':_0x674f7(0x1e9),'message':_0x674f7(0x1eb)}});}async[a44_0x5bf55d(0x1d8)](_0x446f4f){const _0x661b6d=a44_0x5bf55d,_0x1856f8=_0x446f4f[_0x661b6d(0x1d0)],_0x5211a1=estimateInputTokensFromRequest(_0x1856f8);return this[_0x661b6d(0x201)][_0x661b6d(0x1fa)](_0x446f4f['method']+'\x20'+_0x446f4f[_0x661b6d(0x268)]+':\x20estimated\x20input_tokens='+_0x5211a1),{'input_tokens':_0x5211a1};}async['start'](){const _0x41739d=a44_0x5bf55d;try{await this['server'][_0x41739d(0x23b)]({'port':this[_0x41739d(0x251)][_0x41739d(0x239)],'host':_0x41739d(0x229)}),this[_0x41739d(0x201)][_0x41739d(0x1fa)]('Proxy\x20server\x20started\x20at\x20localhost:'+this[_0x41739d(0x251)]['port']),this[_0x41739d(0x1ed)]=setInterval(()=>{const _0x19b03b=_0x41739d;this[_0x19b03b(0x25c)]();},CLEANUP_INTERVAL_MS),this[_0x41739d(0x201)]['debug']('Started\x20cache\x20cleanup\x20interval\x20(runs\x20every\x20'+CLEANUP_INTERVAL_MS/0x3e8+'s,\x20expires\x20after\x20'+CACHE_EXPIRATION_MS/0x3e8+'s)');}catch(_0x48283b){const _0x492efa=_0x48283b instanceof Error?_0x48283b[_0x41739d(0x213)]:_0x41739d(0x1f5);throw new Error('Failed\x20to\x20start\x20proxy\x20server:\x20'+_0x492efa);}}async[a44_0x5bf55d(0x1c6)](){const _0x15c00a=a44_0x5bf55d;this[_0x15c00a(0x1ed)]&&(clearInterval(this[_0x15c00a(0x1ed)]),this[_0x15c00a(0x1ed)]=undefined),await this['server'][_0x15c00a(0x1f9)]();}[a44_0x5bf55d(0x225)](){const _0x430d91=a44_0x5bf55d,_0x3c43f4=this[_0x430d91(0x20a)]['server'][_0x430d91(0x1f6)]();if(typeof _0x3c43f4===_0x430d91(0x204))return _0x3c43f4;if(_0x3c43f4)return _0x430d91(0x1e5)+_0x3c43f4[_0x430d91(0x1f6)]+':'+_0x3c43f4[_0x430d91(0x239)];return _0x430d91(0x1ce)+this['config'][_0x430d91(0x239)];}}
@@ -1 +1 @@
1
- const a45_0x32b425=a45_0x5ef5;(function(_0x441af4,_0x2fc603){const _0x23878a=a45_0x5ef5,_0x1db3f4=_0x441af4();while(!![]){try{const _0x579de3=-parseInt(_0x23878a(0xcc))/0x1*(-parseInt(_0x23878a(0xd3))/0x2)+-parseInt(_0x23878a(0xb5))/0x3+-parseInt(_0x23878a(0xcf))/0x4*(-parseInt(_0x23878a(0xc1))/0x5)+parseInt(_0x23878a(0xbc))/0x6*(parseInt(_0x23878a(0xb6))/0x7)+-parseInt(_0x23878a(0xca))/0x8+parseInt(_0x23878a(0xb9))/0x9+-parseInt(_0x23878a(0xc9))/0xa*(-parseInt(_0x23878a(0xbb))/0xb);if(_0x579de3===_0x2fc603)break;else _0x1db3f4['push'](_0x1db3f4['shift']());}catch(_0x163031){_0x1db3f4['push'](_0x1db3f4['shift']());}}}(a45_0x2e0a,0x5a957));export class SessionCache{[a45_0x32b425(0xc8)];['config'];constructor(_0xc64fc6){const _0x4fc5d4=a45_0x32b425;this[_0x4fc5d4(0xd2)]=_0xc64fc6,this[_0x4fc5d4(0xc8)]=new Map();}[a45_0x32b425(0xc2)](_0x4e5a7e,_0x47261){const _0x2f9639=a45_0x32b425;let _0x3484b0=this[_0x2f9639(0xc8)][_0x2f9639(0xd1)](_0x4e5a7e);return!_0x3484b0&&(_0x3484b0={'projectId':_0x47261,'chats':new Map()},this[_0x2f9639(0xc8)][_0x2f9639(0xce)](_0x4e5a7e,_0x3484b0)),_0x3484b0;}[a45_0x32b425(0xb8)](_0x41eed9){const _0x3c3570=a45_0x32b425;return this[_0x3c3570(0xc8)][_0x3c3570(0xd1)](_0x41eed9);}[a45_0x32b425(0xcd)](_0x1a4d93,_0x148cb8,_0x2bfbc9){const _0x1bd110=a45_0x32b425,_0x1f3490=this[_0x1bd110(0xc8)][_0x1bd110(0xd1)](_0x1a4d93);if(!_0x1f3490)throw new Error(_0x1bd110(0xbf)+_0x1a4d93+'\x20not\x20found');let _0x3c0697=_0x1f3490[_0x1bd110(0xc0)][_0x1bd110(0xd1)](_0x148cb8);if(!_0x3c0697){_0x3c0697={'chatId':'','agentId':_0x2bfbc9,'contextSignature':_0x148cb8,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'messageHistory':[],'lastUsedAt':Date[_0x1bd110(0xd0)]()},_0x1f3490[_0x1bd110(0xc0)][_0x1bd110(0xce)](_0x148cb8,_0x3c0697);if(_0x1f3490[_0x1bd110(0xc0)][_0x1bd110(0xbe)]>this[_0x1bd110(0xd2)]['maxChatsPerSession']){let _0x3ce985=null,_0x4cd9f2=Date[_0x1bd110(0xd0)]();for(const [_0x270227,_0x1924d8]of _0x1f3490[_0x1bd110(0xc0)]){_0x1924d8['lastUsedAt']<_0x4cd9f2&&(_0x4cd9f2=_0x1924d8[_0x1bd110(0xc7)],_0x3ce985=_0x270227);}_0x3ce985&&_0x1f3490[_0x1bd110(0xc0)][_0x1bd110(0xcb)](_0x3ce985);}}else _0x3c0697[_0x1bd110(0xc7)]=Date[_0x1bd110(0xd0)]();return _0x3c0697;}[a45_0x32b425(0xbd)](){const _0x1af8df=a45_0x32b425,_0x5399ce=Date[_0x1af8df(0xd0)]();let _0x5ad266=0x0;for(const [_0x14f686,_0x20d91e]of this[_0x1af8df(0xc8)]){const _0x10c551=[];for(const [_0x294026,_0x26bdee]of _0x20d91e[_0x1af8df(0xc0)]){_0x5399ce-_0x26bdee[_0x1af8df(0xc7)]>this['config'][_0x1af8df(0xc4)]&&_0x10c551[_0x1af8df(0xc3)](_0x294026);}for(const _0x38edb1 of _0x10c551){_0x20d91e['chats'][_0x1af8df(0xcb)](_0x38edb1),_0x5ad266++;}_0x20d91e['chats'][_0x1af8df(0xbe)]===0x0&&this[_0x1af8df(0xc8)]['delete'](_0x14f686);}return _0x5ad266;}[a45_0x32b425(0xb7)](){const _0xa8fbd5=a45_0x32b425;return this['sessions'][_0xa8fbd5(0xbe)];}[a45_0x32b425(0xc6)](){const _0x3c6f8d=a45_0x32b425;let _0x417f50=0x0;for(const _0x38ca22 of this['sessions'][_0x3c6f8d(0xba)]()){_0x417f50+=_0x38ca22[_0x3c6f8d(0xc0)][_0x3c6f8d(0xbe)];}return _0x417f50;}[a45_0x32b425(0xc5)](){const _0x2d1d94=a45_0x32b425;this['sessions'][_0x2d1d94(0xc5)]();}}function a45_0x5ef5(_0x406202,_0x2804fb){const _0x2e0aaf=a45_0x2e0a();return a45_0x5ef5=function(_0x5ef5c5,_0x2da045){_0x5ef5c5=_0x5ef5c5-0xb5;let _0x53e624=_0x2e0aaf[_0x5ef5c5];return _0x53e624;},a45_0x5ef5(_0x406202,_0x2804fb);}function a45_0x2e0a(){const _0x4c597d=['delete','4VmPBIA','getOrCreateChat','set','92JiXQnR','now','get','config','106380bYXDye','1504512mtyGEB','7VLQiZK','getSessionCount','getSession','1135629Ntndwo','values','7161iGKIkF','2178966qGSgMl','cleanupExpiredChats','size','Session\x20','chats','5045wQmyjk','getOrCreateSession','push','cacheExpirationMs','clear','getTotalChatCount','lastUsedAt','sessions','8450vWluTd','3222952gcmVzE'];a45_0x2e0a=function(){return _0x4c597d;};return a45_0x2e0a();}
1
+ const a45_0x5d4699=a45_0x1b4e;(function(_0x19839c,_0x8fbdc7){const _0x5cca4d=a45_0x1b4e,_0x377051=_0x19839c();while(!![]){try{const _0x12cf97=parseInt(_0x5cca4d(0xbb))/0x1*(parseInt(_0x5cca4d(0xbe))/0x2)+parseInt(_0x5cca4d(0xc8))/0x3+parseInt(_0x5cca4d(0xce))/0x4+-parseInt(_0x5cca4d(0xc6))/0x5+parseInt(_0x5cca4d(0xca))/0x6+-parseInt(_0x5cca4d(0xc2))/0x7+-parseInt(_0x5cca4d(0xbf))/0x8;if(_0x12cf97===_0x8fbdc7)break;else _0x377051['push'](_0x377051['shift']());}catch(_0x5cf305){_0x377051['push'](_0x377051['shift']());}}}(a45_0x2cac,0xce7cc));function a45_0x1b4e(_0x4033dd,_0x167d22){const _0x2cac86=a45_0x2cac();return a45_0x1b4e=function(_0x1b4eb0,_0x35917c){_0x1b4eb0=_0x1b4eb0-0xb7;let _0x58a559=_0x2cac86[_0x1b4eb0];return _0x58a559;},a45_0x1b4e(_0x4033dd,_0x167d22);}export class SessionCache{[a45_0x5d4699(0xb9)];[a45_0x5d4699(0xcc)];constructor(_0x3d3edb){const _0x2050e2=a45_0x5d4699;this[_0x2050e2(0xcc)]=_0x3d3edb,this[_0x2050e2(0xb9)]=new Map();}[a45_0x5d4699(0xcf)](_0x363d90,_0x2d8ec6){const _0x2b04f3=a45_0x5d4699;let _0x554fbb=this[_0x2b04f3(0xb9)][_0x2b04f3(0xc7)](_0x363d90);return!_0x554fbb&&(_0x554fbb={'projectId':_0x2d8ec6,'chats':new Map()},this[_0x2b04f3(0xb9)][_0x2b04f3(0xcd)](_0x363d90,_0x554fbb)),_0x554fbb;}['getSession'](_0x879167){const _0x1069f4=a45_0x5d4699;return this[_0x1069f4(0xb9)][_0x1069f4(0xc7)](_0x879167);}['getOrCreateChat'](_0x1cd378,_0x450819,_0x17fb6c){const _0x4137ad=a45_0x5d4699,_0x2a43a5=this[_0x4137ad(0xb9)][_0x4137ad(0xc7)](_0x1cd378);if(!_0x2a43a5)throw new Error(_0x4137ad(0xc0)+_0x1cd378+_0x4137ad(0xb8));let _0xe058bc=_0x2a43a5[_0x4137ad(0xcb)][_0x4137ad(0xc7)](_0x450819);if(!_0xe058bc){_0xe058bc={'chatId':'','agentId':_0x17fb6c,'contextSignature':_0x450819,'embeddedSystemPrompts':new Set(),'embeddedToolsByName':new Map(),'messageHistory':[],'lastUsedAt':Date[_0x4137ad(0xba)]()},_0x2a43a5[_0x4137ad(0xcb)]['set'](_0x450819,_0xe058bc);if(_0x2a43a5[_0x4137ad(0xcb)][_0x4137ad(0xc5)]>this[_0x4137ad(0xcc)][_0x4137ad(0xd0)]){let _0x31a4be=null,_0xd781d=Date[_0x4137ad(0xba)]();for(const [_0x486211,_0xf9adde]of _0x2a43a5['chats']){_0xf9adde[_0x4137ad(0xc3)]<_0xd781d&&(_0xd781d=_0xf9adde[_0x4137ad(0xc3)],_0x31a4be=_0x486211);}_0x31a4be&&_0x2a43a5['chats'][_0x4137ad(0xb7)](_0x31a4be);}}else _0xe058bc['lastUsedAt']=Date[_0x4137ad(0xba)]();return _0xe058bc;}[a45_0x5d4699(0xc4)](){const _0x5e8fca=a45_0x5d4699,_0x46796d=Date[_0x5e8fca(0xba)]();let _0x412dc9=0x0;for(const [_0x3a8094,_0x441a5f]of this['sessions']){const _0x3ff272=[];for(const [_0x59483b,_0x3a1e54]of _0x441a5f[_0x5e8fca(0xcb)]){_0x46796d-_0x3a1e54[_0x5e8fca(0xc3)]>this[_0x5e8fca(0xcc)][_0x5e8fca(0xbc)]&&_0x3ff272['push'](_0x59483b);}for(const _0x38366f of _0x3ff272){_0x441a5f[_0x5e8fca(0xcb)]['delete'](_0x38366f),_0x412dc9++;}_0x441a5f['chats'][_0x5e8fca(0xc5)]===0x0&&this['sessions']['delete'](_0x3a8094);}return _0x412dc9;}[a45_0x5d4699(0xc1)](){const _0x56d8a9=a45_0x5d4699;return this[_0x56d8a9(0xb9)][_0x56d8a9(0xc5)];}['getTotalChatCount'](){const _0x23e684=a45_0x5d4699;let _0x2c17a9=0x0;for(const _0x423b40 of this[_0x23e684(0xb9)][_0x23e684(0xc9)]()){_0x2c17a9+=_0x423b40['chats'][_0x23e684(0xc5)];}return _0x2c17a9;}[a45_0x5d4699(0xbd)](){const _0x1c9458=a45_0x5d4699;this[_0x1c9458(0xb9)]['clear']();}}function a45_0x2cac(){const _0x5a922e=['4309863UERScW','values','6753966XQexpZ','chats','config','set','3233756hHtALZ','getOrCreateSession','maxChatsPerSession','delete','\x20not\x20found','sessions','now','5pCscHL','cacheExpirationMs','clear','340258rgJIBK','15333152KVBMyu','Session\x20','getSessionCount','2117717Szqvmb','lastUsedAt','cleanupExpiredChats','size','5782095eUiZaH','get'];a45_0x2cac=function(){return _0x5a922e;};return a45_0x2cac();}
package/dist/sdk/api.js CHANGED
@@ -1 +1 @@
1
- const a46_0x530707=a46_0x1a89;(function(_0x2408d2,_0x19225e){const _0x401a53=a46_0x1a89,_0x3ee771=_0x2408d2();while(!![]){try{const _0x1bdbb1=-parseInt(_0x401a53(0x149))/0x1+-parseInt(_0x401a53(0x14d))/0x2+parseInt(_0x401a53(0x14f))/0x3+-parseInt(_0x401a53(0x154))/0x4*(parseInt(_0x401a53(0x155))/0x5)+-parseInt(_0x401a53(0x146))/0x6+parseInt(_0x401a53(0x140))/0x7*(-parseInt(_0x401a53(0x150))/0x8)+parseInt(_0x401a53(0x14c))/0x9;if(_0x1bdbb1===_0x19225e)break;else _0x3ee771['push'](_0x3ee771['shift']());}catch(_0x334f84){_0x3ee771['push'](_0x3ee771['shift']());}}}(a46_0x5478,0x6e0e9));function a46_0x1a89(_0x19b617,_0x581204){const _0x5478af=a46_0x5478();return a46_0x1a89=function(_0x1a89e8,_0x3bbb7a){_0x1a89e8=_0x1a89e8-0x13f;let _0x2329d7=_0x5478af[_0x1a89e8];return _0x2329d7;},a46_0x1a89(_0x19b617,_0x581204);}import{HTTPClient}from'../client/http-client.js';import{getEndpoint}from'../types/index.js';import{getAuthHeaders,getTrinoHeaders,toHeaderRecord}from'../core/auth.js';function a46_0x5478(){const _0x3e8a3c=['29864610RjVmXM','1696420waQKCj','status','571410uMwOyc','16HsHmSn','data','apiKey','utf-8','12GMsqVN','358335vnsEKb','headers','site','context','2759687TPsSSs','logger','stringify','Error:\x20','message','readBodyFromFile','4427628luQHJR','string','Content-Type','468336kkppsk','Endpoint\x20must\x20start\x20with\x20/:\x20','request'];a46_0x5478=function(){return _0x3e8a3c;};return a46_0x5478();}import{readFileSync}from'fs';export class RawAPI{[a46_0x530707(0x13f)];constructor(_0x4be78d){const _0x2cef1e=a46_0x530707;this[_0x2cef1e(0x13f)]=_0x4be78d;}async[a46_0x530707(0x14b)](_0x925880,_0xdfdbbf={}){const _0x16e44e=a46_0x530707,{method:method='GET',body:_0x52748f,headers:_0x418ba1={},apiType:apiType='td',includeHeaders:includeHeaders=![]}=_0xdfdbbf;if(!_0x925880['startsWith']('/'))throw new Error(_0x16e44e(0x14a)+_0x925880);const _0x5f1431=getEndpoint(this['context'][_0x16e44e(0x157)],apiType);let _0x5899fd;if(apiType==='trino'){const _0x228e66=getTrinoHeaders(this[_0x16e44e(0x13f)][_0x16e44e(0x157)],this['context'][_0x16e44e(0x152)]);_0x5899fd={..._0x228e66,..._0x418ba1};}else{const _0x173a84=getAuthHeaders(this['context'][_0x16e44e(0x157)],this[_0x16e44e(0x13f)][_0x16e44e(0x152)]);_0x5899fd={...toHeaderRecord(_0x173a84),..._0x418ba1};}const _0x263a91=_0x5899fd;let _0x2aa4fd;_0x52748f!==undefined&&(_0x2aa4fd=typeof _0x52748f===_0x16e44e(0x147)?_0x52748f:JSON[_0x16e44e(0x142)](_0x52748f),!_0x263a91[_0x16e44e(0x148)]&&(_0x263a91['Content-Type']='application/json'));const _0x3a53b3=new HTTPClient(_0x5f1431,_0x263a91,this[_0x16e44e(0x13f)][_0x16e44e(0x141)]),_0x23c7fb=await _0x3a53b3[_0x16e44e(0x14b)](method,_0x925880,{'body':_0x2aa4fd,'includeHeaders':!![]});return includeHeaders?{'data':_0x23c7fb[_0x16e44e(0x151)],'status':_0x23c7fb[_0x16e44e(0x14e)],'headers':_0x23c7fb[_0x16e44e(0x156)]}:{'data':_0x23c7fb[_0x16e44e(0x151)],'status':_0x23c7fb['status']};}static[a46_0x530707(0x145)](_0x530309){const _0x58ba98=a46_0x530707;try{return readFileSync(_0x530309,_0x58ba98(0x153));}catch(_0x146f9c){throw new Error('Failed\x20to\x20read\x20request\x20body\x20from\x20file:\x20'+_0x530309+'.\x20'+(_0x58ba98(0x143)+(_0x146f9c instanceof Error?_0x146f9c[_0x58ba98(0x144)]:String(_0x146f9c))));}}}
1
+ function a46_0x4415(_0x2d4f48,_0x472c57){const _0x526910=a46_0x5269();return a46_0x4415=function(_0x441513,_0x4b05ab){_0x441513=_0x441513-0x7d;let _0x3519ca=_0x526910[_0x441513];return _0x3519ca;},a46_0x4415(_0x2d4f48,_0x472c57);}const a46_0x297c70=a46_0x4415;(function(_0x3f5729,_0x2511ce){const _0x4cb732=a46_0x4415,_0x19829e=_0x3f5729();while(!![]){try{const _0x4cf66b=-parseInt(_0x4cb732(0x98))/0x1*(-parseInt(_0x4cb732(0x89))/0x2)+-parseInt(_0x4cb732(0x94))/0x3*(parseInt(_0x4cb732(0x7e))/0x4)+-parseInt(_0x4cb732(0x93))/0x5*(-parseInt(_0x4cb732(0x8b))/0x6)+parseInt(_0x4cb732(0x96))/0x7+-parseInt(_0x4cb732(0x90))/0x8*(-parseInt(_0x4cb732(0x86))/0x9)+parseInt(_0x4cb732(0x81))/0xa*(parseInt(_0x4cb732(0x80))/0xb)+-parseInt(_0x4cb732(0x7d))/0xc;if(_0x4cf66b===_0x2511ce)break;else _0x19829e['push'](_0x19829e['shift']());}catch(_0x2eccf1){_0x19829e['push'](_0x19829e['shift']());}}}(a46_0x5269,0x2b0ec));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';function a46_0x5269(){const _0x2a2877=['Error:\x20','application/json','13648XwQCXW','headers','Content-Type','15LfLHLH','5667DCzVhF','request','559881ETtFsh','data','1hfesJJ','status','readBodyFromFile','5416164fhfOtR','4EanWVT','apiKey','11bvmbjl','2890970SQkGjW','stringify','utf-8','site','Endpoint\x20must\x20start\x20with\x20/:\x20','657lZZEeT','trino','string','71558VoyeVQ','Failed\x20to\x20read\x20request\x20body\x20from\x20file:\x20','200406uFdeqZ','logger','context'];a46_0x5269=function(){return _0x2a2877;};return a46_0x5269();}export class RawAPI{['context'];constructor(_0x1842ad){const _0x17b2cd=a46_0x4415;this[_0x17b2cd(0x8d)]=_0x1842ad;}async[a46_0x297c70(0x95)](_0x4ee0f4,_0x5af8ee={}){const _0x4652d0=a46_0x297c70,{method:method='GET',body:_0x4596de,headers:_0x38a721={},apiType:apiType='td',includeHeaders:includeHeaders=![]}=_0x5af8ee;if(!_0x4ee0f4['startsWith']('/'))throw new Error(_0x4652d0(0x85)+_0x4ee0f4);const _0x13e7ee=getEndpoint(this[_0x4652d0(0x8d)][_0x4652d0(0x84)],apiType);let _0x5a3e8f;if(apiType===_0x4652d0(0x87)){const _0x154db1=getTrinoHeaders(this[_0x4652d0(0x8d)][_0x4652d0(0x84)],this[_0x4652d0(0x8d)][_0x4652d0(0x7f)]);_0x5a3e8f={..._0x154db1,..._0x38a721};}else{const _0x307ece=getAuthHeaders(this['context']['site'],this[_0x4652d0(0x8d)][_0x4652d0(0x7f)]);_0x5a3e8f={...toHeaderRecord(_0x307ece),..._0x38a721};}const _0x1fd880=_0x5a3e8f;let _0x6754fa;_0x4596de!==undefined&&(_0x6754fa=typeof _0x4596de===_0x4652d0(0x88)?_0x4596de:JSON[_0x4652d0(0x82)](_0x4596de),!_0x1fd880[_0x4652d0(0x92)]&&(_0x1fd880[_0x4652d0(0x92)]=_0x4652d0(0x8f)));const _0x3fb508=new HTTPClient(_0x13e7ee,_0x1fd880,this[_0x4652d0(0x8d)][_0x4652d0(0x8c)]),_0x2fca8b=await _0x3fb508['request'](method,_0x4ee0f4,{'body':_0x6754fa,'includeHeaders':!![]});return includeHeaders?{'data':_0x2fca8b[_0x4652d0(0x97)],'status':_0x2fca8b['status'],'headers':_0x2fca8b[_0x4652d0(0x91)]}:{'data':_0x2fca8b[_0x4652d0(0x97)],'status':_0x2fca8b[_0x4652d0(0x99)]};}static[a46_0x297c70(0x9a)](_0x11ff17){const _0x39961b=a46_0x297c70;try{return readFileSync(_0x11ff17,_0x39961b(0x83));}catch(_0x59d1bf){throw new Error(_0x39961b(0x8a)+_0x11ff17+'.\x20'+(_0x39961b(0x8e)+(_0x59d1bf instanceof Error?_0x59d1bf['message']:String(_0x59d1bf))));}}}
@@ -1 +1 @@
1
- const a47_0x4385df=a47_0x2a27;function a47_0x2a27(_0x12e72e,_0x383dac){const _0x1790b9=a47_0x1790();return a47_0x2a27=function(_0x2a276e,_0xb35b5c){_0x2a276e=_0x2a276e-0x112;let _0x393f06=_0x1790b9[_0x2a276e];return _0x393f06;},a47_0x2a27(_0x12e72e,_0x383dac);}(function(_0x5b47b8,_0x2cc229){const _0x37db7a=a47_0x2a27,_0x68e466=_0x5b47b8();while(!![]){try{const _0x3b1fae=parseInt(_0x37db7a(0x12a))/0x1*(parseInt(_0x37db7a(0x141))/0x2)+-parseInt(_0x37db7a(0x11e))/0x3*(parseInt(_0x37db7a(0x134))/0x4)+parseInt(_0x37db7a(0x12e))/0x5*(-parseInt(_0x37db7a(0x120))/0x6)+-parseInt(_0x37db7a(0x125))/0x7+parseInt(_0x37db7a(0x143))/0x8+parseInt(_0x37db7a(0x11b))/0x9+parseInt(_0x37db7a(0x11f))/0xa*(parseInt(_0x37db7a(0x140))/0xb);if(_0x3b1fae===_0x2cc229)break;else _0x68e466['push'](_0x68e466['shift']());}catch(_0x393dcd){_0x68e466['push'](_0x68e466['shift']());}}}(a47_0x1790,0x4dfc6));export var ErrorCategory;(function(_0x2c2d5a){const _0x6076e=a47_0x2a27;_0x2c2d5a['USER_ERROR']=_0x6076e(0x145),_0x2c2d5a['INTERNAL_ERROR']=_0x6076e(0x123);}(ErrorCategory||(ErrorCategory={})));export var ErrorCode;function a47_0x1790(){const _0x4cd7fc=['category','message','code','CANCELLED','replace','TRINO_INTERNAL_ERROR','UNAUTHENTICATED','\x0aCaused\x20by:\x20','CHAT_NOT_FOUND','ALREADY_EXISTS','1809855YmvToJ','NOT_FOUND','LLM_EMPTY_MESSAGE','408XkyPQu','5023270fGecIL','6wPRkpn','LLM_PROJECT_NOT_FOUND','AGENT_NOT_FOUND','INTERNAL_ERROR','INTERNAL','2055060nefawp','RATE_LIMITED','isRetryable','UNAVAILABLE','helpText','37594SiCDmT','INSTALLATION_FAILED','COMMAND_NOT_FOUND','originalMessage','998365uJgRue','TIMEOUT','HTTP_REQUEST_FAILURE','cause','includes','LLM_MALFORMED_MESSAGE','10016JHWAbc','PERMISSION_DENIED','stack','LLM_STREAM_ERROR','TABLE_NOT_FOUND','TRINO_INSUFFICIENT_RESOURCES','TRINO_USER_CANCELLED','TRINO_INVALID_ARGUMENT','MISSING_ARGUMENT','DATABASE_NOT_FOUND','WORKFLOW_PROJECT_NOT_FOUND','TRINO_SYNTAX_ERROR','11VyEjLI','20yRgpfh','INVALID_ARGUMENT','590920USjdUE','name','USER_ERROR','LLM_CHAT_CREATION_FAILURE','some','TRINO_NOT_FOUND'];a47_0x1790=function(){return _0x4cd7fc;};return a47_0x1790();}(function(_0x1c97de){const _0x580495=a47_0x2a27;_0x1c97de[_0x580495(0x13c)]=_0x580495(0x13c),_0x1c97de['INVALID_ARGUMENT']=_0x580495(0x142),_0x1c97de[_0x580495(0x11c)]='NOT_FOUND',_0x1c97de[_0x580495(0x13d)]=_0x580495(0x13d),_0x1c97de[_0x580495(0x138)]=_0x580495(0x138),_0x1c97de[_0x580495(0x121)]='LLM_PROJECT_NOT_FOUND',_0x1c97de[_0x580495(0x122)]=_0x580495(0x122),_0x1c97de[_0x580495(0x13e)]=_0x580495(0x13e),_0x1c97de[_0x580495(0x119)]='CHAT_NOT_FOUND',_0x1c97de[_0x580495(0x11d)]=_0x580495(0x11d),_0x1c97de[_0x580495(0x12c)]=_0x580495(0x12c),_0x1c97de[_0x580495(0x12b)]=_0x580495(0x12b),_0x1c97de[_0x580495(0x135)]=_0x580495(0x135),_0x1c97de['UNAUTHENTICATED']=_0x580495(0x117),_0x1c97de[_0x580495(0x11a)]=_0x580495(0x11a),_0x1c97de[_0x580495(0x114)]='CANCELLED',_0x1c97de[_0x580495(0x13f)]=_0x580495(0x13f),_0x1c97de['TRINO_NOT_FOUND']=_0x580495(0x148),_0x1c97de[_0x580495(0x13b)]=_0x580495(0x13b),_0x1c97de[_0x580495(0x13a)]='TRINO_USER_CANCELLED',_0x1c97de[_0x580495(0x128)]='UNAVAILABLE',_0x1c97de[_0x580495(0x12f)]=_0x580495(0x12f),_0x1c97de[_0x580495(0x130)]=_0x580495(0x130),_0x1c97de[_0x580495(0x124)]=_0x580495(0x124),_0x1c97de[_0x580495(0x126)]=_0x580495(0x126),_0x1c97de[_0x580495(0x116)]=_0x580495(0x116),_0x1c97de[_0x580495(0x139)]=_0x580495(0x139),_0x1c97de[_0x580495(0x133)]=_0x580495(0x133),_0x1c97de[_0x580495(0x137)]=_0x580495(0x137),_0x1c97de[_0x580495(0x146)]=_0x580495(0x146);}(ErrorCode||(ErrorCode={})));const ERROR_CODE_CATEGORY={[ErrorCode[a47_0x4385df(0x13c)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a47_0x4385df(0x142)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['NOT_FOUND']]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x13d)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a47_0x4385df(0x138)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['LLM_PROJECT_NOT_FOUND']]:ErrorCategory['USER_ERROR'],[ErrorCode[a47_0x4385df(0x122)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x13e)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['CHAT_NOT_FOUND']]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x11d)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x12c)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x12b)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a47_0x4385df(0x135)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x117)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x11a)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['CANCELLED']]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x13f)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x148)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode[a47_0x4385df(0x13b)]]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['TRINO_USER_CANCELLED']]:ErrorCategory[a47_0x4385df(0x145)],[ErrorCode['UNAVAILABLE']]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a47_0x4385df(0x12f)]]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode[a47_0x4385df(0x130)]]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode[a47_0x4385df(0x124)]]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode[a47_0x4385df(0x126)]]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode['TRINO_INTERNAL_ERROR']]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode['TRINO_INSUFFICIENT_RESOURCES']]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a47_0x4385df(0x133)]]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode['LLM_STREAM_ERROR']]:ErrorCategory[a47_0x4385df(0x123)],[ErrorCode[a47_0x4385df(0x146)]]:ErrorCategory[a47_0x4385df(0x123)]};export function getErrorCategory(_0x3f7ec8){return ERROR_CODE_CATEGORY[_0x3f7ec8];}export function isRetryableError(_0x653604){const _0xd8ea04=a47_0x4385df;return getErrorCategory(_0x653604)===ErrorCategory[_0xd8ea04(0x123)];}export class SDKError extends Error{[a47_0x4385df(0x113)];[a47_0x4385df(0x129)];[a47_0x4385df(0x131)];constructor(_0x48d094,_0x3d877d,_0x29c2ac,_0x154d49){const _0x20a86b=a47_0x4385df;super('['+_0x48d094+']\x20'+_0x3d877d),this[_0x20a86b(0x144)]='SDKError',this[_0x20a86b(0x113)]=_0x48d094,this[_0x20a86b(0x129)]=_0x154d49?.['helpText'],this[_0x20a86b(0x131)]=_0x29c2ac,_0x29c2ac instanceof Error&&(this[_0x20a86b(0x136)]=this[_0x20a86b(0x136)]+_0x20a86b(0x118)+_0x29c2ac[_0x20a86b(0x136)]);}get[a47_0x4385df(0x149)](){return getErrorCategory(this['code']);}[a47_0x4385df(0x127)](){const _0x583c1d=a47_0x4385df;return isRetryableError(this[_0x583c1d(0x113)]);}get[a47_0x4385df(0x12d)](){const _0x52b6dd=a47_0x4385df;return this[_0x52b6dd(0x112)][_0x52b6dd(0x115)](/^\[.*?\]\s*/,'');}}export function errorContains(_0x46e988,..._0x503990){const _0x1a5905=a47_0x4385df,_0x27bc86=_0x46e988?.['message']||'',_0x5e25e1=_0x46e988?.[_0x1a5905(0x131)],_0x53b6bb=_0x5e25e1?.[_0x1a5905(0x112)]||'';return _0x503990[_0x1a5905(0x147)](_0x9739e9=>_0x27bc86['includes'](_0x9739e9)||_0x53b6bb[_0x1a5905(0x132)](_0x9739e9));}
1
+ const a47_0x130104=a47_0x44ff;(function(_0x102b02,_0x1b4ccb){const _0x43ac0d=a47_0x44ff,_0x3279d6=_0x102b02();while(!![]){try{const _0x4167f2=-parseInt(_0x43ac0d(0xa7))/0x1*(parseInt(_0x43ac0d(0x8d))/0x2)+parseInt(_0x43ac0d(0x92))/0x3*(-parseInt(_0x43ac0d(0x96))/0x4)+parseInt(_0x43ac0d(0xb1))/0x5+-parseInt(_0x43ac0d(0x8e))/0x6*(parseInt(_0x43ac0d(0x8a))/0x7)+-parseInt(_0x43ac0d(0x9f))/0x8*(-parseInt(_0x43ac0d(0xb2))/0x9)+parseInt(_0x43ac0d(0xb5))/0xa+parseInt(_0x43ac0d(0xa1))/0xb*(parseInt(_0x43ac0d(0xaf))/0xc);if(_0x4167f2===_0x1b4ccb)break;else _0x3279d6['push'](_0x3279d6['shift']());}catch(_0x270f75){_0x3279d6['push'](_0x3279d6['shift']());}}}(a47_0x1458,0xbb13c));export var ErrorCategory;function a47_0x44ff(_0x326e1d,_0x1a251e){const _0x145808=a47_0x1458();return a47_0x44ff=function(_0x44ff42,_0x8ce8b8){_0x44ff42=_0x44ff42-0x87;let _0x36ba42=_0x145808[_0x44ff42];return _0x36ba42;},a47_0x44ff(_0x326e1d,_0x1a251e);}(function(_0x4c73a6){const _0x4000f0=a47_0x44ff;_0x4c73a6[_0x4000f0(0xba)]=_0x4000f0(0xba),_0x4c73a6[_0x4000f0(0xab)]=_0x4000f0(0xab);}(ErrorCategory||(ErrorCategory={})));export var ErrorCode;(function(_0x3abd3a){const _0x1897ab=a47_0x44ff;_0x3abd3a[_0x1897ab(0xa5)]=_0x1897ab(0xa5),_0x3abd3a[_0x1897ab(0x87)]=_0x1897ab(0x87),_0x3abd3a['NOT_FOUND']=_0x1897ab(0x8f),_0x3abd3a[_0x1897ab(0xa2)]=_0x1897ab(0xa2),_0x3abd3a['TABLE_NOT_FOUND']='TABLE_NOT_FOUND',_0x3abd3a[_0x1897ab(0xb8)]=_0x1897ab(0xb8),_0x3abd3a[_0x1897ab(0xb3)]=_0x1897ab(0xb3),_0x3abd3a[_0x1897ab(0xb7)]='WORKFLOW_PROJECT_NOT_FOUND',_0x3abd3a[_0x1897ab(0xb6)]=_0x1897ab(0xb6),_0x3abd3a[_0x1897ab(0xb0)]=_0x1897ab(0xb0),_0x3abd3a[_0x1897ab(0xb9)]=_0x1897ab(0xb9),_0x3abd3a[_0x1897ab(0x9c)]=_0x1897ab(0x9c),_0x3abd3a[_0x1897ab(0x9e)]=_0x1897ab(0x9e),_0x3abd3a[_0x1897ab(0xa9)]=_0x1897ab(0xa9),_0x3abd3a[_0x1897ab(0xa0)]=_0x1897ab(0xa0),_0x3abd3a[_0x1897ab(0xa4)]='CANCELLED',_0x3abd3a[_0x1897ab(0xae)]='TRINO_SYNTAX_ERROR',_0x3abd3a[_0x1897ab(0x97)]=_0x1897ab(0x97),_0x3abd3a['TRINO_INVALID_ARGUMENT']=_0x1897ab(0xad),_0x3abd3a[_0x1897ab(0x9b)]=_0x1897ab(0x9b),_0x3abd3a[_0x1897ab(0xa3)]=_0x1897ab(0xa3),_0x3abd3a[_0x1897ab(0xaa)]=_0x1897ab(0xaa),_0x3abd3a['HTTP_REQUEST_FAILURE']=_0x1897ab(0x89),_0x3abd3a[_0x1897ab(0x9a)]=_0x1897ab(0x9a),_0x3abd3a[_0x1897ab(0x88)]=_0x1897ab(0x88),_0x3abd3a[_0x1897ab(0x90)]=_0x1897ab(0x90),_0x3abd3a[_0x1897ab(0x95)]=_0x1897ab(0x95),_0x3abd3a['LLM_MALFORMED_MESSAGE']='LLM_MALFORMED_MESSAGE',_0x3abd3a[_0x1897ab(0xac)]=_0x1897ab(0xac),_0x3abd3a[_0x1897ab(0x99)]='LLM_CHAT_CREATION_FAILURE';}(ErrorCode||(ErrorCode={})));const ERROR_CODE_CATEGORY={[ErrorCode[a47_0x130104(0xa5)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0x87)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['NOT_FOUND']]:ErrorCategory['USER_ERROR'],[ErrorCode['DATABASE_NOT_FOUND']]:ErrorCategory['USER_ERROR'],[ErrorCode['TABLE_NOT_FOUND']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0xb8)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0xb3)]]:ErrorCategory['USER_ERROR'],[ErrorCode['WORKFLOW_PROJECT_NOT_FOUND']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0xb6)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['LLM_EMPTY_MESSAGE']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['COMMAND_NOT_FOUND']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0x9c)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0x9e)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['UNAUTHENTICATED']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['ALREADY_EXISTS']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['CANCELLED']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0xae)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode['TRINO_NOT_FOUND']]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0xad)]]:ErrorCategory[a47_0x130104(0xba)],[ErrorCode[a47_0x130104(0x9b)]]:ErrorCategory['USER_ERROR'],[ErrorCode[a47_0x130104(0xa3)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode['TIMEOUT']]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode[a47_0x130104(0x89)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode[a47_0x130104(0x9a)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode[a47_0x130104(0x88)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode[a47_0x130104(0x90)]]:ErrorCategory['INTERNAL_ERROR'],[ErrorCode[a47_0x130104(0x95)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode[a47_0x130104(0xb4)]]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode['LLM_STREAM_ERROR']]:ErrorCategory[a47_0x130104(0xab)],[ErrorCode['LLM_CHAT_CREATION_FAILURE']]:ErrorCategory[a47_0x130104(0xab)]};export function getErrorCategory(_0x2f4dd4){return ERROR_CODE_CATEGORY[_0x2f4dd4];}export function isRetryableError(_0x39db89){const _0x399d6a=a47_0x130104;return getErrorCategory(_0x39db89)===ErrorCategory[_0x399d6a(0xab)];}export class SDKError extends Error{[a47_0x130104(0x9d)];['helpText'];[a47_0x130104(0x8c)];constructor(_0x21b956,_0x2047dd,_0x6acefb,_0x5ac6cb){const _0x1737f8=a47_0x130104;super('['+_0x21b956+']\x20'+_0x2047dd),this['name']=_0x1737f8(0x91),this['code']=_0x21b956,this[_0x1737f8(0x94)]=_0x5ac6cb?.['helpText'],this['cause']=_0x6acefb,_0x6acefb instanceof Error&&(this[_0x1737f8(0x8b)]=this[_0x1737f8(0x8b)]+'\x0aCaused\x20by:\x20'+_0x6acefb[_0x1737f8(0x8b)]);}get['category'](){const _0x3aa813=a47_0x130104;return getErrorCategory(this[_0x3aa813(0x9d)]);}['isRetryable'](){return isRetryableError(this['code']);}get['originalMessage'](){const _0x25ede5=a47_0x130104;return this[_0x25ede5(0x98)][_0x25ede5(0xa8)](/^\[.*?\]\s*/,'');}}export function errorContains(_0x12217d,..._0x6624d4){const _0x1c4150=a47_0x130104,_0x545e46=_0x12217d?.[_0x1c4150(0x98)]||'',_0x28a896=_0x12217d?.['cause'],_0x30ec2d=_0x28a896?.[_0x1c4150(0x98)]||'';return _0x6624d4[_0x1c4150(0x93)](_0x200527=>_0x545e46[_0x1c4150(0xa6)](_0x200527)||_0x30ec2d['includes'](_0x200527));}function a47_0x1458(){const _0x4385f4=['2536610eCREvv','CHAT_NOT_FOUND','WORKFLOW_PROJECT_NOT_FOUND','LLM_PROJECT_NOT_FOUND','COMMAND_NOT_FOUND','USER_ERROR','INVALID_ARGUMENT','RATE_LIMITED','HTTP_REQUEST_FAILURE','14vnXZhI','stack','cause','4kpgHrK','271488sZVbrF','NOT_FOUND','TRINO_INTERNAL_ERROR','SDKError','3loPjyx','some','helpText','TRINO_INSUFFICIENT_RESOURCES','1933508NEMxuZ','TRINO_NOT_FOUND','message','LLM_CHAT_CREATION_FAILURE','INTERNAL','TRINO_USER_CANCELLED','INSTALLATION_FAILED','code','PERMISSION_DENIED','8TsPiHF','ALREADY_EXISTS','11NRJvTN','DATABASE_NOT_FOUND','UNAVAILABLE','CANCELLED','MISSING_ARGUMENT','includes','514687KgQnyK','replace','UNAUTHENTICATED','TIMEOUT','INTERNAL_ERROR','LLM_STREAM_ERROR','TRINO_INVALID_ARGUMENT','TRINO_SYNTAX_ERROR','4777236ragVHb','LLM_EMPTY_MESSAGE','2241665teIVQi','11424762zyhdbE','AGENT_NOT_FOUND','LLM_MALFORMED_MESSAGE'];a47_0x1458=function(){return _0x4385f4;};return a47_0x1458();}
package/dist/sdk/index.js CHANGED
@@ -1 +1 @@
1
- const a48_0x1a3b13=a48_0x5b3d;(function(_0x38955a,_0x5ea0c3){const _0x48163d=a48_0x5b3d,_0x571502=_0x38955a();while(!![]){try{const _0x324829=parseInt(_0x48163d(0x13b))/0x1*(parseInt(_0x48163d(0x139))/0x2)+-parseInt(_0x48163d(0x12f))/0x3*(parseInt(_0x48163d(0x12d))/0x4)+-parseInt(_0x48163d(0x13e))/0x5+-parseInt(_0x48163d(0x135))/0x6*(parseInt(_0x48163d(0x138))/0x7)+-parseInt(_0x48163d(0x129))/0x8*(-parseInt(_0x48163d(0x12b))/0x9)+parseInt(_0x48163d(0x128))/0xa+-parseInt(_0x48163d(0x134))/0xb*(-parseInt(_0x48163d(0x133))/0xc);if(_0x324829===_0x5ea0c3)break;else _0x571502['push'](_0x571502['shift']());}catch(_0x569466){_0x571502['push'](_0x571502['shift']());}}}(a48_0x2671,0xb16db));import{loadUserConfigOnce,getAPIKey}from'../core/config.js';import{SegmentSDK}from'./segment.js';import{WorkflowSDK}from'./workflow.js';import{LLMSDK}from'./llm.js';import{JobSDK}from'./job.js';import{RawAPI}from'./api.js';import{QuerySDK}from'./query.js';import{LogLevel,TDXLogger}from'../utils/tdx-logger.js';export*from'./errors.js';export*from'./segment.js';function a48_0x2671(){const _0x537b80=['apiKey','1216845xhLbJw','catch','site','11372980UZqwot','101856nnutiI','INFO','9BAsGpW','jobs','2228TcnppM','api','4155kBydCp','logger','segment','logLevel','9708YGCduF','341AxXkhH','6HFonPt','workflow','query','4214959cpwkkC','218uvwjns','context','10721MCIUdq','create'];a48_0x2671=function(){return _0x537b80;};return a48_0x2671();}export*from'./workflow.js';export*from'./llm.js';function a48_0x5b3d(_0x5f5bab,_0xb9866){const _0x26711c=a48_0x2671();return a48_0x5b3d=function(_0x5b3d73,_0x286cd3){_0x5b3d73=_0x5b3d73-0x126;let _0x2ccb60=_0x26711c[_0x5b3d73];return _0x2ccb60;},a48_0x5b3d(_0x5f5bab,_0xb9866);}export*from'./job.js';export*from'./api.js';export*from'./query.js';export{LogLevel}from'../utils/tdx-logger.js';export class TDX{[a48_0x1a3b13(0x13a)];[a48_0x1a3b13(0x137)];[a48_0x1a3b13(0x131)];[a48_0x1a3b13(0x136)];['llm'];[a48_0x1a3b13(0x12c)];['api'];static[a48_0x1a3b13(0x13c)](_0x58804b={}){const _0x49496e=a48_0x1a3b13,_0x31cdf3=_0x58804b[_0x49496e(0x127)]||'us01',_0x20488e=_0x58804b[_0x49496e(0x132)]??LogLevel[_0x49496e(0x12a)];let _0x14d0d3=_0x58804b[_0x49496e(0x13d)];!_0x14d0d3&&(loadUserConfigOnce(),_0x14d0d3=getAPIKey(_0x31cdf3));const _0x113887=new TDXLogger(_0x20488e,!![]);return _0x113887['init']()[_0x49496e(0x126)](()=>{}),new TDX({'site':_0x31cdf3,'apiKey':_0x14d0d3,'logLevel':_0x20488e,'logger':_0x113887});}constructor(_0x42e730){const _0x4e46c9=a48_0x1a3b13;this[_0x4e46c9(0x13a)]=_0x42e730,this[_0x4e46c9(0x137)]=new QuerySDK(_0x42e730),this[_0x4e46c9(0x131)]=new SegmentSDK(_0x42e730),this[_0x4e46c9(0x136)]=new WorkflowSDK(_0x42e730),this['llm']=new LLMSDK(_0x42e730),this[_0x4e46c9(0x12c)]=new JobSDK(_0x42e730),this[_0x4e46c9(0x12e)]=new RawAPI(_0x42e730);}get[a48_0x1a3b13(0x130)](){const _0x117c91=a48_0x1a3b13;return this['context'][_0x117c91(0x130)];}}
1
+ const a48_0x9d5792=a48_0x1e35;(function(_0x118e66,_0x5c93d8){const _0xde83f3=a48_0x1e35,_0x3d7f27=_0x118e66();while(!![]){try{const _0x21d304=-parseInt(_0xde83f3(0xcc))/0x1+parseInt(_0xde83f3(0xc8))/0x2+parseInt(_0xde83f3(0xce))/0x3+parseInt(_0xde83f3(0xbd))/0x4*(parseInt(_0xde83f3(0xc0))/0x5)+-parseInt(_0xde83f3(0xc1))/0x6+-parseInt(_0xde83f3(0xca))/0x7+-parseInt(_0xde83f3(0xc6))/0x8*(-parseInt(_0xde83f3(0xbf))/0x9);if(_0x21d304===_0x5c93d8)break;else _0x3d7f27['push'](_0x3d7f27['shift']());}catch(_0x1ef3eb){_0x3d7f27['push'](_0x3d7f27['shift']());}}}(a48_0x16d7,0x528b2));import{loadUserConfigOnce,getAPIKey}from'../core/config.js';import{SegmentSDK}from'./segment.js';import{WorkflowSDK}from'./workflow.js';function a48_0x16d7(){const _0x2bfa00=['370022iOfpIF','workflow','3484810iGFGKx','apiKey','325861ozfXtA','logLevel','1323705PuiBPm','site','llm','INFO','segment','8IGbSki','query','72GriKVj','673195HUSAlN','2591322foDhZW','api','us01','jobs','catch','698152vyqFEl','context'];a48_0x16d7=function(){return _0x2bfa00;};return a48_0x16d7();}import{LLMSDK}from'./llm.js';import{JobSDK}from'./job.js';import{RawAPI}from'./api.js';import{QuerySDK}from'./query.js';import{LogLevel,TDXLogger}from'../utils/tdx-logger.js';export*from'./errors.js';export*from'./segment.js';export*from'./workflow.js';export*from'./llm.js';export*from'./job.js';function a48_0x1e35(_0x41c5ac,_0x3700b1){const _0x16d77e=a48_0x16d7();return a48_0x1e35=function(_0x1e3514,_0x250ae2){_0x1e3514=_0x1e3514-0xbd;let _0x16c0e0=_0x16d77e[_0x1e3514];return _0x16c0e0;},a48_0x1e35(_0x41c5ac,_0x3700b1);}export*from'./api.js';export*from'./query.js';export{LogLevel}from'../utils/tdx-logger.js';export class TDX{[a48_0x9d5792(0xc7)];[a48_0x9d5792(0xbe)];[a48_0x9d5792(0xd2)];[a48_0x9d5792(0xc9)];[a48_0x9d5792(0xd0)];['jobs'];[a48_0x9d5792(0xc2)];static['create'](_0x259cbf={}){const _0x85f170=a48_0x9d5792,_0x110c96=_0x259cbf[_0x85f170(0xcf)]||_0x85f170(0xc3),_0x3b6ab4=_0x259cbf[_0x85f170(0xcd)]??LogLevel[_0x85f170(0xd1)];let _0x139de1=_0x259cbf[_0x85f170(0xcb)];!_0x139de1&&(loadUserConfigOnce(),_0x139de1=getAPIKey(_0x110c96));const _0x4b6fcb=new TDXLogger(_0x3b6ab4,!![]);return _0x4b6fcb['init']()[_0x85f170(0xc5)](()=>{}),new TDX({'site':_0x110c96,'apiKey':_0x139de1,'logLevel':_0x3b6ab4,'logger':_0x4b6fcb});}constructor(_0xc77d50){const _0x39721d=a48_0x9d5792;this[_0x39721d(0xc7)]=_0xc77d50,this[_0x39721d(0xbe)]=new QuerySDK(_0xc77d50),this['segment']=new SegmentSDK(_0xc77d50),this[_0x39721d(0xc9)]=new WorkflowSDK(_0xc77d50),this[_0x39721d(0xd0)]=new LLMSDK(_0xc77d50),this[_0x39721d(0xc4)]=new JobSDK(_0xc77d50),this['api']=new RawAPI(_0xc77d50);}get['logger'](){return this['context']['logger'];}}
package/dist/sdk/job.js CHANGED
@@ -1 +1 @@
1
- const a49_0x52e3fa=a49_0x885b;function a49_0x2880(){const _0xd4059c=['184OAmXVV','submitPrestoJob','872773KVtrxi','start_at','test','replace','listJobs','11342504ScEvDB','3120234yqMmgv','client','submitHiveJob','show','2010232OxjtRX','getUserInfo','trino','kill','showJob','cancelJob','3594745ozECul','updated_at','9IhRIah','list','67314TswhAs','getJobResult','6001177RQOyBA','\x20UTC','result','end_at'];a49_0x2880=function(){return _0xd4059c;};return a49_0x2880();}(function(_0x17c50d,_0x561722){const _0x1a4a18=a49_0x885b,_0x2f0174=_0x17c50d();while(!![]){try{const _0x39120e=parseInt(_0x1a4a18(0xb4))/0x1+parseInt(_0x1a4a18(0xa2))/0x2+-parseInt(_0x1a4a18(0xac))/0x3*(-parseInt(_0x1a4a18(0xb2))/0x4)+parseInt(_0x1a4a18(0xa8))/0x5+-parseInt(_0x1a4a18(0x9e))/0x6+-parseInt(_0x1a4a18(0xae))/0x7+-parseInt(_0x1a4a18(0x9d))/0x8*(parseInt(_0x1a4a18(0xaa))/0x9);if(_0x39120e===_0x561722)break;else _0x2f0174['push'](_0x2f0174['shift']());}catch(_0x47decb){_0x2f0174['push'](_0x2f0174['shift']());}}}(a49_0x2880,0xcb91f));import{TDApiClient}from'../client/td-api-client.js';function normalizeTimestamp(_0x4f3fb3){const _0xbeb4d=a49_0x885b;if(!_0x4f3fb3)return undefined;if(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/[_0xbeb4d(0xb6)](_0x4f3fb3))return _0x4f3fb3;return _0x4f3fb3['replace'](_0xbeb4d(0xaf),'Z')[_0xbeb4d(0xb7)]('\x20','T');}function a49_0x885b(_0x11fc46,_0x433b3a){const _0x288006=a49_0x2880();return a49_0x885b=function(_0x885b2a,_0x4a780f){_0x885b2a=_0x885b2a-0x9d;let _0x26269a=_0x288006[_0x885b2a];return _0x26269a;},a49_0x885b(_0x11fc46,_0x433b3a);}export class JobSDK{[a49_0x52e3fa(0x9f)];constructor(_0x4720d0){const _0x743bec=a49_0x52e3fa;this[_0x743bec(0x9f)]=new TDApiClient(_0x4720d0,_0x4720d0['logger']);}async[a49_0x52e3fa(0xab)](_0x3fabac){const _0x58678d=a49_0x52e3fa,_0x1ce3d5=await this[_0x58678d(0x9f)][_0x58678d(0xb8)](_0x3fabac);return _0x1ce3d5['map'](_0x219ea3=>({..._0x219ea3,'created_at':normalizeTimestamp(_0x219ea3['created_at']),'updated_at':normalizeTimestamp(_0x219ea3['updated_at']),'start_at':normalizeTimestamp(_0x219ea3[_0x58678d(0xb5)]),'end_at':normalizeTimestamp(_0x219ea3[_0x58678d(0xb1)])}));}async[a49_0x52e3fa(0xa1)](_0x42b10b){const _0x13f7f9=a49_0x52e3fa,_0x3db955=await this['client'][_0x13f7f9(0xa6)](_0x42b10b);return{..._0x3db955,'created_at':normalizeTimestamp(_0x3db955['created_at']),'updated_at':normalizeTimestamp(_0x3db955[_0x13f7f9(0xa9)]),'start_at':normalizeTimestamp(_0x3db955[_0x13f7f9(0xb5)]),'end_at':normalizeTimestamp(_0x3db955[_0x13f7f9(0xb1)])};}async[a49_0x52e3fa(0xa5)](_0xd106ee){const _0x5b75fc=a49_0x52e3fa;await this[_0x5b75fc(0x9f)][_0x5b75fc(0xa7)](_0xd106ee);}async['submit'](_0x4a54a6,_0x47b7bc,_0x323daf=a49_0x52e3fa(0xa4)){const _0x99f32f=a49_0x52e3fa;return _0x323daf==='hive'?await this[_0x99f32f(0x9f)][_0x99f32f(0xa0)](_0x4a54a6,_0x47b7bc):await this[_0x99f32f(0x9f)][_0x99f32f(0xb3)](_0x4a54a6,_0x47b7bc);}async[a49_0x52e3fa(0xb0)](_0x2f26e7){const _0xaa455a=a49_0x52e3fa;return await this['client'][_0xaa455a(0xad)](_0x2f26e7);}async[a49_0x52e3fa(0xa3)](){const _0x5f51db=a49_0x52e3fa;return await this['client'][_0x5f51db(0xa3)]();}}
1
+ const a49_0x18a7e8=a49_0x5198;(function(_0x2a34b1,_0x4f8db0){const _0x4da922=a49_0x5198,_0x11e206=_0x2a34b1();while(!![]){try{const _0x597a0c=-parseInt(_0x4da922(0xc6))/0x1*(parseInt(_0x4da922(0xc8))/0x2)+parseInt(_0x4da922(0xd6))/0x3*(-parseInt(_0x4da922(0xd5))/0x4)+parseInt(_0x4da922(0xb9))/0x5+parseInt(_0x4da922(0xc9))/0x6*(-parseInt(_0x4da922(0xbb))/0x7)+-parseInt(_0x4da922(0xc1))/0x8+parseInt(_0x4da922(0xd3))/0x9+-parseInt(_0x4da922(0xcf))/0xa*(-parseInt(_0x4da922(0xc7))/0xb);if(_0x597a0c===_0x4f8db0)break;else _0x11e206['push'](_0x11e206['shift']());}catch(_0x216d3e){_0x11e206['push'](_0x11e206['shift']());}}}(a49_0x8445,0xdc981));import{TDApiClient}from'../client/td-api-client.js';function normalizeTimestamp(_0x20bcd4){const _0x3bc6e4=a49_0x5198;if(!_0x20bcd4)return undefined;if(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/[_0x3bc6e4(0xcc)](_0x20bcd4))return _0x20bcd4;return _0x20bcd4['replace'](_0x3bc6e4(0xbe),'Z')['replace']('\x20','T');}function a49_0x5198(_0x3e262b,_0x27c917){const _0x844521=a49_0x8445();return a49_0x5198=function(_0x5198f3,_0x1e4b44){_0x5198f3=_0x5198f3-0xb9;let _0x42da05=_0x844521[_0x5198f3];return _0x42da05;},a49_0x5198(_0x3e262b,_0x27c917);}function a49_0x8445(){const _0x4497a0=['kill','start_at','submitPrestoJob','client','15YPDOWS','6787bqzTeB','202228kfBRYJ','6vlGIwi','logger','list','test','getUserInfo','end_at','78190IkupxI','submit','hive','listJobs','4687650ukTWnd','created_at','4xstLdt','5122893vvVUIc','8370510PDSsEC','result','12026252bisYWW','trino','updated_at','\x20UTC','getJobResult','show','9386760OSbQfK'];a49_0x8445=function(){return _0x4497a0;};return a49_0x8445();}export class JobSDK{[a49_0x18a7e8(0xc5)];constructor(_0x5ec35d){const _0x2a0a5e=a49_0x18a7e8;this['client']=new TDApiClient(_0x5ec35d,_0x5ec35d[_0x2a0a5e(0xca)]);}async[a49_0x18a7e8(0xcb)](_0x253f34){const _0x529bba=a49_0x18a7e8,_0x4cc3c5=await this['client'][_0x529bba(0xd2)](_0x253f34);return _0x4cc3c5['map'](_0x215058=>({..._0x215058,'created_at':normalizeTimestamp(_0x215058[_0x529bba(0xd4)]),'updated_at':normalizeTimestamp(_0x215058[_0x529bba(0xbd)]),'start_at':normalizeTimestamp(_0x215058['start_at']),'end_at':normalizeTimestamp(_0x215058[_0x529bba(0xce)])}));}async[a49_0x18a7e8(0xc0)](_0x117cb5){const _0x172ca0=a49_0x18a7e8,_0xbdbb0b=await this[_0x172ca0(0xc5)]['showJob'](_0x117cb5);return{..._0xbdbb0b,'created_at':normalizeTimestamp(_0xbdbb0b[_0x172ca0(0xd4)]),'updated_at':normalizeTimestamp(_0xbdbb0b[_0x172ca0(0xbd)]),'start_at':normalizeTimestamp(_0xbdbb0b[_0x172ca0(0xc3)]),'end_at':normalizeTimestamp(_0xbdbb0b[_0x172ca0(0xce)])};}async[a49_0x18a7e8(0xc2)](_0x15af49){await this['client']['cancelJob'](_0x15af49);}async[a49_0x18a7e8(0xd0)](_0x34aeb1,_0xdebd29,_0x2877cf=a49_0x18a7e8(0xbc)){const _0x4ae9dc=a49_0x18a7e8;return _0x2877cf===_0x4ae9dc(0xd1)?await this[_0x4ae9dc(0xc5)]['submitHiveJob'](_0x34aeb1,_0xdebd29):await this[_0x4ae9dc(0xc5)][_0x4ae9dc(0xc4)](_0x34aeb1,_0xdebd29);}async[a49_0x18a7e8(0xba)](_0x3b6c18){const _0x3ab13d=a49_0x18a7e8;return await this[_0x3ab13d(0xc5)][_0x3ab13d(0xbf)](_0x3b6c18);}async[a49_0x18a7e8(0xcd)](){const _0x3fc7e6=a49_0x18a7e8;return await this[_0x3fc7e6(0xc5)][_0x3fc7e6(0xcd)]();}}