@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.
- package/dist/built-in-routes.js +31 -5
- package/dist/built-in-routes.js.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +16 -4
- package/dist/runtime.js.map +1 -1
- package/package.json +5 -5
package/dist/runtime.d.ts
CHANGED
package/dist/runtime.js
CHANGED
|
@@ -918,13 +918,25 @@ var init_ProviderRegistry = __esm({
|
|
|
918
918
|
*/
|
|
919
919
|
async buildThreadScopedEnv(state) {
|
|
920
920
|
const threadEnv = state.thread.metadata?.env ?? state.thread.metadata?.tenvs ?? null;
|
|
921
|
-
const
|
|
921
|
+
const agentBuilderId = state.env.AGENT_BUILDER.idFromName("singleton");
|
|
922
|
+
const agentBuilder = state.env.AGENT_BUILDER.get(agentBuilderId);
|
|
923
|
+
let userId = state.thread.metadata?.user_id ?? null;
|
|
924
|
+
let parent = state.thread.metadata?.parent ?? null;
|
|
925
|
+
let hops = 0;
|
|
926
|
+
while (!userId && parent && typeof agentBuilder.getThread === "function" && hops < 8) {
|
|
927
|
+
hops++;
|
|
928
|
+
try {
|
|
929
|
+
const parentThread = await agentBuilder.getThread(parent);
|
|
930
|
+
userId = parentThread?.user_id ?? null;
|
|
931
|
+
parent = parentThread?.parent ?? null;
|
|
932
|
+
} catch {
|
|
933
|
+
break;
|
|
934
|
+
}
|
|
935
|
+
}
|
|
922
936
|
let userEnv = null;
|
|
923
|
-
let diagnostic = userId ? "" : "no thread user_id";
|
|
937
|
+
let diagnostic = userId ? hops > 0 ? `owner via ${hops} parent hop(s)` : "" : "no thread user_id";
|
|
924
938
|
if (userId) {
|
|
925
939
|
try {
|
|
926
|
-
const agentBuilderId = state.env.AGENT_BUILDER.idFromName("singleton");
|
|
927
|
-
const agentBuilder = state.env.AGENT_BUILDER.get(agentBuilderId);
|
|
928
940
|
if (typeof agentBuilder.getUserEnvEntries === "function") {
|
|
929
941
|
const entries = await agentBuilder.getUserEnvEntries(userId);
|
|
930
942
|
if (Array.isArray(entries) && entries.length > 0) {
|