/** * Pure logic backing the payments widgets. Mirrors the web builder's tools-ui * counterparts (useSelectPaymentProvider.ts, useConfigurePspCredentials.ts * and their utils/) with the English strings from the builder's i18n catalog. */ import type { SuperagentToolCall } from '../types'; import { type ToolWidgetStatus } from './toolWidgetUtils'; export type ProviderEntry = { key: string; display_name: string; methods: string[]; }; /** * Provider radio entries coerced to well-formed {key, display_name, methods[]} * (web useSelectPaymentProvider parity — args are model-controlled JSON even * though the prepare hook overwrites them with the trusted list). */ export declare function normalizeProviders(args: Record | null): ProviderEntry[]; export declare function formatMethods(methods: string[]): string; export type PspOption = { label: string; value: string; }; export type PspField = { name: string; label: string; type?: string; options: PspOption[]; }; /** Wix marks secret fields with type PASSWORD — render them masked. */ export declare function isSecretPspField(field: PspField): boolean; /** args.schema as a plain object (model-controlled — may be anything). */ export declare function getPspSchema(args: Record | null): Record | null; /** No hardcoded provider: display_name → schema title → raw key → generic. */ export declare function getPspProcessorName(args: Record | null): string; /** * schema.fields coerced to entries with a string `name` (the key the backend * requires), label falling back to the name (web useConfigurePspCredentials * parity — dropping name-only fields would make Connect fail server-side). */ export declare function normalizePspFields(args: Record | null): PspField[]; /** args are model-controlled — only display values that are real strings. */ export declare function asTrimmedString(value: unknown): string | null; /** * Prompt-injection guard: only http(s) URLs may be opened from tool args. * Parsed with URL (web parity, supported by Hermes) instead of a prefix * regex, so strings that merely start with "http" but aren't valid URLs * are dropped. */ export declare function sanitizeHttpUrl(raw: unknown): string | null; /** Backend tool results are a raw string or {success, message}. */ export declare function resultText(results: SuperagentToolCall['results']): string; /** Skip resolves the PSP tools as success — don't claim connected/selected. */ export declare function wasPspSkipped(results: SuperagentToolCall['results']): boolean; /** Web parsePspToolErrorMessage parity, minus the runner's user-input prefix. */ export declare function parsePspToolErrorMessage(results: SuperagentToolCall['results']): string | null; /** * Whether the PSP widgets render their actionable form (web showForm parity: * `(waiting || error) && isLastAssistantMessage`). The backend keeps these * tools submittable after an error for in-place retry * (RETRY_IN_PLACE_ON_ERROR_TOOLS) — resubmitting reruns the same tool call — * so `error` keeps the form alongside `waiting`. Both are gated to the latest * assistant turn; a stale card falls back to the read-only status row. */ export declare function showsPspForm(status: ToolWidgetStatus, isLastAssistantMessage?: boolean): boolean; /** * Status row title for select_payment_provider (web statusLabel parity). * `stopped` means the call was rejected/stopped without resolving (the old * generic approval card's Reject, or another client) — it must not fall * through to "selected". `waiting` is the stale non-actionable card (not the * latest turn): the web shows the prompt label with the form gated off. */ export declare function selectPaymentProviderTitle(status: ToolWidgetStatus, results: SuperagentToolCall['results']): string; /** Status row title for configure_psp_credentials — same mapping as above. */ export declare function configurePspCredentialsTitle(status: ToolWidgetStatus, results: SuperagentToolCall['results'], processorName: string): string; /** * Backend rejection messages embed LLM directives — substitute clean copy for * the user (web useConfigurePspCredentials parity). */ export declare function pspCredentialsErrorMessage(results: SuperagentToolCall['results'], processorName: string): string | null; //# sourceMappingURL=interactiveWidgetUtils.d.ts.map