@apifuse/provider-sdk 2.2.0-beta.22 → 2.2.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts CHANGED
@@ -243,6 +243,61 @@ export interface SmsOtpMatcherDefinition {
243
243
  extractOtp(body: string): string | null;
244
244
  }
245
245
 
246
+ export interface ProviderOcrConfig {
247
+ readonly mode: "required" | "optional";
248
+ }
249
+
250
+ export type OcrImageInput =
251
+ | { readonly kind: "base64"; readonly data: string; readonly mediaType?: string }
252
+ | { readonly kind: "url"; readonly url: string };
253
+
254
+ export interface OcrRecognizeRequest {
255
+ readonly image: OcrImageInput;
256
+ readonly hint?: "captcha" | "document" | "generic";
257
+ readonly prompt?: string;
258
+ readonly maxTokens?: number;
259
+ readonly timeoutMs?: number;
260
+ }
261
+
262
+ export interface OcrWarning {
263
+ readonly code: string;
264
+ readonly message: string;
265
+ }
266
+
267
+ export interface OcrResult {
268
+ readonly text: string;
269
+ readonly model: string;
270
+ readonly warnings?: readonly OcrWarning[];
271
+ }
272
+
273
+ export interface OcrCaptchaOptions {
274
+ readonly length?: number;
275
+ /** Allowed characters. A RegExp is applied to each character, not to the whole text. */
276
+ readonly charset?: string | RegExp;
277
+ readonly caseSensitive?: boolean;
278
+ readonly maxCandidates?: number;
279
+ }
280
+
281
+ export interface OcrCaptchaCandidate {
282
+ readonly text: string;
283
+ readonly satisfiesConstraints: boolean;
284
+ }
285
+
286
+ export interface OcrCaptchaResult {
287
+ readonly text: string;
288
+ readonly candidates: readonly OcrCaptchaCandidate[];
289
+ readonly satisfiesConstraints: boolean;
290
+ readonly model: string;
291
+ }
292
+
293
+ export interface OcrContext {
294
+ recognize(request: OcrRecognizeRequest): Promise<OcrResult>;
295
+ extractCaptchaText(
296
+ image: OcrImageInput,
297
+ options?: OcrCaptchaOptions,
298
+ ): Promise<OcrCaptchaResult>;
299
+ }
300
+
246
301
  export type SttTranscribeMode = "general" | "otp";
247
302
  export type SttPromptPolicy = "none" | "default-hint" | "custom-hint";
248
303
  export type SttUnsupportedOptionPolicy = "warn" | "error";
@@ -1889,6 +1944,7 @@ export interface FlowContext {
1889
1944
  env: EnvContext;
1890
1945
  credential?: CredentialContext;
1891
1946
  context: ContextScratchpad;
1947
+ ocr: OcrContext;
1892
1948
  stt: SttContext;
1893
1949
  auth: AuthFlowTerminalContext;
1894
1950
  }
@@ -2014,6 +2070,7 @@ export interface ProviderContext {
2014
2070
  browser: BrowserClient;
2015
2071
  trace: TraceContext;
2016
2072
  auth: AuthContext;
2073
+ ocr: OcrContext;
2017
2074
  stt: SttContext;
2018
2075
  choice: ProviderChoiceContext;
2019
2076
  }
@@ -2187,6 +2244,7 @@ export interface ProviderDefinition {
2187
2244
  platform: StealthPlatform;
2188
2245
  };
2189
2246
  proxy?: ProviderProxyConfig;
2247
+ ocr?: ProviderOcrConfig;
2190
2248
  stt?: ProviderSttConfig;
2191
2249
  browser?: {
2192
2250
  engine: BrowserEngine;