fix: keep image sanitizer scoped
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
|||||||
} from "../auto-reply/thinking.js";
|
} from "../auto-reply/thinking.js";
|
||||||
import type { ClawdbotConfig } from "../config/config.js";
|
import type { ClawdbotConfig } from "../config/config.js";
|
||||||
import { formatSandboxToolPolicyBlockedMessage } from "./sandbox.js";
|
import { formatSandboxToolPolicyBlockedMessage } from "./sandbox.js";
|
||||||
import { repairToolUseResultPairing } from "./session-transcript-repair.js";
|
|
||||||
import {
|
import {
|
||||||
isValidCloudCodeAssistToolId,
|
isValidCloudCodeAssistToolId,
|
||||||
sanitizeToolCallId,
|
sanitizeToolCallId,
|
||||||
@@ -96,11 +95,9 @@ export async function sanitizeSessionMessagesImages(
|
|||||||
): Promise<AgentMessage[]> {
|
): Promise<AgentMessage[]> {
|
||||||
// We sanitize historical session messages because Anthropic can reject a request
|
// We sanitize historical session messages because Anthropic can reject a request
|
||||||
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
// if the transcript contains oversized base64 images (see MAX_IMAGE_DIMENSION_PX).
|
||||||
const sanitizedIds = options?.sanitizeToolCallIds
|
const base = options?.sanitizeToolCallIds
|
||||||
? sanitizeToolCallIdsForCloudCodeAssist(messages)
|
? sanitizeToolCallIdsForCloudCodeAssist(messages)
|
||||||
: messages;
|
: messages;
|
||||||
const repaired = repairToolUseResultPairing(sanitizedIds);
|
|
||||||
const base = repaired.messages;
|
|
||||||
const out: AgentMessage[] = [];
|
const out: AgentMessage[] = [];
|
||||||
for (const msg of base) {
|
for (const msg of base) {
|
||||||
if (!msg || typeof msg !== "object") {
|
if (!msg || typeof msg !== "object") {
|
||||||
|
|||||||
25
src/types/node-llama-cpp.d.ts
vendored
Normal file
25
src/types/node-llama-cpp.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
declare module "node-llama-cpp" {
|
||||||
|
export enum LlamaLogLevel {
|
||||||
|
error = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LlamaEmbedding = { vector: Float32Array | number[] };
|
||||||
|
|
||||||
|
export type LlamaEmbeddingContext = {
|
||||||
|
getEmbeddingFor: (text: string) => Promise<LlamaEmbedding>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type LlamaModel = {
|
||||||
|
createEmbeddingContext: () => Promise<LlamaEmbeddingContext>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Llama = {
|
||||||
|
loadModel: (params: { modelPath: string }) => Promise<LlamaModel>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getLlama(params: { logLevel: LlamaLogLevel }): Promise<Llama>;
|
||||||
|
export function resolveModelFile(
|
||||||
|
modelPath: string,
|
||||||
|
cacheDir?: string,
|
||||||
|
): Promise<string>;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user