/** * Background tool-runs transport — the `/api/tool-runs*` surface. * * This is a SELF-CONTAINED api-client module (its own zod, not the shared * `schemas.ts`), so the tools feature owns these wire types end to end. The * `createApiClient` object wires three thin methods onto it (`submitToolRun`, * `getToolRun`, `listToolRuns`) since only it holds the `ApiConfig` (base URL + * auth token). * * The background surface detaches a run from its HTTP request: submit returns a * `run_id` immediately (202), then the caller POLLS the single-run GET until the * status is terminal (`succeeded | failed | lost | parked`). The list GET returns * the recent runs for one tool — id/status/timestamps only, never `result`/`error`. */ import { z } from 'zod'; import type { ApiConfig } from './http'; import type { StateSubject } from './schemas/states'; /** A run's lifecycle state. `lost` = the server restarted mid-run; the result is * unrecoverable. `parked` = the run's tool async-parked; its `result` is the park * answer (see {@link toolRunParkAnswer}). `running` is the only non-terminal state. */ export declare const toolRunStatus: z.ZodEnum<{ running: "running"; failed: "failed"; parked: "parked"; succeeded: "succeeded"; lost: "lost"; }>; /** `POST /api/tool-runs` → the handle for the detached run. */ export declare const toolRunSubmitResult: z.ZodObject<{ run_id: z.ZodString; }, z.core.$strip>; /** `GET /api/tool-runs/{run_id}` → the full record. `result` is arbitrary JSON: the * tool's own value on `succeeded`, the park answer ({@link toolRunParkAnswer}) on * `parked`. `error` is present only on `failed`. `resumed_interactions` is the parked * interaction ids the run resumed or took while it executed (`[]` when it resumed none). */ export declare const toolRunRecord: z.ZodObject<{ run_id: z.ZodString; tool_name: z.ZodString; status: z.ZodEnum<{ running: "running"; failed: "failed"; parked: "parked"; succeeded: "succeeded"; lost: "lost"; }>; started_at: z.ZodString; finished_at: z.ZodOptional; result: z.ZodOptional; error: z.ZodOptional; resumed_interactions: z.ZodOptional>; }, z.core.$strip>; /** One entry of `GET /api/tool-runs?tool_name=...` — id/status/timestamps only, * deliberately carrying NO `result`/`error` (the list is not secret-bearing). */ export declare const toolRunListItem: z.ZodObject<{ run_id: z.ZodString; tool_name: z.ZodString; status: z.ZodEnum<{ running: "running"; failed: "failed"; parked: "parked"; succeeded: "succeeded"; lost: "lost"; }>; started_at: z.ZodString; finished_at: z.ZodOptional; }, z.core.$strip>; export declare const toolRunList: z.ZodArray; started_at: z.ZodString; finished_at: z.ZodOptional; }, z.core.$strip>>; /** * The `result` a `parked` record carries — the SAME park answer the synchronous run-tool * door returns: either the caller-ask envelope `{asks: [...]}` (the tool asked its CALLER * and parked) or the suspension receipt (the run parked only USER asks, ids only). A poller * reads it to tell a caller-ask park from a user-only one, exactly as the sync door's caller does. */ export declare const toolRunParkAnswer: z.ZodUnion; to: z.ZodOptional>>; question: z.ZodOptional>; payload: z.ZodOptional>>; asked_by: z.ZodOptional>>; }, z.core.$strip>>; }, z.core.$strip>, z.ZodObject<{ interaction_id: z.ZodString; interaction_ids: z.ZodArray; caller_interaction_ids: z.ZodDefault>; }, z.core.$strip>]>; export type ToolRunStatus = z.infer; export type ToolRunParkAnswer = z.infer; export type ToolRunSubmitResult = z.infer; export type ToolRunRecord = z.infer; export type ToolRunListItem = z.infer; /** Body for `POST /api/tool-runs`. */ export interface SubmitToolRunArgs { readonly tool_name: string; readonly arguments?: Record; /** The addressed subject an async park of the detached run indexes under. Omitted * from the request body when unset. */ readonly subject?: StateSubject; } /** Submit a tool for detached background execution; resolves with its `run_id`. */ export declare function submitToolRun(config: ApiConfig, args: SubmitToolRunArgs, signal?: AbortSignal): Promise; /** Read one background run's current record (the poll target). */ export declare function getToolRun(config: ApiConfig, runId: string, signal?: AbortSignal): Promise; /** List the recent background runs for one tool (newest first). */ export declare function listToolRuns(config: ApiConfig, toolName: string, signal?: AbortSignal): Promise; /** Whether a run has reached a terminal state (polling stops here). */ export declare function isTerminalRunStatus(status: ToolRunStatus): boolean; //# sourceMappingURL=tool-runs.d.ts.map