@standardagents/builder 0.37.2 → 0.37.4

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/runtime.js CHANGED
@@ -10103,10 +10103,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
10103
10103
  const mimeType = match[1];
10104
10104
  const base64Data = match[2];
10105
10105
  const ext = mimeType.split("/")[1] || "png";
10106
+ if (base64Data.length < 64) {
10107
+ console.error("[FlowEngine] Generated image payload is empty/truncated, skipping");
10108
+ continue;
10109
+ }
10106
10110
  const attachmentId = crypto.randomUUID();
10107
10111
  const path = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
10108
10112
  try {
10109
- await state.thread.instance.writeFile(path, base64Data, mimeType);
10113
+ const written = await state.thread.instance.writeFile(path, base64Data, mimeType);
10114
+ if (written && written.success === false) {
10115
+ console.error("[FlowEngine] Generated image write failed:", written.error);
10116
+ continue;
10117
+ }
10110
10118
  if (image.id) {
10111
10119
  imagePathMap.set(image.id, path);
10112
10120
  }
@@ -10173,10 +10181,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
10173
10181
  const mimeType = imageUrl.slice(dataPrefix.length, base64Index);
10174
10182
  const base64Data = imageUrl.slice(base64Index + base64Marker.length);
10175
10183
  const ext = mimeType.split("/")[1] || "png";
10184
+ if (base64Data.length < 64) {
10185
+ console.error(`[FlowEngine] ${toolName} image payload is empty/truncated, skipping`);
10186
+ continue;
10187
+ }
10176
10188
  const attachmentId = crypto.randomUUID();
10177
10189
  const path = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
10178
10190
  try {
10179
- await state.thread.instance.writeFile(path, base64Data, mimeType);
10191
+ const written = await state.thread.instance.writeFile(path, base64Data, mimeType);
10192
+ if (written && written.success === false) {
10193
+ console.error(`[FlowEngine] ${toolName} image write failed:`, written.error);
10194
+ continue;
10195
+ }
10180
10196
  const attachmentRef = {
10181
10197
  id: attachmentId,
10182
10198
  type: "file",
@@ -14303,14 +14319,17 @@ var init_ThreadStateImpl = __esm({
14303
14319
  * dispatcher recorded in the runtime context instead.
14304
14320
  */
14305
14321
  _getRuntimeEnv() {
14322
+ const contextEnv = this._runtimeContext.env;
14323
+ if (contextEnv?.AGENT_BUILDER) {
14324
+ return contextEnv;
14325
+ }
14306
14326
  const instanceEnv = this._threadInstance.env;
14307
- const env = instanceEnv?.AGENT_BUILDER ? instanceEnv : this._runtimeContext.env;
14308
- if (!env?.AGENT_BUILDER) {
14327
+ if (!instanceEnv?.AGENT_BUILDER) {
14309
14328
  throw new Error(
14310
14329
  "No runtime environment available on this ThreadState. Stub-backed states must be constructed with runtimeContext.env."
14311
14330
  );
14312
14331
  }
14313
- return env;
14332
+ return instanceEnv;
14314
14333
  }
14315
14334
  /** The per-user hub stub for this thread's user (user-scope surfaces). */
14316
14335
  _getUserHubStub(userId) {