@standardagents/builder 0.37.6 → 0.37.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.
Files changed (33) hide show
  1. package/dist/built-in-routes.js +121 -6
  2. package/dist/built-in-routes.js.map +1 -1
  3. package/dist/client/{ApiKeysView-Pk5oljVU.js → ApiKeysView-L85eJb6G.js} +1 -1
  4. package/dist/client/{CenteredContentView-HGpMGAQj.js → CenteredContentView-D9jkWoLc.js} +1 -1
  5. package/dist/client/{CompositionView-DN8dTOCO.js → CompositionView-BGp0EJCk.js} +1 -1
  6. package/dist/client/{ConfirmDialog.vue_vue_type_script_setup_true_lang--j_hnMZ0.js → ConfirmDialog.vue_vue_type_script_setup_true_lang-DgwqZrLV.js} +1 -1
  7. package/dist/client/{CopyButton.vue_vue_type_script_setup_true_lang-CpJDcbZx.js → CopyButton.vue_vue_type_script_setup_true_lang-B8cGgU2J.js} +1 -1
  8. package/dist/client/{DataTable.vue_vue_type_script_setup_true_lang-unLrY-PY.js → DataTable.vue_vue_type_script_setup_true_lang-CRBXym9D.js} +1 -1
  9. package/dist/client/{JsonViewer-BYj_yrGB.js → JsonViewer-DkHnIfq3.js} +1 -1
  10. package/dist/client/{LoginView-CfVqItZV.js → LoginView-BXD9Odc-.js} +1 -1
  11. package/dist/client/{MarketplaceView-Cidt0nLf.js → MarketplaceView-DEnujUBs.js} +1 -1
  12. package/dist/client/{Modal.vue_vue_type_script_setup_true_lang-C1dmm1HX.js → Modal.vue_vue_type_script_setup_true_lang-keKEwm3K.js} +1 -1
  13. package/dist/client/{ModelModal.vue_vue_type_script_setup_true_lang-DIKLuPXT.js → ModelModal.vue_vue_type_script_setup_true_lang-t1n0bbJe.js} +1 -1
  14. package/dist/client/{ModelsView-DH6wNe38.js → ModelsView-BkCLr8sp.js} +1 -1
  15. package/dist/client/{PromptEditView-D_VjoAa-.js → PromptEditView-BjCfsJQE.js} +1 -1
  16. package/dist/client/{PromptModal-a9LTOWNt.js → PromptModal-nxu_LIv6.js} +1 -1
  17. package/dist/client/{PromptsView-BCCCryKR.js → PromptsView-1yXGCmEZ.js} +1 -1
  18. package/dist/client/{ProvidersView-CF4x5F6G.js → ProvidersView-DxF6gafk.js} +1 -1
  19. package/dist/client/{ThreadInspectorPane.vue_vue_type_script_setup_true_lang-D5VDoQiK.js → ThreadInspectorPane.vue_vue_type_script_setup_true_lang-CjwWJ3uw.js} +14 -14
  20. package/dist/client/{ThreadsView-BzscU1l2.js → ThreadsView-CBup_w8u.js} +1 -1
  21. package/dist/client/{ToolsView-CeEtxDZV.js → ToolsView-B30TfXU9.js} +1 -1
  22. package/dist/client/{UsersView-Di5cmUYL.js → UsersView-kE7Xr4f3.js} +1 -1
  23. package/dist/client/{VariablesView-CXUr05jD.js → VariablesView-yYuynG0M.js} +1 -1
  24. package/dist/client/assets/{ThreadInspectorPane-D9ZMzSTn.css → ThreadInspectorPane-BRGO_P0_.css} +1 -1
  25. package/dist/client/{index-BMqXblce.js → index-AUGwDdSH.js} +2 -2
  26. package/dist/client/index.html +1 -1
  27. package/dist/index.js +56 -5
  28. package/dist/index.js.map +1 -1
  29. package/dist/plugin.js.map +1 -1
  30. package/dist/runtime.d.ts +0 -1
  31. package/dist/runtime.js +56 -5
  32. package/dist/runtime.js.map +1 -1
  33. package/package.json +5 -5
@@ -9431,7 +9431,12 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
9431
9431
  const threadState = ThreadStateImpl.fromFlowState(state);
9432
9432
  for (const executor of executors) {
9433
9433
  try {
9434
- result = await executor(threadState, result);
9434
+ const hooked = await executor(threadState, _FlowEngine.rowToHookMessage(result));
9435
+ result = {
9436
+ ...result,
9437
+ ...hooked,
9438
+ attachments: hooked.attachments === void 0 ? result.attachments : hooked.attachments === null ? null : typeof hooked.attachments === "string" ? hooked.attachments : JSON.stringify(hooked.attachments)
9439
+ };
9435
9440
  } catch (error) {
9436
9441
  console.error("[Hooks] \u2717 Error running before_create_message hook:", error);
9437
9442
  }
@@ -9451,12 +9456,31 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
9451
9456
  const threadState = ThreadStateImpl.fromFlowState(state);
9452
9457
  for (const executor of executors) {
9453
9458
  try {
9454
- await executor(threadState, message);
9459
+ await executor(threadState, _FlowEngine.rowToHookMessage(message));
9455
9460
  } catch (error) {
9456
9461
  console.error("[Hooks] \u2717 Error running after_create_message hook:", error);
9457
9462
  }
9458
9463
  }
9459
9464
  }
9465
+ /**
9466
+ * Builder rows store `attachments` as a JSON string; the spec hook surface
9467
+ * carries parsed AttachmentRef[]. Convert at every hook boundary so hooks
9468
+ * see the spec shape and cannot corrupt the stored row shape.
9469
+ */
9470
+ static rowToHookMessage(row) {
9471
+ const { attachments, ...rest } = row;
9472
+ let parsed = void 0;
9473
+ if (attachments === null) parsed = null;
9474
+ else if (typeof attachments === "string" && attachments) {
9475
+ try {
9476
+ const p = JSON.parse(attachments);
9477
+ parsed = Array.isArray(p) ? p : void 0;
9478
+ } catch {
9479
+ parsed = void 0;
9480
+ }
9481
+ }
9482
+ return { ...rest, attachments: parsed };
9483
+ }
9460
9484
  /**
9461
9485
  * Run the before_update_message hook if it exists
9462
9486
  * This hook allows developers to modify a message before it's updated
@@ -9495,7 +9519,7 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
9495
9519
  const threadState = ThreadStateImpl.fromFlowState(state);
9496
9520
  for (const executor of executors) {
9497
9521
  try {
9498
- await executor(threadState, message);
9522
+ await executor(threadState, _FlowEngine.rowToHookMessage(message));
9499
9523
  } catch (error) {
9500
9524
  console.error("[Hooks] \u2717 Error running after_update_message hook:", error);
9501
9525
  }
@@ -10584,7 +10608,11 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
10584
10608
  const threadState = ThreadStateImpl.fromFlowState(state);
10585
10609
  for (const executor of executors) {
10586
10610
  try {
10587
- result = await executor(threadState, result);
10611
+ const byId = /* @__PURE__ */ new Map();
10612
+ for (const row of result) if (row.id) byId.set(row.id, row);
10613
+ const hookView = result.map((row) => _FlowEngine.rowToHookMessage(row));
10614
+ const kept = await executor(threadState, hookView);
10615
+ result = kept.map((m) => m.id && byId.get(m.id) || null).filter((row) => row !== null);
10588
10616
  } catch (error) {
10589
10617
  console.error("[Hooks] \u2717 Error running filter_messages hook:", error);
10590
10618
  }
@@ -13882,9 +13910,25 @@ var init_ThreadStateImpl = __esm({
13882
13910
  parent_id: msg.parent_id,
13883
13911
  depth: msg.depth,
13884
13912
  silent: msg.silent,
13885
- metadata: msg.metadata
13913
+ metadata: msg.metadata,
13914
+ status: msg.status,
13915
+ tool_status: msg.tool_status,
13916
+ attachments: this._parseAttachmentRefs(msg.attachments)
13886
13917
  };
13887
13918
  };
13919
+ /** Builder rows store attachments as a JSON string of AttachmentRef[];
13920
+ * spec messages carry the parsed refs. Dropping them here is what made
13921
+ * generated assets invisible to every session_state consumer. */
13922
+ _parseAttachmentRefs = (raw) => {
13923
+ if (!raw) return void 0;
13924
+ if (Array.isArray(raw)) return raw;
13925
+ try {
13926
+ const parsed = JSON.parse(raw);
13927
+ return Array.isArray(parsed) ? parsed : void 0;
13928
+ } catch {
13929
+ return void 0;
13930
+ }
13931
+ };
13888
13932
  _mapFileRecord = (record24) => {
13889
13933
  return {
13890
13934
  path: record24.path,
@@ -67987,7 +68031,7 @@ var config_get_default = defineController2(async ({ config, env: env2, req }) =>
67987
68031
  });
67988
68032
 
67989
68033
  // src/version.ts
67990
- var BUILDER_VERSION = "0.37.6".length > 0 ? "0.37.6" : "dev";
68034
+ var BUILDER_VERSION = "0.37.8".length > 0 ? "0.37.8" : "dev";
67991
68035
 
67992
68036
  // src/api/diagnostics.get.ts
67993
68037
  init_LLMRequest();
@@ -75605,6 +75649,76 @@ var messageId_patch_default = defineController2(async ({ req, params, env: env2
75605
75649
  }
75606
75650
  });
75607
75651
 
75652
+ // src/api/threads/[id]/public/[...path].ts
75653
+ var path_default4 = defineController2(async ({ req, params, env: env2 }) => {
75654
+ if (req.method !== "GET" && req.method !== "HEAD") {
75655
+ return Response.json({ error: "Method not allowed" }, { status: 405 });
75656
+ }
75657
+ const threadId = params.id;
75658
+ if (!threadId) {
75659
+ return Response.json({ error: "Thread ID required" }, { status: 400 });
75660
+ }
75661
+ const rawPathParam = params._ || params.path || params["*"] || "";
75662
+ const relative4 = rawPathParam === "public" ? "" : rawPathParam.replace(/^\/?public\//, "");
75663
+ const segments = [];
75664
+ for (const part of relative4.replace(/\\/g, "/").split("/")) {
75665
+ if (!part || part === ".") continue;
75666
+ if (part === "..") return notFound();
75667
+ segments.push(part);
75668
+ }
75669
+ if (segments.length === 0) return notFound();
75670
+ const path10 = `/public/${segments.join("/")}`;
75671
+ try {
75672
+ const durableId = env2.AGENT_BUILDER_THREAD.idFromName(threadId);
75673
+ const stub = env2.AGENT_BUILDER_THREAD.get(durableId);
75674
+ const statResult = await stub.statFile(path10);
75675
+ if (!statResult?.success) return notFound();
75676
+ const file = statResult.file;
75677
+ if (!file || file.isDirectory || file.storage !== "local") return notFound();
75678
+ const headers = {
75679
+ "Content-Type": file.mimeType || "application/octet-stream",
75680
+ "Content-Length": String(file.size),
75681
+ "Content-Disposition": `inline; filename="${file.name}"`,
75682
+ // Public files are mutable (unlike content-addressed assets): cache
75683
+ // briefly so shares are fast without pinning stale content for a year.
75684
+ "Cache-Control": "public, max-age=300"
75685
+ };
75686
+ if (req.method === "HEAD") return new Response(null, { headers });
75687
+ if (file.isChunked && file.chunkCount) {
75688
+ const { readable, writable } = new TransformStream();
75689
+ const writer = writable.getWriter();
75690
+ (async () => {
75691
+ try {
75692
+ for (let i = 0; i < file.chunkCount; i++) {
75693
+ const chunk = await stub.readFileChunk(path10, i);
75694
+ if (!chunk?.success) break;
75695
+ const binary2 = atob(chunk.data);
75696
+ const bytes2 = new Uint8Array(binary2.length);
75697
+ for (let j = 0; j < binary2.length; j++) bytes2[j] = binary2.charCodeAt(j);
75698
+ await writer.write(bytes2);
75699
+ }
75700
+ } finally {
75701
+ await writer.close().catch(() => {
75702
+ });
75703
+ }
75704
+ })();
75705
+ return new Response(readable, { headers });
75706
+ }
75707
+ const result = await stub.readFile(path10);
75708
+ if (!result?.success) return notFound();
75709
+ const binary = atob(result.data);
75710
+ const bytes = new Uint8Array(binary.length);
75711
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
75712
+ return new Response(bytes, { headers });
75713
+ } catch (error) {
75714
+ console.error(`Error serving public file for thread ${threadId}:`, error);
75715
+ return notFound();
75716
+ }
75717
+ });
75718
+ function notFound() {
75719
+ return Response.json({ error: "Not found" }, { status: 404 });
75720
+ }
75721
+
75608
75722
  // src/api/threads/[id]/variables/[requestId].get.ts
75609
75723
  var requestId_get_default = defineController2(async ({ req, params, env: env2 }) => {
75610
75724
  const authResult = await requireAuth(req, env2);
@@ -76249,6 +76363,7 @@ var routeHandlers = {
76249
76363
  "GET:/threads/:id/logs/:logId": logId_get_default,
76250
76364
  "DELETE:/threads/:id/messages/:messageId": messageId_delete_default,
76251
76365
  "PATCH:/threads/:id/messages/:messageId": messageId_patch_default,
76366
+ "GET:/threads/:id/public/**": path_default4,
76252
76367
  "GET:/threads/:id/variables/:requestId": requestId_get_default,
76253
76368
  "POST:/threads/:id/variables/:requestId": requestId_post_default,
76254
76369
  "POST:/threads/:id/effects/:effectId/cancel": cancel_post_default,