@standardagents/builder 0.27.10 → 0.27.12
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/built-in-routes.js +21 -7
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +19 -5
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +19 -5
- package/dist/runtime.js.map +1 -1
- package/package.json +5 -5
package/dist/built-in-routes.js
CHANGED
|
@@ -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
|
|
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) {
|
|
@@ -1771,7 +1783,9 @@ var init_LLMRequest = __esm({
|
|
|
1771
1783
|
console.error(`Error calling ${actualModelId} (attempt ${attempts}):`, error2);
|
|
1772
1784
|
await this.logError(state, error2, "api_error", actualModelId, startTime, logId);
|
|
1773
1785
|
if (attempts < MAX_RETRIES_PER_MODEL) {
|
|
1774
|
-
const
|
|
1786
|
+
const base = BACKOFF_BASE * Math.pow(2, attempts - 1);
|
|
1787
|
+
const retryAfterMs = typeof error2?.retryAfter === "number" ? error2.retryAfter * 1e3 : 0;
|
|
1788
|
+
const backoffMs = Math.max(base, retryAfterMs);
|
|
1775
1789
|
await this.sleep(backoffMs);
|
|
1776
1790
|
previousLogId = logId;
|
|
1777
1791
|
logId = void 0;
|
|
@@ -43647,7 +43661,7 @@ var init_dist6 = __esm({
|
|
|
43647
43661
|
return new ProviderError(error.message, "rate_limit", status, retryAfter);
|
|
43648
43662
|
}
|
|
43649
43663
|
if (status === 403 && _OpenAIProvider.isEdgeBlock(anyError)) {
|
|
43650
|
-
return new ProviderError(error.message, "server_error", status);
|
|
43664
|
+
return new ProviderError(error.message, "server_error", status, retryAfter ?? 3);
|
|
43651
43665
|
}
|
|
43652
43666
|
if (status === 401 || status === 403) {
|
|
43653
43667
|
return new ProviderError(error.message, "auth_error", status);
|
|
@@ -66277,7 +66291,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
|
|
|
66277
66291
|
});
|
|
66278
66292
|
|
|
66279
66293
|
// src/version.ts
|
|
66280
|
-
var BUILDER_VERSION = "0.27.
|
|
66294
|
+
var BUILDER_VERSION = "0.27.12".length > 0 ? "0.27.12" : "dev";
|
|
66281
66295
|
|
|
66282
66296
|
// src/api/diagnostics.get.ts
|
|
66283
66297
|
init_LLMRequest();
|