import { UpdateDefinition } from "@temporalio/client"; import { getExternalWorkflowHandle as getExternalAgentHandle, workflowInfo as agentInfo, sleep, condition, uuid4, ApplicationFailure, allHandlersFinished as allEventsFinished, Workflow } from "@temporalio/workflow"; import { UpdateHandlerOptions } from "@temporalio/workflow/lib/interfaces"; import { QueryDefinition } from "@temporalio/client"; import { customLog, childExecute, childStart, step } from "./workflow"; /** * Define an event for an Agent. * * A definition is used to register an event listener in the Agent via onEvent and to send an event to an Agent using sendAgentEvent. * A definition can be reused in multiple Agents. */ export declare function defineEvent(name: Name): UpdateDefinition; /** * Set a listener for an event in an Agent. * * If this is called multiple times for a given event the last handler will overwrite any previous calls. * * @param def an event definition as returned by {@link defineEvent}. * @param handler a compatible handler function for the given definition or `undefined` to unset the handler. * @param options an optional `description` of the handler and an optional update `validator` function. */ export declare function onEvent>(def: T, handler: (args: Args[0]) => Promise | Ret, options?: UpdateHandlerOptions): void; export type AgentEvent = { name: string; input?: { [key: string]: any; }; }; export type SendAgentEvent = { event: AgentEvent; agent?: { agentId: string; runId?: string; }; waitForCompletion?: boolean; }; /** * Define a state method for an agent. * * A definition is used to register a handler in the Agent via {@link setHandler} and to query a Agent using a {@link AgentHandle}. * A definition can be reused in multiple Agents. */ export declare function defineState(name: Name): QueryDefinition; /** * Set a handler function for an Agent state. * * If this function is called multiple times for a given state name the last handler will overwrite any previous calls. * * @param def a state definition as returned by {@link defineState}. * @param handler a compatible handler function for the given definition or `undefined` to unset the handler. * @param options an optional `description` of the handler and an optional update `validator` function. */ export declare function handleState>(def: T, handler: (args: Args[0]) => Promise | Ret, options?: UpdateHandlerOptions): void; export declare function shouldContinueAsNew(): boolean; /** * Resets the agent to start fresh when its history becomes too large. * This ensures all pending events are completed before the reset, * preventing any data loss or incomplete operations. * * Call this when your agent will be running for a long time/receving lots of events (Above 2000 events). * * @param args - Arguments to pass to the agent when it restarts. Typically the same arguments that were passed to the agent when it was started. */ export declare function agentContinueAsNew(...args: Parameters): Promise; export { customLog as log, getExternalAgentHandle, agentInfo, sleep, condition, uuid4 as uuid, childStart, childExecute, step, ApplicationFailure as AgentError, allEventsFinished, };