/** * Host-neutral execution seam for Saved Workflow IM commands. * * This module deliberately returns a notification payload instead of sending * it. Persistence/launch completion is therefore never reclassified as a * business failure merely because the Lark reply failed afterwards. */ import type { BotConfig } from '../../bot-registry.js'; import type { RunChatBinding } from '../../workflows/v3/grill-state.js'; import { instantiatePublishedSavedWorkflow, listVisibleSavedWorkflows, loadVisibleSavedWorkflow, resolveOwnedTerminalRunDir, saveTerminalRunAsWorkflow, type SavedWorkflowActorContext } from '../../workflows/v3/library-service.js'; import { readV3RunChatBinding, requestV3RunCancel } from '../../workflows/v3/daemon-run.js'; import type { V3SavedWorkflowCommand } from './v3-saved-workflow-command.js'; export type ExecutableV3SavedWorkflowCommand = Exclude; export interface V3SavedWorkflowMessageTargetsInput { /** Existing daemon routing anchor; it may be an oc_ chat id in chat scope. */ anchor: string; /** Real thread/fold-back root supplied by the event dispatcher, when any. */ replyRootId?: string; /** Stable inbound message id. */ messageId: string; } export interface V3SavedWorkflowMessageTargets { /** Where every user-visible reply for this invocation must land. */ replyAnchor: string; /** Binding frozen into run.json. Always a message id, never the chat id. */ runRootMessageId: string; /** Stable id used by quota deduplication. */ quotaMessageId: string; } export declare function resolveV3SavedWorkflowMessageTargets(input: V3SavedWorkflowMessageTargetsInput): V3SavedWorkflowMessageTargets; export type V3SavedWorkflowPolicyResult = { ok: true; } | { ok: false; reason: 'global_requires_operate' | 'quota_denied'; }; /** * One authorization seam shared by all Saved Workflow verbs. Read commands * consume quota too, so a command can never accidentally become a free CLI * path merely by moving code between read/write branches. Cancellation is the * deliberate exception: it only reduces already-authorized work and must stay * available after the run-launching message exhausts a user's last quota. */ export declare function authorizeV3SavedWorkflowInvocation(command: ExecutableV3SavedWorkflowCommand, deps: { canPublishGlobal(): boolean; consumeMessageQuotaOnce(): Promise; }): Promise; export interface V3SavedWorkflowExecutionInput { command: ExecutableV3SavedWorkflowCommand; dataDir: string; baseDir: string; context: SavedWorkflowActorContext; /** Host-authorized operate permission for run-level mutations. Ownership is * checked independently against the immutable run binding. */ operatorCanOperate?: boolean; } export interface V3SavedWorkflowExecutionDeps { listVisible: typeof listVisibleSavedWorkflows; loadVisible: typeof loadVisibleSavedWorkflow; resolveOwnedRun: typeof resolveOwnedTerminalRunDir; saveRun: typeof saveTerminalRunAsWorkflow; instantiate: typeof instantiatePublishedSavedWorkflow; loadBots(): BotConfig[]; persistStartIntent(runId: string, runDir: string): void; driveDetached(runId: string): void; readRunBinding(runDir: string): RunChatBinding | undefined; requestCancel: typeof requestV3RunCancel; cancelAndDrive(runId: string, cancelRequestId: string): void; } export type V3SavedWorkflowExecutionEffect = 'read_completed' | 'save_committed' | 'run_started' | 'run_materialized_not_started' | 'cancel_requested' | 'cancel_terminal' | 'failed'; export interface V3SavedWorkflowExecutionResult { effect: V3SavedWorkflowExecutionEffect; message: string; } /** Best-effort transport boundary kept outside the business execution try/catch. */ export declare function deliverV3SavedWorkflowNotification(result: V3SavedWorkflowExecutionResult, send: (message: string) => Promise, onError: (error: unknown, effect: V3SavedWorkflowExecutionEffect) => void): Promise; export declare function executeV3SavedWorkflowCommand(input: V3SavedWorkflowExecutionInput, deps: V3SavedWorkflowExecutionDeps): Promise; export declare const defaultV3SavedWorkflowExecutionServices: { listVisible: typeof listVisibleSavedWorkflows; loadVisible: typeof loadVisibleSavedWorkflow; resolveOwnedRun: typeof resolveOwnedTerminalRunDir; saveRun: typeof saveTerminalRunAsWorkflow; instantiate: typeof instantiatePublishedSavedWorkflow; readRunBinding: typeof readV3RunChatBinding; requestCancel: typeof requestV3RunCancel; }; //# sourceMappingURL=v3-saved-workflow-handler.d.ts.map