@standardagents/builder 0.27.7 → 0.27.8

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/index.js CHANGED
@@ -893,6 +893,10 @@ var init_ProviderRegistry = __esm({
893
893
  init_factory();
894
894
  ProviderRegistryImpl = class {
895
895
  providerCache = /* @__PURE__ */ new Map();
896
+ /** Why the last thread-scoped resolution did (not) contribute user env,
897
+ * keyed by the env object handed back — surfaced in missing-variable
898
+ * errors so a silent user-env failure is diagnosable from the log. */
899
+ scopeDiagnostics = /* @__PURE__ */ new WeakMap();
896
900
  providerOverrideFn = null;
897
901
  providerOverrideRevision = 0;
898
902
  setProviderOverride(fn) {
@@ -915,6 +919,7 @@ var init_ProviderRegistry = __esm({
915
919
  const threadEnv = state.thread.metadata?.env ?? state.thread.metadata?.tenvs ?? null;
916
920
  const userId = state.thread.metadata?.user_id ?? null;
917
921
  let userEnv = null;
922
+ let diagnostic = userId ? "" : "no thread user_id";
918
923
  if (userId) {
919
924
  try {
920
925
  const agentBuilderId = state.env.AGENT_BUILDER.idFromName("singleton");
@@ -926,14 +931,25 @@ var init_ProviderRegistry = __esm({
926
931
  for (const entry of entries) {
927
932
  if (entry?.name) userEnv[entry.name] = entry.value;
928
933
  }
934
+ diagnostic = `user env: ${Object.keys(userEnv).length} entries`;
935
+ } else {
936
+ diagnostic = `user env empty for ${userId} (entries: ${Array.isArray(entries) ? entries.length : typeof entries})`;
929
937
  }
938
+ } else {
939
+ diagnostic = "singleton has no getUserEnvEntries";
930
940
  }
931
941
  } catch (error) {
932
- console.warn("buildThreadScopedEnv: user env unavailable:", error instanceof Error ? error.message : String(error));
942
+ diagnostic = `user env lookup failed: ${error instanceof Error ? error.message : String(error)}`;
943
+ console.warn("buildThreadScopedEnv:", diagnostic);
933
944
  }
934
945
  }
935
- if (!userEnv && !threadEnv) return state.env;
936
- return { ...state.env, ...userEnv ?? {}, ...threadEnv ?? {} };
946
+ if (!userEnv && !threadEnv) {
947
+ this.scopeDiagnostics.set(state.env, diagnostic);
948
+ return state.env;
949
+ }
950
+ const merged = { ...state.env, ...userEnv ?? {}, ...threadEnv ?? {} };
951
+ this.scopeDiagnostics.set(merged, diagnostic);
952
+ return merged;
937
953
  }
938
954
  /**
939
955
  * Get provider for a model.
@@ -972,8 +988,9 @@ var init_ProviderRegistry = __esm({
972
988
  if (providerDefinition) {
973
989
  const resolved = resolveDefinedProviderConfig(providerDefinition, env);
974
990
  if (resolved.missing.length > 0) {
991
+ const scopeNote = this.scopeDiagnostics.get(env);
975
992
  throw new Error(
976
- `Missing required environment variables for provider '${providerName}': ${resolved.missing.join(", ")}.`
993
+ `Missing required environment variables for provider '${providerName}': ${resolved.missing.join(", ")}.` + (scopeNote ? ` [thread-scoped env: ${scopeNote}]` : "")
977
994
  );
978
995
  }
979
996
  const config = resolved.providerConfig;