From ab6ddf7245b31345c9643eea8dc5af92a81ceef9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 27 Mar 2026 01:22:52 +0000 Subject: [PATCH] refactor: slim plugin sdk provider entrypoints --- docs/.generated/plugin-sdk-api-baseline.json | 15 +- docs/.generated/plugin-sdk-api-baseline.jsonl | 7 +- extensions/firecrawl/src/config.ts | 6 +- extensions/firecrawl/src/firecrawl-client.ts | 3 +- .../firecrawl/src/firecrawl-scrape-tool.ts | 6 +- .../firecrawl/src/firecrawl-search-tool.ts | 4 +- extensions/google/gemini-cli-provider.ts | 2 +- .../google/image-generation-provider.ts | 2 +- extensions/google/index.ts | 206 +++++++++++++++++- extensions/moonshot/index.ts | 2 +- extensions/tavily/src/config.ts | 6 +- extensions/tavily/src/tavily-extract-tool.ts | 6 +- extensions/tavily/src/tavily-search-tool.ts | 6 +- package.json | 8 + scripts/lib/plugin-sdk-entrypoints.json | 2 + src/plugin-sdk/provider-google.ts | 8 + src/plugin-sdk/provider-moonshot.ts | 6 + src/plugin-sdk/provider-web-search.ts | 8 +- src/plugin-sdk/secret-input.ts | 2 + 19 files changed, 275 insertions(+), 30 deletions(-) create mode 100644 src/plugin-sdk/provider-moonshot.ts diff --git a/docs/.generated/plugin-sdk-api-baseline.json b/docs/.generated/plugin-sdk-api-baseline.json index f09f6af523..b60757e45a 100644 --- a/docs/.generated/plugin-sdk-api-baseline.json +++ b/docs/.generated/plugin-sdk-api-baseline.json @@ -4792,7 +4792,7 @@ "exportName": "buildOptionalSecretInputSchema", "kind": "function", "source": { - "line": 18, + "line": 20, "path": "src/plugin-sdk/secret-input.ts" } }, @@ -4801,7 +4801,7 @@ "exportName": "buildSecretInputArraySchema", "kind": "function", "source": { - "line": 23, + "line": 25, "path": "src/plugin-sdk/secret-input.ts" } }, @@ -4810,7 +4810,7 @@ "exportName": "buildSecretInputSchema", "kind": "function", "source": { - "line": 11, + "line": 54, "path": "src/plugin-sdk/secret-input-schema.ts" } }, @@ -4832,6 +4832,15 @@ "path": "src/config/types.secrets.ts" } }, + { + "declaration": "export function normalizeSecretInput(value: unknown): string;", + "exportName": "normalizeSecretInput", + "kind": "function", + "source": { + "line": 16, + "path": "src/utils/normalize-secret-input.ts" + } + }, { "declaration": "export function normalizeSecretInputString(value: unknown): string | undefined;", "exportName": "normalizeSecretInputString", diff --git a/docs/.generated/plugin-sdk-api-baseline.jsonl b/docs/.generated/plugin-sdk-api-baseline.jsonl index 8a24faa1bd..dcb420892d 100644 --- a/docs/.generated/plugin-sdk-api-baseline.jsonl +++ b/docs/.generated/plugin-sdk-api-baseline.jsonl @@ -527,11 +527,12 @@ {"declaration":"export function createPluginRuntimeStore(errorMessage: string): { setRuntime: (next: T) => void; clearRuntime: () => void; tryGetRuntime: () => T | null; getRuntime: () => T; };","entrypoint":"runtime-store","exportName":"createPluginRuntimeStore","importSpecifier":"openclaw/plugin-sdk/runtime-store","kind":"function","recordType":"export","sourceLine":4,"sourcePath":"src/plugin-sdk/runtime-store.ts"} {"declaration":"export type PluginRuntime = PluginRuntime;","entrypoint":"runtime-store","exportName":"PluginRuntime","importSpecifier":"openclaw/plugin-sdk/runtime-store","kind":"type","recordType":"export","sourceLine":54,"sourcePath":"src/plugins/runtime/types.ts"} {"category":"channel","entrypoint":"secret-input","importSpecifier":"openclaw/plugin-sdk/secret-input","recordType":"module","sourceLine":1,"sourcePath":"src/plugin-sdk/secret-input.ts"} -{"declaration":"export function buildOptionalSecretInputSchema(): ZodOptional; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>>;","entrypoint":"secret-input","exportName":"buildOptionalSecretInputSchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":18,"sourcePath":"src/plugin-sdk/secret-input.ts"} -{"declaration":"export function buildSecretInputArraySchema(): ZodArray; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>>;","entrypoint":"secret-input","exportName":"buildSecretInputArraySchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":23,"sourcePath":"src/plugin-sdk/secret-input.ts"} -{"declaration":"export function buildSecretInputSchema(): ZodUnion; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>;","entrypoint":"secret-input","exportName":"buildSecretInputSchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":11,"sourcePath":"src/plugin-sdk/secret-input-schema.ts"} +{"declaration":"export function buildOptionalSecretInputSchema(): ZodOptional; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>>;","entrypoint":"secret-input","exportName":"buildOptionalSecretInputSchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":20,"sourcePath":"src/plugin-sdk/secret-input.ts"} +{"declaration":"export function buildSecretInputArraySchema(): ZodArray; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>>;","entrypoint":"secret-input","exportName":"buildSecretInputArraySchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":25,"sourcePath":"src/plugin-sdk/secret-input.ts"} +{"declaration":"export function buildSecretInputSchema(): ZodUnion; provider: ZodString; id: ZodString; }, $strip>, ZodObject<...>, ZodObject<...>], \"source\">]>;","entrypoint":"secret-input","exportName":"buildSecretInputSchema","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":54,"sourcePath":"src/plugin-sdk/secret-input-schema.ts"} {"declaration":"export function hasConfiguredSecretInput(value: unknown, defaults?: SecretDefaults | undefined): boolean;","entrypoint":"secret-input","exportName":"hasConfiguredSecretInput","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":106,"sourcePath":"src/config/types.secrets.ts"} {"declaration":"export function normalizeResolvedSecretInputString(params: { value: unknown; refValue?: unknown; defaults?: SecretDefaults | undefined; path: string; }): string | undefined;","entrypoint":"secret-input","exportName":"normalizeResolvedSecretInputString","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":144,"sourcePath":"src/config/types.secrets.ts"} +{"declaration":"export function normalizeSecretInput(value: unknown): string;","entrypoint":"secret-input","exportName":"normalizeSecretInput","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":16,"sourcePath":"src/utils/normalize-secret-input.ts"} {"declaration":"export function normalizeSecretInputString(value: unknown): string | undefined;","entrypoint":"secret-input","exportName":"normalizeSecretInputString","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"function","recordType":"export","sourceLine":113,"sourcePath":"src/config/types.secrets.ts"} {"declaration":"export type SecretInput = SecretInput;","entrypoint":"secret-input","exportName":"SecretInput","importSpecifier":"openclaw/plugin-sdk/secret-input","kind":"type","recordType":"export","sourceLine":16,"sourcePath":"src/config/types.secrets.ts"} {"category":"utilities","entrypoint":"testing","importSpecifier":"openclaw/plugin-sdk/testing","recordType":"module","sourceLine":1,"sourcePath":"src/plugin-sdk/testing.ts"} diff --git a/extensions/firecrawl/src/config.ts b/extensions/firecrawl/src/config.ts index 3c2c2f3c25..df4ee14af0 100644 --- a/extensions/firecrawl/src/config.ts +++ b/extensions/firecrawl/src/config.ts @@ -1,6 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; -import { normalizeSecretInput } from "openclaw/plugin-sdk/provider-auth"; -import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input"; +import { + normalizeResolvedSecretInputString, + normalizeSecretInput, +} from "openclaw/plugin-sdk/secret-input"; export const DEFAULT_FIRECRAWL_BASE_URL = "https://api.firecrawl.dev"; export const DEFAULT_FIRECRAWL_SEARCH_TIMEOUT_SECONDS = 30; diff --git a/extensions/firecrawl/src/firecrawl-client.ts b/extensions/firecrawl/src/firecrawl-client.ts index fa38c5bdab..33ce9fe860 100644 --- a/extensions/firecrawl/src/firecrawl-client.ts +++ b/extensions/firecrawl/src/firecrawl-client.ts @@ -1,11 +1,12 @@ -import { markdownToText, truncateText } from "openclaw/plugin-sdk/agent-runtime"; import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { DEFAULT_CACHE_TTL_MINUTES, + markdownToText, normalizeCacheKey, postTrustedWebToolsJson, readCache, resolveCacheTtlMs, + truncateText, writeCache, } from "openclaw/plugin-sdk/provider-web-search"; import { wrapExternalContent, wrapWebContent } from "openclaw/plugin-sdk/security-runtime"; diff --git a/extensions/firecrawl/src/firecrawl-scrape-tool.ts b/extensions/firecrawl/src/firecrawl-scrape-tool.ts index 8a4145eb50..ba77ce87f7 100644 --- a/extensions/firecrawl/src/firecrawl-scrape-tool.ts +++ b/extensions/firecrawl/src/firecrawl-scrape-tool.ts @@ -1,6 +1,10 @@ import { Type } from "@sinclair/typebox"; -import { jsonResult, readNumberParam, readStringParam } from "openclaw/plugin-sdk/agent-runtime"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime"; +import { + jsonResult, + readNumberParam, + readStringParam, +} from "openclaw/plugin-sdk/provider-web-search"; import { runFirecrawlScrape } from "./firecrawl-client.js"; function optionalStringEnum( diff --git a/extensions/firecrawl/src/firecrawl-search-tool.ts b/extensions/firecrawl/src/firecrawl-search-tool.ts index 9a1201ec6e..fd99bcf470 100644 --- a/extensions/firecrawl/src/firecrawl-search-tool.ts +++ b/extensions/firecrawl/src/firecrawl-search-tool.ts @@ -1,11 +1,11 @@ import { Type } from "@sinclair/typebox"; +import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime"; import { jsonResult, readNumberParam, readStringArrayParam, readStringParam, -} from "openclaw/plugin-sdk/agent-runtime"; -import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime"; +} from "openclaw/plugin-sdk/provider-web-search"; import { runFirecrawlSearch } from "./firecrawl-client.js"; const FirecrawlSearchToolSchema = Type.Object( diff --git a/extensions/google/gemini-cli-provider.ts b/extensions/google/gemini-cli-provider.ts index 412d02dd85..06f11598c4 100644 --- a/extensions/google/gemini-cli-provider.ts +++ b/extensions/google/gemini-cli-provider.ts @@ -3,7 +3,7 @@ import type { ProviderAuthContext, ProviderFetchUsageSnapshotContext, } from "openclaw/plugin-sdk/plugin-entry"; -import { buildOauthProviderAuthResult } from "openclaw/plugin-sdk/provider-auth"; +import { buildOauthProviderAuthResult } from "openclaw/plugin-sdk/provider-auth-result"; import { fetchGeminiUsage } from "openclaw/plugin-sdk/provider-usage"; import { isModernGoogleModel, resolveGoogle31ForwardCompatModel } from "./provider-models.js"; diff --git a/extensions/google/image-generation-provider.ts b/extensions/google/image-generation-provider.ts index f138ff86be..2f46eb356c 100644 --- a/extensions/google/image-generation-provider.ts +++ b/extensions/google/image-generation-provider.ts @@ -1,5 +1,5 @@ import type { ImageGenerationProvider } from "openclaw/plugin-sdk/image-generation"; -import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth"; +import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/image-generation-core"; import { DEFAULT_GOOGLE_API_BASE_URL, normalizeGoogleApiBaseUrl, diff --git a/extensions/google/index.ts b/extensions/google/index.ts index ef88a5e8dd..0b5b7756ca 100644 --- a/extensions/google/index.ts +++ b/extensions/google/index.ts @@ -1,17 +1,203 @@ -import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry"; -import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth"; +import type { ImageGenerationProvider } from "openclaw/plugin-sdk/image-generation"; +import type { MediaUnderstandingProvider } from "openclaw/plugin-sdk/media-understanding"; +import { + definePluginEntry, + type OpenClawPluginApi, + type ProviderAuthContext, + type ProviderFetchUsageSnapshotContext, +} from "openclaw/plugin-sdk/plugin-entry"; +import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-auth-api-key"; import { GOOGLE_GEMINI_DEFAULT_MODEL, applyGoogleGeminiModelDefault, -} from "openclaw/plugin-sdk/provider-models"; -import { createGoogleThinkingPayloadWrapper } from "openclaw/plugin-sdk/provider-stream"; + createGoogleThinkingPayloadWrapper, +} from "openclaw/plugin-sdk/provider-google"; +import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-models"; import { buildGoogleGeminiCliBackend } from "./cli-backend.js"; -import { registerGoogleGeminiCliProvider } from "./gemini-cli-provider.js"; -import { buildGoogleImageGenerationProvider } from "./image-generation-provider.js"; -import { googleMediaUnderstandingProvider } from "./media-understanding-provider.js"; import { isModernGoogleModel, resolveGoogle31ForwardCompatModel } from "./provider-models.js"; import { createGeminiWebSearchProvider } from "./src/gemini-web-search-provider.js"; +const GOOGLE_GEMINI_CLI_PROVIDER_ID = "google-gemini-cli"; +const GOOGLE_GEMINI_CLI_PROVIDER_LABEL = "Gemini CLI OAuth"; +const GOOGLE_GEMINI_CLI_DEFAULT_MODEL = "google-gemini-cli/gemini-3.1-pro-preview"; +const GOOGLE_GEMINI_CLI_ENV_VARS = [ + "OPENCLAW_GEMINI_OAUTH_CLIENT_ID", + "OPENCLAW_GEMINI_OAUTH_CLIENT_SECRET", + "GEMINI_CLI_OAUTH_CLIENT_ID", + "GEMINI_CLI_OAUTH_CLIENT_SECRET", +] as const; + +type GoogleOauthApiKeyCredential = { + type?: string; + access?: string; + projectId?: string; +}; + +let googleGeminiCliProviderPromise: Promise | null = null; +let googleImageGenerationProviderPromise: Promise | null = null; +let googleMediaUnderstandingProviderPromise: Promise | null = null; + +type GoogleMediaUnderstandingProvider = MediaUnderstandingProvider & { + describeImage: NonNullable; + describeImages: NonNullable; + transcribeAudio: NonNullable; + describeVideo: NonNullable; +}; + +function formatGoogleOauthApiKey(cred: GoogleOauthApiKeyCredential): string { + if (cred.type !== "oauth" || typeof cred.access !== "string" || !cred.access.trim()) { + return ""; + } + return JSON.stringify({ + token: cred.access, + projectId: cred.projectId, + }); +} + +async function loadGoogleGeminiCliProvider(): Promise { + if (!googleGeminiCliProviderPromise) { + googleGeminiCliProviderPromise = import("./gemini-cli-provider.js").then((mod) => { + let provider: ProviderPlugin | undefined; + mod.registerGoogleGeminiCliProvider({ + registerProvider(entry) { + provider = entry; + }, + } as Pick as OpenClawPluginApi); + if (!provider) { + throw new Error("google gemini cli provider missing provider registration"); + } + return provider; + }); + } + return await googleGeminiCliProviderPromise; +} + +async function loadGoogleImageGenerationProvider(): Promise { + if (!googleImageGenerationProviderPromise) { + googleImageGenerationProviderPromise = import("./image-generation-provider.js").then((mod) => + mod.buildGoogleImageGenerationProvider(), + ); + } + return await googleImageGenerationProviderPromise; +} + +async function loadGoogleMediaUnderstandingProvider(): Promise { + if (!googleMediaUnderstandingProviderPromise) { + googleMediaUnderstandingProviderPromise = import("./media-understanding-provider.js").then( + (mod) => mod.googleMediaUnderstandingProvider, + ); + } + return await googleMediaUnderstandingProviderPromise; +} + +async function loadGoogleRequiredMediaUnderstandingProvider(): Promise { + const provider = await loadGoogleMediaUnderstandingProvider(); + if ( + !provider.describeImage || + !provider.describeImages || + !provider.transcribeAudio || + !provider.describeVideo + ) { + throw new Error("google media understanding provider missing required handlers"); + } + return provider as GoogleMediaUnderstandingProvider; +} + +function createLazyGoogleGeminiCliProvider(): ProviderPlugin { + return { + id: GOOGLE_GEMINI_CLI_PROVIDER_ID, + label: GOOGLE_GEMINI_CLI_PROVIDER_LABEL, + docsPath: "/providers/models", + aliases: ["gemini-cli"], + envVars: [...GOOGLE_GEMINI_CLI_ENV_VARS], + auth: [ + { + id: "oauth", + label: "Google OAuth", + hint: "PKCE + localhost callback", + kind: "oauth", + run: async (ctx: ProviderAuthContext) => { + const provider = await loadGoogleGeminiCliProvider(); + const authMethod = provider.auth?.[0]; + if (!authMethod || authMethod.kind !== "oauth") { + return { profiles: [] }; + } + return await authMethod.run(ctx); + }, + }, + ], + wizard: { + setup: { + choiceId: "google-gemini-cli", + choiceLabel: "Gemini CLI OAuth", + choiceHint: "Google OAuth with project-aware token payload", + methodId: "oauth", + }, + }, + resolveDynamicModel: (ctx) => + resolveGoogle31ForwardCompatModel({ providerId: GOOGLE_GEMINI_CLI_PROVIDER_ID, ctx }), + isModernModelRef: ({ modelId }) => isModernGoogleModel(modelId), + formatApiKey: (cred) => formatGoogleOauthApiKey(cred as GoogleOauthApiKeyCredential), + resolveUsageAuth: async (ctx) => { + const provider = await loadGoogleGeminiCliProvider(); + return await provider.resolveUsageAuth?.(ctx); + }, + fetchUsageSnapshot: async (ctx: ProviderFetchUsageSnapshotContext) => { + const provider = await loadGoogleGeminiCliProvider(); + if (!provider.fetchUsageSnapshot) { + throw new Error("google gemini cli provider missing usage snapshot handler"); + } + return await provider.fetchUsageSnapshot(ctx); + }, + }; +} + +function createLazyGoogleImageGenerationProvider(): ImageGenerationProvider { + return { + id: "google", + label: "Google", + defaultModel: "gemini-3.1-flash-image-preview", + models: ["gemini-3.1-flash-image-preview", "gemini-3-pro-image-preview"], + capabilities: { + generate: { + maxCount: 4, + supportsSize: true, + supportsAspectRatio: true, + supportsResolution: true, + }, + edit: { + enabled: true, + maxCount: 4, + maxInputImages: 5, + supportsSize: true, + supportsAspectRatio: true, + supportsResolution: true, + }, + geometry: { + sizes: ["1024x1024", "1024x1536", "1536x1024", "1024x1792", "1792x1024"], + aspectRatios: ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"], + resolutions: ["1K", "2K", "4K"], + }, + }, + generateImage: async (req) => (await loadGoogleImageGenerationProvider()).generateImage(req), + }; +} + +function createLazyGoogleMediaUnderstandingProvider(): MediaUnderstandingProvider { + return { + id: "google", + capabilities: ["image", "audio", "video"], + describeImage: async (...args) => + await (await loadGoogleRequiredMediaUnderstandingProvider()).describeImage(...args), + describeImages: async (...args) => + await (await loadGoogleRequiredMediaUnderstandingProvider()).describeImages(...args), + transcribeAudio: async (...args) => + await (await loadGoogleRequiredMediaUnderstandingProvider()).transcribeAudio(...args), + describeVideo: async (...args) => + await (await loadGoogleRequiredMediaUnderstandingProvider()).describeVideo(...args), + }; +} + export default definePluginEntry({ id: "google", name: "Google Plugin", @@ -50,9 +236,9 @@ export default definePluginEntry({ isModernModelRef: ({ modelId }) => isModernGoogleModel(modelId), }); api.registerCliBackend(buildGoogleGeminiCliBackend()); - registerGoogleGeminiCliProvider(api); - api.registerImageGenerationProvider(buildGoogleImageGenerationProvider()); - api.registerMediaUnderstandingProvider(googleMediaUnderstandingProvider); + api.registerProvider(createLazyGoogleGeminiCliProvider()); + api.registerImageGenerationProvider(createLazyGoogleImageGenerationProvider()); + api.registerMediaUnderstandingProvider(createLazyGoogleMediaUnderstandingProvider()); api.registerWebSearchProvider(createGeminiWebSearchProvider()); }, }); diff --git a/extensions/moonshot/index.ts b/extensions/moonshot/index.ts index a5908547ac..ccd2f6a126 100644 --- a/extensions/moonshot/index.ts +++ b/extensions/moonshot/index.ts @@ -2,7 +2,7 @@ import { defineSingleProviderPluginEntry } from "openclaw/plugin-sdk/provider-en import { createMoonshotThinkingWrapper, resolveMoonshotThinkingType, -} from "openclaw/plugin-sdk/provider-stream"; +} from "openclaw/plugin-sdk/provider-moonshot"; import { moonshotMediaUnderstandingProvider } from "./media-understanding-provider.js"; import { applyMoonshotConfig, diff --git a/extensions/tavily/src/config.ts b/extensions/tavily/src/config.ts index 7bef2dcdd5..b2c1405a82 100644 --- a/extensions/tavily/src/config.ts +++ b/extensions/tavily/src/config.ts @@ -1,6 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; -import { normalizeSecretInput } from "openclaw/plugin-sdk/provider-auth"; -import { normalizeResolvedSecretInputString } from "openclaw/plugin-sdk/secret-input"; +import { + normalizeResolvedSecretInputString, + normalizeSecretInput, +} from "openclaw/plugin-sdk/secret-input"; export const DEFAULT_TAVILY_BASE_URL = "https://api.tavily.com"; export const DEFAULT_TAVILY_SEARCH_TIMEOUT_SECONDS = 30; diff --git a/extensions/tavily/src/tavily-extract-tool.ts b/extensions/tavily/src/tavily-extract-tool.ts index 46da455544..f33882358d 100644 --- a/extensions/tavily/src/tavily-extract-tool.ts +++ b/extensions/tavily/src/tavily-extract-tool.ts @@ -1,6 +1,10 @@ import { Type } from "@sinclair/typebox"; -import { jsonResult, readNumberParam, readStringParam } from "openclaw/plugin-sdk/agent-runtime"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime"; +import { + jsonResult, + readNumberParam, + readStringParam, +} from "openclaw/plugin-sdk/provider-web-search"; import { runTavilyExtract } from "./tavily-client.js"; function optionalStringEnum( diff --git a/extensions/tavily/src/tavily-search-tool.ts b/extensions/tavily/src/tavily-search-tool.ts index 2f0b012e59..dad9b7d1bb 100644 --- a/extensions/tavily/src/tavily-search-tool.ts +++ b/extensions/tavily/src/tavily-search-tool.ts @@ -1,6 +1,10 @@ import { Type } from "@sinclair/typebox"; -import { jsonResult, readNumberParam, readStringParam } from "openclaw/plugin-sdk/agent-runtime"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-runtime"; +import { + jsonResult, + readNumberParam, + readStringParam, +} from "openclaw/plugin-sdk/provider-web-search"; import { runTavilySearch } from "./tavily-client.js"; function optionalStringEnum( diff --git a/package.json b/package.json index 54d123b902..e7108a2aa7 100644 --- a/package.json +++ b/package.json @@ -456,6 +456,10 @@ "types": "./dist/plugin-sdk/provider-auth-api-key.d.ts", "default": "./dist/plugin-sdk/provider-auth-api-key.js" }, + "./plugin-sdk/provider-auth-result": { + "types": "./dist/plugin-sdk/provider-auth-result.d.ts", + "default": "./dist/plugin-sdk/provider-auth-result.js" + }, "./plugin-sdk/provider-auth-login": { "types": "./dist/plugin-sdk/provider-auth-login.d.ts", "default": "./dist/plugin-sdk/provider-auth-login.js" @@ -488,6 +492,10 @@ "types": "./dist/plugin-sdk/provider-models.d.ts", "default": "./dist/plugin-sdk/provider-models.js" }, + "./plugin-sdk/provider-moonshot": { + "types": "./dist/plugin-sdk/provider-moonshot.d.ts", + "default": "./dist/plugin-sdk/provider-moonshot.js" + }, "./plugin-sdk/provider-onboard": { "types": "./dist/plugin-sdk/provider-onboard.d.ts", "default": "./dist/plugin-sdk/provider-onboard.js" diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 085dd941c8..b38d86fdbe 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -104,6 +104,7 @@ "nostr", "provider-auth", "provider-auth-api-key", + "provider-auth-result", "provider-auth-login", "plugin-entry", "provider-catalog", @@ -112,6 +113,7 @@ "provider-http", "provider-google", "provider-models", + "provider-moonshot", "provider-onboard", "provider-stream", "provider-usage", diff --git a/src/plugin-sdk/provider-google.ts b/src/plugin-sdk/provider-google.ts index 47b755ffb1..4f3bac00fb 100644 --- a/src/plugin-sdk/provider-google.ts +++ b/src/plugin-sdk/provider-google.ts @@ -4,3 +4,11 @@ export { normalizeGoogleModelId } from "../agents/model-id-normalization.js"; export { DEFAULT_GOOGLE_API_BASE_URL } from "../infra/google-api-base-url.js"; export { normalizeGoogleApiBaseUrl } from "../infra/google-api-base-url.js"; export { parseGeminiAuth } from "../infra/gemini-auth.js"; +export { + createGoogleThinkingPayloadWrapper, + sanitizeGoogleThinkingPayload, +} from "../agents/pi-embedded-runner/google-stream-wrappers.js"; +export { + applyGoogleGeminiModelDefault, + GOOGLE_GEMINI_DEFAULT_MODEL, +} from "../plugins/provider-model-defaults.js"; diff --git a/src/plugin-sdk/provider-moonshot.ts b/src/plugin-sdk/provider-moonshot.ts new file mode 100644 index 0000000000..48d14a5504 --- /dev/null +++ b/src/plugin-sdk/provider-moonshot.ts @@ -0,0 +1,6 @@ +// Public Moonshot provider helpers shared by bundled Moonshot extensions. + +export { + createMoonshotThinkingWrapper, + resolveMoonshotThinkingType, +} from "../agents/pi-embedded-runner/moonshot-stream-wrappers.js"; diff --git a/src/plugin-sdk/provider-web-search.ts b/src/plugin-sdk/provider-web-search.ts index b03aebff79..1fd90707ef 100644 --- a/src/plugin-sdk/provider-web-search.ts +++ b/src/plugin-sdk/provider-web-search.ts @@ -5,7 +5,12 @@ import type { WebSearchProviderPlugin, WebSearchProviderToolDefinition, } from "../plugins/types.js"; -export { readNumberParam, readStringArrayParam, readStringParam } from "../agents/tools/common.js"; +export { + jsonResult, + readNumberParam, + readStringArrayParam, + readStringParam, +} from "../agents/tools/common.js"; export { resolveCitationRedirectUrl } from "../agents/tools/web-search-citation-redirect.js"; export { buildSearchCacheKey, @@ -41,6 +46,7 @@ export { export type { SearchConfigRecord } from "../agents/tools/web-search-provider-common.js"; export { resolveWebSearchProviderCredential } from "../agents/tools/web-search-provider-credentials.js"; export { withTrustedWebToolsEndpoint } from "../agents/tools/web-guarded-fetch.js"; +export { markdownToText, truncateText } from "../agents/tools/web-fetch-utils.js"; export { DEFAULT_CACHE_TTL_MINUTES, DEFAULT_TIMEOUT_SECONDS, diff --git a/src/plugin-sdk/secret-input.ts b/src/plugin-sdk/secret-input.ts index 1aee32fbf6..b1bcdd7c78 100644 --- a/src/plugin-sdk/secret-input.ts +++ b/src/plugin-sdk/secret-input.ts @@ -4,6 +4,7 @@ import { normalizeResolvedSecretInputString, normalizeSecretInputString, } from "../config/types.secrets.js"; +import { normalizeSecretInput } from "../utils/normalize-secret-input.js"; import { buildSecretInputSchema } from "./secret-input-schema.js"; export type { SecretInput } from "../config/types.secrets.js"; @@ -11,6 +12,7 @@ export { buildSecretInputSchema, hasConfiguredSecretInput, normalizeResolvedSecretInputString, + normalizeSecretInput, normalizeSecretInputString, };