refactor: trim media understanding helper types

This commit is contained in:
Peter Steinberger
2026-05-02 03:22:08 +01:00
parent ed214817fb
commit 9d4a98e599
5 changed files with 11 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
export type MediaUnderstandingSkipReason =
type MediaUnderstandingSkipReason =
| "maxBytes"
| "timeout"
| "unsupported"

View File

@@ -1,4 +1,4 @@
export function extractLastJsonObject(raw: string): unknown {
function extractLastJsonObject(raw: string): unknown {
const trimmed = raw.trim();
const start = trimmed.lastIndexOf("{");
if (start === -1) {

View File

@@ -42,7 +42,7 @@ export type DescribeImageFileWithModelParams = {
timeoutMs?: number;
};
export type DescribeImageFileWithModelResult = Awaited<
type DescribeImageFileWithModelResult = Awaited<
ReturnType<NonNullable<MediaUnderstandingProvider["describeImage"]>>
>;

View File

@@ -2,7 +2,7 @@ import { normalizeChatType } from "../channels/chat-type.js";
import type { MediaUnderstandingScopeConfig } from "../config/types.tools.js";
import { normalizeOptionalLowercaseString } from "../shared/string-coerce.js";
export type MediaUnderstandingScopeDecision = "allow" | "deny";
type MediaUnderstandingScopeDecision = "allow" | "deny";
function normalizeDecision(value?: string | null): MediaUnderstandingScopeDecision | undefined {
const normalized = normalizeOptionalLowercaseString(value);

View File

@@ -1,10 +1,7 @@
import type { AuthProfileStore } from "../agents/auth-profiles/types.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
export type MediaUnderstandingKind =
| "audio.transcription"
| "video.description"
| "image.description";
type MediaUnderstandingKind = "audio.transcription" | "video.description" | "image.description";
export type MediaUnderstandingCapability = "image" | "audio" | "video";
@@ -31,7 +28,7 @@ export type MediaUnderstandingOutput = {
model?: string;
};
export type MediaUnderstandingDecisionOutcome =
type MediaUnderstandingDecisionOutcome =
| "success"
| "failed"
| "skipped"
@@ -47,7 +44,7 @@ export type MediaUnderstandingModelDecision = {
reason?: string;
};
export type MediaUnderstandingAttachmentDecision = {
type MediaUnderstandingAttachmentDecision = {
attachmentIndex: number;
attempts: MediaUnderstandingModelDecision[];
chosen?: MediaUnderstandingModelDecision;
@@ -59,12 +56,12 @@ export type MediaUnderstandingDecision = {
attachments: MediaUnderstandingAttachmentDecision[];
};
export type MediaUnderstandingProviderRequestAuthOverride =
type MediaUnderstandingProviderRequestAuthOverride =
| { mode: "provider-default" }
| { mode: "authorization-bearer"; token: string }
| { mode: "header"; headerName: string; value: string; prefix?: string };
export type MediaUnderstandingProviderRequestTlsOverride = {
type MediaUnderstandingProviderRequestTlsOverride = {
ca?: string;
cert?: string;
key?: string;
@@ -73,11 +70,11 @@ export type MediaUnderstandingProviderRequestTlsOverride = {
insecureSkipVerify?: boolean;
};
export type MediaUnderstandingProviderRequestProxyOverride =
type MediaUnderstandingProviderRequestProxyOverride =
| { mode: "env-proxy"; tls?: MediaUnderstandingProviderRequestTlsOverride }
| { mode: "explicit-proxy"; url: string; tls?: MediaUnderstandingProviderRequestTlsOverride };
export type MediaUnderstandingProviderRequestTransportOverrides = {
type MediaUnderstandingProviderRequestTransportOverrides = {
headers?: Record<string, string>;
auth?: MediaUnderstandingProviderRequestAuthOverride;
proxy?: MediaUnderstandingProviderRequestProxyOverride;