openvibe-sdk/tools

Generated at from openvibe-contracts v0.454.0 and openvibe-sdk v0.193.0.

From types/tools.d.ts (both). Declarations are shown verbatim.

re-export ToolDescriptor, ToolList, ToolsRunRequest, ToolsRun, ToolsJob

export type { ToolDescriptor, ToolList, ToolsRunRequest, ToolsRun, ToolsJob } from './contracts';

type ToolFileRef

A file that is already somewhere (tools.run-request@1 files).

export type ToolFileRef =
    /** A Media object the caller may read. */
    | { media_id: string }
    /** Result file `index` of a job the same caller owns: one tool's output feeds the next. */
    | { job_id: string; index: number };

type ToolRunFile

An upload (multipart `file` part) or a reference.

export type ToolRunFile = JobFile | ToolFileRef;

interface ToolSchema

GET /api/v1/tools/:id/schema: what the list's `$ref`s point at.

export interface ToolSchema {
    $schema?: string;
    $id?: string;
    $defs: { input: Record<string, unknown> | null; output: Record<string, unknown> | null };
}

interface ToolListQuery

export interface ToolListQuery {
    family?: string;
    /** Name, summary and keywords. */
    q?: string;
    execution?: ToolDescriptor['execution'];
    /** Sent as api=true|false. */
    api?: boolean;
    status?: ToolDescriptor['status'];
    signal?: AbortSignal;
}

interface ToolsExecutionReceipt

Durable job execution receipt at result.data.execution, or error.execution on failure/cancellation.

export interface ToolsExecutionReceipt {
    worker: string;
    location: 'home' | 'host';
    took_ms: number;
    attempts: Array<{ worker: string; location: 'home' | 'host'; took_ms: number; state: 'succeeded' | 'failed' | 'cancelled' | 'disconnected' }>;
}

interface ToolRunOptions

export interface ToolRunOptions {
    /** host keeps work on the host; home is advisory and respects owner order. Default auto. */
    prefer?: 'auto' | 'home' | 'host';
    /** Uploads first, then references, in order; the count must fit the descriptor's files.min..max. */
    files?: ToolRunFile | ToolRunFile[];
    /** Job tools: wait up to this long (0..60000 ms) before answering; 200 finished, else 202. */
    waitMs?: number;
    /** 8-200 printable ASCII characters; generated when omitted (returned as `idempotencyKey`). */
    idempotencyKey?: string;
    signal?: AbortSignal;
    /** Per attempt. Default: the client's, raised to waitMs or the tool's known limits.timeoutMs, plus 10 s. */
    timeoutMs?: number;
}

type ToolRunWaitOptions

export type ToolRunWaitOptions = JobEventsOptions & { onEvent?: (e: JobEvent) => void | Promise<void> };

type ToolRunResult

tools.run@1 `result`: data (output kind json), text (kind text) or files (kind file or files: the job's result files).

export type ToolRunResult = Extract<ToolsRun, { state: 'succeeded' }>['result'];

class ToolRunError

A run that finished `failed` or `cancelled`, with the tool's own problem+json mapped like any OpenVibeError. `status` is the problem's status (422, 504…), not the HTTP status (200). `isOpenVibeError(err)` is true.

export declare class ToolRunError extends OpenVibeError {
    state: 'failed' | 'cancelled';
    tool: string;
    /** The job, when the tool ran as one (`jobs.retry(err.job.id)` when `retryable`). */
    job: ToolsJob | null;
    /** The tools.run@1 answer, when the failure came in one (null when it came from the job). */
    run: ToolsRun | null;
    constructor(init: { state: 'failed' | 'cancelled'; tool: string; error?: unknown; job?: ToolsJob | null; run?: ToolsRun | null; requestId?: string; traceId?: string });
}

function isToolRunError

export declare function isToolRunError(err: unknown): err is ToolRunError;

interface ToolRankingItem

export interface ToolRankingItem {
    id: string;
    name: string;
    description: string;
    family: string;
    icon: string;
    url: string;
    uses: number;
    /** Trending only: use count in the preceding comparison window. */
    previous_uses?: number;
    increase?: number;
}

interface ToolRanking

export interface ToolRanking {
    metric: 'successful_api_runs';
    window: 'hour' | 'week';
    updated_at: string;
    uses_today: number;
    tools: ToolRankingItem[];
    count: number;
}

interface ToolsClient

export interface ToolsClient {
    /** Rising successful API use versus the preceding UTC hour or seven-day window. */
    trending(opts?: { window?: 'hour' | 'week'; limit?: number; signal?: AbortSignal }): Promise<ToolRanking>;
    /** Most successful API uses in the last seven days. */
    popular(opts?: { limit?: number; signal?: AbortSignal }): Promise<ToolRanking>;
    /** GET /api/v1/tools: tools.tool-list@1, schemas as { $ref }. */
    list(query?: ToolListQuery): Promise<ToolList>;
    /** GET /api/v1/tools/:id: the descriptor with its schemas embedded, or null. */
    get(id: string, opts?: { signal?: AbortSignal }): Promise<ToolDescriptor | null>;
    /** GET /api/v1/tools/:id/schema, or null. */
    schema(id: string, opts?: { signal?: AbortSignal }): Promise<ToolSchema | null>;
    /**
     * POST /api/v1/tools/:id/run. Resolves finished (succeeded) or pending (a job still queued or
     * running); throws ToolRunError when the run failed or was cancelled, OpenVibeError when it was
     * refused (404 tools.tool.not_found | not_runnable, 422 tools.input.invalid, 403, 429, 503…).
     */
    run(id: string, input?: Record<string, unknown>, opts?: ToolRunOptions): Promise<ToolRunOutcome>;
    /** openvibe-sdk/jobs on the same origin and credentials: the gateway's /api/v1/jobs facade. */
    jobs: JobsClient;
    /** Domain history: what the WHOIS and RDAP tools saw of a domain over time (public registration facts only). */
    domains: {
        history(domain: string, opts?: { signal?: AbortSignal }): Promise<DomainHistory | null>;
        lists(opts?: { limit?: number; signal?: AbortSignal }): Promise<DomainLists>;
    };
}

interface ToolsClientOptions

export interface ToolsClientOptions {
    /** Default: the `tools` origin from the platform descriptor (https://openvibe.tools). */
    baseUrl?: string;
    service?: string;
    audience?: string;
    /** Registry reads send no token (default true); false sends the client's token. */
    anonymousReads?: boolean;
}

function createToolsClient

export declare function createToolsClient(client: OpenVibeClient, opts?: ToolsClientOptions): ToolsClient;

interface DomainFacts

A domain's public registration facts at one time (RDAP). Never contact details.

export interface DomainFacts {
    registrar: string | null;
    created: string | null;
    updated: string | null;
    expires: string | null;
    status: string[];
    nameservers: string[];
    dnssec: boolean | null;
}

interface DomainHistory

export interface DomainHistory {
    ok: true;
    domain: string;
    snapshots: Array<{ facts: DomainFacts; first_seen: string; last_seen: string; seen: number }>;
    changes: Array<{ at: string; changes: Array<{ field: keyof DomainFacts; before: unknown; after: unknown }> }>;
    lookups: number;
    first_seen: string | null;
}

interface DomainListed

export interface DomainListed { domain: string; lookups: number; registrar: string | null; expires: string | null }

interface DomainLists

export interface DomainLists { ok: true; most_looked_up: DomainListed[]; expiring_soon: DomainListed[]; min_lookups: number }