@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/index.js CHANGED
@@ -10112,10 +10112,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
10112
10112
  const mimeType = match[1];
10113
10113
  const base64Data = match[2];
10114
10114
  const ext = mimeType.split("/")[1] || "png";
10115
+ if (base64Data.length < 64) {
10116
+ console.error("[FlowEngine] Generated image payload is empty/truncated, skipping");
10117
+ continue;
10118
+ }
10115
10119
  const attachmentId = crypto.randomUUID();
10116
10120
  const path21 = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
10117
10121
  try {
10118
- await state.thread.instance.writeFile(path21, base64Data, mimeType);
10122
+ const written = await state.thread.instance.writeFile(path21, base64Data, mimeType);
10123
+ if (written && written.success === false) {
10124
+ console.error("[FlowEngine] Generated image write failed:", written.error);
10125
+ continue;
10126
+ }
10119
10127
  if (image.id) {
10120
10128
  imagePathMap.set(image.id, path21);
10121
10129
  }
@@ -10182,10 +10190,18 @@ ${msg.content}` : `${imageDescriptions}${nonImageList}`;
10182
10190
  const mimeType = imageUrl.slice(dataPrefix.length, base64Index);
10183
10191
  const base64Data = imageUrl.slice(base64Index + base64Marker.length);
10184
10192
  const ext = mimeType.split("/")[1] || "png";
10193
+ if (base64Data.length < 64) {
10194
+ console.error(`[FlowEngine] ${toolName} image payload is empty/truncated, skipping`);
10195
+ continue;
10196
+ }
10185
10197
  const attachmentId = crypto.randomUUID();
10186
10198
  const path21 = `/attachments/${Date.now()}-${attachmentId.slice(0, 8)}.${ext}`;
10187
10199
  try {
10188
- await state.thread.instance.writeFile(path21, base64Data, mimeType);
10200
+ const written = await state.thread.instance.writeFile(path21, base64Data, mimeType);
10201
+ if (written && written.success === false) {
10202
+ console.error(`[FlowEngine] ${toolName} image write failed:`, written.error);
10203
+ continue;
10204
+ }
10189
10205
  const attachmentRef = {
10190
10206
  id: attachmentId,
10191
10207
  type: "file",
@@ -14312,14 +14328,17 @@ var init_ThreadStateImpl = __esm({
14312
14328
  * dispatcher recorded in the runtime context instead.
14313
14329
  */
14314
14330
  _getRuntimeEnv() {
14331
+ const contextEnv = this._runtimeContext.env;
14332
+ if (contextEnv?.AGENT_BUILDER) {
14333
+ return contextEnv;
14334
+ }
14315
14335
  const instanceEnv = this._threadInstance.env;
14316
- const env = instanceEnv?.AGENT_BUILDER ? instanceEnv : this._runtimeContext.env;
14317
- if (!env?.AGENT_BUILDER) {
14336
+ if (!instanceEnv?.AGENT_BUILDER) {
14318
14337
  throw new Error(
14319
14338
  "No runtime environment available on this ThreadState. Stub-backed states must be constructed with runtimeContext.env."
14320
14339
  );
14321
14340
  }
14322
- return env;
14341
+ return instanceEnv;
14323
14342
  }
14324
14343
  /** The per-user hub stub for this thread's user (user-scope surfaces). */
14325
14344
  _getUserHubStub(userId) {