@theokit/sdk 4.16.0 → 4.16.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/eval.cjs CHANGED
@@ -5859,6 +5859,44 @@ var init_router = __esm({
5859
5859
  }
5860
5860
  });
5861
5861
 
5862
+ // src/internal/local-agent/real-local-run-provider.ts
5863
+ var real_local_run_provider_exports = {};
5864
+ __export(real_local_run_provider_exports, {
5865
+ detectPrimaryProvider: () => detectPrimaryProvider,
5866
+ inferProviderFromApiKey: () => inferProviderFromApiKey
5867
+ });
5868
+ function inferProviderFromApiKey(apiKey) {
5869
+ if (apiKey === void 0 || apiKey.length === 0) return void 0;
5870
+ const byPrefix = [
5871
+ { provider: "openrouter", prefix: "sk-or-" },
5872
+ { provider: "anthropic", prefix: "sk-ant-" },
5873
+ { provider: "openai", prefix: "sk-" }
5874
+ ];
5875
+ for (const { provider, prefix } of byPrefix) {
5876
+ if (apiKey.startsWith(prefix) && getProviderProfile(provider) !== void 0) {
5877
+ return provider;
5878
+ }
5879
+ }
5880
+ return void 0;
5881
+ }
5882
+ function detectPrimaryProvider() {
5883
+ if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
5884
+ return "anthropic";
5885
+ }
5886
+ if (process.env.OPENAI_API_KEY !== void 0 && process.env.OPENAI_API_KEY.length > 0) {
5887
+ return "openai";
5888
+ }
5889
+ if (process.env.OPENROUTER_API_KEY !== void 0 && process.env.OPENROUTER_API_KEY.length > 0) {
5890
+ return "openrouter";
5891
+ }
5892
+ return "openai";
5893
+ }
5894
+ var init_real_local_run_provider = __esm({
5895
+ "src/internal/local-agent/real-local-run-provider.ts"() {
5896
+ init_providers();
5897
+ }
5898
+ });
5899
+
5862
5900
  // src/internal/session/compact-session.ts
5863
5901
  var compact_session_exports = {};
5864
5902
  __export(compact_session_exports, {
@@ -5921,13 +5959,20 @@ function buildDefaultSummarizer(opts) {
5921
5959
  const { compressConversationWindow: compressConversationWindow2 } = await Promise.resolve().then(() => (init_compression_summarizer(), compression_summarizer_exports));
5922
5960
  const { resolveCompressionModel: resolveCompressionModel2 } = await Promise.resolve().then(() => (init_compression_model_registry(), compression_model_registry_exports));
5923
5961
  const { resolveProviderChain: resolveProviderChain2 } = await Promise.resolve().then(() => (init_router(), router_exports));
5962
+ const { inferProviderFromApiKey: inferProviderFromApiKey2, detectPrimaryProvider: detectPrimaryProvider2 } = await Promise.resolve().then(() => (init_real_local_run_provider(), real_local_run_provider_exports));
5963
+ const keyProvider = inferProviderFromApiKey2(opts.apiKey);
5964
+ const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
5965
+ const provider = keyProvider ?? modelPrefix ?? detectPrimaryProvider2();
5924
5966
  let model;
5925
- try {
5926
- model = resolveCompressionModel2(opts.agentModel);
5927
- } catch {
5967
+ if (keyProvider !== void 0 && keyProvider !== modelPrefix) {
5928
5968
  model = opts.agentModel;
5969
+ } else {
5970
+ try {
5971
+ model = resolveCompressionModel2(opts.agentModel);
5972
+ } catch {
5973
+ model = opts.agentModel;
5974
+ }
5929
5975
  }
5930
- const provider = model.includes("/") ? model.slice(0, model.indexOf("/")) : "openai";
5931
5976
  const callLlm = async (m, system, user) => {
5932
5977
  const chain = resolveProviderChain2({
5933
5978
  primary: provider,
@@ -15528,35 +15573,7 @@ function registerPluginProviderProfiles(entries) {
15528
15573
 
15529
15574
  // src/internal/local-agent/real-local-run.ts
15530
15575
  init_async_local_storage();
15531
-
15532
- // src/internal/local-agent/real-local-run-provider.ts
15533
- init_providers();
15534
- function inferProviderFromApiKey(apiKey) {
15535
- if (apiKey === void 0 || apiKey.length === 0) return void 0;
15536
- const byPrefix = [
15537
- { provider: "openrouter", prefix: "sk-or-" },
15538
- { provider: "anthropic", prefix: "sk-ant-" },
15539
- { provider: "openai", prefix: "sk-" }
15540
- ];
15541
- for (const { provider, prefix } of byPrefix) {
15542
- if (apiKey.startsWith(prefix) && getProviderProfile(provider) !== void 0) {
15543
- return provider;
15544
- }
15545
- }
15546
- return void 0;
15547
- }
15548
- function detectPrimaryProvider() {
15549
- if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
15550
- return "anthropic";
15551
- }
15552
- if (process.env.OPENAI_API_KEY !== void 0 && process.env.OPENAI_API_KEY.length > 0) {
15553
- return "openai";
15554
- }
15555
- if (process.env.OPENROUTER_API_KEY !== void 0 && process.env.OPENROUTER_API_KEY.length > 0) {
15556
- return "openrouter";
15557
- }
15558
- return "openai";
15559
- }
15576
+ init_real_local_run_provider();
15560
15577
 
15561
15578
  // src/a2a/subagent.ts
15562
15579
  init_agent_factory_registry();
@@ -19864,7 +19881,11 @@ var Agent = class _Agent {
19864
19881
  * @public
19865
19882
  */
19866
19883
  static async compact(agentId, options = {}) {
19867
- const reg = getRegisteredAgent(agentId);
19884
+ let reg = getRegisteredAgent(agentId);
19885
+ if (reg === void 0) {
19886
+ await hydrateRegistryFromDisk(process.cwd());
19887
+ reg = getRegisteredAgent(agentId);
19888
+ }
19868
19889
  if (reg === void 0 || reg.runtime !== "local") {
19869
19890
  throw new UnknownAgentError(`No local agent "${agentId}" registered \u2014 compact targets local sessions.`);
19870
19891
  }