refactor: move provider replay runtime ownership into plugins (#60126)

* refactor: move provider replay runtime ownership into plugins

* fix(provider-runtime): address review followups

---------

Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
This commit is contained in:
Josh Lehman
2026-04-03 07:14:37 -07:00
committed by GitHub
parent f328e7f4a6
commit 799c6f40aa
63 changed files with 2865 additions and 1802 deletions

View File

@@ -63,9 +63,12 @@ export type {
ProviderReasoningOutputModeContext,
ProviderReplayPolicy,
ProviderReplayPolicyContext,
ProviderReplaySessionEntry,
ProviderReplaySessionState,
ProviderResolveDynamicModelContext,
ProviderResolvedUsageAuth,
ProviderSanitizeReplayHistoryContext,
ProviderToolSchemaDiagnostic,
ProviderResolveUsageAuthContext,
ProviderRuntimeModel,
ProviderThinkingPolicyContext,
@@ -108,21 +111,6 @@ export type {
export type { ChannelMessageActionContext } from "../channels/plugins/types.js";
export type { ChannelConfigUiHint, ChannelPlugin } from "../channels/plugins/types.plugin.js";
export type { PluginRuntime } from "../plugins/runtime/types.js";
export type {
BoundTaskFlowsRuntime,
BoundTaskRunsRuntime,
PluginRuntimeTaskFlows,
PluginRuntimeTaskRuns,
PluginRuntimeTasks,
} from "../plugins/runtime/runtime-tasks.js";
export type {
TaskFlowDetail,
TaskFlowView,
TaskRunAggregateSummary,
TaskRunCancelResult,
TaskRunDetail,
TaskRunView,
} from "../plugins/runtime/task-domain-types.js";
export { definePluginEntry } from "./plugin-entry.js";
export { buildPluginConfigSchema, emptyPluginConfigSchema } from "../plugins/config-schema.js";

View File

@@ -45,9 +45,12 @@ import type {
ProviderReasoningOutputModeContext,
ProviderReplayPolicy,
ProviderReplayPolicyContext,
ProviderReplaySessionEntry,
ProviderReplaySessionState,
ProviderResolvedUsageAuth,
ProviderResolveDynamicModelContext,
ProviderSanitizeReplayHistoryContext,
ProviderToolSchemaDiagnostic,
ProviderResolveUsageAuthContext,
ProviderRuntimeModel,
ProviderThinkingPolicyContext,
@@ -85,10 +88,13 @@ export type {
ProviderNormalizeModelIdContext,
ProviderReplayPolicy,
ProviderReplayPolicyContext,
ProviderReplaySessionEntry,
ProviderReplaySessionState,
ProviderPreparedRuntimeAuth,
ProviderReasoningOutputMode,
ProviderReasoningOutputModeContext,
ProviderResolvedUsageAuth,
ProviderToolSchemaDiagnostic,
ProviderPrepareExtraParamsContext,
ProviderPrepareDynamicModelContext,
ProviderPrepareRuntimeAuthContext,

View File

@@ -1,5 +1,6 @@
// Public stream-wrapper helpers for provider plugins.
export { createAnthropicToolPayloadCompatibilityWrapper } from "../agents/pi-embedded-runner/anthropic-family-tool-payload-compat.js";
export {
createBedrockNoCacheWrapper,
isAnthropicBedrockModel,
@@ -8,6 +9,7 @@ export {
createGoogleThinkingPayloadWrapper,
sanitizeGoogleThinkingPayload,
} from "../agents/pi-embedded-runner/google-stream-wrappers.js";
export { createMinimaxFastModeWrapper } from "../agents/pi-embedded-runner/minimax-stream-wrappers.js";
export {
createKilocodeWrapper,
createOpenRouterSystemCacheWrapper,
@@ -20,7 +22,16 @@ export {
} from "../agents/pi-embedded-runner/moonshot-thinking-stream-wrappers.js";
export {
createOpenAIAttributionHeadersWrapper,
createCodexNativeWebSearchWrapper,
createOpenAIDefaultTransportWrapper,
createOpenAIFastModeWrapper,
createOpenAIReasoningCompatibilityWrapper,
createOpenAIResponsesContextManagementWrapper,
createOpenAIServiceTierWrapper,
createOpenAITextVerbosityWrapper,
resolveOpenAIFastMode,
resolveOpenAIServiceTier,
resolveOpenAITextVerbosity,
} from "../agents/pi-embedded-runner/openai-stream-wrappers.js";
export { streamWithPayloadPatch } from "../agents/pi-embedded-runner/stream-payload-utils.js";
export {

View File

@@ -1,4 +1,8 @@
// Shared provider-tool helpers for plugin-owned schema compatibility rewrites.
export {
cleanSchemaForGemini,
GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS,
} from "../agents/schema/clean-for-gemini.js";
export const XAI_UNSUPPORTED_SCHEMA_KEYWORDS = new Set([
"minLength",
@@ -54,3 +58,45 @@ export function stripUnsupportedSchemaKeywords(
export function stripXaiUnsupportedKeywords(schema: unknown): unknown {
return stripUnsupportedSchemaKeywords(schema, XAI_UNSUPPORTED_SCHEMA_KEYWORDS);
}
export function findUnsupportedSchemaKeywords(
schema: unknown,
path: string,
unsupportedKeywords: ReadonlySet<string>,
): string[] {
if (!schema || typeof schema !== "object") {
return [];
}
if (Array.isArray(schema)) {
return schema.flatMap((item, index) =>
findUnsupportedSchemaKeywords(item, `${path}[${index}]`, unsupportedKeywords),
);
}
const record = schema as Record<string, unknown>;
const violations: string[] = [];
const properties =
record.properties && typeof record.properties === "object" && !Array.isArray(record.properties)
? (record.properties as Record<string, unknown>)
: undefined;
if (properties) {
for (const [key, value] of Object.entries(properties)) {
violations.push(
...findUnsupportedSchemaKeywords(value, `${path}.properties.${key}`, unsupportedKeywords),
);
}
}
for (const [key, value] of Object.entries(record)) {
if (key === "properties") {
continue;
}
if (unsupportedKeywords.has(key)) {
violations.push(`${path}.${key}`);
}
if (value && typeof value === "object") {
violations.push(
...findUnsupportedSchemaKeywords(value, `${path}.${key}`, unsupportedKeywords),
);
}
}
return violations;
}