import { JsonRecord } from "../storage/types"; export type KnownTaskKind = "node" | "breakpoint" | "orchestrator_task" | "sleep" | "subprocess"; export type TaskKind = string; export interface TaskIOHints { inputJsonPath?: string; outputJsonPath?: string; stdoutPath?: string; stderrPath?: string; } export type ResponderType = "internal" | "human" | "agent" | "tracker" | "auto"; export interface ResponderRoutingOptions { external?: boolean; responderType?: ResponderType; adapter?: string; fallbackType?: ResponderType; fallbackToInternal?: boolean; targetResponders?: string[]; trackerBackend?: string; capabilities?: string[]; timeout?: number; timeoutMs?: number; } export type AgentPrompt = string | JsonRecord; export interface AgentTaskOptions extends ResponderRoutingOptions { name?: string; prompt?: AgentPrompt; outputSchema?: Record; model?: string; provider?: string; approvalMode?: string; maxTurns?: number; [key: string]: unknown; } export interface NodeTaskOptions { entry: string; args?: string[]; env?: Record; cwd?: string; timeoutMs?: number; } export interface BreakpointTaskOptions { payload?: unknown; confirmationRequired?: boolean; responderType?: ResponderType; fallbackType?: ResponderType; targetResponders?: string[]; trackerBackend?: string; timeoutMs?: number; } export interface OrchestratorTaskOptions { payload?: JsonRecord; resumeCommand?: string; } export interface SleepTaskOptions { iso: string; targetEpochMs: number; } export interface SubprocessTaskOptions { processPath: string; exportName?: string; processId?: string; prompt?: string; inputs?: unknown; inputSchema?: Record; outputSchema?: Record; harness?: string; model?: string; maxIterations?: number; shareSession?: boolean; metadata?: JsonRecord; } export interface EffectExecutionHints { /** Preferred internal harness CLI (e.g., 'pi', 'claude-code'). Not a universal cross-plugin contract. */ harness?: string; /** Preferred model identifier (e.g., 'claude-opus-4-6'). Used for subagent model selection. */ model?: string; /** Internal harness permission hints. Plugins may ignore them; do not treat them as a security boundary. */ permissions?: string[]; } export interface TaskDef { kind: TaskKind; title?: string; description?: string; labels?: string[]; inputSchema?: Record; outputSchema?: Record | false | null; io?: TaskIOHints; metadata?: JsonRecord; execution?: EffectExecutionHints; agent?: AgentTaskOptions; node?: NodeTaskOptions; breakpoint?: BreakpointTaskOptions; orchestratorTask?: OrchestratorTaskOptions; sleep?: SleepTaskOptions; subprocess?: SubprocessTaskOptions; [key: string]: unknown; } export interface BlobWriteOptions { /** * Optional content-type metadata (reserved for future integrations). */ contentType?: string; /** * Text encoding to use when serializing string payloads (default: utf8). */ encoding?: BufferEncoding; /** * Force JSON serialization (default: true for objects, false for strings/Buffers). */ asJson?: boolean; } export interface TaskBuildContext { effectId: string; invocationKey: string; /** * Stable id returned from defineTask (used for serialization + hashing). */ taskId: string; /** * Active run identifier (matches run.json:id). */ runId: string; /** * Absolute path to the run directory containing journal/tasks/etc. */ runDir: string; /** * Absolute path to the effect-specific task directory (runs//tasks/). */ taskDir: string; /** * Absolute path to the run-level tasks directory (runs//tasks). * @deprecated Use taskDir instead. */ tasksDir: string; /** * Optional label provided at invocation time. */ label?: string; labels: string[]; /** * Writes the provided payload under tasks//blobs and returns a run-relative POSIX path. */ createBlobRef(name: string, value: unknown, options?: BlobWriteOptions): Promise; /** * Resolves a task-scoped relative path to a run-relative POSIX string. */ toTaskRelativePath(relativePath: string): string; } export type TaskValueFactory = (args: TArgs, ctx: TaskBuildContext) => TValue | Promise; export type TaskValueOrFactory = TValue | TaskValueFactory; export type TaskImpl = (args: TArgs, ctx: TaskBuildContext) => TaskDef | Promise; export interface DefinedTask { id: string; build(args: TArgs, ctx: TaskBuildContext): TaskDef | Promise; } export interface TaskInvokeOptions { label?: string; /** * Explicit invocation key for retry/idempotent patterns. When provided, the ReplayCursor * is NOT advanced - all calls with the same key resolve to the same effect slot. * Use dotted-namespace kebab-case (e.g., 'bootstrap.fetch-data') unique within the process. * This prevents the phantom duplicate effects bug when ctx.task() is inside a retry loop. */ key?: string; /** @deprecated Use `key`. */ stableKey?: string; } export interface TaskSerializerContext { runDir: string; effectId: string; taskId: string; invocationKey: string; stepId?: string; } export interface NodeTaskDefinitionOptions { entry: TaskValueOrFactory; title?: TaskValueOrFactory; description?: TaskValueOrFactory; labels?: TaskValueOrFactory; metadata?: TaskValueOrFactory; io?: TaskValueOrFactory; env?: TaskValueOrFactory | undefined>; cwd?: TaskValueOrFactory; args?: TaskValueOrFactory; timeoutMs?: TaskValueOrFactory; } export interface AgentTaskDefinitionOptions { title?: TaskValueOrFactory; description?: TaskValueOrFactory; labels?: TaskValueOrFactory; metadata?: TaskValueOrFactory; io?: TaskValueOrFactory; name?: TaskValueOrFactory; prompt?: TaskValueOrFactory; outputSchema?: TaskValueOrFactory | undefined>; external?: TaskValueOrFactory; responderType?: TaskValueOrFactory; adapter?: TaskValueOrFactory; fallbackType?: TaskValueOrFactory; fallbackToInternal?: TaskValueOrFactory; model?: TaskValueOrFactory; provider?: TaskValueOrFactory; approvalMode?: TaskValueOrFactory; maxTurns?: TaskValueOrFactory; timeout?: TaskValueOrFactory; timeoutMs?: TaskValueOrFactory; } export interface BreakpointTaskDefinitionOptions { title?: TaskValueOrFactory; description?: TaskValueOrFactory; labels?: TaskValueOrFactory; metadata?: TaskValueOrFactory; payload?: TaskValueOrFactory; confirmationRequired?: TaskValueOrFactory; responderType?: TaskValueOrFactory; fallbackType?: TaskValueOrFactory; targetResponders?: TaskValueOrFactory; trackerBackend?: TaskValueOrFactory; timeoutMs?: TaskValueOrFactory; } export interface OrchestratorTaskDefinitionOptions { title?: TaskValueOrFactory; description?: TaskValueOrFactory; labels?: TaskValueOrFactory; metadata?: TaskValueOrFactory; payload?: TaskValueOrFactory; resumeCommand?: TaskValueOrFactory; } export interface SleepTaskBuilderArgs { iso: string; targetEpochMs: number; } export interface SleepTaskDefinitionOptions { title?: TaskValueOrFactory; description?: TaskValueOrFactory; labels?: TaskValueOrFactory; metadata?: TaskValueOrFactory; } //# sourceMappingURL=types.d.ts.map