mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 01:31:23 +00:00
fix(agents): restore missing runtime helpers and sandbox types
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user