threads.fork
Forks a thread into a new thread of the same workspace, with its conversation up to an entry (DMN-1072); the source is untouched.
Params: ForkParams
Section titled “Params: ForkParams”/** `thread.fork` and `threads.fork` params. */export type ForkParams = { /** * Fork history through this message entry of the source's session (the tool results answering it kept too); the * whole session when absent. */ entryId?: string | null; threadId: string;};Result: ThreadSummary
Section titled “Result: ThreadSummary”/** What the thread list shows about a thread. */export type ThreadSummary = { /** * The background jobs the thread's agent started that run, then the newest of those that ended, at most 3, in the * order they started (PRT-354); absent when there is none. */ agentJobs?: AgentJob[]; /** * The thread's approval mode (DMN-952, PRT-450): set by `threads.create` / `threads.update`, inherited by a fork; * absent for `yolo`, the default. */ approvalMode?: ApprovalMode | null; archivedAt?: number | null; createdAt: number; /** A disposable thread (`threads.create { ephemeral: true }`, DMN-1400); absent for any other. */ ephemeral?: boolean; /** * How many parents up to a thread without one (AGT-420): 1 for a child, 2 for a child's child; absent for a thread * without a parent (depth 0). */ depth?: number; /** The thread this one was forked from (`threads.fork`, DMN-1072); absent for a thread that is no fork. */ forkedFrom?: ForkOrigin | null; id: string; /** * When the daemon stopped (unix ms) while the thread's agent was mid-turn or waiting on async work: its last turn * was interrupted by a daemon restart and nothing continued it since (PRT-229, DMN-1071). `thread.resume` * continues it; any message to the thread clears it. Absent otherwise. */ interruptedAt?: number | null; /** Interactive requests are waiting for an answer. */ needsAttention: boolean; /** * Its place among the threads of its workspace (archived ones included) in the left column, from 0; the same in * every window (DMN-282). */ position: number; /** * The thread whose agent started this one as its child (a subagent, `task`, or `threads.create` with * `parentThreadId`, AGT-420); absent for a thread without a parent. */ parentThreadId?: string; /** Whether the thread's host runs, starts, stopped or failed. */ process: ProcessState; provenance: Provenance; /** A child that windows may show but not send anything (AGT-421); absent when they may. */ readOnly?: boolean; /** Idle with nothing queued or pending (pi's `agent_settled`). */ settled: boolean; /** `""` until the first message (DMN-1070). */ title: string; titleSource: TitleSource; /** The thread's only tools (`threads.create`'s `tools`, AGT-500, PRT-490); absent for a thread with every tool. */ tools?: string[]; updatedAt: number; /** The workspace the thread lives in: its session's working directory is the workspace folder. */ workspaceId: string;};Types they use
Section titled “Types they use”/** * A background job a thread's agent started (`job_start`, AGT-320), as its summary lists it (PRT-354): its id, its * command, its state as `jobs.output` reports it (PRT-351) and its exit code once it exited. */export type AgentJob = { command: string; /** `null` while it runs or when a signal ended it. */ exitCode: number | null; jobId: string; /** The label its agent gave it (`job_start`'s `name`). */ name?: string | null; /** `completed` on exit 0, `failed` on another exit or a signal, `cancelled` when killed (PRT-351). */ state: "running" | "completed" | "failed" | "cancelled";};
/** * A thread's approval mode: which tool calls the thread's host asks the user to approve before they run (DMN-952, * DMN-953). Read-only tools run without asking in every mode; any other value is `bad_request`. */export type ApprovalMode = /** Runs read-only tools; asks before every other tool, file edits included. */ | "always-ask" /** * Like `always-ask`, but the question can allow the tool (for `omfp_call`, that method) for the rest of the * thread host's session (DMN-954). */ | "always-ask-cached" /** Runs read-only tools and file edits (`edit`, `write`); asks before the rest (the shell, evals, …). */ | "write" /** Runs every tool without asking (the default). */ | "yolo";
/** Where a forked thread comes from (PRT-401): the source thread and the message it was forked at. */export type ForkOrigin = { /** The pi session entry the fork ends at; absent when the whole session was copied. */ entryId?: string | null; /** The first line of that entry's message text (at most 120 characters). */ message?: string | null; /** The source thread; it may have been deleted since. */ threadId: string; /** The source's title when it was forked. */ title: string;};
/** Who created an entity. */export type Provenance = { /** `client` of the creating connection's `system.hello`. */ client?: string | null; createdBy: CreatedBy;};
/** Where a thread's title comes from (DMN-1070). */export type TitleSource = /** The first words of the first message (or `""` before it), until a title is generated or set. */ | "placeholder" /** Generated from the conversation by the daemon. */ | "generated" /** Set by the user or an agent (`threads.create`, `threads.update`, `agents.set_title`); never replaced. */ | "set";
/** * The principal behind a created entity: the user, the agent of a thread, or an MCP client outside omfp, * named by the provenance's `client`. */export type CreatedBy = | { kind: "user"; } | { kind: "thread"; threadId: string; } | { kind: "mcp"; } /** A run of the declared job `job` of the entity's workspace (PRT-209). */ | { job: string; kind: "job"; };