@theokit/sdk 4.16.0 → 4.16.1

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/cron.js CHANGED
@@ -5857,6 +5857,44 @@ var init_router = __esm({
5857
5857
  }
5858
5858
  });
5859
5859
 
5860
+ // src/internal/local-agent/real-local-run-provider.ts
5861
+ var real_local_run_provider_exports = {};
5862
+ __export(real_local_run_provider_exports, {
5863
+ detectPrimaryProvider: () => detectPrimaryProvider,
5864
+ inferProviderFromApiKey: () => inferProviderFromApiKey
5865
+ });
5866
+ function inferProviderFromApiKey(apiKey) {
5867
+ if (apiKey === void 0 || apiKey.length === 0) return void 0;
5868
+ const byPrefix = [
5869
+ { provider: "openrouter", prefix: "sk-or-" },
5870
+ { provider: "anthropic", prefix: "sk-ant-" },
5871
+ { provider: "openai", prefix: "sk-" }
5872
+ ];
5873
+ for (const { provider, prefix } of byPrefix) {
5874
+ if (apiKey.startsWith(prefix) && getProviderProfile(provider) !== void 0) {
5875
+ return provider;
5876
+ }
5877
+ }
5878
+ return void 0;
5879
+ }
5880
+ function detectPrimaryProvider() {
5881
+ if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
5882
+ return "anthropic";
5883
+ }
5884
+ if (process.env.OPENAI_API_KEY !== void 0 && process.env.OPENAI_API_KEY.length > 0) {
5885
+ return "openai";
5886
+ }
5887
+ if (process.env.OPENROUTER_API_KEY !== void 0 && process.env.OPENROUTER_API_KEY.length > 0) {
5888
+ return "openrouter";
5889
+ }
5890
+ return "openai";
5891
+ }
5892
+ var init_real_local_run_provider = __esm({
5893
+ "src/internal/local-agent/real-local-run-provider.ts"() {
5894
+ init_providers();
5895
+ }
5896
+ });
5897
+
5860
5898
  // src/internal/session/compact-session.ts
5861
5899
  var compact_session_exports = {};
5862
5900
  __export(compact_session_exports, {
@@ -5919,13 +5957,20 @@ function buildDefaultSummarizer(opts) {
5919
5957
  const { compressConversationWindow: compressConversationWindow2 } = await Promise.resolve().then(() => (init_compression_summarizer(), compression_summarizer_exports));
5920
5958
  const { resolveCompressionModel: resolveCompressionModel2 } = await Promise.resolve().then(() => (init_compression_model_registry(), compression_model_registry_exports));
5921
5959
  const { resolveProviderChain: resolveProviderChain2 } = await Promise.resolve().then(() => (init_router(), router_exports));
5960
+ const { inferProviderFromApiKey: inferProviderFromApiKey2, detectPrimaryProvider: detectPrimaryProvider2 } = await Promise.resolve().then(() => (init_real_local_run_provider(), real_local_run_provider_exports));
5961
+ const keyProvider = inferProviderFromApiKey2(opts.apiKey);
5962
+ const modelPrefix = opts.agentModel.includes("/") ? opts.agentModel.slice(0, opts.agentModel.indexOf("/")) : void 0;
5963
+ const provider = keyProvider ?? modelPrefix ?? detectPrimaryProvider2();
5922
5964
  let model;
5923
- try {
5924
- model = resolveCompressionModel2(opts.agentModel);
5925
- } catch {
5965
+ if (keyProvider !== void 0 && keyProvider !== modelPrefix) {
5926
5966
  model = opts.agentModel;
5967
+ } else {
5968
+ try {
5969
+ model = resolveCompressionModel2(opts.agentModel);
5970
+ } catch {
5971
+ model = opts.agentModel;
5972
+ }
5927
5973
  }
5928
- const provider = model.includes("/") ? model.slice(0, model.indexOf("/")) : "openai";
5929
5974
  const callLlm = async (m, system, user) => {
5930
5975
  const chain = resolveProviderChain2({
5931
5976
  primary: provider,
@@ -15530,35 +15575,7 @@ function registerPluginProviderProfiles(entries) {
15530
15575
 
15531
15576
  // src/internal/local-agent/real-local-run.ts
15532
15577
  init_async_local_storage();
15533
-
15534
- // src/internal/local-agent/real-local-run-provider.ts
15535
- init_providers();
15536
- function inferProviderFromApiKey(apiKey) {
15537
- if (apiKey === void 0 || apiKey.length === 0) return void 0;
15538
- const byPrefix = [
15539
- { provider: "openrouter", prefix: "sk-or-" },
15540
- { provider: "anthropic", prefix: "sk-ant-" },
15541
- { provider: "openai", prefix: "sk-" }
15542
- ];
15543
- for (const { provider, prefix } of byPrefix) {
15544
- if (apiKey.startsWith(prefix) && getProviderProfile(provider) !== void 0) {
15545
- return provider;
15546
- }
15547
- }
15548
- return void 0;
15549
- }
15550
- function detectPrimaryProvider() {
15551
- if (process.env.ANTHROPIC_API_KEY !== void 0 && process.env.ANTHROPIC_API_KEY.length > 0) {
15552
- return "anthropic";
15553
- }
15554
- if (process.env.OPENAI_API_KEY !== void 0 && process.env.OPENAI_API_KEY.length > 0) {
15555
- return "openai";
15556
- }
15557
- if (process.env.OPENROUTER_API_KEY !== void 0 && process.env.OPENROUTER_API_KEY.length > 0) {
15558
- return "openrouter";
15559
- }
15560
- return "openai";
15561
- }
15578
+ init_real_local_run_provider();
15562
15579
 
15563
15580
  // src/a2a/subagent.ts
15564
15581
  init_agent_factory_registry();