import type { TSchema } from "typebox"; import type { OpenClawConfig } from "../config/types.openclaw.js"; import type { RuntimeEnv } from "../runtime.js"; import type { RuntimeWebFetchMetadata, RuntimeWebSearchMetadata, } from "../secrets/runtime-web-tools.types.js"; import type { WizardPrompter } from "../wizard/prompts.js"; import type { SecretInputMode } from "./provider-auth-types.js"; export type WebSearchProviderId = string; export type WebFetchProviderId = string; export type WebSearchProviderToolDefinition = { description: string; parameters: TSchema; execute: ( args: Record, context?: WebSearchProviderToolExecutionContext, ) => Promise>; }; export type WebFetchProviderToolDefinition = { description: string; parameters: TSchema; execute: (args: Record) => Promise>; }; export type WebSearchProviderContext = { config?: OpenClawConfig; searchConfig?: Record; runtimeMetadata?: RuntimeWebSearchMetadata; }; export type WebSearchProviderToolExecutionContext = { signal?: AbortSignal; }; export type WebFetchProviderContext = { config?: OpenClawConfig; fetchConfig?: Record; runtimeMetadata?: RuntimeWebFetchMetadata; }; export type WebSearchCredentialResolutionSource = "config" | "secretRef" | "env" | "missing"; export type WebSearchProviderConfiguredCredentialFallback = { path: string; value: unknown; }; export type WebSearchRuntimeMetadataContext = { config?: OpenClawConfig; searchConfig?: Record; runtimeMetadata?: RuntimeWebSearchMetadata; resolvedCredential?: { value?: string; source: WebSearchCredentialResolutionSource; fallbackEnvVar?: string; }; }; export type WebSearchProviderSetupContext = { config: OpenClawConfig; runtime: RuntimeEnv; prompter: WizardPrompter; quickstartDefaults?: boolean; secretInputMode?: SecretInputMode; }; export type WebFetchCredentialResolutionSource = "config" | "secretRef" | "env" | "missing"; export type WebFetchRuntimeMetadataContext = { config?: OpenClawConfig; fetchConfig?: Record; runtimeMetadata?: RuntimeWebFetchMetadata; resolvedCredential?: { value?: string; source: WebFetchCredentialResolutionSource; fallbackEnvVar?: string; }; }; export type WebSearchProviderPlugin = { id: WebSearchProviderId; label: string; hint: string; onboardingScopes?: readonly "text-inference"[]; requiresCredential?: boolean; credentialLabel?: string; envVars: string[]; placeholder: string; signupUrl: string; docsUrl?: string; /** Optional note shown before credential collection for provider-specific prerequisites. */ credentialNote?: string; autoDetectOrder?: number; credentialPath: string; inactiveSecretPaths?: string[]; getCredentialValue: (searchConfig?: Record) => unknown; setCredentialValue: (searchConfigTarget: Record, value: unknown) => void; getConfiguredCredentialValue?: (config?: OpenClawConfig) => unknown; setConfiguredCredentialValue?: (configTarget: OpenClawConfig, value: unknown) => void; getConfiguredCredentialFallback?: ( config?: OpenClawConfig, ) => WebSearchProviderConfiguredCredentialFallback | undefined; applySelectionConfig?: (config: OpenClawConfig) => OpenClawConfig; runSetup?: (ctx: WebSearchProviderSetupContext) => OpenClawConfig | Promise; resolveRuntimeMetadata?: ( ctx: WebSearchRuntimeMetadataContext, ) => Partial | Promise>; createTool: (ctx: WebSearchProviderContext) => WebSearchProviderToolDefinition | null; }; export type PluginWebSearchProviderEntry = WebSearchProviderPlugin & { pluginId: string; }; export type WebFetchProviderPlugin = { id: WebFetchProviderId; label: string; hint: string; requiresCredential?: boolean; credentialLabel?: string; envVars: string[]; placeholder: string; signupUrl: string; docsUrl?: string; autoDetectOrder?: number; credentialPath: string; inactiveSecretPaths?: string[]; getCredentialValue: (fetchConfig?: Record) => unknown; setCredentialValue: (fetchConfigTarget: Record, value: unknown) => void; getConfiguredCredentialValue?: (config?: OpenClawConfig) => unknown; setConfiguredCredentialValue?: (configTarget: OpenClawConfig, value: unknown) => void; applySelectionConfig?: (config: OpenClawConfig) => OpenClawConfig; resolveRuntimeMetadata?: ( ctx: WebFetchRuntimeMetadataContext, ) => Partial | Promise>; createTool: (ctx: WebFetchProviderContext) => WebFetchProviderToolDefinition | null; }; export type PluginWebFetchProviderEntry = WebFetchProviderPlugin & { pluginId: string; };