@standardagents/builder 0.16.0 → 0.17.0-next.a4b7340

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/runtime.js CHANGED
@@ -857,11 +857,38 @@ var init_TestProvider = __esm({
857
857
  }
858
858
  });
859
859
 
860
+ // src/agents/providers/platform-routing.ts
861
+ function stringEnv(value) {
862
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
863
+ }
864
+ function resolvePlatformRouting(providerName, env) {
865
+ const apiKey = stringEnv(env.STANDARD_AGENTS_API_KEY) ?? stringEnv(env.PLATFORM_API_KEY);
866
+ if (!apiKey) return null;
867
+ const origin = (stringEnv(env.STANDARD_AGENTS_PROXY_URL) ?? stringEnv(env.PLATFORM_ENDPOINT) ?? stringEnv(env.STANDARD_AGENTS_API_URL) ?? DEFAULT_PLATFORM_PROXY_ORIGIN).replace(/\/+$/, "");
868
+ const provider = providerName.toLowerCase();
869
+ const basePath = PROVIDER_BASE_PATHS[provider] ?? "";
870
+ return {
871
+ apiKey,
872
+ origin,
873
+ baseUrl: `${origin}/v1/proxy/${encodeURIComponent(provider)}${basePath}`
874
+ };
875
+ }
876
+ var DEFAULT_PLATFORM_PROXY_ORIGIN, PROVIDER_BASE_PATHS;
877
+ var init_platform_routing = __esm({
878
+ "src/agents/providers/platform-routing.ts"() {
879
+ DEFAULT_PLATFORM_PROXY_ORIGIN = "https://proxy.standardagents.ai";
880
+ PROVIDER_BASE_PATHS = {
881
+ cloudflare: "/ai/v1"
882
+ };
883
+ }
884
+ });
885
+
860
886
  // src/agents/providers/ProviderRegistry.ts
861
887
  var ProviderRegistryImpl, ProviderRegistry;
862
888
  var init_ProviderRegistry = __esm({
863
889
  "src/agents/providers/ProviderRegistry.ts"() {
864
890
  init_TestProvider();
891
+ init_platform_routing();
865
892
  ProviderRegistryImpl = class {
866
893
  providerCache = /* @__PURE__ */ new Map();
867
894
  providerOverrideFn = null;
@@ -933,6 +960,19 @@ var init_ProviderRegistry = __esm({
933
960
  return this.cacheAndReturn(modelName, overrideProvider, modelDef, overrideFingerprint);
934
961
  }
935
962
  }
963
+ const routing = resolvePlatformRouting(providerName, env);
964
+ if (routing) {
965
+ const config = {
966
+ apiKey: routing.apiKey,
967
+ baseUrl: routing.baseUrl
968
+ };
969
+ const fingerprint = this.getProviderFingerprint(`platform:${providerName}`, modelDef, config);
970
+ const cached = this.providerCache.get(modelName);
971
+ if (cached?.fingerprint === fingerprint) {
972
+ return this.buildResult(cached.provider, modelDef);
973
+ }
974
+ return this.cacheAndReturn(modelName, providerFactory(config), modelDef, fingerprint);
975
+ }
936
976
  throw new Error(`No API key found for provider: ${providerName}. Set the provider key or STANDARD_AGENTS_API_KEY.`);
937
977
  }
938
978
  buildResult(provider, modelDef) {
@@ -945,7 +985,7 @@ var init_ProviderRegistry = __esm({
945
985
  getProviderFingerprint(providerName, modelDef, config) {
946
986
  return JSON.stringify({
947
987
  providerName,
948
- baseUrl: modelDef.providerOptions?.baseUrl ?? null,
988
+ baseUrl: config?.baseUrl ?? modelDef.providerOptions?.baseUrl ?? null,
949
989
  apiKey: config?.apiKey ?? null,
950
990
  accountId: config?.accountId ?? null
951
991
  });