import { v as Agent } from "./agent-tool-types-DSteYkkS.js"; import { S as WorkflowTrackingRow, _ as WorkflowPage, a as ApprovalEventPayload, b as WorkflowRejectedError, c as WaitForApprovalOptions, d as WorkflowCallbackType, f as WorkflowCompleteCallback, g as WorkflowInfo, h as WorkflowEventPayload, i as AgentWorkflowStep, l as WorkflowCallback, m as WorkflowEventCallback, o as DefaultProgress, p as WorkflowErrorCallback, r as AgentWorkflowParams, s as RunWorkflowOptions, t as AgentWorkflowEvent, v as WorkflowProgressCallback, x as WorkflowStatus, y as WorkflowQueryCriteria } from "./workflow-types-DHs0L0KP.js"; import { WorkflowEntrypoint } from "cloudflare:workers"; //#region src/workflows.d.ts /** * Base class for Workflows that need access to their originating Agent. * * @template AgentType - The Agent class type (for typed RPC access) * @template Params - User-defined params passed to the workflow (optional) * @template ProgressType - Type for progress reporting (defaults to DefaultProgress) * @template Env - Environment type (defaults to Cloudflare.Env) */ declare class AgentWorkflow< AgentType extends Agent = Agent, Params = unknown, ProgressType = DefaultProgress, Env extends Cloudflare.Env = Cloudflare.Env > extends WorkflowEntrypoint> { /** * The Agent stub - initialized before run() is called. * Use this.agent to access the Agent's RPC methods. */ private _agent; /** * Workflow instance ID */ private _workflowId; /** * Workflow binding name (for callbacks) */ private _workflowName; /** * Instance-level guard to prevent double initialization. * Used when a subclass calls super.run() after its own run() was wrapped. */ private __agentInitCalled; /** * Guard to prevent double error notification. * Set to true when reportError() is called explicitly, so the automatic * error catch in the run() wrapper doesn't send a duplicate notification. */ private _errorReported; constructor(ctx: ExecutionContext, env: Env); /** * Initialize the Agent stub from workflow params. * Called automatically before run() executes. */ private _initAgent; /** * Wrap WorkflowStep with durable Agent communication methods. * Methods added to the wrapped step are idempotent and won't repeat on retry. * * Note: We add methods directly to the step object to preserve instanceof checks * that Cloudflare's runtime may perform on the WorkflowStep class. */ private _wrapStep; /** * Get the Agent stub for RPC calls. * Provides typed access to the Agent's methods. * * @example * ```typescript * // Call any public method on the Agent * await this.agent.updateStatus('processing'); * const data = await this.agent.getData(); * ``` */ get agent(): DurableObjectStub; /** * Get the workflow instance ID */ get workflowId(): string; /** * Get the workflow binding name */ get workflowName(): string; /** * Automatically report an unhandled error to the Agent. * Skipped if reportError() was already called (prevents double notification). * Best-effort: notification failures are swallowed so the original error propagates. * * @param err - The caught error */ private _autoReportError; /** * Send a notification to the Agent via RPC. * * @param callback - Callback payload to send */ protected notifyAgent(callback: WorkflowCallback): Promise; /** * Report progress to the Agent with typed progress data. * Triggers onWorkflowProgress() on the Agent. * * @param progress - Typed progress data * * @example * ```typescript * // Using default progress type * await this.reportProgress({ step: 'fetch', status: 'running' }); * await this.reportProgress({ step: 'fetch', status: 'complete', percent: 0.5 }); * * // With custom progress type * await this.reportProgress({ stage: 'extract', recordsProcessed: 100 }); * ``` */ protected reportProgress(progress: ProgressType): Promise; /** * Broadcast a message to all connected WebSocket clients via the Agent. * This is non-durable and may repeat on workflow retry. * * @param message - Message to broadcast (will be JSON-stringified) */ protected broadcastToClients(message: unknown): void; /** * Wait for approval from the Agent. * Handles rejection by reporting error (durably) and throwing WorkflowRejectedError. * * @param step - AgentWorkflowStep object * @param options - Wait options (timeout, eventType, stepName) * @returns Approval payload (throws WorkflowRejectedError if rejected) * * @example * ```typescript * const approval = await this.waitForApproval(step, { timeout: '7 days' }); * // approval contains the payload from approveWorkflow() * ``` */ protected waitForApproval( step: AgentWorkflowStep, options?: WaitForApprovalOptions ): Promise; } //#endregion export { AgentWorkflow, type AgentWorkflowEvent, type AgentWorkflowStep, type ApprovalEventPayload, type DefaultProgress, type RunWorkflowOptions, type WaitForApprovalOptions, type WorkflowCallback, type WorkflowCallbackType, type WorkflowCompleteCallback, type WorkflowErrorCallback, type WorkflowEventCallback, type WorkflowEventPayload, type WorkflowInfo, type WorkflowPage, type WorkflowProgressCallback, type WorkflowQueryCriteria, WorkflowRejectedError, type WorkflowStatus, type WorkflowTrackingRow }; //# sourceMappingURL=workflows.d.ts.map