@standardagents/builder 0.41.21 → 0.41.22

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.
Files changed (33) hide show
  1. package/dist/built-in-routes.js +56 -17
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-DJ5e-6IS.js → ApiKeysView-D4g6ZNWG.js} +1 -1
  4. package/dist/client/{CenteredContentView-DH6ikaTT.js → CenteredContentView-B3WUhJPU.js} +1 -1
  5. package/dist/client/{CompositionView-C9pK57FR.js → CompositionView-pL0H07yI.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang-9-6_KYkD.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-uehuZFVv.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-C5uwr2FJ.js → CopyButton.vue_vue_type_script_setup_true_lang-vwNMv4kh.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-n5tnXZVz.js → DataTable.vue_vue_type_script_setup_true_lang-lgIAQ4Oz.js} +1 -1
  9. package/dist/client/{JsonViewer-CsxlDLYj.js → JsonViewer-BsC-w_01.js} +1 -1
  10. package/dist/client/LoginView-DriOurmS.js +1 -0
  11. package/dist/client/{MarketplaceView-CEusJBzY.js → MarketplaceView-7pl01VFg.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-B_YbDdpO.js → Modal.vue_vue_type_script_setup_true_lang-CQE6ME9a.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-DXwJcbrW.js → ModelModal.vue_vue_type_script_setup_true_lang-Dv-GVzNy.js} +1 -1
  14. package/dist/client/{ModelsView-Cs7N2v6t.js → ModelsView-BDxyu8pj.js} +1 -1
  15. package/dist/client/{PromptEditView-B82KeSCI.js → PromptEditView-Brn_lMum.js} +1 -1
  16. package/dist/client/{PromptModal-B_QwV83W.js → PromptModal-BeqgBmpj.js} +1 -1
  17. package/dist/client/{PromptsView-B3iCVeqG.js → PromptsView-Dgu1UMES.js} +1 -1
  18. package/dist/client/{ProvidersView-BUr74f5F.js → ProvidersView-B3SPkaxt.js} +1 -1
  19. package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-Bk0yDRsY.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-DaArzwIz.js} +1 -1
  20. package/dist/client/{ThreadsView-DvRb3bRz.js → ThreadsView-D0hT0NXg.js} +1 -1
  21. package/dist/client/{ToolsView-DtoMgKuf.js → ToolsView-BitH87Mf.js} +1 -1
  22. package/dist/client/{UsersView-CnBhWD5G.js → UsersView-BArKqDfJ.js} +1 -1
  23. package/dist/client/{VariablesView-D2Zj2_RJ.js → VariablesView-BJtT_XLQ.js} +1 -1
  24. package/dist/client/assets/index-Bu6PNXui.css +1 -0
  25. package/dist/client/{index-DH0i006N.js → index-CAiyJVjz.js} +2 -2
  26. package/dist/client/index.html +2 -2
  27. package/dist/index.js +55 -16
  28. package/dist/index.js.map +1 -1
  29. package/dist/runtime.js +55 -16
  30. package/dist/runtime.js.map +1 -1
  31. package/package.json +5 -5
  32. package/dist/client/LoginView-BOFP143E.js +0 -1
  33. package/dist/client/assets/index-yfhU3str.css +0 -1
package/dist/runtime.js CHANGED
@@ -5203,7 +5203,7 @@ Message one with subagent_message(referenceId, message).`
5203
5203
  parent: childThread.parent ?? state.threadId,
5204
5204
  terminated: childThread.terminated ?? null,
5205
5205
  created_at: childThread.created_at ?? Math.floor(Date.now() / 1e3)
5206
- });
5206
+ }, { env: state.env });
5207
5207
  await FlowEngine2.runAfterSubagentCreatedHook(state, childState);
5208
5208
  } catch (error) {
5209
5209
  console.error("[Hooks] \u2717 Error running after_subagent_created hook:", error);
@@ -29012,8 +29012,8 @@ var init_ThreadStateImpl = __esm({
29012
29012
  if (!child || child.parent !== this.threadId) {
29013
29013
  return null;
29014
29014
  }
29015
- const durableId = this._threadInstance.env.AGENT_BUILDER_THREAD.idFromName(referenceId);
29016
- const childStub = this._threadInstance.env.AGENT_BUILDER_THREAD.get(durableId);
29015
+ const threads = this._getThreadNamespace();
29016
+ const childStub = threads.get(threads.idFromName(referenceId));
29017
29017
  return _ThreadStateImpl.fromThreadInstance(childStub, {
29018
29018
  id: child.id,
29019
29019
  agent_id: child.agent_name,
@@ -29025,7 +29025,7 @@ var init_ThreadStateImpl = __esm({
29025
29025
  parent: child.parent ?? null,
29026
29026
  terminated: child.terminated ?? null,
29027
29027
  created_at: child.created_at
29028
- });
29028
+ }, this._relatedRuntimeContext());
29029
29029
  }
29030
29030
  async getParentThread() {
29031
29031
  const agentBuilder = this._getAgentBuilderStub();
@@ -29038,8 +29038,8 @@ var init_ThreadStateImpl = __esm({
29038
29038
  if (!parent) {
29039
29039
  return null;
29040
29040
  }
29041
- const durableId = this._threadInstance.env.AGENT_BUILDER_THREAD.idFromName(parentId);
29042
- const parentStub = this._threadInstance.env.AGENT_BUILDER_THREAD.get(durableId);
29041
+ const threads = this._getThreadNamespace();
29042
+ const parentStub = threads.get(threads.idFromName(parentId));
29043
29043
  return _ThreadStateImpl.fromThreadInstance(parentStub, {
29044
29044
  id: parent.id,
29045
29045
  agent_id: parent.agent_name,
@@ -29051,7 +29051,7 @@ var init_ThreadStateImpl = __esm({
29051
29051
  parent: parent.parent ?? null,
29052
29052
  terminated: parent.terminated ?? null,
29053
29053
  created_at: parent.created_at
29054
- });
29054
+ }, this._relatedRuntimeContext());
29055
29055
  }
29056
29056
  // ─────────────────────────────────────────────────────────────────────────
29057
29057
  // Tool Invocation
@@ -29312,14 +29312,14 @@ var init_ThreadStateImpl = __esm({
29312
29312
  canPark && toolCallId ? { toolCallId, side } : void 0
29313
29313
  );
29314
29314
  if (local.ok || !this.isNoClient(local)) return local;
29315
- const env = this._threadInstance.env;
29316
- if (env?.AGENT_BUILDER_THREAD) {
29315
+ const threads = this._optionalThreadNamespace();
29316
+ if (threads) {
29317
29317
  const seen = /* @__PURE__ */ new Set([this._metadata.id]);
29318
29318
  let parentId = await this.resolveParentThreadId(this._metadata.id);
29319
29319
  while (parentId && !seen.has(parentId)) {
29320
29320
  seen.add(parentId);
29321
29321
  try {
29322
- const stub = env.AGENT_BUILDER_THREAD.get(env.AGENT_BUILDER_THREAD.idFromName(parentId));
29322
+ const stub = threads.get(threads.idFromName(parentId));
29323
29323
  const res = await stub.callClientTool(request);
29324
29324
  if (res.ok || !this.isNoClient(res)) return res;
29325
29325
  } catch {
@@ -29467,8 +29467,8 @@ var init_ThreadStateImpl = __esm({
29467
29467
  if (threadId === this._metadata.id && this._metadata.parent) {
29468
29468
  return this._metadata.parent;
29469
29469
  }
29470
- const env = this._threadInstance.env;
29471
- if (!env?.AGENT_BUILDER) return null;
29470
+ const env = this._optionalRuntimeEnv();
29471
+ if (!env) return null;
29472
29472
  for (let attempt = 0; attempt < 3; attempt++) {
29473
29473
  try {
29474
29474
  const agentBuilder = env.AGENT_BUILDER.get(env.AGENT_BUILDER.idFromName("singleton"));
@@ -29876,8 +29876,8 @@ var init_ThreadStateImpl = __esm({
29876
29876
  return null;
29877
29877
  }
29878
29878
  try {
29879
- const threadNamespace = this._threadInstance.env.AGENT_BUILDER_THREAD;
29880
- if (!threadNamespace || typeof threadNamespace.idFromName !== "function" || typeof threadNamespace.get !== "function") {
29879
+ const threadNamespace = this._optionalThreadNamespace();
29880
+ if (!threadNamespace) {
29881
29881
  return null;
29882
29882
  }
29883
29883
  const durableId = threadNamespace.idFromName(parentThreadId);
@@ -29889,8 +29889,8 @@ var init_ThreadStateImpl = __esm({
29889
29889
  }
29890
29890
  async _getParentThreadStub() {
29891
29891
  const parentThreadId = await this._getParentThreadId();
29892
- const durableId = this._threadInstance.env.AGENT_BUILDER_THREAD.idFromName(parentThreadId);
29893
- const parentStub = this._threadInstance.env.AGENT_BUILDER_THREAD.get(durableId);
29892
+ const threads = this._getThreadNamespace();
29893
+ const parentStub = threads.get(threads.idFromName(parentThreadId));
29894
29894
  return { parentThreadId, parentStub };
29895
29895
  }
29896
29896
  _getAgentBuilderStub() {
@@ -29916,6 +29916,45 @@ var init_ThreadStateImpl = __esm({
29916
29916
  }
29917
29917
  return instanceEnv;
29918
29918
  }
29919
+ /** `_getRuntimeEnv`, or null where this state has no usable environment. */
29920
+ _optionalRuntimeEnv() {
29921
+ if (isThreadStateRuntimeEnvironment(this._runtimeContext.env)) {
29922
+ return this._runtimeContext.env;
29923
+ }
29924
+ const instanceEnv = this._threadInstance.env;
29925
+ return isThreadStateRuntimeEnvironment(instanceEnv) ? instanceEnv : null;
29926
+ }
29927
+ /**
29928
+ * The thread Durable Object namespace, from the runtime env (the recorded
29929
+ * context env first). Never `this._threadInstance.env` directly: on a
29930
+ * stub-backed state that is a pipelined RpcPromise proxy.
29931
+ */
29932
+ _getThreadNamespace() {
29933
+ const namespace = this._optionalThreadNamespace();
29934
+ if (!namespace) {
29935
+ this._getRuntimeEnv();
29936
+ throw new Error("Thread namespace unavailable: AGENT_BUILDER_THREAD binding is missing.");
29937
+ }
29938
+ return namespace;
29939
+ }
29940
+ _optionalThreadNamespace() {
29941
+ const env = this._optionalRuntimeEnv();
29942
+ const namespace = env?.AGENT_BUILDER_THREAD;
29943
+ return isRuntimeDurableNamespace(namespace) ? namespace : null;
29944
+ }
29945
+ /**
29946
+ * The runtime context for a ThreadState this state hands out for another
29947
+ * thread (its parent, a child). That state is stub-backed, so it carries
29948
+ * this state's environment, and the user-scope reentrancy guard, with it:
29949
+ * without them every env-dependent surface on the handle (`user()`,
29950
+ * `env()`, user values, its own parent/child lookups) throws.
29951
+ */
29952
+ _relatedRuntimeContext() {
29953
+ return {
29954
+ env: this._getRuntimeEnv(),
29955
+ ...this._runtimeContext.inUserScope === true ? { inUserScope: true } : {}
29956
+ };
29957
+ }
29919
29958
  /** The per-user hub stub for this thread's user (user-scope surfaces). */
29920
29959
  _getUserHubStub(userId) {
29921
29960
  const env = this._getRuntimeEnv();