import type { PlatformClient } from "./client"; import type { WorkflowConfig, TaskDefinition, EdgeDefinition, Edge, ImportWeb3WalletRequest, SignFeedbackAuthResponse, Web3Wallet } from "./types"; import type { TriggerConfig } from "./triggers-api"; import { Workflow } from "./workflow"; /** * API for managing workflows on the OpenServ platform. * * @example * ```typescript * const client = new PlatformClient({ apiKey: 'your-key' }); * * // Create a workflow * const workflow = await client.workflows.create({ * name: 'My Workflow', * goal: 'Process data automatically', * agentIds: [123, 456] * }); * * // List all workflows * const workflows = await client.workflows.list(); * * // Get a specific workflow * const workflow = await client.workflows.get({ id: 789 }); * ``` */ export declare class WorkflowsAPI { private client; constructor(client: PlatformClient); /** * Create a new workflow. * * Can create an empty workflow or a fully configured one with triggers, tasks, and edges. * * @param config - Workflow configuration * @param config.name - Name of the workflow (also used as the agent name in ERC-8004) * @param config.goal - Goal/description of what the workflow does * @param config.agentIds - Array of agent IDs to include in the workflow * @param config.triggers - Optional array of trigger definitions * @param config.tasks - Optional array of task definitions * @param config.edges - Optional array of edge definitions connecting nodes * @returns The created Workflow object * * @example * ```typescript * // Simple workflow * const workflow = await client.workflows.create({ * name: 'Data Pipeline', * goal: 'Process incoming data', * agentIds: [123] * }); * * // Workflow with tasks * const workflow = await client.workflows.create({ * name: 'Data Pipeline', * goal: 'Process incoming data', * agentIds: [123], * tasks: [{ name: 'process', agentId: 123, description: 'Process data' }] * }); * ``` */ create(config: WorkflowConfig): Promise; /** * Get a workflow by ID. * @param params - Parameters object * @param params.id - The workflow ID * @returns The Workflow object with full data including triggers, tasks, and edges */ get(params: { id: number | string; }): Promise; /** * List all workflows owned by the authenticated user. * @returns Array of Workflow objects */ list(): Promise; /** * Update workflow metadata. * @param params - Parameters object * @param params.id - The workflow ID to update * @param params.name - New name (optional, also used as the agent name in ERC-8004) * @param params.goal - New goal (optional) * @returns The updated Workflow object */ update(params: { id: number | string; name?: string; goal?: string; }): Promise; /** * Delete a workflow. * @param params - Parameters object * @param params.id - The workflow ID to delete */ delete(params: { id: number | string; }): Promise; /** * Set a workflow to running state. * * This activates the workflow so it can process triggers and execute tasks. * * @param params - Parameters object * @param params.id - The workflow ID */ setRunning(params: { id: number | string; }): Promise; /** * Connect edges in the workflow graph. * @param params - Parameters object * @param params.id - The workflow ID * @param params.edges - Array of edges to add */ connect(params: { id: number | string; edges: Edge[]; }): Promise; /** * Add an agent to an existing workflow's workspace. * * This is required before assigning tasks to agents that aren't yet * members of the workspace. Called automatically by sync() when tasks * reference agents not already in the workspace. * * @param params - Parameters object * @param params.id - The workflow ID * @param params.agentId - The agent ID to add * * @example * ```typescript * // Add an agent to a workspace so it can be assigned tasks * await client.workflows.addAgent({ id: workflowId, agentId: 456 }); * ``` */ addAgent(params: { id: number | string; agentId: number; }): Promise; /** * Sync workflow with declarative configuration. * * This allows updating triggers, tasks, and edges in a single call. * This is the recommended approach for creating and updating workflows. * * @param params - Parameters object * @param params.id - The workflow ID * @param params.triggers - Array of trigger definitions (optional) * @param params.tasks - Array of task definitions (optional) * @param params.edges - Array of edge definitions (optional) */ sync(params: { id: number | string; triggers?: TriggerConfig[]; tasks?: TaskDefinition[]; edges?: EdgeDefinition[]; }): Promise; private syncInternal; private getIntegrationIdentifier; private getTriggerName; private resolveEdgeRef; private resolveNodeId; /** * Get the web3 wallet associated with a workspace. * * @param params - Parameters * @param params.id - The workflow (workspace) ID * @returns The web3 wallet details * * @example * ```typescript * const wallet = await client.workflows.getWallet({ id: 123 }); * console.log(wallet.address, wallet.deployed, wallet.erc8004AgentId); * ``` */ getWallet(params: { id: number; }): Promise; /** * Generate a new web3 wallet for a workspace. * * Creates a fresh wallet with a server-generated private key. The wallet * is stored securely on the platform and used for ERC-8004 operations. * A workspace can only have one web3 wallet. * * @param params - Parameters * @param params.id - The workflow (workspace) ID * @returns The generated web3 wallet * @throws Error if the workspace already has a web3 wallet * * @example * ```typescript * const wallet = await client.workflows.generateWallet({ id: 123 }); * console.log('Wallet address:', wallet.address); * ``` */ generateWallet(params: { id: number; }): Promise; /** * Import an existing web3 wallet into a workspace. * * Use this to associate a pre-existing wallet (e.g., one that already has * an ERC-8004 registration) with a workspace. * A workspace can only have one web3 wallet. * * @param params - Import parameters * @param params.id - The workflow (workspace) ID * @param params.address - Wallet address * @param params.network - Network name (e.g., "base") * @param params.chainId - Chain ID (e.g., 8453) * @param params.privateKey - Wallet private key * @returns The imported web3 wallet * @throws Error if the workspace already has a web3 wallet * * @example * ```typescript * const wallet = await client.workflows.importWallet({ * id: 123, * address: '0x...', * network: 'base', * chainId: 8453, * privateKey: '0x...', * }); * ``` */ importWallet(params: ImportWeb3WalletRequest & { id: number; }): Promise; /** * Delete the web3 wallet associated with a workspace. * * This removes the wallet record from the platform. Note that the on-chain * ERC-8004 registration is not affected -- this only removes the platform's * association. * * @param params - Parameters * @param params.id - The workflow (workspace) ID * * @example * ```typescript * await client.workflows.deleteWallet({ id: 123 }); * ``` */ deleteWallet(params: { id: number; }): Promise; /** * Sign a feedback auth message for a buyer address. * * This is used for the ERC-8004 reputation system. The workspace's web3 wallet * signs an auth message that allows a buyer to submit feedback/reputation * for the agent on-chain. * * @param params - Parameters * @param params.id - The workflow (workspace) ID * @param params.buyerAddress - The buyer's wallet address to authorize * @returns Object containing the signed feedback auth * * @example * ```typescript * const { signature } = await client.workflows.signFeedbackAuth({ * id: 123, * buyerAddress: '0xBuyer...', * }); * ``` */ signFeedbackAuth(params: { id: number; buyerAddress: string; }): Promise; } //# sourceMappingURL=workflows-api.d.ts.map