fix(agents): restore missing runtime helpers and sandbox types

This commit is contained in:
Peter Steinberger
2026-02-13 15:42:00 +00:00
parent 5643a93479
commit 31c6a12cfa
4 changed files with 29 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ import type { ImageContent } from "@mariozechner/pi-ai";
import path from "node:path";
import { fileURLToPath } from "node:url";
import type { SandboxFsBridge } from "../../sandbox/fs-bridge.js";
import { resolveUserPath } from "../../../utils.js";
import { loadWebMedia } from "../../../web/media.js";
import { sanitizeImageBlocks } from "../../tool-images.js";
import { log } from "../logger.js";
@@ -244,6 +246,30 @@ export function modelSupportsImages(model: { input?: string[] }): boolean {
return model.input?.includes("image") ?? false;
}
function extractTextFromMessage(message: unknown): string {
if (!message || typeof message !== "object") {
return "";
}
const content = (message as { content?: unknown }).content;
if (typeof content === "string") {
return content;
}
if (!Array.isArray(content)) {
return "";
}
const textParts: string[] = [];
for (const part of content) {
if (!part || typeof part !== "object") {
continue;
}
const record = part as Record<string, unknown>;
if (record.type === "text" && typeof record.text === "string") {
textParts.push(record.text);
}
}
return textParts.join("\n").trim();
}
/**
* Extracts image references from conversation history messages.
* Scans user messages for image paths/URLs that can be loaded.