import type { TokenUsage, WorkflowContinuationResult, WorkflowRunLimits } from "@automatalabs/shared-types"; import type { WorkflowRunResult, WorkflowRunStatus } from "@automatalabs/workflows"; import { z } from "zod"; declare const pendingPermissionSchema: z.ZodObject<{ version: z.ZodLiteral<1>; permissionId: z.ZodString; runId: z.ZodString; callIndex: z.ZodNumber; backendId: z.ZodString; label: z.ZodOptional; requestedAt: z.ZodString; request: z.ZodObject<{ toolCall: z.ZodRecord; options: z.ZodArray>>; }, z.core.$strip>>; _meta: z.ZodOptional>>; }, z.core.$strip>; requestTruncated: z.ZodBoolean; requestRedacted: z.ZodBoolean; }, z.core.$strip>; declare const permissionAcknowledgementSchema: z.ZodObject<{ permissionId: z.ZodString; runId: z.ZodString; callIndex: z.ZodNumber; outcome: z.ZodDiscriminatedUnion<[z.ZodObject<{ outcome: z.ZodLiteral<"cancelled">; }, z.core.$strict>, z.ZodObject<{ outcome: z.ZodLiteral<"selected">; optionId: z.ZodString; }, z.core.$strict>], "outcome">; respondedAt: z.ZodString; }, z.core.$strip>; declare const scriptSourceSchema: z.ZodEnum<{ path: "path"; inline: "inline"; stored: "stored"; }>; declare const setupSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{ state: z.ZodLiteral<"preparing">; }, z.core.$strict>, z.ZodObject<{ state: z.ZodLiteral<"input-required">; request: z.ZodObject<{ id: z.ZodString; kind: z.ZodLiteral<"backend-approval">; title: z.ZodString; message: z.ZodString; requestedSchema: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord; required: z.ZodArray; additionalProperties: z.ZodOptional>; }, z.core.$strip>; }, z.core.$strict>; }, z.core.$strict>], "state">; declare const stopControlSchema: z.ZodObject<{ state: z.ZodLiteral<"pending">; operationId: z.ZodString; requestedAt: z.ZodString; owner: z.ZodOptional; version: z.ZodOptional; lameDuck: z.ZodOptional; activeRuns: z.ZodOptional; controlProtocol: z.ZodOptional>; }, z.core.$strip>>; }, z.core.$strip>; /** * Keep the SDK-facing output rooted in an object schema. Exact branch constraints are * published as JSON Schema metadata and enforced by the matching runtime refinements. */ export declare const workflowToolOutputShape: z.ZodObject<{ scriptSource: z.ZodOptional>; scriptUri: z.ZodOptional; scriptPath: z.ZodOptional; resultUri: z.ZodOptional; eventsUri: z.ZodOptional; workflowName: z.ZodOptional; phases: z.ZodOptional>; currentPhase: z.ZodOptional; reason: z.ZodOptional; errorCode: z.ZodOptional; latestActivity: z.ZodOptional; timestamp: z.ZodString; cursor: z.ZodNumber; turnCount: z.ZodNumber; observedEvents: z.ZodNumber; latestText: z.ZodOptional; lastToolName: z.ZodOptional; tokensObserved: z.ZodOptional; relevance: z.ZodEnum<{ terminal: "terminal"; current: "current"; }>; }, z.core.$strip>>>; calls: z.ZodOptional; label: z.ZodOptional; phase: z.ZodOptional; model: z.ZodOptional; backendId: z.ZodOptional; errorCode: z.ZodOptional; status: z.ZodOptional>; resultPreview: z.ZodString; resultRedacted: z.ZodBoolean; resultTruncated: z.ZodBoolean; }, z.core.$strip>>>; filter: z.ZodOptional; }, z.core.$strip>>; truncation: z.ZodOptional; logs: z.ZodObject<{ total: z.ZodNumber; returned: z.ZodNumber; shortened: z.ZodNumber; redacted: z.ZodNumber; }, z.core.$strip>; calls: z.ZodObject<{ total: z.ZodNumber; returned: z.ZodNumber; matched: z.ZodNumber; shortenedResults: z.ZodNumber; redactedResults: z.ZodNumber; }, z.core.$strip>; }, z.core.$strip>>; outcome: z.ZodOptional; eventsUri: z.ZodOptional; limits: z.ZodOptional>; result: z.ZodOptional; tokenUsage: z.ZodOptional; cacheWrite: z.ZodOptional; }, z.core.$strip>>; logs: z.ZodOptional>; logTail: z.ZodOptional; totalLines: z.ZodNumber; omittedLines: z.ZodNumber; truncatedLines: z.ZodNumber; redactedLines: z.ZodNumber; }, z.core.$strip>>; authContext: z.ZodOptional; methods: z.ZodArray; name: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; checkpointContext: z.ZodOptional; choices: z.ZodOptional>; timeoutMs: z.ZodOptional; }, z.core.$strict>>; fallbacks: z.ZodOptional; requestedSpec: z.ZodString; resolvedModel: z.ZodOptional; backendId: z.ZodOptional; kind: z.ZodEnum<{ model: "model"; modifier: "modifier"; continuation: "continuation"; }>; message: z.ZodString; continuation: z.ZodOptional; method: z.ZodEnum<{ resume: "resume"; load: "load"; }>; }, z.core.$strip>, z.ZodObject<{ outcome: z.ZodLiteral<"skipped">; reason: z.ZodEnum<{ "hash-mismatch": "hash-mismatch"; "inputs-mismatch": "inputs-mismatch"; "worktree-isolated": "worktree-isolated"; "cwd-mismatch": "cwd-mismatch"; "cwd-missing": "cwd-missing"; "backend-mismatch": "backend-mismatch"; "capability-missing": "capability-missing"; "reattach-failed": "reattach-failed"; "runner-declined": "runner-declined"; }>; }, z.core.$strip>], "outcome">>; }, z.core.$strip>>>; checkpointsTaken: z.ZodOptional; decision: z.ZodUnknown; source: z.ZodEnum<{ live: "live"; "journal-replay": "journal-replay"; injected: "injected"; }>; }, z.core.$strict>>>; runId: z.ZodString; status: z.ZodEnum<{ failed: "failed"; paused: "paused"; completed: "completed"; aborted: "aborted"; }>; }, z.core.$strict>>; stopped: z.ZodOptional; alreadyTerminal: z.ZodOptional; control: z.ZodOptional; operationId: z.ZodString; requestedAt: z.ZodString; owner: z.ZodOptional; version: z.ZodOptional; lameDuck: z.ZodOptional; activeRuns: z.ZodOptional; controlProtocol: z.ZodOptional>; }, z.core.$strip>>; }, z.core.$strip>>; pauseRequested: z.ZodOptional; paused: z.ZodOptional; pendingPermissions: z.ZodOptional; permissionId: z.ZodString; runId: z.ZodString; callIndex: z.ZodNumber; backendId: z.ZodString; label: z.ZodOptional; requestedAt: z.ZodString; request: z.ZodObject<{ toolCall: z.ZodRecord; options: z.ZodArray>>; }, z.core.$strip>>; _meta: z.ZodOptional>>; }, z.core.$strip>; requestTruncated: z.ZodBoolean; requestRedacted: z.ZodBoolean; }, z.core.$strip>>>; permissionResponse: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ outcome: z.ZodLiteral<"selected">; optionId: z.ZodString; }, z.core.$strict>], "outcome">; respondedAt: z.ZodString; }, z.core.$strip>>; mimeType: z.ZodOptional>; encoding: z.ZodOptional>; totalBytes: z.ZodOptional; offset: z.ZodOptional; endOffset: z.ZodOptional; hasMore: z.ZodOptional; chunk: z.ZodOptional; limits: z.ZodOptional>; result: z.ZodOptional; tokenUsage: z.ZodOptional; cacheWrite: z.ZodOptional; }, z.core.$strip>>; logs: z.ZodOptional>; logTail: z.ZodOptional; totalLines: z.ZodNumber; omittedLines: z.ZodNumber; truncatedLines: z.ZodNumber; redactedLines: z.ZodNumber; }, z.core.$strip>>; authContext: z.ZodOptional; methods: z.ZodArray; name: z.ZodOptional; }, z.core.$strip>>; }, z.core.$strip>>; checkpointContext: z.ZodOptional; choices: z.ZodOptional>; timeoutMs: z.ZodOptional; }, z.core.$strict>>; fallbacks: z.ZodOptional; requestedSpec: z.ZodString; resolvedModel: z.ZodOptional; backendId: z.ZodOptional; kind: z.ZodEnum<{ model: "model"; modifier: "modifier"; continuation: "continuation"; }>; message: z.ZodString; continuation: z.ZodOptional; method: z.ZodEnum<{ resume: "resume"; load: "load"; }>; }, z.core.$strip>, z.ZodObject<{ outcome: z.ZodLiteral<"skipped">; reason: z.ZodEnum<{ "hash-mismatch": "hash-mismatch"; "inputs-mismatch": "inputs-mismatch"; "worktree-isolated": "worktree-isolated"; "cwd-mismatch": "cwd-mismatch"; "cwd-missing": "cwd-missing"; "backend-mismatch": "backend-mismatch"; "capability-missing": "capability-missing"; "reattach-failed": "reattach-failed"; "runner-declined": "runner-declined"; }>; }, z.core.$strip>], "outcome">>; }, z.core.$strip>>>; checkpointsTaken: z.ZodOptional; decision: z.ZodUnknown; source: z.ZodEnum<{ live: "live"; "journal-replay": "journal-replay"; injected: "injected"; }>; }, z.core.$strict>>>; action: z.ZodOptional>; ok: z.ZodOptional; accepted: z.ZodOptional>; continuation: z.ZodOptional>; resolvedCheckpoints: z.ZodOptional; decision: z.ZodUnknown; ignored: z.ZodOptional; }, z.core.$strict>>>; }, z.core.$strict>>; setupId: z.ZodOptional; setup: z.ZodOptional; }, z.core.$strict>, z.ZodObject<{ state: z.ZodLiteral<"input-required">; request: z.ZodObject<{ id: z.ZodString; kind: z.ZodLiteral<"backend-approval">; title: z.ZodString; message: z.ZodString; requestedSchema: z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord; required: z.ZodArray; additionalProperties: z.ZodOptional>; }, z.core.$strip>; }, z.core.$strict>; }, z.core.$strict>], "state">>; harnessOptions: z.ZodOptional>; defaultModeId: z.ZodOptional; model: z.ZodOptional; probed: z.ZodBoolean; error: z.ZodOptional; modes: z.ZodOptional; _meta: z.ZodOptional>>; }, z.core.$strip>>; _meta: z.ZodOptional>>; }, z.core.$strip>>>; options: z.ZodArray; omittedOptions: z.ZodNumber; }, z.core.$strip>>>; omittedHarnesses: z.ZodOptional; models: z.ZodOptional; hasModelOption: z.ZodBoolean; filter: z.ZodOptional; total: z.ZodOptional; groups: z.ZodOptional>; matches: z.ZodArray; matchCount: z.ZodNumber; omittedMatches: z.ZodNumber; }, z.core.$strip>>>; authoringSummary: z.ZodOptional>; omittedHarnesses: z.ZodNumber; }, z.core.$strict>>; runId: z.ZodOptional; status: z.ZodOptional>; }, z.core.$strict>; /** * Output shape for the app-only `workflow-events` tool: the same document served by the * `workflow://runs/{runId}/events` resource (cursor-paged, redacted, append-only records). */ export declare const workflowEventsOutputShape: { readonly schemaVersion: z.ZodLiteral<1>; readonly runId: z.ZodString; readonly streamId: z.ZodString; readonly workflowName: z.ZodString; readonly status: z.ZodEnum<{ failed: "failed"; running: "running"; pending: "pending"; paused: "paused"; completed: "completed"; aborted: "aborted"; }>; readonly finalized: z.ZodBoolean; readonly after: z.ZodNumber; readonly cursor: z.ZodNumber; readonly endCursor: z.ZodNumber; readonly hasMore: z.ZodBoolean; readonly events: z.ZodArray; }; export type WorkflowScriptSource = z.infer; /** One bounded, durable activity summary per logical agent call. */ export interface WorkflowRunLatestActivity { scope: string; callIndex: number; executionStartSeq: number; label: string; phase?: string; timestamp: string; /** Sequence/cursor of the source agentProgress record in the linked events stream. */ cursor: number; turnCount: number; observedEvents: number; latestText?: string; lastToolName?: string; tokensObserved?: number; /** Whether this execution is still current or has reached call/run terminal relevance. */ relevance: "current" | "terminal"; } export interface WorkflowScriptResourceFields { scriptUri: string; resultUri?: string; eventsUri?: string; } export interface WorkflowExecutionScriptResourceFields { scriptSource: WorkflowScriptSource; /** `file://` URI of the run's editable script: the store copy of an inline script, or the caller's scriptPath. */ scriptUri: string; /** Absolute path behind scriptUri. */ scriptPath?: string; eventsUri: string; } export interface WorkflowExecutionOutcome { runId: string; status: Exclude; scriptUri: string; resultUri?: string; eventsUri?: string; limits?: WorkflowRunLimits; result?: T; tokenUsage?: WorkflowRunResult["tokenUsage"]; logs?: string[]; logTail?: WorkflowRunResult["logTail"]; authContext?: WorkflowRunResult["authContext"]; checkpointContext?: WorkflowRunResult["checkpointContext"]; fallbacks?: WorkflowRunResult["fallbacks"]; checkpointsTaken?: WorkflowRunResult["checkpointsTaken"]; } interface WorkflowOperationAcceptedBase extends WorkflowExecutionScriptResourceFields { accepted: true; runId: string; status: WorkflowRunStatus["status"]; limits: WorkflowRunLimits; setup?: z.infer; } export type WorkflowOperationAccepted = WorkflowOperationAcceptedBase & ({ action: "run"; continuation?: never; } | { action: "resume"; continuation: WorkflowContinuationResult; }); export interface WorkflowSetupResponseResult extends WorkflowScriptResourceFields { action: "setup-response"; runId: string; setupId: string; status: WorkflowRunStatus["status"]; setup?: z.infer; } export interface WorkflowRunObservation extends WorkflowRunStatus, WorkflowScriptResourceFields { latestActivity?: WorkflowRunLatestActivity[]; pendingPermissions?: z.infer[]; setup?: z.infer; permissionResponse?: z.infer; } export interface WorkflowStatusToolResult extends WorkflowRunObservation { /** Cumulative usage observed for live calls in this execution; absent before any is known. */ tokenUsage?: TokenUsage; pendingPermissions?: z.infer[]; setup?: z.infer; /** Present exactly when status is paused/completed/failed/aborted. */ outcome?: WorkflowExecutionOutcome; } export type WorkflowInspectionToolResult = WorkflowRunObservation; export interface WorkflowResultRetrieval { action: "result"; runId: string; status: "completed"; resultUri: string; eventsUri?: string; mimeType: "application/json"; encoding: "utf-8"; totalBytes: number; offset: number; endOffset: number; hasMore: boolean; chunk: string; } export interface WorkflowConfigToolResult { action: "config"; ok: boolean; harnessOptions: Array>; omittedHarnesses: number; models: Array>; authoringSummary: { harnesses: Array>; omittedHarnesses: number; }; } export interface WorkflowPermissionResponseResult extends WorkflowRunStatus, WorkflowScriptResourceFields { latestActivity?: WorkflowRunLatestActivity[]; pendingPermissions?: z.infer[]; permissionResponse: z.infer; } export interface WorkflowStopResult extends WorkflowRunStatus, WorkflowScriptResourceFields { latestActivity?: WorkflowRunLatestActivity[]; status: "completed" | "failed" | "aborted"; stopped: boolean; alreadyTerminal: boolean; } export interface WorkflowStopPendingResult extends WorkflowRunStatus, WorkflowScriptResourceFields { latestActivity?: WorkflowRunLatestActivity[]; status: "pending" | "running"; stopped: false; alreadyTerminal: false; control: z.infer; } /** * Pause acknowledgement. `pauseRequested` says the request reached the live execution owner in * this call; `paused` says the run is durably paused now. A pending request (`running`) settles * once every executing agent call has finished; observe it with status. */ export interface WorkflowPauseResult extends WorkflowRunStatus, WorkflowScriptResourceFields { latestActivity?: WorkflowRunLatestActivity[]; status: "running" | "paused" | "completed" | "failed" | "aborted"; pauseRequested: boolean; paused: boolean; } export type WorkflowToolResult = WorkflowResultRetrieval | WorkflowConfigToolResult | WorkflowOperationAccepted | WorkflowSetupResponseResult | WorkflowStatusToolResult | WorkflowPermissionResponseResult | WorkflowStopResult | WorkflowStopPendingResult | WorkflowPauseResult; export declare function toWorkflowExecutionOutcome(run: WorkflowRunResult, resources: WorkflowScriptResourceFields): WorkflowExecutionOutcome; export {}; //# sourceMappingURL=workflow-tool-output.d.ts.map