@standardagents/builder 0.27.9 → 0.27.11

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.
@@ -943,13 +943,25 @@ var init_ProviderRegistry = __esm({
943
943
  */
944
944
  async buildThreadScopedEnv(state) {
945
945
  const threadEnv = state.thread.metadata?.env ?? state.thread.metadata?.tenvs ?? null;
946
- const userId = state.thread.metadata?.user_id ?? null;
946
+ const agentBuilderId = state.env.AGENT_BUILDER.idFromName("singleton");
947
+ const agentBuilder = state.env.AGENT_BUILDER.get(agentBuilderId);
948
+ let userId = state.thread.metadata?.user_id ?? null;
949
+ let parent = state.thread.metadata?.parent ?? null;
950
+ let hops = 0;
951
+ while (!userId && parent && typeof agentBuilder.getThread === "function" && hops < 8) {
952
+ hops++;
953
+ try {
954
+ const parentThread = await agentBuilder.getThread(parent);
955
+ userId = parentThread?.user_id ?? null;
956
+ parent = parentThread?.parent ?? null;
957
+ } catch {
958
+ break;
959
+ }
960
+ }
947
961
  let userEnv = null;
948
- let diagnostic = userId ? "" : "no thread user_id";
962
+ let diagnostic = userId ? hops > 0 ? `owner via ${hops} parent hop(s)` : "" : "no thread user_id";
949
963
  if (userId) {
950
964
  try {
951
- const agentBuilderId = state.env.AGENT_BUILDER.idFromName("singleton");
952
- const agentBuilder = state.env.AGENT_BUILDER.get(agentBuilderId);
953
965
  if (typeof agentBuilder.getUserEnvEntries === "function") {
954
966
  const entries = await agentBuilder.getUserEnvEntries(userId);
955
967
  if (Array.isArray(entries) && entries.length > 0) {
@@ -43624,6 +43636,17 @@ var init_dist6 = __esm({
43624
43636
  // ============================================================================
43625
43637
  // Error Handling
43626
43638
  // ============================================================================
43639
+ /**
43640
+ * True when a 403 is an edge/CDN block page (HTML challenge such as
43641
+ * Cloudflare's "Unable to load site") rather than a real API auth error.
43642
+ * Real API 403s carry a JSON error body; edge blocks carry HTML.
43643
+ */
43644
+ static isEdgeBlock(error) {
43645
+ const parts = [error?.message];
43646
+ if (typeof error?.error === "string") parts.push(error.error);
43647
+ const body = parts.filter(Boolean).join(" ");
43648
+ return /<html|<!doctype|unable to load site|ray id|cloudflare|attention required/i.test(body);
43649
+ }
43627
43650
  toProviderError(error) {
43628
43651
  if (error instanceof ProviderError) {
43629
43652
  return error;
@@ -43635,6 +43658,9 @@ var init_dist6 = __esm({
43635
43658
  if (status === 429) {
43636
43659
  return new ProviderError(error.message, "rate_limit", status, retryAfter);
43637
43660
  }
43661
+ if (status === 403 && _OpenAIProvider.isEdgeBlock(anyError)) {
43662
+ return new ProviderError(error.message, "server_error", status);
43663
+ }
43638
43664
  if (status === 401 || status === 403) {
43639
43665
  return new ProviderError(error.message, "auth_error", status);
43640
43666
  }
@@ -66263,7 +66289,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
66263
66289
  });
66264
66290
 
66265
66291
  // src/version.ts
66266
- var BUILDER_VERSION = "0.27.9".length > 0 ? "0.27.9" : "dev";
66292
+ var BUILDER_VERSION = "0.27.11".length > 0 ? "0.27.11" : "dev";
66267
66293
 
66268
66294
  // src/api/diagnostics.get.ts
66269
66295
  init_LLMRequest();