@aragon-agent/core 0.2.92 → 0.2.94

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 (48) hide show
  1. package/dist/engine/accept-steering.js +1 -15
  2. package/dist/engine/agent-loop.js +1 -533
  3. package/dist/engine/agent.js +1 -538
  4. package/dist/engine/compaction.js +1 -268
  5. package/dist/engine/context-manager.js +1 -13
  6. package/dist/engine/message-manager.js +1 -39
  7. package/dist/engine/steering.js +1 -72
  8. package/dist/engine/tool-result-content.js +1 -39
  9. package/dist/engine/watchdog.js +1 -73
  10. package/dist/index.js +1 -99
  11. package/dist/llm/context-window.js +1 -46
  12. package/dist/llm/image-tokens.js +1 -11
  13. package/dist/llm/model-discovery.js +1 -18
  14. package/dist/llm/model-registry.js +1 -370
  15. package/dist/llm/output-limit-recovery.js +1 -263
  16. package/dist/llm/output-limits.js +1 -283
  17. package/dist/llm/provider.js +1 -171
  18. package/dist/llm/providers/anthropic.js +1 -514
  19. package/dist/llm/providers/google.js +1 -464
  20. package/dist/llm/providers/index.js +1 -205
  21. package/dist/llm/providers/openai.js +1 -520
  22. package/dist/llm/providers/tool-result-images.js +1 -52
  23. package/dist/llm/retry.js +1 -948
  24. package/dist/llm/sse-parser.js +1 -103
  25. package/dist/llm/stream-utils.js +1 -118
  26. package/dist/llm/types.js +1 -17
  27. package/dist/sandbox/console-capture.js +1 -56
  28. package/dist/sandbox/http-bridge.js +1 -143
  29. package/dist/sandbox/isolated-vm-sandbox.js +1 -226
  30. package/dist/sandbox/tool-bridge.js +1 -98
  31. package/dist/sandbox/types.js +1 -8
  32. package/dist/skills/constants.js +1 -179
  33. package/dist/skills/disclosure.js +1 -788
  34. package/dist/skills/frontmatter.js +1 -177
  35. package/dist/skills/index.js +1 -18
  36. package/dist/skills/skill-find-tool.js +1 -117
  37. package/dist/skills/skill-registry.js +1 -208
  38. package/dist/skills/skill-tool.js +1 -96
  39. package/dist/skills/tool-policy.js +1 -272
  40. package/dist/skills/types.js +1 -8
  41. package/dist/skills/validate.js +1 -264
  42. package/dist/tools/executor.js +1 -281
  43. package/dist/tools/helpers.js +1 -87
  44. package/dist/tools/registry.js +1 -119
  45. package/dist/tools/types.js +1 -7
  46. package/dist/tools/validator.js +1 -210
  47. package/dist/types.js +1 -7
  48. package/package.json +3 -2
package/dist/index.js CHANGED
@@ -1,99 +1 @@
1
- /**
2
- * Agent core — barrel export.
3
- *
4
- * This is the single entry point for importing agent-core functionality.
5
- * Other tasks will expand this file as more modules are added (engine, tools,
6
- * sandbox).
7
- */
8
- export { THINKING_BUDGET } from './llm/types.js';
9
- export { LLMError, classifyHttpError, wrapFetchError, } from './llm/provider.js';
10
- // ---------------------------------------------------------------------------
11
- // Output-token limits — the authority for "how many tokens may this model
12
- // produce". Every adapter resolves through here; nothing else spells 64000.
13
- // ---------------------------------------------------------------------------
14
- export { DEFAULT_MAX_OUTPUT_TOKENS, MIN_MAX_OUTPUT_TOKENS, SAFE_FALLBACK_MAX_OUTPUT_TOKENS, ABSOLUTE_MAX_OUTPUT_TOKENS, THINKING_HEADROOM_TOKENS, CONTEXT_SAFETY_MARGIN_TOKENS, resolveOutputTokens, staticCeilingFor, learnModelCeiling, getLearnedCeiling, clearLearnedCeilings, estimatePromptTokens,
15
- // Promoted from module-private for the compaction digest's budget arithmetic
16
- // (context-auto-compaction P2-3): two chars-per-token constants that must agree
17
- // and nothing checking that they do is how a budget and an estimate drift.
18
- CHARS_PER_TOKEN, } from './llm/output-limits.js';
19
- // Single source of the per-image token cost (desktop-attachments-and-tool-voice D-21).
20
- export { IMAGE_TOKEN_ESTIMATE } from './llm/image-tokens.js';
21
- export { classifyOutputLimitFailure, sendWithOutputLimitRecovery, learnTokenField, getLearnedTokenField, clearLearnedTokenFields, } from './llm/output-limit-recovery.js';
22
- // ---------------------------------------------------------------------------
23
- // Retry & exponential backoff — the authority for "a provider call failed, now
24
- // what". Installed by default on `ProviderRegistry.stream()`; opt out with
25
- // `initProviders({ retryPolicy: null })` or `setRetryPolicy(null)`.
26
- //
27
- // `normalizePolicy` and `decide` are deliberately NOT here: they are the
28
- // implementation of the two entry points below, nobody outside the module has a
29
- // reason to call them, and promoting them would add two symbols to the frozen
30
- // public surface for nothing.
31
- // ---------------------------------------------------------------------------
32
- export { RETRY_LIMITS, DEFAULT_RETRY_POLICY, isRetryableError, computeBackoffDelay, parseRetryAfterMs, withRetry, } from './llm/retry.js';
33
- export { parseSSEStream, consumeStream, } from './llm/stream-utils.js';
34
- // ---------------------------------------------------------------------------
35
- // Provider registry
36
- // ---------------------------------------------------------------------------
37
- export { ProviderRegistry, initProviders, getProviderRegistry, setProviderRegistry, streamLLM, completeLLM, } from './llm/providers/index.js';
38
- // ---------------------------------------------------------------------------
39
- // Individual providers (for direct use when needed)
40
- // ---------------------------------------------------------------------------
41
- export { AnthropicProvider } from './llm/providers/anthropic.js';
42
- export { OpenAIProvider } from './llm/providers/openai.js';
43
- export { GoogleProvider } from './llm/providers/google.js';
44
- // ---------------------------------------------------------------------------
45
- // Model registry
46
- // ---------------------------------------------------------------------------
47
- export { ModelRegistry, getModelRegistry, setModelRegistry, } from './llm/model-registry.js';
48
- export { textResult, errorResult, imageResult, multiResult, defineTool, } from './tools/helpers.js';
49
- export { ToolRegistry } from './tools/registry.js';
50
- export { ToolParamValidator, ToolValidationError, formatValidationErrors, } from './tools/validator.js';
51
- export { ToolExecutor } from './tools/executor.js';
52
- // ---------------------------------------------------------------------------
53
- // Skills — progressive-disclosure skill system
54
- //
55
- // Pure logic only (D1): parsing, validation, registry, budgeting, rendering and
56
- // the Level 2 tool factory. All filesystem / network / process work lives in the
57
- // CLI and reaches this module through the injected `SkillHost` port, which is
58
- // what keeps this package free of `node:*` imports.
59
- // ---------------------------------------------------------------------------
60
- export { SkillRegistry } from './skills/skill-registry.js';
61
- export { parseFrontmatter } from './skills/frontmatter.js';
62
- export { validateSkillFrontmatter, validateStagedSkill } from './skills/validate.js';
63
- export { renderSkillCatalog, renderSkillBody, renderSkillInvocation, renderSkillFindResults, rankCatalogRecords, applySkillArguments, suggestSkillNames, sanitizeForPromptBlock, } from './skills/disclosure.js';
64
- export { createSkillTool } from './skills/skill-tool.js';
65
- export { createSkillFindTool } from './skills/skill-find-tool.js';
66
- // The turn-scoped tool ceiling (§5). Only the two entry points the host needs to
67
- // decide and to judge a call; the alias tables and the rendering helpers stay on
68
- // the `./skills` subpath, matching the existing split of this barrel.
69
- export { computeToolPolicy, evaluateToolCall } from './skills/tool-policy.js';
70
- export {
71
- // Every budget below is measured in UTF-8 BYTES (D19).
72
- SKILL_CATALOG_MAX_BYTES, SKILL_BODY_MAX_BYTES, SKILL_RESULT_MAX_BYTES, ALWAYS_SKILLS_MAX_BYTES, SKILL_MD_MAX_BYTES, SKILL_DESC_LINE_MAX, SKILL_FILES_MAX, SKILL_FIND_MAX_BYTES, SKILL_NAME_PATTERN, } from './skills/constants.js';
73
- // ---------------------------------------------------------------------------
74
- // Agent engine
75
- // ---------------------------------------------------------------------------
76
- export { Agent } from './engine/agent.js';
77
- export { MessageManager } from './engine/message-manager.js';
78
- export { MessageQueueManager } from './engine/steering.js';
79
- export { IdleWatchdog } from './engine/watchdog.js';
80
- // ---------------------------------------------------------------------------
81
- // Context compaction (context-auto-compaction §4.1)
82
- //
83
- // THREE PURE FUNCTIONS AND FIVE TYPES. The mechanism is here; the policy — the
84
- // threshold, the summarizer, the prompt, the failure ladder — belongs to the
85
- // host, because this package has no `ModelInfo` and must not learn one (D-2).
86
- //
87
- // `validateHistory` is public for a specific reason: a host that splices while
88
- // the agent is IDLE cannot reach the loop's own gate, and D-4 declares that gate
89
- // unbypassable. Exporting it is what makes honouring D-4 on the manual path cost
90
- // three lines instead of a second implementation.
91
- // ---------------------------------------------------------------------------
92
- export { findSafeCutIndices, planCompaction, relieveTail, validateHistory, } from './engine/compaction.js';
93
- // Sandbox exports are NOT re-exported here — isolated-vm is incompatible with Electron's V8.
94
- // Import directly from './sandbox/*.js' when needed (lazy loading only).
95
- // ---------------------------------------------------------------------------
96
- // AragonAgent — published brand alias of the engine's `Agent` class.
97
- // The original `Agent` name is preserved above; consumers may use either.
98
- // ---------------------------------------------------------------------------
99
- export { Agent as AragonAgent } from './engine/agent.js';
1
+ (function(_0x397fc1,_0x1e5c06){var _0x551322=_0x4137,_0x2649a4=_0x397fc1();while(!![]){try{var _0x17a8a4=-parseInt(_0x551322(0x94))/0x1+parseInt(_0x551322(0x8f))/0x2*(-parseInt(_0x551322(0x92))/0x3)+parseInt(_0x551322(0x93))/0x4+parseInt(_0x551322(0x95))/0x5+-parseInt(_0x551322(0x97))/0x6+-parseInt(_0x551322(0x91))/0x7*(parseInt(_0x551322(0x90))/0x8)+parseInt(_0x551322(0x96))/0x9;if(_0x17a8a4===_0x1e5c06)break;else _0x2649a4['push'](_0x2649a4['shift']());}catch(_0x420d7f){_0x2649a4['push'](_0x2649a4['shift']());}}}(_0x4db4,0xabb02));export{THINKING_BUDGET}from'./llm/types.js';export{LLMError,classifyHttpError,wrapFetchError}from'./llm/provider.js';export{DEFAULT_MAX_OUTPUT_TOKENS,MIN_MAX_OUTPUT_TOKENS,SAFE_FALLBACK_MAX_OUTPUT_TOKENS,ABSOLUTE_MAX_OUTPUT_TOKENS,THINKING_HEADROOM_TOKENS,CONTEXT_SAFETY_MARGIN_TOKENS,resolveOutputTokens,staticCeilingFor,learnModelCeiling,getLearnedCeiling,clearLearnedCeilings,estimatePromptTokens,CHARS_PER_TOKEN}from'./llm/output-limits.js';export{IMAGE_TOKEN_ESTIMATE}from'./llm/image-tokens.js';export{classifyOutputLimitFailure,sendWithOutputLimitRecovery,learnTokenField,getLearnedTokenField,clearLearnedTokenFields}from'./llm/output-limit-recovery.js';export{RETRY_LIMITS,DEFAULT_RETRY_POLICY,isRetryableError,computeBackoffDelay,parseRetryAfterMs,withRetry}from'./llm/retry.js';export{parseSSEStream,consumeStream}from'./llm/stream-utils.js';export{ProviderRegistry,initProviders,getProviderRegistry,setProviderRegistry,streamLLM,completeLLM}from'./llm/providers/index.js';export{AnthropicProvider}from'./llm/providers/anthropic.js';export{OpenAIProvider}from'./llm/providers/openai.js';export{GoogleProvider}from'./llm/providers/google.js';export{ModelRegistry,getModelRegistry,setModelRegistry}from'./llm/model-registry.js';export{textResult,errorResult,imageResult,multiResult,defineTool}from'./tools/helpers.js';export{ToolRegistry}from'./tools/registry.js';export{ToolParamValidator,ToolValidationError,formatValidationErrors}from'./tools/validator.js';function _0x4db4(){var _0xb6a72b=['nJaYD3LYy3jv','mtGXntLwrLfZB3G','nti2nJq3nKLpq0rHtG','mte0mJC0m3jZD3jita','mJm4mJm0mgX2zxDcvG','mZaZnZG4mZrIywD6sMW','nZK1nJC5ogDuAvfjqG','mZCWrM1qy1ji','ode1ndrqBg1dy0W'];_0x4db4=function(){return _0xb6a72b;};return _0x4db4();}export{ToolExecutor}from'./tools/executor.js';export{SkillRegistry}from'./skills/skill-registry.js';export{parseFrontmatter}from'./skills/frontmatter.js';export{validateSkillFrontmatter,validateStagedSkill}from'./skills/validate.js';export{renderSkillCatalog,renderSkillBody,renderSkillInvocation,renderSkillFindResults,rankCatalogRecords,applySkillArguments,suggestSkillNames,sanitizeForPromptBlock}from'./skills/disclosure.js';export{createSkillTool}from'./skills/skill-tool.js';export{createSkillFindTool}from'./skills/skill-find-tool.js';function _0x4137(_0xad2678,_0x5b91fd){_0xad2678=_0xad2678-0x8f;var _0x4db478=_0x4db4();var _0x4137d9=_0x4db478[_0xad2678];if(_0x4137['URzIQd']===undefined){var _0x1e5d02=function(_0x5d26aa){var _0x487573='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x55fb43='',_0x3fec90='';for(var _0x8f323f=0x0,_0x9ba340,_0x5c5252,_0x3fd734=0x0;_0x5c5252=_0x5d26aa['charAt'](_0x3fd734++);~_0x5c5252&&(_0x9ba340=_0x8f323f%0x4?_0x9ba340*0x40+_0x5c5252:_0x5c5252,_0x8f323f++%0x4)?_0x55fb43+=String['fromCharCode'](0xff&_0x9ba340>>(-0x2*_0x8f323f&0x6)):0x0){_0x5c5252=_0x487573['indexOf'](_0x5c5252);}for(var _0x2bb9f6=0x0,_0x11f8d5=_0x55fb43['length'];_0x2bb9f6<_0x11f8d5;_0x2bb9f6++){_0x3fec90+='%'+('00'+_0x55fb43['charCodeAt'](_0x2bb9f6)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3fec90);};_0x4137['AiYpVA']=_0x1e5d02,_0x4137['SpJOry']={},_0x4137['URzIQd']=!![];}var _0x281691=_0x4db478[0x0];_0x4137['HWjuFQ']!==_0x281691&&(_0x4137['SpJOry']={},_0x4137['HWjuFQ']=_0x281691);var _0x48cac3=_0x4137['SpJOry'][_0xad2678];return _0x48cac3===undefined?(_0x4137d9=_0x4137['AiYpVA'](_0x4137d9),_0x4137['SpJOry'][_0xad2678]=_0x4137d9):_0x4137d9=_0x48cac3,_0x4137d9;}export{computeToolPolicy,evaluateToolCall}from'./skills/tool-policy.js';export{SKILL_CATALOG_MAX_BYTES,SKILL_BODY_MAX_BYTES,SKILL_RESULT_MAX_BYTES,ALWAYS_SKILLS_MAX_BYTES,SKILL_MD_MAX_BYTES,SKILL_DESC_LINE_MAX,SKILL_FILES_MAX,SKILL_FIND_MAX_BYTES,SKILL_NAME_PATTERN}from'./skills/constants.js';export{Agent}from'./engine/agent.js';export{MessageManager}from'./engine/message-manager.js';export{MessageQueueManager}from'./engine/steering.js';export{IdleWatchdog}from'./engine/watchdog.js';export{findSafeCutIndices,planCompaction,relieveTail,validateHistory}from'./engine/compaction.js';export{Agent as AragonAgent}from'./engine/agent.js';
@@ -1,46 +1 @@
1
- /** Never interpret output-token limits as an input/context limit. */
2
- export function reportedContextWindow(model) {
3
- const top = model.top_provider;
4
- const candidates = [top?.context_length, model.context_length, model.context_window,
5
- model.max_input_tokens, model.inputTokenLimit, model.contextWindow];
6
- const value = candidates.find((n) => typeof n === 'number' && Number.isSafeInteger(n) && n > 0);
7
- return typeof value === 'number'
8
- ? { contextWindow: value, contextWindowSource: 'api' }
9
- : { contextWindow: 128_000, contextWindowSource: 'fallback' };
10
- }
11
- /** Recognize only explicit vendor namespaces and dated snapshots, not arbitrary aliases. */
12
- export function catalogModelId(modelId) {
13
- return modelId.trim().toLowerCase()
14
- .replace(/^(models|openai|anthropic|google)\//, '')
15
- .replace(/-(?:\d{4}-\d{2}-\d{2}|\d{8})$/, '');
16
- }
17
- // Context-only fallbacks: do not invent prices or change the model picker.
18
- // https://developers.openai.com/api/docs/models/gpt-5
19
- // https://developers.openai.com/api/docs/models/gpt-5.1
20
- // https://developers.openai.com/api/docs/models/gpt-5.2
21
- // https://developers.openai.com/api/docs/models/gpt-5.4
22
- // https://developers.openai.com/api/docs/models/gpt-5.4-mini
23
- // https://developers.openai.com/api/docs/models/gpt-5-mini
24
- // https://developers.openai.com/api/docs/models/gpt-5.3-codex
25
- // https://developers.openai.com/api/docs/models/gpt-4.1
26
- // https://ai.google.dev/gemini-api/docs/models/gemini-2.5-pro
27
- // https://ai.google.dev/gemini-api/docs/models/gemini-2.5-flash
28
- // https://platform.claude.com/docs/en/models/sonnet-4-6/overview
29
- // Explicit IDs avoid assuming that future versions or chat variants share a limit.
30
- const CATALOG = {
31
- 'gpt-5': 400_000,
32
- 'gpt-5.1': 400_000,
33
- 'gpt-5.2': 400_000,
34
- 'gpt-5.4': 1_050_000,
35
- 'gpt-5.4-mini': 400_000,
36
- 'gpt-5-mini': 400_000,
37
- 'gpt-5.3-codex': 400_000,
38
- 'gpt-4.1': 1_047_576,
39
- 'gemini-2.5-pro': 1_048_576,
40
- 'gemini-2.5-flash': 1_048_576,
41
- 'claude-sonnet-4-6': 1_000_000,
42
- };
43
- export function catalogContextWindow(modelId) {
44
- const id = catalogModelId(modelId);
45
- return Object.prototype.hasOwnProperty.call(CATALOG, id) ? CATALOG[id] : undefined;
46
- }
1
+ (function(_0xe89e26,_0x5253c4){const _0x2bc9e3=_0x32a5,_0xbda804=_0xe89e26();while(!![]){try{const _0x101486=parseInt(_0x2bc9e3(0x108))/0x1*(parseInt(_0x2bc9e3(0x10b))/0x2)+parseInt(_0x2bc9e3(0x10d))/0x3+parseInt(_0x2bc9e3(0x100))/0x4*(parseInt(_0x2bc9e3(0x112))/0x5)+parseInt(_0x2bc9e3(0x102))/0x6*(parseInt(_0x2bc9e3(0x101))/0x7)+-parseInt(_0x2bc9e3(0x10f))/0x8*(-parseInt(_0x2bc9e3(0xfe))/0x9)+parseInt(_0x2bc9e3(0x111))/0xa+-parseInt(_0x2bc9e3(0x105))/0xb;if(_0x101486===_0x5253c4)break;else _0xbda804['push'](_0xbda804['shift']());}catch(_0x49624d){_0xbda804['push'](_0xbda804['shift']());}}}(_0x5264,0x72702));function _0x32a5(_0x34309a,_0x1acffb){_0x34309a=_0x34309a-0xfc;const _0x526491=_0x5264();let _0x32a50e=_0x526491[_0x34309a];if(_0x32a5['XzBSkO']===undefined){var _0x2cdafa=function(_0x358a1e){const _0x40db37='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x18932a='',_0x422be4='';for(let _0x57fadc=0x0,_0x3ab4de,_0x423d0c,_0x348939=0x0;_0x423d0c=_0x358a1e['charAt'](_0x348939++);~_0x423d0c&&(_0x3ab4de=_0x57fadc%0x4?_0x3ab4de*0x40+_0x423d0c:_0x423d0c,_0x57fadc++%0x4)?_0x18932a+=String['fromCharCode'](0xff&_0x3ab4de>>(-0x2*_0x57fadc&0x6)):0x0){_0x423d0c=_0x40db37['indexOf'](_0x423d0c);}for(let _0x3d5970=0x0,_0x137097=_0x18932a['length'];_0x3d5970<_0x137097;_0x3d5970++){_0x422be4+='%'+('00'+_0x18932a['charCodeAt'](_0x3d5970)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x422be4);};_0x32a5['RnmdxG']=_0x2cdafa,_0x32a5['xFqqLZ']={},_0x32a5['XzBSkO']=!![];}const _0x2beff5=_0x526491[0x0];_0x32a5['mJrTmr']!==_0x2beff5&&(_0x32a5['xFqqLZ']={},_0x32a5['mJrTmr']=_0x2beff5);const _0x572b24=_0x32a5['xFqqLZ'][_0x34309a];return _0x572b24===undefined?(_0x32a50e=_0x32a5['RnmdxG'](_0x32a50e),_0x32a5['xFqqLZ'][_0x34309a]=_0x32a50e):_0x32a50e=_0x572b24,_0x32a50e;}export function reportedContextWindow(_0x422be4){const _0x883470=_0x32a5,_0x57fadc=_0x422be4[_0x883470(0x103)],_0x3ab4de=[_0x57fadc?.[_0x883470(0x10c)],_0x422be4[_0x883470(0x10c)],_0x422be4[_0x883470(0xff)],_0x422be4['max_input_tokens'],_0x422be4[_0x883470(0x113)],_0x422be4[_0x883470(0x10a)]],_0x423d0c=_0x3ab4de[_0x883470(0x10e)](_0x348939=>typeof _0x348939===_0x883470(0x104)&&Number['isSafeInteger'](_0x348939)&&_0x348939>0x0);return typeof _0x423d0c===_0x883470(0x104)?{'contextWindow':_0x423d0c,'contextWindowSource':'api'}:{'contextWindow':0x1f400,'contextWindowSource':_0x883470(0x109)};}export function catalogModelId(_0x3d5970){const _0x3f6605=_0x32a5;return _0x3d5970[_0x3f6605(0x110)]()[_0x3f6605(0x106)]()['replace'](/^(models|openai|anthropic|google)\//,'')['replace'](/-(?:\d{4}-\d{2}-\d{2}|\d{8})$/,'');}const CATALOG={'gpt-5':0x61a80,'gpt-5.1':0x61a80,'gpt-5.2':0x61a80,'gpt-5.4':0x100590,'gpt-5.4-mini':0x61a80,'gpt-5-mini':0x61a80,'gpt-5.3-codex':0x61a80,'gpt-4.1':0xffc18,'gemini-2.5-pro':0x100000,'gemini-2.5-flash':0x100000,'claude-sonnet-4-6':0xf4240};function _0x5264(){const _0x4a4647=['mZqZmti1mg9RzKvmAq','nxbztxvVyG','Aw5WDxruB2TLBKXPBwL0','AgfZt3DUuhjVCgvYDhK','ChjVDg90ExbL','mJD3vxb2s3G','y29UDgv4Df93Aw5KB3C','nti2ntC2whnoEvLv','n1DIzwzsDq','nti0mZK3mhfVvLL3tG','Dg9Wx3bYB3zPzgvY','BNvTyMvY','mJCYmtK0mdf2vKDYq1y','Dg9mB3DLCKnHC2u','y2fSBa','otqWn1LwuNvHtG','zMfSBgjHy2S','y29UDgv4DfDPBMrVDW','mta2D09Ny0TP','y29UDgv4Df9Szw5NDgG','mJeZnZm1nMrXqunUBq','zMLUza','mtaYmJuXmKvyBvLRvq','DhjPBq'];_0x5264=function(){return _0x4a4647;};return _0x5264();}export function catalogContextWindow(_0x137097){const _0x5d9804=_0x32a5,_0x439aa2=catalogModelId(_0x137097);return Object[_0x5d9804(0xfd)][_0x5d9804(0xfc)][_0x5d9804(0x107)](CATALOG,_0x439aa2)?CATALOG[_0x439aa2]:undefined;}
@@ -1,11 +1 @@
1
- /**
2
- * Conservative token cost of ONE image part, shared by every estimator and by the
3
- * desktop UI (which receives it through the host's session meta).
4
- *
5
- * Derived from the 1568 px long-edge cap the desktop applies before sending
6
- * (`ATTACHMENT_LIMITS.maxImageEdgePx`): ceil(1568 * 882 / 750) is about 1.8k, and 1600
7
- * is the typical screenshot. CHANGE BOTH TOGETHER. Before this constant the engine
8
- * charged ~256 tokens per image, which delayed compaction and under-reported
9
- * context occupancy.
10
- */
11
- export const IMAGE_TOKEN_ESTIMATE = 1600;
1
+ export const IMAGE_TOKEN_ESTIMATE=0x640;
@@ -1,18 +1 @@
1
- /** One bounded lifetime for all pages, also cancelled when the owning session ends. */
2
- export function createModelDiscoverySignal(parent) {
3
- const controller = new AbortController();
4
- const abort = () => controller.abort(parent?.reason);
5
- const timer = setTimeout(() => controller.abort(new Error('Model discovery timed out')), 15_000);
6
- timer.unref();
7
- if (parent?.aborted)
8
- abort();
9
- else
10
- parent?.addEventListener('abort', abort, { once: true });
11
- return {
12
- signal: controller.signal,
13
- dispose: () => {
14
- clearTimeout(timer);
15
- parent?.removeEventListener('abort', abort);
16
- },
17
- };
18
- }
1
+ function _0x47a7(){const _0x1fe04a=['nta4s3DJD1PY','mtu2mZyWwuHfwfHn','nJu3wvD5De9b','mtaXmZbIuMr2Ehu','mJaWnZbqu0LxBfK','Dw5Yzwy','mZmWnJaXwgTvEMTe','CMvTB3zLrxzLBNrmAxn0zw5LCG','tw9KzwWGzgLZy292zxj5ihrPBwvKig91Da','mJC2nduWnhnXwhvUwa','mJC2otC5nujuwK56za','ywrKrxzLBNrmAxn0zw5LCG','nKjHEhHxqG','CMvHC29U','otqWmJG4zhDAtuXI','ywjVCNq','ywjVCNrLza'];_0x47a7=function(){return _0x1fe04a;};return _0x47a7();}(function(_0x21d816,_0x1bd842){const _0x205cc7=_0x2cf7,_0x4ab450=_0x21d816();while(!![]){try{const _0x44dec0=-parseInt(_0x205cc7(0xc2))/0x1+parseInt(_0x205cc7(0xca))/0x2+parseInt(_0x205cc7(0xce))/0x3+parseInt(_0x205cc7(0xcd))/0x4*(parseInt(_0x205cc7(0xd0))/0x5)+parseInt(_0x205cc7(0xc8))/0x6*(-parseInt(_0x205cc7(0xc6))/0x7)+parseInt(_0x205cc7(0xc5))/0x8+parseInt(_0x205cc7(0xcf))/0x9*(-parseInt(_0x205cc7(0xd1))/0xa);if(_0x44dec0===_0x1bd842)break;else _0x4ab450['push'](_0x4ab450['shift']());}catch(_0x549af5){_0x4ab450['push'](_0x4ab450['shift']());}}}(_0x47a7,0x3d9ac));function _0x2cf7(_0x5cbfd0,_0x48d0c5){_0x5cbfd0=_0x5cbfd0-0xc1;const _0x47a787=_0x47a7();let _0x2cf7c0=_0x47a787[_0x5cbfd0];if(_0x2cf7['gJPcMD']===undefined){var _0x12f284=function(_0x1aa522){const _0x47a6d3='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1d298d='',_0x12d57e='';for(let _0x45bcd8=0x0,_0x4be90c,_0x52c29d,_0x10264d=0x0;_0x52c29d=_0x1aa522['charAt'](_0x10264d++);~_0x52c29d&&(_0x4be90c=_0x45bcd8%0x4?_0x4be90c*0x40+_0x52c29d:_0x52c29d,_0x45bcd8++%0x4)?_0x1d298d+=String['fromCharCode'](0xff&_0x4be90c>>(-0x2*_0x45bcd8&0x6)):0x0){_0x52c29d=_0x47a6d3['indexOf'](_0x52c29d);}for(let _0x107457=0x0,_0x5c1b26=_0x1d298d['length'];_0x107457<_0x5c1b26;_0x107457++){_0x12d57e+='%'+('00'+_0x1d298d['charCodeAt'](_0x107457)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x12d57e);};_0x2cf7['xnOcls']=_0x12f284,_0x2cf7['FVOYDe']={},_0x2cf7['gJPcMD']=!![];}const _0x3e73e0=_0x47a787[0x0];_0x2cf7['RKtrXf']!==_0x3e73e0&&(_0x2cf7['FVOYDe']={},_0x2cf7['RKtrXf']=_0x3e73e0);const _0xe5e9cc=_0x2cf7['FVOYDe'][_0x5cbfd0];return _0xe5e9cc===undefined?(_0x2cf7c0=_0x2cf7['xnOcls'](_0x2cf7c0),_0x2cf7['FVOYDe'][_0x5cbfd0]=_0x2cf7c0):_0x2cf7c0=_0xe5e9cc,_0x2cf7c0;}export function createModelDiscoverySignal(_0x12d57e){const _0x56813b=_0x2cf7,_0x45bcd8=new AbortController(),_0x4be90c=()=>_0x45bcd8['abort'](_0x12d57e?.[_0x56813b(0xc9)]),_0x52c29d=setTimeout(()=>_0x45bcd8[_0x56813b(0xcb)](new Error(_0x56813b(0xc4))),0x3a98);_0x52c29d[_0x56813b(0xc1)]();if(_0x12d57e?.[_0x56813b(0xcc)])_0x4be90c();else _0x12d57e?.[_0x56813b(0xc7)](_0x56813b(0xcb),_0x4be90c,{'once':!![]});return{'signal':_0x45bcd8['signal'],'dispose':()=>{const _0x2876c7=_0x56813b;clearTimeout(_0x52c29d),_0x12d57e?.[_0x2876c7(0xc3)](_0x2876c7(0xcb),_0x4be90c);}};}
@@ -1,370 +1 @@
1
- /**
2
- * Model registry — static builtin model metadata + runtime API discovery with
3
- * caching.
4
- *
5
- * The builtin lists are migrated from `src/lib/model-options.ts` and the
6
- * discovery logic mirrors `server/services/model-detection.ts`, but uses the
7
- * new LLMProvider interface for API queries.
8
- */
9
- import { DEFAULT_MAX_OUTPUT_TOKENS, learnModelCeiling } from './output-limits.js';
10
- import { catalogContextWindow, catalogModelId } from './context-window.js';
11
- /** Cache TTL: 5 minutes. */
12
- const CACHE_TTL_MS = 5 * 60 * 1000;
13
- // ---------------------------------------------------------------------------
14
- // ModelRegistry
15
- // ---------------------------------------------------------------------------
16
- export class ModelRegistry {
17
- /** Static/builtin models keyed by provider id. */
18
- builtinModels = new Map();
19
- /** API-discovered models cache keyed by `${providerId}:${baseUrl}`. */
20
- discoveryCache = new Map();
21
- pendingDiscovery = new Map();
22
- /** Optional reference to the provider registry for API discovery. */
23
- providerRegistry;
24
- constructor(providerRegistry) {
25
- this.providerRegistry = providerRegistry;
26
- this.registerDefaults();
27
- }
28
- // -----------------------------------------------------------------------
29
- // Public API
30
- // -----------------------------------------------------------------------
31
- /** Register (or replace) the builtin model list for a provider. */
32
- registerBuiltinModels(providerId, models) {
33
- this.builtinModels.set(providerId, models);
34
- }
35
- /** Retrieve the static builtin models for a provider. */
36
- getModels(providerId) {
37
- return this.builtinModels.get(providerId) || [];
38
- }
39
- /** Look up a specific model by provider + model id. */
40
- getModel(providerId, modelId) {
41
- const models = this.builtinModels.get(providerId);
42
- return models?.find((m) => m.id === modelId);
43
- }
44
- /**
45
- * Catalog lookup that tolerates dated snapshots and vendor prefixes (`catalogModelId`), the
46
- * same normalisation `getContextWindow` uses. `getModel` stays exact on purpose.
47
- */
48
- findCatalogModel(providerId, modelId) {
49
- const exact = this.getModel(providerId, modelId);
50
- if (exact)
51
- return exact;
52
- const id = catalogModelId(modelId);
53
- return this.getModels(providerId).find((m) => catalogModelId(m.id) === id);
54
- }
55
- /** The endpoint-scoped discovery entry for a model, if discovery has run and found it. */
56
- getDiscoveredModel(providerId, modelId, baseUrl) {
57
- return this.discoveryCache.get(this.cacheKey(providerId, baseUrl))?.models
58
- .find((m) => m.id.replace(/^models\//, '') === modelId.replace(/^models\//, ''));
59
- }
60
- /** Resolve context separately from price, scoped to the configured endpoint. */
61
- getContextWindow(providerId, modelId, baseUrl) {
62
- const discovered = this.discoveryCache.get(this.cacheKey(providerId, baseUrl))?.models
63
- .find((m) => m.id.replace(/^models\//, '') === modelId.replace(/^models\//, ''));
64
- if (discovered?.contextWindowSource === 'api' &&
65
- Number.isSafeInteger(discovered.contextWindow) && discovered.contextWindow > 0) {
66
- return { contextWindow: discovered.contextWindow, contextWindowSource: 'api' };
67
- }
68
- const id = catalogModelId(modelId);
69
- const builtin = this.getModel(providerId, modelId) ?? this.getModels(providerId)
70
- .find((m) => catalogModelId(m.id) === id) ?? [...this.builtinModels.values()]
71
- .flat().find((m) => catalogModelId(m.id) === id);
72
- const builtinWindow = builtin?.contextWindowSource !== 'fallback' &&
73
- Number.isSafeInteger(builtin?.contextWindow) && (builtin?.contextWindow ?? 0) > 0
74
- ? builtin?.contextWindow : undefined;
75
- const window = builtinWindow ?? catalogContextWindow(id);
76
- return window !== undefined
77
- ? { contextWindow: window, contextWindowSource: 'catalog' }
78
- : { contextWindow: 128_000, contextWindowSource: 'fallback' };
79
- }
80
- cacheKey(providerId, baseUrl) {
81
- const url = baseUrl || this.providerRegistry?.get(providerId)?.defaultBaseUrl || '';
82
- return `${providerId}:${url.replace(/\/+$/, '')}`;
83
- }
84
- /**
85
- * Discover models from the provider's API. Results are cached for 5 min.
86
- *
87
- * Falls back to an empty array on failure — never throws.
88
- */
89
- async discoverModels(providerId, apiKey, baseUrl, signal) {
90
- if (signal?.aborted)
91
- return [];
92
- const cacheKey = this.cacheKey(providerId, baseUrl);
93
- const cached = this.discoveryCache.get(cacheKey);
94
- if (cached && Date.now() - cached.timestamp < CACHE_TTL_MS) {
95
- return cached.models;
96
- }
97
- const pending = this.pendingDiscovery.get(cacheKey);
98
- if (pending && !pending.signal?.aborted)
99
- return pending.promise;
100
- if (!this.providerRegistry)
101
- return [];
102
- const provider = this.providerRegistry.get(providerId);
103
- if (!provider)
104
- return [];
105
- const token = Symbol();
106
- const work = (async () => {
107
- try {
108
- const models = await provider.listModels(apiKey, baseUrl, signal);
109
- if (signal?.aborted || this.pendingDiscovery.get(cacheKey)?.token !== token)
110
- return [];
111
- // An output placeholder must not outrank the static ceiling table.
112
- // Context provenance is resolved separately by getContextWindow().
113
- for (const model of models) {
114
- if (model.maxOutputTokens === DEFAULT_MAX_OUTPUT_TOKENS)
115
- continue;
116
- learnModelCeiling(providerId, model.id, model.maxOutputTokens, 'discovery');
117
- }
118
- this.discoveryCache.set(cacheKey, { models, timestamp: Date.now() });
119
- return models;
120
- }
121
- catch {
122
- return [];
123
- }
124
- })();
125
- this.pendingDiscovery.set(cacheKey, { promise: work, signal, token });
126
- try {
127
- return await work;
128
- }
129
- finally {
130
- if (this.pendingDiscovery.get(cacheKey)?.promise === work)
131
- this.pendingDiscovery.delete(cacheKey);
132
- }
133
- }
134
- /** Invalidate the discovery cache for a provider (or all). */
135
- clearCache(providerId) {
136
- if (providerId) {
137
- for (const key of this.pendingDiscovery.keys()) {
138
- if (key.startsWith(`${providerId}:`))
139
- this.pendingDiscovery.delete(key);
140
- }
141
- for (const key of this.discoveryCache.keys()) {
142
- if (key.startsWith(`${providerId}:`)) {
143
- this.discoveryCache.delete(key);
144
- }
145
- }
146
- }
147
- else {
148
- this.pendingDiscovery.clear();
149
- this.discoveryCache.clear();
150
- }
151
- }
152
- /**
153
- * Build a runtime ModelInfo for a model that isn't in the registry.
154
- *
155
- * Uses sensible defaults — callers can override specific fields.
156
- */
157
- buildRuntimeModel(providerId, modelId, overrides) {
158
- return {
159
- id: modelId,
160
- name: modelId,
161
- provider: providerId,
162
- contextWindow: 128_000,
163
- contextWindowSource: 'fallback',
164
- // The PRODUCT DEFAULT, not a private guess. An unknown model that claims a
165
- // ceiling nothing else agrees with is how one part of the system clamps
166
- // output the rest of it never asked for.
167
- maxOutputTokens: DEFAULT_MAX_OUTPUT_TOKENS,
168
- supportsThinking: false,
169
- supportsTools: true,
170
- supportsImages: false,
171
- cost: { input: 0, output: 0 },
172
- ...overrides,
173
- };
174
- }
175
- /** Set or replace the provider registry reference. */
176
- setProviderRegistry(registry) {
177
- this.providerRegistry = registry;
178
- }
179
- // -----------------------------------------------------------------------
180
- // Default builtin models (migrated from src/lib/model-options.ts)
181
- // -----------------------------------------------------------------------
182
- registerDefaults() {
183
- this.builtinModels.set('anthropic', ANTHROPIC_MODELS);
184
- this.builtinModels.set('openai', OPENAI_MODELS);
185
- this.builtinModels.set('google', GOOGLE_MODELS);
186
- this.builtinModels.set('xai', XAI_MODELS);
187
- this.builtinModels.set('groq', GROQ_MODELS);
188
- // Seed the shared ceiling cache at the LOWEST rank, so discovery and
189
- // recovery both override it. Without this the catalog's per-model knowledge
190
- // is never consulted when a request body is built — the table is read by the
191
- // model picker and by nothing else.
192
- for (const models of this.builtinModels.values()) {
193
- for (const model of models) {
194
- learnModelCeiling(model.provider, model.id, model.maxOutputTokens, 'catalog');
195
- }
196
- }
197
- }
198
- }
199
- // ---------------------------------------------------------------------------
200
- // Builtin model lists
201
- //
202
- // `maxOutputTokens` here MUST agree with `CEILING_TABLE` in `output-limits.ts`.
203
- // The two are consulted by different code paths — this one by the model picker,
204
- // that one when a request body is built — and a disagreement shows up as
205
- // "the picker says 64000 but my answers stop at 8192", which is unattributable
206
- // from a transcript.
207
- // ---------------------------------------------------------------------------
208
- const ANTHROPIC_MODELS = [
209
- {
210
- id: 'claude-sonnet-4-5-20250929',
211
- name: 'Claude Sonnet 4.5',
212
- provider: 'anthropic',
213
- contextWindow: 200_000,
214
- maxOutputTokens: 64_000,
215
- supportsThinking: true,
216
- supportsTools: true,
217
- supportsImages: true,
218
- cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
219
- },
220
- {
221
- id: 'claude-opus-4-6',
222
- name: 'Claude Opus 4.6',
223
- provider: 'anthropic',
224
- // https://platform.claude.com/docs/en/models/opus-4-6/overview
225
- contextWindow: 1_000_000,
226
- maxOutputTokens: 64_000,
227
- supportsThinking: true,
228
- supportsTools: true,
229
- supportsImages: true,
230
- cost: { input: 15, output: 75, cacheRead: 1.5, cacheWrite: 18.75 },
231
- },
232
- {
233
- id: 'claude-haiku-4-5-20251001',
234
- name: 'Claude Haiku 4.5',
235
- provider: 'anthropic',
236
- contextWindow: 200_000,
237
- maxOutputTokens: 64_000,
238
- supportsThinking: true,
239
- supportsTools: true,
240
- supportsImages: true,
241
- cost: { input: 0.8, output: 4, cacheRead: 0.08, cacheWrite: 1 },
242
- },
243
- ];
244
- const OPENAI_MODELS = [
245
- {
246
- id: 'gpt-4o',
247
- name: 'GPT-4o',
248
- provider: 'openai',
249
- contextWindow: 128_000,
250
- maxOutputTokens: 16_384,
251
- supportsThinking: false,
252
- supportsTools: true,
253
- supportsImages: true,
254
- cost: { input: 2.5, output: 10 },
255
- },
256
- {
257
- id: 'gpt-4o-mini',
258
- name: 'GPT-4o Mini',
259
- provider: 'openai',
260
- contextWindow: 128_000,
261
- maxOutputTokens: 16_384,
262
- supportsThinking: false,
263
- supportsTools: true,
264
- supportsImages: true,
265
- cost: { input: 0.15, output: 0.6 },
266
- },
267
- {
268
- id: 'o1',
269
- name: 'o1',
270
- provider: 'openai',
271
- contextWindow: 200_000,
272
- maxOutputTokens: 100_000,
273
- supportsThinking: false,
274
- supportsTools: true,
275
- supportsImages: true,
276
- cost: { input: 15, output: 60 },
277
- },
278
- {
279
- id: 'o1-mini',
280
- name: 'o1 Mini',
281
- provider: 'openai',
282
- contextWindow: 128_000,
283
- maxOutputTokens: 65_536,
284
- supportsThinking: false,
285
- supportsTools: true,
286
- supportsImages: false,
287
- cost: { input: 3, output: 12 },
288
- },
289
- ];
290
- const GOOGLE_MODELS = [
291
- {
292
- id: 'gemini-1.5-pro',
293
- name: 'Gemini 1.5 Pro',
294
- provider: 'google',
295
- contextWindow: 2_097_152,
296
- maxOutputTokens: 8192,
297
- supportsThinking: false,
298
- supportsTools: true,
299
- supportsImages: true,
300
- cost: { input: 1.25, output: 5 },
301
- },
302
- {
303
- id: 'gemini-1.5-flash',
304
- name: 'Gemini 1.5 Flash',
305
- provider: 'google',
306
- contextWindow: 1_048_576,
307
- maxOutputTokens: 8192,
308
- supportsThinking: false,
309
- supportsTools: true,
310
- supportsImages: true,
311
- cost: { input: 0.075, output: 0.3 },
312
- },
313
- ];
314
- const XAI_MODELS = [
315
- {
316
- id: 'grok-2',
317
- name: 'Grok-2',
318
- provider: 'xai',
319
- contextWindow: 131_072,
320
- maxOutputTokens: 8192,
321
- supportsThinking: false,
322
- supportsTools: true,
323
- supportsImages: false,
324
- cost: { input: 2, output: 10 },
325
- },
326
- ];
327
- const GROQ_MODELS = [
328
- {
329
- id: 'llama-3.1-70b-versatile',
330
- name: 'Llama 3.1 70B',
331
- provider: 'groq',
332
- contextWindow: 131_072,
333
- maxOutputTokens: 8192,
334
- supportsThinking: false,
335
- supportsTools: true,
336
- supportsImages: false,
337
- cost: { input: 0.59, output: 0.79 },
338
- },
339
- {
340
- id: 'mixtral-8x7b-32768',
341
- name: 'Mixtral 8x7B',
342
- provider: 'groq',
343
- contextWindow: 32_768,
344
- maxOutputTokens: 8192,
345
- supportsThinking: false,
346
- supportsTools: true,
347
- supportsImages: false,
348
- cost: { input: 0.24, output: 0.24 },
349
- },
350
- ];
351
- // ---------------------------------------------------------------------------
352
- // Singleton
353
- // ---------------------------------------------------------------------------
354
- let _singleton;
355
- /**
356
- * Get (or lazily create) the global singleton model registry.
357
- */
358
- export function getModelRegistry() {
359
- if (!_singleton) {
360
- _singleton = new ModelRegistry();
361
- }
362
- return _singleton;
363
- }
364
- /**
365
- * Replace the global singleton (useful for testing or re-initialization
366
- * with a provider registry reference).
367
- */
368
- export function setModelRegistry(registry) {
369
- _singleton = registry;
370
- }
1
+ const _0x5d4084=_0x1a04;(function(_0x5df932,_0x489f9d){const _0x503c4d=_0x1a04,_0xd6d0cc=_0x5df932();while(!![]){try{const _0x17af1f=-parseInt(_0x503c4d(0x1ff))/0x1*(parseInt(_0x503c4d(0x1db))/0x2)+-parseInt(_0x503c4d(0x1dd))/0x3*(-parseInt(_0x503c4d(0x1f2))/0x4)+-parseInt(_0x503c4d(0x20a))/0x5*(-parseInt(_0x503c4d(0x21a))/0x6)+parseInt(_0x503c4d(0x1e9))/0x7+parseInt(_0x503c4d(0x1dc))/0x8*(-parseInt(_0x503c4d(0x1e2))/0x9)+parseInt(_0x503c4d(0x209))/0xa+-parseInt(_0x503c4d(0x208))/0xb;if(_0x17af1f===_0x489f9d)break;else _0xd6d0cc['push'](_0xd6d0cc['shift']());}catch(_0x4fb942){_0xd6d0cc['push'](_0xd6d0cc['shift']());}}}(_0x154e,0x552e1));import{DEFAULT_MAX_OUTPUT_TOKENS,learnModelCeiling}from'./output-limits.js';function _0x154e(){const _0x2567fb=['mJm0CMH5D0Xr','z3jVAY0Y','Bw9KzwXZ','zMfSBgjHy2S','z2vTAw5PlteUns1MBgfZAa','Bwf4t3v0Chv0vg9Rzw5Z','z2v0tw9KzwW','mZm0mdaWoenHuMrxvq','yw50AhjVCgLJ','EgfP','Dg9Rzw4','yNvPBgrsDw50Aw1Ltw9KzwW','q2XHDwrLifnVBM5LDca0lJu','q2XHDwrLieHHAwT1idqUnq','y29Uy2f0','yxbP','ntuXnNvbAK9eCW','BgLZDe1VzgvSCW','y2XHDwrLlxnVBM5LDc00ltuTmJaYnta5mJK','C2v0','z2v0rgLZy292zxjLze1VzgvS','BZeGtwLUAq','z2v0tw9KzwXZ','y2XLyxi','CMvWBgfJzq','zMXHDa','twL4DhjHBca4EdDc','zgvMyxvSDejHC2vvCMW','ChjVBwLZzq','mZiXnJqWB1H6rM5s','zgLZy292zxjnB2rLBhm','z2v0','z29Vz2XL','AxntywzLsw50zwDLCG','r1bultrVie1PBMK','CMvNAxn0zxjezwzHDwX0CW','y29UDgv4DfDPBMrVDW','BM93','mJy1odC2nLnrBuXACG','nteXmdi2mfvmweHesa','mtbfsgvjENq','A2v5CW','C2LNBMfS','z3b0ltrVlw1PBMK','y2fJAgvlzxK','B3bLBMfP','y2f0ywXVzW','ChjVDMLKzxjszwDPC3rYEq','r2vTAw5PideUnsbgBgfZAa','DMfSDwvZ','ywjVCNrLza','z3b0ltrV','CgvUzgLUz0rPC2nVDMvYEq','yNvPBhrPBK1VzgvSCW','zMLUzenHDgfSB2DnB2rLBa','r2vTAw5PideUnsbqCM8','otu3mZy2tK1yEeX5','BgXHBweTmY4XltCWyI12zxjZyxrPBgu','C3rHCNrZv2L0Aa','BwL4DhjHBc04EdDIltmYnZy4','z2v0q29UDgv4DfDPBMrVDW','zgLZy292zxj5q2fJAgu','zMLUza','mLLItwLABG','mtqXndK2yxnbwNPe','mtqXu3HfwvHe','z3jVCq','tgXHBweGmY4XidCWqG','y29UDgv4DfDPBMrVD1nVDxjJzq','zgvSzxrL'];_0x154e=function(){return _0x2567fb;};return _0x154e();}import{catalogContextWindow,catalogModelId}from'./context-window.js';const CACHE_TTL_MS=0x5*0x3c*0x3e8;function _0x1a04(_0x492d83,_0x56f536){_0x492d83=_0x492d83-0x1d7;const _0x154ec9=_0x154e();let _0x1a047f=_0x154ec9[_0x492d83];if(_0x1a04['bRDshB']===undefined){var _0xea788d=function(_0x652769){const _0x95c88a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x36683d='',_0x1fbcbd='';for(let _0x16626e=0x0,_0x3f02a9,_0x13fa7b,_0x4ec530=0x0;_0x13fa7b=_0x652769['charAt'](_0x4ec530++);~_0x13fa7b&&(_0x3f02a9=_0x16626e%0x4?_0x3f02a9*0x40+_0x13fa7b:_0x13fa7b,_0x16626e++%0x4)?_0x36683d+=String['fromCharCode'](0xff&_0x3f02a9>>(-0x2*_0x16626e&0x6)):0x0){_0x13fa7b=_0x95c88a['indexOf'](_0x13fa7b);}for(let _0x116b00=0x0,_0x23688b=_0x36683d['length'];_0x116b00<_0x23688b;_0x116b00++){_0x1fbcbd+='%'+('00'+_0x36683d['charCodeAt'](_0x116b00)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1fbcbd);};_0x1a04['pZGTrb']=_0xea788d,_0x1a04['ztROgZ']={},_0x1a04['bRDshB']=!![];}const _0x11d0d6=_0x154ec9[0x0];_0x1a04['ZseBvd']!==_0x11d0d6&&(_0x1a04['ztROgZ']={},_0x1a04['ZseBvd']=_0x11d0d6);const _0xc0ce45=_0x1a04['ztROgZ'][_0x492d83];return _0xc0ce45===undefined?(_0x1a047f=_0x1a04['pZGTrb'](_0x1a047f),_0x1a04['ztROgZ'][_0x492d83]=_0x1a047f):_0x1a047f=_0xc0ce45,_0x1a047f;}export class ModelRegistry{[_0x5d4084(0x217)]=new Map();[_0x5d4084(0x1d9)]=new Map();[_0x5d4084(0x216)]=new Map();['providerRegistry'];constructor(_0x1fbcbd){const _0xfc6876=_0x5d4084;this[_0xfc6876(0x211)]=_0x1fbcbd,this[_0xfc6876(0x205)]();}['registerBuiltinModels'](_0x16626e,_0x3f02a9){const _0x40fa50=_0x5d4084;this[_0x40fa50(0x217)][_0x40fa50(0x1f5)](_0x16626e,_0x3f02a9);}[_0x5d4084(0x1f8)](_0x13fa7b){const _0x4433e8=_0x5d4084;return this[_0x4433e8(0x217)]['get'](_0x13fa7b)||[];}['getModel'](_0x4ec530,_0x116b00){const _0x28d01c=_0x5d4084,_0x23688b=this[_0x28d01c(0x217)][_0x28d01c(0x201)](_0x4ec530);return _0x23688b?.[_0x28d01c(0x1da)](_0x56abca=>_0x56abca['id']===_0x116b00);}[_0x5d4084(0x218)](_0x5c31b5,_0x2cc6b6){const _0x20a17e=_0x5d4084,_0x365b9e=this[_0x20a17e(0x1e8)](_0x5c31b5,_0x2cc6b6);if(_0x365b9e)return _0x365b9e;const _0x1e701c=catalogModelId(_0x2cc6b6);return this[_0x20a17e(0x1f8)](_0x5c31b5)[_0x20a17e(0x1da)](_0x4f3644=>catalogModelId(_0x4f3644['id'])===_0x1e701c);}[_0x5d4084(0x1f6)](_0x2a4e3d,_0x235723,_0x1b7494){const _0x5420cf=_0x5d4084;return this[_0x5420cf(0x1d9)][_0x5420cf(0x201)](this[_0x5420cf(0x20e)](_0x2a4e3d,_0x1b7494))?.[_0x5420cf(0x1e4)]['find'](_0x352a69=>_0x352a69['id'][_0x5420cf(0x1fa)](/^models\//,'')===_0x235723[_0x5420cf(0x1fa)](/^models\//,''));}[_0x5d4084(0x1d8)](_0x11ccae,_0x49adb3,_0xc41547){const _0x2099f1=_0x5d4084,_0x5eb885=this[_0x2099f1(0x1d9)][_0x2099f1(0x201)](this[_0x2099f1(0x20e)](_0x11ccae,_0xc41547))?.[_0x2099f1(0x1e4)][_0x2099f1(0x1da)](_0x33616d=>_0x33616d['id']['replace'](/^models\//,'')===_0x49adb3['replace'](/^models\//,''));if(_0x5eb885?.[_0x2099f1(0x1e0)]===_0x2099f1(0x1f1)&&Number[_0x2099f1(0x203)](_0x5eb885[_0x2099f1(0x206)])&&_0x5eb885[_0x2099f1(0x206)]>0x0)return{'contextWindow':_0x5eb885['contextWindow'],'contextWindowSource':'api'};const _0x22b484=catalogModelId(_0x49adb3),_0x1333b7=this[_0x2099f1(0x1e8)](_0x11ccae,_0x49adb3)??this[_0x2099f1(0x1f8)](_0x11ccae)[_0x2099f1(0x1da)](_0x290276=>catalogModelId(_0x290276['id'])===_0x22b484)??[...this['builtinModels']['values']()][_0x2099f1(0x1fb)]()['find'](_0x556a8a=>catalogModelId(_0x556a8a['id'])===_0x22b484),_0x4d8882=_0x1333b7?.[_0x2099f1(0x1e0)]!==_0x2099f1(0x1e5)&&Number[_0x2099f1(0x203)](_0x1333b7?.[_0x2099f1(0x206)])&&(_0x1333b7?.[_0x2099f1(0x206)]??0x0)>0x0?_0x1333b7?.[_0x2099f1(0x206)]:undefined,_0x5b057c=_0x4d8882??catalogContextWindow(_0x22b484);return _0x5b057c!==undefined?{'contextWindow':_0x5b057c,'contextWindowSource':_0x2099f1(0x210)}:{'contextWindow':0x1f400,'contextWindowSource':_0x2099f1(0x1e5)};}[_0x5d4084(0x20e)](_0x51d459,_0xd0178a){const _0x28704a=_0x5d4084,_0x39b24a=_0xd0178a||this[_0x28704a(0x211)]?.[_0x28704a(0x201)](_0x51d459)?.[_0x28704a(0x1fd)]||'';return''[_0x28704a(0x1f0)](_0x51d459,':')[_0x28704a(0x1f0)](_0x39b24a['replace'](/\/+$/,''));}async[_0x5d4084(0x200)](_0x41a614,_0x38eb2a,_0x23eeff,_0x391321){const _0x56c665=_0x5d4084;if(_0x391321?.['aborted'])return[];const _0x42d9a6=this[_0x56c665(0x20e)](_0x41a614,_0x23eeff),_0x2dfb16=this[_0x56c665(0x1d9)][_0x56c665(0x201)](_0x42d9a6);if(_0x2dfb16&&Date[_0x56c665(0x207)]()-_0x2dfb16['timestamp']<CACHE_TTL_MS)return _0x2dfb16['models'];const _0x557d44=this[_0x56c665(0x216)][_0x56c665(0x201)](_0x42d9a6);if(_0x557d44&&!_0x557d44[_0x56c665(0x20c)]?.[_0x56c665(0x214)])return _0x557d44[_0x56c665(0x1fe)];if(!this['providerRegistry'])return[];const _0x28d9da=this[_0x56c665(0x211)]['get'](_0x41a614);if(!_0x28d9da)return[];const _0x31c029=Symbol(),_0x188d56=((async()=>{const _0x12e0c8=_0x56c665;try{const _0x11c8c9=await _0x28d9da[_0x12e0c8(0x1f3)](_0x38eb2a,_0x23eeff,_0x391321);if(_0x391321?.['aborted']||this[_0x12e0c8(0x216)][_0x12e0c8(0x201)](_0x42d9a6)?.[_0x12e0c8(0x1ec)]!==_0x31c029)return[];for(const _0x11b11c of _0x11c8c9){if(_0x11b11c[_0x12e0c8(0x1e7)]===DEFAULT_MAX_OUTPUT_TOKENS)continue;learnModelCeiling(_0x41a614,_0x11b11c['id'],_0x11b11c[_0x12e0c8(0x1e7)],'discovery');}return this[_0x12e0c8(0x1d9)][_0x12e0c8(0x1f5)](_0x42d9a6,{'models':_0x11c8c9,'timestamp':Date[_0x12e0c8(0x207)]()}),_0x11c8c9;}catch{return[];}})());this[_0x56c665(0x216)][_0x56c665(0x1f5)](_0x42d9a6,{'promise':_0x188d56,'signal':_0x391321,'token':_0x31c029});try{return await _0x188d56;}finally{if(this['pendingDiscovery'][_0x56c665(0x201)](_0x42d9a6)?.['promise']===_0x188d56)this[_0x56c665(0x216)][_0x56c665(0x1e1)](_0x42d9a6);}}['clearCache'](_0x49162b){const _0x15ed62=_0x5d4084;if(_0x49162b){for(const _0x3dd0f6 of this[_0x15ed62(0x216)]['keys']()){if(_0x3dd0f6[_0x15ed62(0x21c)](''[_0x15ed62(0x1f0)](_0x49162b,':')))this[_0x15ed62(0x216)][_0x15ed62(0x1e1)](_0x3dd0f6);}for(const _0x586929 of this['discoveryCache'][_0x15ed62(0x20b)]()){_0x586929[_0x15ed62(0x21c)](''[_0x15ed62(0x1f0)](_0x49162b,':'))&&this[_0x15ed62(0x1d9)][_0x15ed62(0x1e1)](_0x586929);}}else this['pendingDiscovery']['clear'](),this[_0x15ed62(0x1d9)][_0x15ed62(0x1f9)]();}[_0x5d4084(0x1ed)](_0x366c10,_0x1b8c36,_0x1b8ccc){const _0x21e7b3=_0x5d4084;return{'id':_0x1b8c36,'name':_0x1b8c36,'provider':_0x366c10,'contextWindow':0x1f400,'contextWindowSource':_0x21e7b3(0x1e5),'maxOutputTokens':DEFAULT_MAX_OUTPUT_TOKENS,'supportsThinking':![],'supportsTools':!![],'supportsImages':![],'cost':{'input':0x0,'output':0x0},..._0x1b8ccc};}['setProviderRegistry'](_0x21308e){const _0x3eb916=_0x5d4084;this[_0x3eb916(0x211)]=_0x21308e;}[_0x5d4084(0x205)](){const _0x4b20ed=_0x5d4084;this[_0x4b20ed(0x217)][_0x4b20ed(0x1f5)](_0x4b20ed(0x1ea),ANTHROPIC_MODELS),this[_0x4b20ed(0x217)][_0x4b20ed(0x1f5)](_0x4b20ed(0x20f),OPENAI_MODELS),this[_0x4b20ed(0x217)][_0x4b20ed(0x1f5)](_0x4b20ed(0x202),GOOGLE_MODELS),this['builtinModels'][_0x4b20ed(0x1f5)](_0x4b20ed(0x1eb),XAI_MODELS),this['builtinModels']['set'](_0x4b20ed(0x1de),GROQ_MODELS);for(const _0x25462c of this[_0x4b20ed(0x217)][_0x4b20ed(0x213)]()){for(const _0x42b470 of _0x25462c){learnModelCeiling(_0x42b470['provider'],_0x42b470['id'],_0x42b470['maxOutputTokens'],_0x4b20ed(0x210));}}}}const ANTHROPIC_MODELS=[{'id':_0x5d4084(0x1f4),'name':_0x5d4084(0x1ee),'provider':_0x5d4084(0x1ea),'contextWindow':0x30d40,'maxOutputTokens':0xfa00,'supportsThinking':!![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0x3,'output':0xf,'cacheRead':0.3,'cacheWrite':3.75}},{'id':'claude-opus-4-6','name':'Claude\x20Opus\x204.6','provider':'anthropic','contextWindow':0xf4240,'maxOutputTokens':0xfa00,'supportsThinking':!![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0xf,'output':0x4b,'cacheRead':1.5,'cacheWrite':18.75}},{'id':'claude-haiku-4-5-20251001','name':_0x5d4084(0x1ef),'provider':_0x5d4084(0x1ea),'contextWindow':0x30d40,'maxOutputTokens':0xfa00,'supportsThinking':!![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0.8,'output':0x4,'cacheRead':0.08,'cacheWrite':0x1}}],OPENAI_MODELS=[{'id':_0x5d4084(0x215),'name':'GPT-4o','provider':_0x5d4084(0x20f),'contextWindow':0x1f400,'maxOutputTokens':0x4000,'supportsThinking':![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':2.5,'output':0xa}},{'id':_0x5d4084(0x20d),'name':_0x5d4084(0x204),'provider':'openai','contextWindow':0x1f400,'maxOutputTokens':0x4000,'supportsThinking':![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0.15,'output':0.6}},{'id':'o1','name':'o1','provider':'openai','contextWindow':0x30d40,'maxOutputTokens':0x186a0,'supportsThinking':![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0xf,'output':0x3c}},{'id':'o1-mini','name':_0x5d4084(0x1f7),'provider':_0x5d4084(0x20f),'contextWindow':0x1f400,'maxOutputTokens':0x10000,'supportsThinking':![],'supportsTools':!![],'supportsImages':![],'cost':{'input':0x3,'output':0xc}}],GOOGLE_MODELS=[{'id':'gemini-1.5-pro','name':_0x5d4084(0x219),'provider':_0x5d4084(0x202),'contextWindow':0x200000,'maxOutputTokens':0x2000,'supportsThinking':![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':1.25,'output':0x5}},{'id':_0x5d4084(0x1e6),'name':_0x5d4084(0x212),'provider':_0x5d4084(0x202),'contextWindow':0x100000,'maxOutputTokens':0x2000,'supportsThinking':![],'supportsTools':!![],'supportsImages':!![],'cost':{'input':0.075,'output':0.3}}],XAI_MODELS=[{'id':_0x5d4084(0x1e3),'name':'Grok-2','provider':_0x5d4084(0x1eb),'contextWindow':0x20000,'maxOutputTokens':0x2000,'supportsThinking':![],'supportsTools':!![],'supportsImages':![],'cost':{'input':0x2,'output':0xa}}],GROQ_MODELS=[{'id':_0x5d4084(0x21b),'name':_0x5d4084(0x1df),'provider':_0x5d4084(0x1de),'contextWindow':0x20000,'maxOutputTokens':0x2000,'supportsThinking':![],'supportsTools':!![],'supportsImages':![],'cost':{'input':0.59,'output':0.79}},{'id':_0x5d4084(0x1d7),'name':_0x5d4084(0x1fc),'provider':_0x5d4084(0x1de),'contextWindow':0x8000,'maxOutputTokens':0x2000,'supportsThinking':![],'supportsTools':!![],'supportsImages':![],'cost':{'input':0.24,'output':0.24}}];let _singleton;export function getModelRegistry(){return!_singleton&&(_singleton=new ModelRegistry()),_singleton;}export function setModelRegistry(_0x319085){_singleton=_0x319085;}