mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 22:30:21 +00:00
refactor: add provider replay runtime hook surfaces (#59143)
Merged via squash.
Prepared head SHA: 56b41e87a5
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
@@ -20,8 +20,13 @@ import type {
|
||||
ProviderCreateStreamFnContext,
|
||||
ProviderDefaultThinkingPolicyContext,
|
||||
ProviderFetchUsageSnapshotContext,
|
||||
ProviderNormalizeToolSchemasContext,
|
||||
ProviderNormalizeConfigContext,
|
||||
ProviderNormalizeModelIdContext,
|
||||
ProviderReasoningOutputMode,
|
||||
ProviderReasoningOutputModeContext,
|
||||
ProviderReplayPolicy,
|
||||
ProviderReplayPolicyContext,
|
||||
ProviderNormalizeResolvedModelContext,
|
||||
ProviderNormalizeTransportContext,
|
||||
ProviderModernModelPolicyContext,
|
||||
@@ -29,11 +34,13 @@ import type {
|
||||
ProviderPrepareDynamicModelContext,
|
||||
ProviderPrepareRuntimeAuthContext,
|
||||
ProviderResolveConfigApiKeyContext,
|
||||
ProviderSanitizeReplayHistoryContext,
|
||||
ProviderResolveUsageAuthContext,
|
||||
ProviderPlugin,
|
||||
ProviderResolveDynamicModelContext,
|
||||
ProviderRuntimeModel,
|
||||
ProviderThinkingPolicyContext,
|
||||
ProviderValidateReplayTurnsContext,
|
||||
ProviderWrapStreamFnContext,
|
||||
} from "./types.js";
|
||||
|
||||
@@ -435,6 +442,57 @@ export function resolveProviderCapabilitiesWithPlugin(params: {
|
||||
return resolveProviderRuntimePlugin(params)?.capabilities;
|
||||
}
|
||||
|
||||
export function resolveProviderReplayPolicyWithPlugin(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderReplayPolicyContext;
|
||||
}): ProviderReplayPolicy | undefined {
|
||||
return resolveProviderHookPlugin(params)?.buildReplayPolicy?.(params.context) ?? undefined;
|
||||
}
|
||||
|
||||
export async function sanitizeProviderReplayHistoryWithPlugin(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderSanitizeReplayHistoryContext;
|
||||
}) {
|
||||
return await resolveProviderHookPlugin(params)?.sanitizeReplayHistory?.(params.context);
|
||||
}
|
||||
|
||||
export async function validateProviderReplayTurnsWithPlugin(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderValidateReplayTurnsContext;
|
||||
}) {
|
||||
return await resolveProviderHookPlugin(params)?.validateReplayTurns?.(params.context);
|
||||
}
|
||||
|
||||
export function normalizeProviderToolSchemasWithPlugin(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderNormalizeToolSchemasContext;
|
||||
}) {
|
||||
return resolveProviderHookPlugin(params)?.normalizeToolSchemas?.(params.context) ?? undefined;
|
||||
}
|
||||
|
||||
export function resolveProviderReasoningOutputModeWithPlugin(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
context: ProviderReasoningOutputModeContext;
|
||||
}): ProviderReasoningOutputMode | undefined {
|
||||
const mode = resolveProviderHookPlugin(params)?.resolveReasoningOutputMode?.(params.context);
|
||||
return mode === "native" || mode === "tagged" ? mode : undefined;
|
||||
}
|
||||
|
||||
export function prepareProviderExtraParams(params: {
|
||||
provider: string;
|
||||
config?: OpenClawConfig;
|
||||
|
||||
Reference in New Issue
Block a user