openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
308 lines • 12.4 kB
TypeScript
import { P as OpenClawConfig, U as ModelProviderAuthMode, W as ModelProviderConfig } from "./types-D3g9JHH2.js";
import { d as Model, l as MaybePromise, p as ModelRequestHeaders } from "./types-D_RlIixM.js";
import { t as Result } from "./result-VHVNeWs6.js";
import { c as OAuthCredential, o as AuthProfileStore } from "./types-jmhja8No.js";
import "./index-Cj8vHfUP.js";
//#region packages/media-understanding-common/src/types.d.ts
type MediaUnderstandingKind = "audio.transcription" | "video.description" | "image.description";
type MediaUnderstandingCapability = "image" | "audio" | "video";
/** Normalized text output produced by media understanding. */
type MediaUnderstandingOutput = {
kind: MediaUnderstandingKind;
attachmentIndex: number;
text: string;
provider: string;
model?: string;
requestedBackend?: string;
observedBackend?: string;
};
//#endregion
//#region src/agents/provider-request-config.types.d.ts
/** Auth override accepted from sanitized provider/model request config. */
type ProviderRequestAuthOverride = {
mode: "provider-default";
} | {
mode: "authorization-bearer";
token: string;
} | {
mode: "header";
headerName: string;
value: string;
prefix?: string;
};
/** TLS override accepted from sanitized provider/model request config. */
type ProviderRequestTlsOverride = {
ca?: string;
cert?: string;
key?: string;
passphrase?: string;
serverName?: string;
insecureSkipVerify?: boolean;
};
/** Proxy override accepted from sanitized provider/model request config. */
type ProviderRequestProxyOverride = {
mode: "env-proxy";
tls?: ProviderRequestTlsOverride;
} | {
mode: "explicit-proxy";
url: string;
tls?: ProviderRequestTlsOverride;
};
type ProviderRequestTransportOverrides = {
headers?: ModelRequestHeaders;
auth?: ProviderRequestAuthOverride;
proxy?: ProviderRequestProxyOverride;
tls?: ProviderRequestTlsOverride;
};
type ModelProviderRequestTransportOverrides = ProviderRequestTransportOverrides & {
allowPrivateNetwork?: boolean;
};
//#endregion
//#region src/plugins/provider-auth-types.d.ts
/** Provider secret input modes: inline plaintext or external secret reference. */
type SecretInputMode = "plaintext" | "ref";
//#endregion
//#region src/plugins/provider-external-auth.types.d.ts
type ProviderAuthOptionBag = {
token?: string;
tokenProvider?: string;
secretInputMode?: SecretInputMode;
[key: string]: unknown;
};
/** Context for resolving synthetic provider credentials from config. */
type ProviderResolveSyntheticAuthContext = {
config?: OpenClawConfig;
provider: string;
providerConfig?: ModelProviderConfig;
};
/** Synthetic provider credential returned by plugin auth helpers. */
type ProviderSyntheticAuthResult = {
apiKey: string;
source: string;
mode: Exclude<ModelProviderAuthMode, "aws-sdk" | "none">;
expiresAt?: number;
/** Native presence authorizes only this runtime, never a provider bearer request. */
nativeAuth?: {
runtime: string;
mode: "api-key" | "oauth" | "token";
};
};
/** Context for resolving external provider auth profiles. */
type ProviderResolveExternalAuthProfilesContext = {
config?: OpenClawConfig;
agentDir?: string;
workspaceDir?: string;
env: NodeJS.ProcessEnv;
store: AuthProfileStore;
};
/** External auth profile credential resolved for a provider. */
type ProviderExternalAuthProfile = {
profileId: string;
credential: OAuthCredential;
persistence?: "runtime-only" | "persisted";
};
/** Internal synchronous resolver shared by provider hooks and auth-store overlays. */
type ProviderExternalAuthProfileResolver = (params: {
config?: OpenClawConfig;
workspaceDir?: string;
env?: NodeJS.ProcessEnv;
context: ProviderResolveExternalAuthProfilesContext;
}) => ProviderExternalAuthProfile[];
//#endregion
//#region src/media-understanding/types.d.ts
type MediaUnderstandingModelDecision = {
provider?: string;
model?: string;
requestedBackend?: string;
observedBackend?: string;
type: "provider" | "cli";
outcome: "success" | "skipped" | "failed";
reason?: string;
};
type MediaAttachmentDisposition = {
kind: "handled";
} | {
kind: "handed-to-native-vision";
} | {
kind: "not-selected";
} | {
kind: "capability-disabled";
} | {
kind: "no-model";
} | {
kind: "scope-denied";
} | {
kind: "failed";
reason?: string;
};
type MediaAttachmentProcessing = "completed" | "omitted";
type MediaUnderstandingDecision = {
capability: MediaUnderstandingCapability;
outcome: "success" | "failed" | "skipped" | "disabled" | "no-attachment" | "scope-deny";
attachments: {
attachmentIndex: number;
attempts: MediaUnderstandingModelDecision[];
chosen?: MediaUnderstandingModelDecision;
}[];
attachmentDispositions?: Record<number, MediaAttachmentDisposition>;
attachmentProcessing?: Record<number, MediaAttachmentProcessing>;
nativeVisionActive?: boolean;
};
type MediaUnderstandingProviderRequestAuth = {
kind: "api-key";
apiKey: string;
source?: string;
} | {
kind: "none";
source: string;
};
type AudioTranscriptionRequest = MediaUnderstandingProviderRequest & {
language?: string;
query?: Record<string, string | number | boolean | string[]>;
};
type MediaUnderstandingProviderRequest = ImagesDescriptionInput & {
/** Compatibility field for existing providers; prefer auth.kind/apiKey. */
apiKey: string;
auth?: MediaUnderstandingProviderRequestAuth;
baseUrl?: string;
headers?: Record<string, string>;
request?: ModelProviderRequestTransportOverrides;
model?: string;
prompt?: string;
timeoutMs: number;
signal?: AbortSignal;
fetchFn?: typeof fetch;
};
type MediaUnderstandingTextResult = {
text: string;
model?: string;
};
type AudioTranscriptionResult = MediaUnderstandingTextResult;
type AudioTranscriptionConfigContext = Pick<AudioTranscriptionRequest, "baseUrl" | "headers" | "request" | "model"> & {
cfg: OpenClawConfig;
agentDir?: string;
workspaceDir?: string;
profile?: string;
preferredProfile?: string;
};
type AudioTranscriptionContext = Omit<AudioTranscriptionRequest, "apiKey" | "auth"> & AudioTranscriptionConfigContext;
type VideoDescriptionRequest = MediaUnderstandingProviderRequest;
type VideoDescriptionResult = MediaUnderstandingTextResult;
type ImageDescriptionRequest = ImagesDescriptionInput & Omit<ImagesDescriptionRequest, "images">;
type ImagesDescriptionInput = {
buffer: Buffer;
fileName: string;
mime?: string;
};
type ImagesDescriptionRequest = {
images: ImagesDescriptionInput[];
model: string;
provider: string;
prompt?: string;
maxTokens?: number;
timeoutMs: number;
signal?: AbortSignal;
profile?: string;
preferredProfile?: string;
authStore?: AuthProfileStore;
agentId?: string;
agentDir: string;
workspaceDir?: string;
/** Agent-owned runtime handle carried opaquely through media provider requests. */
preparedModelRuntime?: Readonly<{
agentDir: string;
workspaceDir?: string;
config: OpenClawConfig;
createStores: () => unknown;
}>;
cfg: OpenClawConfig;
};
type ImageDescriptionResult = MediaUnderstandingTextResult;
type ImagesDescriptionResult = ImageDescriptionResult;
type StructuredExtractionTextInput = {
type: "text";
text: string;
};
type StructuredExtractionImageInput = ImagesDescriptionInput & {
type: "image";
};
type StructuredExtractionInput = StructuredExtractionTextInput | StructuredExtractionImageInput;
type StructuredExtractionRequest = Omit<ImagesDescriptionRequest, "images" | "prompt" | "maxTokens" | "agentId" | "workspaceDir" | "preparedModelRuntime"> & {
/** Image-first extraction input; callers must include at least one image. */
input: StructuredExtractionInput[];
instructions: string;
schemaName?: string;
jsonSchema?: unknown;
jsonMode?: boolean;
};
type StructuredExtractionResult = {
text: string;
parsed?: unknown;
model?: string;
provider?: string;
contentType?: "json" | "text";
};
type MediaUnderstandingDocumentModelDefaults = {
textExtraction?: string;
image?: string | false;
};
type MediaUnderstandingProviderAuthContext = ProviderResolveSyntheticAuthContext;
type MediaUnderstandingProviderAuthResult = {
kind: "none";
source: string;
} | {
kind: "api-key";
apiKey: string;
source: string;
mode?: "api-key";
};
type MediaUnderstandingProviderSyntheticAuthResult = {
apiKey: string;
source: string;
mode: "api-key";
};
type MediaUnderstandingProvider = {
id: string;
capabilities?: MediaUnderstandingCapability[];
/** Add image capability from this request's configured model inputs, not registration config. */
inheritConfiguredImageCapability?: boolean;
/** Narrow capability-less shared entries; undefined preserves all effective capabilities. */
sharedEntryCapabilities?: MediaUnderstandingCapability[];
defaultModels?: Partial<Record<MediaUnderstandingCapability, string>>;
autoPriority?: Partial<Record<MediaUnderstandingCapability, number>>;
nativeDocumentInputs?: Array<"pdf">;
documentModels?: Partial<Record<"pdf", MediaUnderstandingDocumentModelDefaults>>;
resolveAuth?: (ctx: MediaUnderstandingProviderAuthContext) => MediaUnderstandingProviderAuthResult | null | undefined;
/** @deprecated Use resolveAuth. */
resolveSyntheticAuth?: (ctx: MediaUnderstandingProviderAuthContext) => MediaUnderstandingProviderSyntheticAuthResult | null | undefined;
transcribeAudio?: (req: AudioTranscriptionRequest) => Promise<AudioTranscriptionResult>;
/** Checks provider-owned credentials and transport settings without uploading audio. */
isAudioConfigured?: (context: AudioTranscriptionConfigContext) => boolean | Promise<boolean>;
/** Called after file loading. Result.error is only a rejection before audio upload;
* upload/HTTP failures must throw and stop automatic provider selection. */
transcribeAudioWithContext?: (req: AudioTranscriptionContext) => Promise<Result<AudioTranscriptionResult, unknown>>;
describeVideo?: (req: VideoDescriptionRequest) => Promise<VideoDescriptionResult>;
describeImage?: (req: ImageDescriptionRequest) => Promise<ImageDescriptionResult>;
describeImages?: (req: ImagesDescriptionRequest) => Promise<ImagesDescriptionResult>;
extractStructured?: (req: StructuredExtractionRequest) => Promise<StructuredExtractionResult>;
};
//#endregion
//#region src/media-understanding/image-runtime.d.ts
declare const describeImageWithModel: (params: ImageDescriptionRequest) => Promise<{
text: string;
model?: string;
}>;
declare const describeImagesWithModel: (params: ImagesDescriptionRequest) => Promise<{
text: string;
model?: string;
}>;
declare const describeImageWithModelPayloadTransform: (params: ImageDescriptionRequest, onPayload: ((payload: unknown, model: Model) => MaybePromise<unknown>) | undefined) => Promise<{
text: string;
model?: string;
}>;
declare const describeImagesWithModelPayloadTransform: (params: ImagesDescriptionRequest, onPayload: ((payload: unknown, model: Model) => MaybePromise<unknown>) | undefined) => Promise<{
text: string;
model?: string;
}>;
//#endregion
export { ProviderResolveSyntheticAuthContext as A, StructuredExtractionTextInput as C, ProviderExternalAuthProfile as D, ProviderAuthOptionBag as E, MediaUnderstandingCapability as F, MediaUnderstandingOutput as I, SecretInputMode as M, ModelProviderRequestTransportOverrides as N, ProviderExternalAuthProfileResolver as O, ProviderRequestTransportOverrides as P, StructuredExtractionResult as S, VideoDescriptionResult as T, MediaUnderstandingProviderRequestAuth as _, AudioTranscriptionConfigContext as a, StructuredExtractionInput as b, ImageDescriptionRequest as c, ImagesDescriptionRequest as d, ImagesDescriptionResult as f, MediaUnderstandingProviderAuthResult as g, MediaUnderstandingProviderAuthContext as h, describeImagesWithModelPayloadTransform as i, ProviderSyntheticAuthResult as j, ProviderResolveExternalAuthProfilesContext as k, ImageDescriptionResult as l, MediaUnderstandingProvider as m, describeImageWithModelPayloadTransform as n, AudioTranscriptionRequest as o, MediaUnderstandingDecision as p, describeImagesWithModel as r, AudioTranscriptionResult as s, describeImageWithModel as t, ImagesDescriptionInput as u, MediaUnderstandingProviderSyntheticAuthResult as v, VideoDescriptionRequest as w, StructuredExtractionRequest as x, StructuredExtractionImageInput as y };