import type { Config } from "./config.js"; import type { Events } from "./events.js"; import { type JobClosure, type JobRecord, type JobStore } from "./jobs.js"; import { type JobAnswer } from "./progress.js"; import type { JobQueue } from "./queue.js"; import type { SkillRegistry } from "./registry.js"; import { type Skill } from "./skills.js"; export type AnswerErrorCode = "unknown_job" | "not_waiting" | "unknown_skill" | "running"; export declare class AnswerError extends Error { readonly code: AnswerErrorCode; readonly status: 404 | 409; constructor(code: AnswerErrorCode, message: string, status: 404 | 409); } export interface AnswerJobInput { jobId: string; text: string; /** One of the question's options, when the person picked one. */ option?: string; /** Who answered (a name, an email, a dashboard user), for the record and the prompt. */ by?: string; /** `auto` (default): a finished job is continued by a new job; `never`: only record the answer. */ resume?: "auto" | "never"; } export interface AnswerJobResult { /** The job that was answered, as updated. */ job: JobRecord; answer: JobAnswer; /** `live`: the waiting agent gets it now; `resumed`: `resumeJob` continues the session; `recorded`: stored only. */ delivered: "live" | "resumed" | "recorded"; resumeJob?: JobRecord; /** The skill of the resume job (what `runJobLocally` needs when no server runs it). */ skill?: Skill; } type AnswerOps = { config: Config; store: JobStore; registry: SkillRegistry; }; /** * A new job that continues `original` with a person's answer: the same skill, runner, model and working directory, * the original event as its payload, `resume_of` and, when the original has a session id, `resume` so the runner reopens * that session (`--resume` / `exec resume`) and the prompt is only the `` block. Without a session (a shell * run, a crash before the id was captured) the skill runs afresh with the answer appended, and `runner_reason` says so. */ export declare function createResumeJob(ops: { config: Config; store: JobStore; }, input: { original: JobRecord; skill: Skill; answer: JobAnswer; }): JobRecord; /** * Answers a job. `queue` is the server's queue: it delivers to a job it is running and enqueues the resume job; without * one, a running job owned by another process (`skillhook run` in a terminal) is answered through the files that process * watches, and the caller runs `resumeJob` itself. Throws `AnswerError` (`unknown_job`, `not_waiting`, `unknown_skill`). */ export declare function answerJob(ops: AnswerOps, input: AnswerJobInput, options?: { queue?: JobQueue; events?: Events; }): AnswerJobResult; export interface CloseJobInput { jobId: string; /** Who closed it (a name, an email, a dashboard user). */ by?: string; /** Why it no longer needs a person (the finding cleared by itself, the question went stale, it was handled elsewhere). */ reason?: string; } /** * Closes a finished job that waits for a person without answering it: nothing is delivered and no agent resumes. The * job leaves `waiting` (list_jobs, stats, the cloud's inbox) and records `closed: {at, by?, reason?}`; `job.updated` * carries it to the cloud. A running job's question is answered or the job cancelled instead (`running`, 409), so an * agent never blocks on a question nobody can answer any more. Throws `AnswerError` (`unknown_job`, `not_waiting`, `running`). */ export declare function closeJob(ops: { store: JobStore; }, input: CloseJobInput, options?: { queue?: JobQueue; events?: Events; }): { job: JobRecord; closed: JobClosure; }; export {};