import { A2AModule } from '../modules/a2a/a2a.module.js'; import { ThreadObject } from '../types/memory.js'; import { SlotFillInitiator } from '../types/schedule.js'; import { MemoryModule } from '../modules/memory/memory.module.js'; import { StreamEvent } from '../types/stream.js'; import { ModelModule } from '../modules/models/model.module.js'; import { ToolCallingService } from './tool-calling.service.js'; import { UserWorkflowService } from './user-workflow.service.js'; import { WorkflowVariableResolver } from './workflow-variable-resolver.service.js'; import '@a2a-js/sdk'; import '../types/connector.js'; import '../modules/memory/base.memory.js'; import '../types/document.js'; import '../types/list.js'; import '../modules/models/base.model.js'; import '../modules/mcp/mcp.module.js'; import '../types/mcp.js'; import '@modelcontextprotocol/sdk/client/sse.js'; import '@modelcontextprotocol/sdk/client/stdio.js'; import '@modelcontextprotocol/sdk/client/streamableHttp.js'; type WorkflowExecutionResult = { content: string; threadId?: string; }; declare class WorkflowExecutionService { private userWorkflowService; private workflowVariableResolver; private memoryModule; private workflowTaskRunner; private workflowResponseComposer; private workflowVariableExtraction; constructor(userWorkflowService: UserWorkflowService, workflowVariableResolver: WorkflowVariableResolver, modelModule: ModelModule, memoryModule: MemoryModule, toolCallingService: ToolCallingService, a2aModule?: A2AModule); executeWorkflow(workflowId: string, executionVariables?: Record, signal?: AbortSignal): Promise; executeWorkflowStream(workflowId: string, executionVariables?: Record, signal?: AbortSignal): AsyncGenerator; /** * Runs an intent-mapped workflow and streams its progress into the chat * stream. Unlike {@link executeWorkflowStream}, this does NOT create or * persist a workflow thread, document, or lastRunAt bookkeeping — the * chat thread (persisted by the intent fulfillment path) is the only * artifact. Accepts a user workflow id or a template id, like slot * bindings. Variable values are extracted from the subquery via one LLM * call and merged over the workflow's stored variableValues. Setup * failures (unknown id, no definition) throw before the first yield so * callers can fall back; task failures throw after streaming. */ executeIntentWorkflowStream(workflowId: string, chatThread: ThreadObject, subquery: string, signal?: AbortSignal): AsyncGenerator; /** * Runs a structured workflow definition (tasks → response blocks) against a * thread context, streaming progress events. Never throws — any failure is * captured and returned as `executionError` so callers can decide how to * persist the (partial) result. */ private renderStructuredDefinition; /** * Generates AI advice for a document by running the bound advice workflow * over the document's rendered content, then caches the result on * `document.advice`. Mirrors {@link fillDocumentSlotStream}: ephemeral * non-persisted thread — the advice field is the only artifact. */ generateDocumentAdviceStream(documentId: string, options: { workflowId: string; executionVariables?: Record; }, signal?: AbortSignal): AsyncGenerator; /** * Runs a workflow **template** with caller-supplied variables and streams the * rendered result. Nothing is persisted — no thread, no document — so the * caller's screen is the only artifact. * * This is {@link generateDocumentAdviceStream} without the document. Dashboards * show a workflow's output against a selection (a period, a group of outlets) * that no document represents, and {@link executeWorkflowStream} cannot serve * them: it resolves user workflows only and it persists a chat thread per run. * * Templates only, deliberately: the screens that need this have no per-user * workflow copy — everyone shares one catalog entry. A user workflow id is not * accepted here, so there is no ownership question to answer. * * Variables resolve with document-fill semantics — there is no creation step, so * every supplied value applies regardless of its declared `resolveAt`, and values * the caller omits fall back to the template's stored ones. */ runTemplateStream(templateId: string, options: { userId: string; executionVariables?: Record; }, signal?: AbortSignal): AsyncGenerator; /** * Non-streaming variant of {@link fillDocumentSlotStream}. */ fillDocumentSlot(documentId: string, slotId: string, options?: { workflowId?: string; executionVariables?: Record; initiator?: SlotFillInitiator; }, signal?: AbortSignal): Promise<{ documentId: string; slotId: string; content: string; }>; /** * Fills a single document slot by running its bound workflow (or an * explicitly provided one). Unlike {@link executeWorkflowStream}, this does * NOT create or persist a thread — the document slot is the only artifact. * Progress is streamed live but not persisted anywhere. */ fillDocumentSlotStream(documentId: string, slotId: string, options?: { workflowId?: string; executionVariables?: Record; /** Who initiated this fill; logged so unexpected fills are traceable. */ initiator?: SlotFillInitiator; }, signal?: AbortSignal): AsyncGenerator; /** * Atomically patches a single slot via the memory layer. Must NOT rebuild * the whole slots array from `document` (a snapshot taken when the fill * started): concurrent fills of other slots would clobber each other's * results. `updateDocumentSlot` targets only the matched slot and bumps * `version`/`updatedAt` in the same write. */ private updateSlot; /** * Resolves a slot binding's `workflowId` to a runnable workflow, accepting * either a user workflow or a workflow template. User workflows take * precedence; falls back to a template with the same id. */ private getFillableWorkflow; private createWorkflowThread; } export { WorkflowExecutionService };