// Generated by pipeline/contract/build.mjs from pipeline/schemas/*.schema.json. // Do not edit: change the schema and run `node pipeline/contract/build.mjs --write`. export type ContractVersion = "2.5.0"; export type SurfaceId = "runs" | "run" | "commands" | "skills" | "questions" | "issues" | "worktrees" | "launch-spec" | "repos" | "repo-add" | "repo-remove" | "launch" | "answer" | "run-log" | "resume" | "kill" | "gc" | "autopilot" | "autopilot-off" | "autopilot-on" | "steer" | "activity" | "activity-stream" | "agent-chat" | "routines" | "routine-delete" | "routines-shared" | "routine-shared" | "routine-shared-import" | "jobs" | "job-start" | "stack" | "stack-set" | "ledger" | "system" | "prune-logs" | "disk-clean" | "settings" | "settings-set" | "learning-curve" | "credentials" | "memory" | "server-room" | "mcp-health" | "archive" | "run-results" | "run-evidence" | "review-verdict" | "issue-maturity" | "prs" | "prs-reach" | "tools" | "tool-call" | "service-confluence" | "service-crashlytics" | "service-figma" | "permissions"; /** What `runs-index.mjs --json` prints: every run under the log root and the unattended log root (one record per task id), grouped per status/SKILL.md 3b. Fields are only ever added - a decoder ignores keys it does not know. `--redact` drops every x-sensitivity local field (and `logsRoot`) and scrubs the free text in the title, `now`, sub-step names, task subjects and the pending question. */ export interface RunsIndex { contractVersion: string; /** Absent under --redact. */ logsRoot?: string; count: number; runs: Array; } export interface RunsIndexRun { taskId: string; project: string | null; /** The run directory. */ dir?: string; layout: "nested" | "flat"; /** The other layout's directory for the same task id, when both exist. */ duplicateOf?: string | null; salvaged: boolean; kind: "pipeline" | "tracker-only" | "empty"; stateReadable: boolean; status: string | null; currentPhase: number | null; branch: string | null; baseBranch: string | null; startedAt: string | null; worktreePath?: string | null; /** Carries the host, so it stays on this machine. */ prUrl?: string | null; autopilot: boolean; /** The run's agent-state schemaVersion. Always a string; a number in a hand-edited state is printed as its string. */ schemaVersion: string | null; rev: number | null; /** The session id the run was launched under (agent-state sessionId). A client that launched a run through launch.json finds it by this id. Added in 1.1.0. */ sessionId?: string | null; /** The step a paused run re-enters (agent-state waitingFor): maturity, user-channels-choice, local-test, attended-reply or question; null or absent when the run is not waiting. Added in 1.1.0. */ waitingFor?: string | null; /** When a run in the waiting group began to wait: the state's own waitingSince when it has one, else the state file's modification time. Null outside the waiting group. Added in 1.5.0. */ waitingSince?: string | null; /** Where waitingSince came from: state is the run's own record of when it parked, file-time is the state file's modification time, which a rewrite moves, so a client shows it as approximate. Null when waitingSince is null. Added in 1.5.0. */ waitingSinceSource?: "state" | "file-time" | null; /** When the run finished or was stopped (agent-state finishedAt); null while it is going and when its state records no end. Added in 1.5.0. */ finishedAt?: string | null; /** The question the run stopped on, present only with waitingFor question. Answer it with one of options[].id through `answer-question.mjs` or POST /v1/runs/{id}/answer. text and labels are scrubbed under --redact. Added in 1.1.0. */ pendingQuestion?: null | RunsIndexQuestion; /** done (added in 1.4.0): the run's status is complete, completed, done, abandoned or cancelled; it is placed before every other test, so a finished run is never offered resume. */ group: "waiting" | "stopped" | "question" | "unknown" | "done"; phases: Array; tokens: { in: number; out: number; cached: number; }; estUsd: number; unlockedWrites: number; /** agent-state.json mode as the run recorded it (analysis, test-gen, review...), so a reader can name the command; null when none was recorded. */ mode?: string | null; /** autopilot when the run is in autopilot mode; analysis for an analysis-family run (agent-state mode analysis, or a tracker with no agent state); development otherwise. Added in 1.2.0. */ runType?: "analysis" | "development" | "autopilot"; /** The issue summary Phase 0 recorded (agent-state title), else the input the run was launched with (launchRequest.input), else null. Scrubbed under --redact. Added in 1.2.0. */ title?: string | null; /** The mean of phases[].progress over the registered phases, a phase whose progress is null counting as 0. Null when no phase is registered. Added in 1.2.0. */ progress?: number | null; /** Whether the session the run was launched under (sessionId) is alive per `claude agents --json`: true listed and its process still there (any status, a row with no pid included), false recorded and either not listed or listed with its process gone, null when no session is recorded or the list could not be read. Added in 1.2.0. */ processAlive?: boolean | null; /** The first in_progress task of the phase in progress, or null. Scrubbed under --redact. Added in 1.2.0. */ currentTask?: { subject: string; activeForm: string | null; } | null; /** Where the work came from: a Jira key, a GitHub issue (owner/repo#N) or free text; a GitHub issue that got a Jira has both. Null when the run recorded neither. Added in 1.3.0. */ source?: { kind: "jira" | "github" | "text"; jira: string | null; issue: string | null; } | null; /** The pull request's number, from the state or its URL; the URL itself is prUrl (local). Added in 1.3.0. */ prNumber?: number | null; /** Where Phase 5 sent the report, per adapter (state.channelResults); empty before then. Added in 1.3.0. */ channels?: Array<{ channel: "pr" | "jira" | "confluence" | "wiki" | "issue"; status: "posted" | "skipped" | "failed"; }>; /** The address each adapter posted to, https only; dropped from a redacted answer. Added in 1.3.0. */ channelUrls?: { pr?: string; jira?: string; confluence?: string; wiki?: string; issue?: string; }; } export interface RunsIndexQuestion { id: string; stepId: string; text: string; kind: "single-select" | "multi-select"; options: Array<{ id: string; label: string; }>; } export interface RunsIndexPhase { id: string; name: string; status: string; model: string | null; startedAt: string | null; completedAt: string | null; /** The phase's one-line current activity: what `phase-tracker.sh now` recorded (meta.Now). Scrubbed under --redact. */ now: string | null; /** How many sub-steps the phase has. Kept as a count for existing readers; the sub-steps are subList. */ subs: number; subList: Array<{ id: string; name: string; status: string; }>; /** What this one phase spent, from its own tracker counters. The run's total is the `tokens` beside it on the run record. Added in 1.6.0. */ tokens: { in: number; out: number; cached: number; }; /** 1 for a completed or skipped phase, 0 for a pending one; otherwise completed tasks over tasks, and null when the phase has no tasks. Added in 1.2.0. */ progress?: number | null; /** The host's native task list for this phase (TaskCreate/TaskUpdate, update_plan steps, card rows) as `phase-tracker.sh task` mirrored it; empty when there are none. subject and activeForm are scrubbed under --redact. Added in 1.2.0. */ tasks?: Array<{ id: string; subject: string; activeForm: string | null; status: "pending" | "in_progress" | "completed"; }>; } /** What `commands.mjs --json` prints: every /multi-agent: command with the parameters, surface and confirmation it declares in its SKILL.md frontmatter, defaults filled in. A client renders a button or a form from this without hard-coding a command. The frontmatter is the source; `_command-contract.mjs` holds it to `argument-hint`. Every field is `x-sensitivity: none`: nothing here is specific to a machine or a person. */ export interface CommandParameters { /** Major 1. A minor bump adds fields; a consumer ignores keys it does not know. */ contractVersion: string; commands: Array; } export interface CommandParametersCommand { /** The command directory name; invoked as /multi-agent:. */ id: string; /** The human hint, verbatim. Empty when the command declares none. */ argumentHint: string; parameters: Array; /** button: runs with no input. form: collect parameters first. hidden: not offered as an action (maintainer tooling, help text). Independent of disable-model-invocation, which only stops the model invoking the command itself. */ gui: "button" | "form" | "hidden"; /** Removes something that is not trivially recreated: a worktree, a branch, logs, an install, user instruction lines. */ destructive: boolean; /** required: a client asks before launching. Always required when destructive. The command keeps its own in-session confirmation either way. */ confirm: "required" | "none"; } export interface CommandParametersParameter { /** `--name` for a flag, typed as written. Otherwise a positional, in order; a positional of kind flag is a literal keyword typed as its name. */ name: string; /** run-id: #N or a task id. pull-request: a PR number or URL. issue-key: a Jira key or a GitHub issue reference. flag: present or absent, no value. */ kind: "run-id" | "branch" | "pull-request" | "issue-key" | "path" | "text" | "enum" | "flag"; /** Omitted in frontmatter means false; the catalog always carries it. */ required?: boolean; /** More than one value: space-separated for a positional, comma-separated for a flag. */ repeat?: boolean; /** The allowed values. Present exactly when kind is enum. */ enum?: Array; } /** What GET /v1/skills returns (`skill-catalog.mjs --json`): every /multi-agent command, marketplace plugin skill and saved routine a person can invoke, with both frontmatter descriptions. enabled is the plugin's state in the chosen repository's .claude/settings.json or its always-on flag, null for a plugin skill when no repository was chosen, and always true for commands and routines. A source that is missing on this machine is a note, not an error. Routine text is scrubbed. */ export interface SkillCatalog { contractVersion: string; /** The repository reference the request named, or null. */ repo: string | null; items: Array<{ /** kind:name for a command or routine, plugin-skill:plugin:name for a plugin skill. */ id: string; name: string; /** What a person types: /multi-agent: for a command or routine, : for a plugin skill. */ invoke: string; kind: "command" | "plugin-skill" | "routine"; /** The plugin name, pipeline for a shipped command, or local for a routine or a local-only command. */ source: string; description: string; descriptionTr: string | null; enabled: boolean | null; alwaysOn: boolean; localOnly: boolean; }>; notes: Array<{ section: "command" | "plugin-skill" | "routine"; /** no-tree: no command tree; no-clone: no marketplace clone; no-manifest: the clone has no readable marketplace.json; unreadable: the routine registry could not be read. */ code: "no-tree" | "no-clone" | "no-manifest" | "unreadable"; }>; } /** Shape of run-questions.json: the Phase 0 pickers of a /multi-agent run as data. Every field is x-sensitivity none - the file ships with the package and describes questions, never a machine's answers. */ export interface RunQuestions { contractVersion: string; description?: string; questions: Array; } export interface RunQuestionsQuestion { /** The key a launch request answers under. */ id: string; /** dynamic: the questions themselves are produced during the run and cannot be answered in advance. */ kind: "single-select" | "multi-select" | "dynamic"; /** Where in phase-0-init.md (or the file it names) the picker lives. */ "asked-at": string; /** Whether a launch request may pre-fill it. false: the run always asks. */ answerable: boolean; /** Static options. An answer is one option id. Absent when the options are enumerated at run time; then `answer` constrains the value. */ options?: Array<{ id: string; label: string; }>; /** For options enumerated at run time: every answered value must match `pattern`. Phase 0 still checks the value is one of the options it enumerated, and asks when it is not. */ answer?: { pattern: string; description?: string; /** A neutral value the pattern admits. */ example?: string; }; /** The option id the picker marks recommended. */ default?: string; /** The agent-state.json field the answer ends up in. */ stateField?: string; /** Conditions under which Phase 0 resolves the step without asking. */ "skippable-when"?: Array; /** An option that may not be chosen under a condition. A launch request choosing it is rejected, not downgraded. */ "disabled-when"?: Array<{ option: string; mode?: "interactive" | "autopilot" | "background"; workingTree?: "dirty"; }>; /** A command that prints the options as redacted JSON. null when none ships. */ source: string | null; sourceNote?: string; } /** What `issues.mjs --json` prints: open items assigned to the current user, Jira and GitHub in one list. No field carries a URL, a host, a person or a path - summaries are scrubbed before they are printed - so every field is x-sensitivity none and --redact changes nothing. */ export interface Issues { contractVersion: string; /** Priority first, then status, then newest. */ items: Array<{ /** A Jira key, or owner/repo#N for GitHub. */ key: string; summary: string; status: string | null; type: string | null; /** Jira's priority name. Always null for GitHub, which has none. */ priority: string | null; source: "jira" | "github"; }>; sources: Array<{ source: "jira" | "github"; ok: boolean; count: number; /** Why a source contributed nothing. A fixed code, never the tool's own message. */ reason?: "not-onboarded" | "unavailable" | "failed"; }>; } /** What `worktrees.mjs --json` prints: one entry per run that owns a worktree, with its size when --measure was passed. --redact removes every x-sensitivity local field. */ export interface Worktrees { contractVersion: string; worktrees: Array<{ taskId: string; project?: string | null; /** Absolute path on this machine. */ worktreePath?: string; /** The directory is on disk. false: removed by Phase 4 or by hand, and the run still names it. */ exists: boolean; /** Disk usage from du -sk. null unless --measure ran and the directory exists. */ sizeBytes: number | null; /** When sizeBytes was taken; null when it was not. */ measuredAt: string | null; }>; } /** Shape of launch.json: per host CLI, the argv template and environment that start a run, and where the launch request file goes. Templates use {placeholder} tokens named in `placeholders`. Every field is x-sensitivity none: the file ships with the package and holds templates, never a machine's values. */ export interface Launch { contractVersion: string; /** false until a live launch trial confirmed the shape on a real host. */ verified: boolean; note: string; requestFile: { env: "MA_LAUNCH_REQUEST"; directory: string; directoryDefault: string; name: string; fileMode: string; schema: string; lifetime: string; }; placeholders: { [key: string]: string; }; hosts: { [key: string]: LaunchHost; }; } export interface LaunchHost { supported: boolean; bin?: string; cwd?: string; note: string; /** The launch shape per declared mode of schemas/phases.json that a client may start without a terminal conversation. autopilot runs the pipeline and stops at a pull request; analysis-autopilot runs the analysis command and stops at a document. */ modes?: { [key: string]: LaunchShape; }; /** The unattended background launch per request kind: development runs /multi-agent without autopilot, analysis runs /multi-agent:analysis. A question nobody pre-answered parks the run (pendingQuestion) instead of being resolved from a default. */ background?: { development: LaunchShape; analysis: LaunchShape; }; /** The unattended background launch of /multi-agent:resume for a run recorded under the unattended log root. */ resume?: LaunchShape; } export interface LaunchShape { argv: Array; env: { [key: string]: string; }; } /** The file MA_LAUNCH_REQUEST names: what a client asked for before the run started. Phase 0 reads it through `launch-request.mjs resolve` and pre-fills the matching pickers; with the variable unset nothing changes. Answers are data, never instructions: each one is an option id from run-questions.json or a value its `answer.pattern` admits, and anything else rejects the whole request. The file lives on the machine that runs the pipeline, so every field is x-sensitivity local - a client that relays a request elsewhere strips it first. */ export interface LaunchRequest { /** Major 1. A request for another major is rejected rather than half-understood. */ contractVersion: string; /** What the run works on. A structured reference - a Jira key (^[A-Z][A-Z0-9]+-[0-9]+$), https://github.com///issues/, repo#N, #N, or a Jira URL on the configured Jira host - reaches the prompt as it is. Free text is accepted as one line of at most 500 printable characters with no quote, backslash, backtick or URL, reaching the prompt as one double-quoted argument. A newline, a control or format character, a leading '-', a flag-like token, or a first token naming a pipeline op or mode keyword rejects the request; a later word is not held to that rule, because a quoted argument cannot route on it. launch-request.mjs inputErrors is the rule. */ input: string; /** Whether the run confirms anything. autopilot resolves every picker itself; background runs unattended without autopilot and parks on a picker the request did not answer (waitingFor question). The workspace is a separate answer, and neither autopilot nor background runs local. */ mode: "interactive" | "autopilot" | "background"; /** Required with mode background and refused with any other mode: development runs /multi-agent, analysis runs /multi-agent:analysis (whose answers must be empty: it reads no request). */ kind?: "analysis" | "development"; /** questionId -> optionId (single-select) or optionId[] (multi-select). Keys come from run-questions.json; an unknown or unanswerable key rejects the request. */ answers: { [key: string]: string | Array; }; } /** What `launch-request.mjs plan` prints, and POST /v1/launch and POST /v1/runs/{id}/resume return: the command a client runs to start a validated launch request unattended, with launch.json's placeholders filled. Neither carrier runs it. argv is an argument vector for a process spawned without a shell (shell is always false): the input is one element, never a string to be split or interpreted. `verified` repeats launch.json's flag; until it is true the shape is provisional. Under redact every x-sensitivity local field is dropped, leaving the session id a client tracks the run by. */ export interface LaunchPlan { contractVersion: string; valid: true; verified: boolean; host: "claude"; /** autopilot and background start a run from a request; resume re-enters a run recorded under the unattended log root (POST /v1/runs/{id}/resume), and carries no request file. */ mode: "autopilot" | "background" | "resume"; /** Present with mode background: the request's kind. */ kind?: "analysis" | "development"; /** Phase 0 records it as sessionId; the runs index carries it, which is how the client finds this run. */ sessionId: string; /** The request file, mode 0600, named for the session. */ requestFile?: string; bin: string; cwd?: string; /** Carries the request's input, which is local. */ argv?: Array; /** Variables to add to the client's own environment for the launched process. */ env?: { [key: string]: string; }; shell: false; } /** The body of POST /v1/runs/{id}/answer: the answer to the question a run stopped on, as `answer-question.mjs --question --answer ` takes it. questionId is the pendingQuestion.id the client read from the runs index; a run that has moved on to another question refuses the answer. Every option id must be one the question offered. Nothing here is free text, so nothing here can become an instruction. */ export interface AnswerRequest { questionId: string; optionIds: Array; } /** What `answer-question.mjs` prints, and POST /v1/runs/{id}/answer returns, once an answer is recorded: the lastAnswer written to the run's state in the same write that cleared pendingQuestion. */ export interface AnswerResult { contractVersion: string; answered: { questionId: string; stepId: string; optionIds: Array; answeredAt: string; }; } /** What GET /v1/runs/{id}/log returns and `run-log.mjs --tail N` prints: the last lines of the run's agent-log.md. `truncated` is true when the file held more than the lines returned. Lines are scrubbed under redact. */ export interface RunLog { contractVersion: string; id: string; lines: Array; truncated: boolean; } /** The body of POST /v1/runs/{id}/resume. `answers` answers the question the run is parked on, keyed by its pendingQuestion id; the answer is recorded before the plan is returned. Any other key is refused (409 wrong-question), and answers to a run that is not waiting are refused (409 not-waiting). */ export interface ResumeRequest { contractVersion: string; answers?: { [key: string]: string | Array; }; } /** The body of POST /v1/runs/{id}/kill. Without confirmToken it asks for the preview; with the token that preview returned it performs the kill. */ export interface KillRequest { contractVersion: string; /** The confirmToken the preview returned. Single use, valid for 120 seconds, bound to the route and the run. */ confirmToken?: string; } /** What POST /v1/runs/{id}/kill returns: the preview with a confirm token (step 1), or the result (step 2, `run-kill.mjs apply`). A kill never deletes the remote branch or the run's logs. worktreePath is dropped under redact. */ export interface Kill { /** Contract version that produced the body. */ contractVersion?: string; } export interface KillPreview { contractVersion: string; preview: { worktreePath?: string | null; branch: string | null; sizeKb: number; /** Lost with the worktree. */ uncommittedFiles: number; /** Commits on no remote; lost with the branch. */ unpushedCommits: number; /** The run's background session is running (or its liveness could not be read). */ processAlive: boolean; }; /** The confirmToken the preview returned. Single use, valid for 120 seconds, bound to the route and the run. */ confirmToken: string; expiresAt: string; } export interface KillResult { contractVersion: string; killed: true; processStopped: boolean; worktreeRemoved: boolean; branchDeleted: boolean; logsKept: true; } /** The body of POST /v1/gc. Step 1 names the scope (default all four); step 2 sends only the confirmToken step 1 returned. */ export interface GcRequest { contractVersion: string; scope?: (Array<"tmp" | "worktrees" | "refs" | "abandoned">); /** The confirmToken the preview returned. Single use, valid for 120 seconds, bound to the route and the run. */ confirmToken?: string; } /** What POST /v1/gc returns: every candidate the collectors would remove with a confirm token (step 1, `gc-plan.mjs preview`), or what was removed (step 2, `gc-plan.mjs apply` over exactly the previewed items). An item a collector declined comes back in failed with the reason. Paths are dropped under redact. */ export interface Gc { /** Contract version that produced the body. */ contractVersion?: string; } export interface GcPreview { contractVersion: string; items: Array<{ kind: "tmp" | "worktrees" | "refs" | "abandoned"; path?: string; sizeKb: number; reason: string; }>; totalKb: number; /** The confirmToken the preview returned. Single use, valid for 120 seconds, bound to the route and the run. */ confirmToken: string; expiresAt: string; } export interface GcResult { contractVersion: string; removed: number; freedKb: number; failed: Array<{ path?: string; reason: string; }>; } /** What GET /v1/autopilot returns: status.json as `autopilot-status.sh --json` builds it (the document the menu bar renders), plus contractVersion. Fields beyond the required ones are the status document's and may grow. */ export interface AutopilotStatus { contractVersion: string; on: boolean; slots: number; running: unknown[]; queued: unknown[]; awaiting: unknown[]; todayCount: number; todayUsd: number; spendUsd: number; ceilingUsd: number; } /** The body of POST /v1/autopilot/off. now: true also ends the item in flight (its session stopped, its run marked abandoned, its worktree kept as it is and named in keptWorktrees). Turning autopilot on is a terminal command, which picks repositories with the user. */ export interface AutopilotOffRequest { contractVersion: string; now?: boolean; } /** What POST /v1/autopilot/off returns (`autopilot-control.mjs off`): the mode is off, whether an in-flight session was stopped, and the worktrees of the items it ended, which are kept as they are. The repo selection, queue and attempt history are kept. */ export interface AutopilotOff { contractVersion: string; enabled: false; stoppedInFlight: boolean; /** The worktree of each in-flight item `now: true` ended. No git runs inside an unattended run's worktree, so whether it holds uncommitted work is not asked; it is kept for a person to look at. Empty without `now`. */ keptWorktrees: Array; } /** What GET /v1/repos returns and `launch-request.mjs repos` prints: the repositories POST /v1/launch?repo= accepts, by real path. source autopilot is a configured autopilot repo (config.json repos[], named by nameWithOwner); registered is one added with `launch-request.mjs register-repo` (launch-repos.json, named by its directory). path is dropped under redact. With --all (?all=1): suggested lists checkouts earlier runs worked in that launch does not accept yet, and missing lists registered entries that are no longer a directory; each carries an id that POST /v1/repos and DELETE /v1/repos/{id} take. */ export interface Repos { contractVersion: string; repos: Array<{ path?: string; name: string; source: "autopilot" | "registered"; }>; suggested?: Array<{ id: string; path?: string; name: string; }>; missing?: Array<{ id: string; path?: string; name: string; }>; } /** The body of POST /v1/repos. The first request names suggestion (an id from GET /v1/repos?all=1) or path (an absolute path to a git checkout); the second sends only confirmToken. */ export interface RepoRequest { contractVersion: string; suggestion?: string; path?: string; confirmToken?: string; } /** What POST /v1/repos and DELETE /v1/repos/{id} return. Without a token: preview (the repository's name) with confirmToken and expiresAt. With it: registered or removed, by name. Paths never leave the server here. */ export interface RepoChange { contractVersion: string; preview?: { name: string; }; confirmToken?: string; expiresAt?: string; registered?: { name: string; }; removed?: { name: string; }; } /** The catalog of jobs the office can start (office-jobs.json), read by job-launch.mjs and served by GET /v1/jobs. */ export interface OfficeJobs { $schema?: string; contractVersion: string; description?: string; jobs: Array<{ id: string; command: string; role: string; team: boolean; launch?: "development" | "analysis" | "autopilot"; /** Flags the job always passes after its parameters, fixed in the catalog. */ fixedArgs?: Array; available?: boolean; reason?: string | null; params: Array<{ name: string; kind: "work-item" | "pull-request" | "branch" | "run-id" | "jira-key" | "github-issue" | "enum" | "repo-path" | "search-text" | "analysis-doc"; values?: Array; /** Where GET /v1/jobs reads an enum's values from on this machine; the catalog itself lists none. */ choices?: "review-priority-teams" | "review-priority-presets"; /** The parameter whose value narrows this one's choices (valuesFor). */ dependsOn?: string; /** Filled by GET /v1/jobs: the allowed values per value of dependsOn. */ valuesFor?: { [key: string]: Array; }; /** Written before the value in the command line, as in preset=. */ prefix?: string; required: boolean; }>; writes: "none" | "branch" | "branch-pr" | "pr-comments" | "issue-comment"; }>; } /** The body of POST /v1/jobs. The first request names jobId (from GET /v1/jobs), repo (a name from GET /v1/repos or its path) and args (by parameter name), plus answers for a pipeline run; the second sends only confirmToken. */ export interface JobRequest { contractVersion: string; jobId?: string; repo?: string; args?: { [key: string]: string; }; answers?: Record; confirmToken?: string; } /** What POST /v1/jobs returns. Without a token: preview (the job, the role that does it, team or solo, the repository by name, the exact prompt the session receives and what it writes outside the machine) with confirmToken and expiresAt. With it: started, the session the server began. */ export interface JobChange { contractVersion: string; preview?: { jobId: string; role: string; team: boolean; repo: string; prompt: string; writes: "none" | "branch" | "branch-pr" | "pr-comments" | "issue-comment"; }; confirmToken?: string; expiresAt?: string; started?: { sessionId: string; jobId: string; role: string; team: boolean; repo: string; }; } /** What GET /v1/activity returns and `activity-snapshot.mjs --json` prints, and what each GET /v1/activity/stream event carries: one room per repository, one table per run (its team; a session no run claims sits at a table of its own), one seat per agent seen in the recent window, the orchestrator at the head. Derived from disk on every call. No field is machine-local: there are no paths, seat labels come from allow-listed fields only (tool name, file basename, sidecar description), and every free-text string has been through the redactor, so the redacted and the full view are the same document. */ export interface Activity { contractVersion: string; generatedAt: string; /** A session or subagent whose transcript changed within this window has a desk. */ recentMinutes: number; /** The cost budget from prefs.global.costBudget, present only while it is enabled and valid. A run's spend (a table's estUsd) is judged against it: ok under warnPct of maxUsd, warn from there to maxUsd, exceeded above. */ costBudget?: { maxUsd: number; warnPct: number; onExceed: "warn" | "halt"; }; counts: { rooms: number; tables: number; seats: number; live: number; waiting: number; }; rooms: Array<{ repo: string; tables: Array; }>; /** Runs over more than one repository: the table and the rooms its corridor joins. */ corridors: Array<{ tableId: string; repos: Array; }>; } export interface ActivityTable { id: string; /** run: a pipeline run; session: a session no run claims (outside the pipeline); unmatched: a session more than one run could claim, kept apart rather than guessed. solo: a session the office started for a one-person job, seated at a desk. */ kind: "run" | "session" | "solo" | "unmatched"; /** The command the table runs, for its room sign: /multi-agent, /multi-agent:analysis, /multi-agent:test-gen. Null for a session no command owns. */ command: string | null; /** Which pipeline the table runs: /multi-agent (development), /multi-agent:analysis, or an autopilot run. Null for a session no pipeline owns. The office names the room after it. */ runType: "development" | "analysis" | "autopilot" | null; taskId: string | null; title: string | null; host: "claude" | "copilot" | "codex"; /** true for a Copilot CLI or Codex session: no subagent detail exists there. */ limited: boolean; sessionId: string | null; /** How the session was tied to the run: the session id the run recorded, or its working directory and branch. */ matchedBy: "session" | "cwd-branch" | null; repos: Array; phase: { id: number; name: string; /** The last phase id, for an n of last display. */ last: number; } | null; /** The task in progress in the phase in progress, from the mirrored task list. */ currentTask: string | null; progress: number | null; now: string | null; status: string | null; waitingForYou: boolean; pendingQuestion: { id: string; text: string; kind: "single-select" | "multi-select"; options: Array<{ id: string; label: string; }>; } | null; tokens: { in: number; out: number; cached: number; } | null; estUsd: number | null; /** Where tokens and estUsd come from. tracker-state: the run's own tracker; transcript: the usage records in a plain session's own transcripts, an estimate at list price; not-measured means the numbers are null, never 0. */ costSource: "tracker-state" | "transcript" | "not-measured"; /** The room this table stands in. */ repo: string; /** worktree: the run works in its own worktree; local: in the main checkout; unknown when the state does not say. */ location: "worktree" | "local" | "unknown"; branch: string | null; phaseHistory: Array<{ id: number | null; /** How far the phase is, from its mirrored task list; null when it has none. */ progress: number | null; /** The phase's task list as the host task widget shows it (mirrored by phase-tracker.sh task), redacted and cut short. */ tasks: Array<{ subject: string; status: "pending" | "in_progress" | "completed"; }>; name: string; status: string; startedAt: string | null; completedAt: string | null; /** The model that spent this phase's tokens, as the tracker recorded it; null until one is set. */ model: string | null; /** What the phase is doing, for a running or failed phase only. Falls back to the name of the in-progress sub-step, and is null when neither exists. */ now: string | null; /** Input plus output tokens for this phase; null when none were recorded. */ tokens: number | null; /** The phase's own steps, as the card and the subject counter use them. */ subs: Array<{ id: string; name: string; status: "pending" | "in_progress" | "completed"; }>; }>; startedAt: string | null; elapsedSeconds: number | null; /** The seat id that holds the work now. */ holder: string | null; /** The last seat of an earlier phase, for drawing the handoff. */ previousHolder: string | null; seats: Array; /** The office job a session was started for (run tables carry none). */ job?: null | { id: string; role: string; team: boolean; }; /** Where the run's work came from, for the table sign: a Jira key, a GitHub issue or free text. Null for a session or a run that recorded neither. */ source: { kind: "jira" | "github" | "text"; jira: string | null; issue: string | null; } | null; /** The pull request the run opened, by number only. */ pr: { number: number; } | null; /** When the run began waiting for a person: its own record of when it parked, else its state file's modification time. Null when the run is not waiting, and for a session no run tracks. */ waitingSince: string | null; /** Where waitingSince came from: state is exact, file-time is approximate because a rewrite of the file moves it. Null when waitingSince is null. */ waitingSinceSource: "state" | "file-time" | null; /** What a waiting run waits for: a step it paused at (the run's waitingFor), or terminal when its session holds a question open in its own window. */ waitingFor: "maturity" | "user-channels-choice" | "local-test" | "attended-reply" | "question" | "terminal" | null; /** Where the run's report went, per adapter, for the run window; empty for a session or before Phase 5. */ channels: Array<{ channel: "pr" | "jira" | "confluence" | "wiki" | "issue"; status: "posted" | "skipped" | "failed"; }>; } export interface ActivitySeat { /** The desk's own task list from its transcript (TaskCreate / TaskUpdate / TodoWrite), phase tiles left out, redacted and cut short. */ tasks: Array<{ subject: string; status: "pending" | "in_progress" | "completed"; }>; /** The desk's last MCP calls, newest last: server, tool, whether it is still running, failed or answered, and how long it took. No input or result. */ mcp: Array<{ server: string; tool: string; state: "running" | "ok" | "error"; ms: number | null; at: string | null; }>; id: string; sessionId: string | null; /** null for the session's own (orchestrator) desk. */ agentId: string | null; agentType: string | null; role: string; /** The role, numbered when agents of the same role sit at one table (Reviewer 1, Reviewer 2). */ label: string; /** false when the agent type is in no role table entry and the raw type is shown. */ known: boolean; sprite: number; color: string; model: string | null; modelLabel: string | null; description: string | null; state: "reading" | "writing" | "spawning" | "waiting" | "idle" | "done"; tool: string | null; detail: string | null; /** Whether the session is alive per `claude agents --json`; null when that list cannot be read. */ live: boolean | null; startedAt: string | null; lastAt: string | null; /** The run phase the agent was spawned in; null for the orchestrator or outside a run. */ phase: number | null; status: "working" | "idle" | "done"; /** What the seat is doing in a few plain words (Reading Foo.swift, Running a command), else the raw tool name. */ doing: string; } /** What GET /v1/agents/{sessionId}/{agentId}/chat returns and `activity-snapshot.mjs chat` prints: one page of an agent's transcript read from its end, oldest first, at most `limit` messages. Only user and assistant records are read; api-request records are never parsed and thinking blocks are never emitted. Every text has been through the redactor; a text the outbound gate still flags is replaced by a marker. `before` is the byte offset to send back for the previous page, null at the start of the file. */ export interface ActivityChat { contractVersion: string; sessionId: string; /** null for the session's own transcript (the orchestrator). */ agentId: string | null; messages: Array<{ offset: number; role: "user" | "assistant"; at: string | null; blocks: Array<{ kind: "text"; text: string; } | { kind: "tool"; name: string; summary: string; toolUseId: string | null; } | { kind: "result"; toolUseId: string | null; text: string; isError: boolean; }>; }>; before: number | null; /** How many items the redactor replaced on this page. */ redacted: number; } /** What GET /v1/routines returns (`routine-registry.mjs list --json`): the routines saved with /multi-agent:save. Description and source are scrubbed. */ export interface Routines { contractVersion: string; routines: Array<{ name: string; description: string; createdAt: string | null; source: string | null; }>; } /** What DELETE /v1/routines/{name} returns. Without ?confirm: preview (the routine) with confirmToken and expiresAt. With it: removed, from `routine-registry.mjs remove`. A shipped command is never removed. */ export interface RoutineDelete { contractVersion: string; preview?: { name: string; description: string; createdAt: string | null; source: string | null; }; confirmToken?: string; expiresAt?: string; removed?: { name: string; removedDir: boolean; removedEntry: boolean; }; } /** What GET /v1/routines/shared returns (`routine-share.mjs browse`): the routines other site members shared that this machine may see, without bodies. available is false when sharing could not answer, with reason: no-usage-token (nothing to authenticate with), endpoint-not-allowed (not https and not loopback), unreachable, redirect-refused, unauthorized, or upstream-error; routines is then empty. importedAs is the local routine imported from that shared id, or null. Descriptions are scrubbed. */ export interface SharedRoutines { contractVersion: string; available: boolean; reason?: "no-usage-token" | "endpoint-not-allowed" | "unreachable" | "redirect-refused" | "unauthorized" | "upstream-error"; routines: Array<{ id: string; name: string; owner: string; version: number; description: string; descriptionTr: string | null; sha256: string | null; updatedAt: string | null; mine: boolean; importedAs: string | null; }>; } /** What GET /v1/routines/shared/{id} returns (`routine-share.mjs fetch`): one shared routine with its body, after the body was checked against its sha256, with the payload digest an import confirms. localNameTaken is true when a routine or any command directory holding a SKILL.md (shipped, or a local-only command the registry does not track) already has its name here, so an import needs another name. */ export interface SharedRoutine { contractVersion: string; routine: { id: string; name: string; owner: string; version: number; /** Exactly as import writes it into the frontmatter, unscrubbed; show it as text. */ description: string; descriptionTr: string | null; sha256: string; /** Hex SHA-256 of the canonical JSON of {argumentHint, body, description, descriptionTr, name}, keys sorted, no whitespace, an absent optional field as "" (routine-registry.mjs payloadDigest, equal to the sharing server's content digest): everything the import installs. */ digest: string; updatedAt: string | null; /** Exactly as import writes it into the frontmatter, unscrubbed; show it as text. */ argumentHint: string | null; /** The procedure text exactly as import installs it; its sha256 is sha256. */ body: string; }; localNameTaken: boolean; } /** The body of POST /v1/routines/shared/{id}/import. Step 1 is {} or {as} (the local name, when the shared one is taken); step 2 sends the confirmToken step 1 returned with the sha256 and the digest it showed, and nothing else. */ export interface SharedRoutineImportRequest { contractVersion: string; /** The local name. One path segment, and never the reserved name shared. */ as?: string; /** The confirmToken the preview returned. Single use, bound to the route and the shared id. */ confirmToken?: string; /** The sha256 the preview showed. The import is refused unless the body still hashes to it. */ sha256?: string; /** The payload digest the preview showed. The import is refused unless the name, both descriptions, the argument hint and the body still hash to it. */ digest?: string; } /** What POST /v1/routines/shared/{id}/import returns. Step 1: preview (the routine with its full body, its sha256, the description, descriptionTr and argument hint exactly as they become frontmatter, the payload digest over all of them, and targetName, the local name it would get) with confirmToken and expiresAt; nothing is written. Step 2: imported, the registry entry routine-share.mjs wrote. The frontmatter is rebuilt locally and the routine is never run. A taken name is 409 name-taken, a sha256 or digest other than the previewed one 409 confirm-mismatch, a routine changed since the preview (any field) 409 state-moved, an unattended server 409 unattended-refused. */ export interface SharedRoutineImport { contractVersion: string; preview?: { id: string; name: string; owner: string; version: number; /** Exactly as import writes it into the frontmatter, unscrubbed; show it as text before the confirmation. */ description: string; descriptionTr: string | null; sha256: string; /** Hex SHA-256 of the canonical JSON of {argumentHint, body, description, descriptionTr, name}, keys sorted, no whitespace, an absent optional field as "" (routine-registry.mjs payloadDigest, equal to the sharing server's content digest): everything the import installs. */ digest: string; updatedAt: string | null; /** Exactly as import writes it into the frontmatter, unscrubbed; show it as text before the confirmation. */ argumentHint: string | null; /** The procedure text exactly as import installs it; its sha256 is sha256. */ body: string; targetName: string; }; confirmToken?: string; expiresAt?: string; imported?: { name: string; description: string; source: string | null; sha256: string; /** The payload digest of what was installed (routine-registry.mjs payloadDigest). */ digest: string; sharedId: string; }; } /** What GET /v1/stack?repo= returns (`stack-toggle.mjs status --json`): the stacks a repository enables in .claude/settings.json and every marketplace plugin with its skills. manifestVerified is false when the marketplace manifest could not be read and the plugin list is the convention. */ export interface Stack { contractVersion: string; stacks: Array; knownStacks: Array; plugins: Array<{ name: string; enabled: boolean; alwaysOn: boolean; stack: string | null; skills: Array; }>; manifestVerified: boolean; } /** The body of POST /v1/stack. The first request names repo (a name from GET /v1/repos or its path) and stacks (as /multi-agent:stack takes them, aliases allowed); the second sends only confirmToken. */ export interface StackRequest { contractVersion: string; repo?: string; stacks?: Array; confirmToken?: string; } /** What POST /v1/stack returns (`stack-toggle.mjs set`). Step one: preview {stacks, changed, enabledPlugins, dropped} with confirmToken and expiresAt, nothing written. Step two: the written enabledPlugins, the keys that changed and written. */ export interface StackChange { contractVersion: string; preview?: { stacks: Array; changed: Array; enabledPlugins: { [key: string]: boolean; }; dropped: Array; }; confirmToken?: string; expiresAt?: string; stacks?: Array; enabledPlugins?: { [key: string]: boolean; }; changed?: Array; dropped?: Array; written?: boolean; } /** The body of POST /v1/autopilot/on. The first request names the selection (repos, by nameWithOwner, each already in the autopilot config) and gets a preview and a confirm token; the second sends only the token and turns the mode on for exactly what was previewed. An empty selection is refused: the mode is never turned on without a repository. */ export interface AutopilotOnRequest { contractVersion: string; repos?: Array; /** Save the selection without scheduling anything. */ configureOnly?: boolean; confirmToken?: string; } /** What POST /v1/autopilot/on returns (`autopilot-control.mjs on-preview`, then `on`). Step one: preview {keep, drop, probe, configureOnly} with confirmToken and expiresAt. Step two: enabled and scheduled say whether the schedule was loaded; it is not when configureOnly was asked or a credential probe failed, and probe says which. */ export interface AutopilotOn { contractVersion: string; preview?: { keep: Array; drop: Array; probe: { ready: boolean; problems: Array; warnings: Array; }; configureOnly: boolean; }; confirmToken?: string; expiresAt?: string; enabled?: boolean; scheduled?: boolean; awake?: boolean | null; repos?: Array; dropped?: Array; probe?: { ready: boolean; problems: Array; warnings: Array; }; } /** The body of POST /v1/runs/{id}/steer. The first request carries text (verbatim, up to 4000 characters) and gets a preview and a confirm token bound to the run and that text; the second carries only confirmToken. */ export interface SteerRequest { contractVersion: string; text?: string; confirmToken?: string; } /** What POST /v1/runs/{id}/steer returns (`steer-run.mjs`). Step one: preview {text, status, currentPhase, replaces} with confirmToken and expiresAt, nothing written. Step two: the instruction is queued as the run's pendingSteer and applied at the entry to its next phase; replaced is the unconsumed instruction it replaced, or null. */ export interface Steer { contractVersion: string; taskId: string; queuedAt?: string; replaced?: string | null; status?: string | null; currentPhase?: number | null; preview?: { text: string; status: string | null; currentPhase: number | null; replaces: string | null; }; confirmToken?: string; expiresAt?: string; } /** What GET /v1/ledger returns and `office-ledger.mjs --json` prints: tokens and estimated USD for today, this week (from Monday) and this month, in local time, broken down by run, repository, model and phase. A run's numbers come from its tracker-state.json when the tracker carries tokens, else from the usage records of the transcripts tied to it; a run with neither is not-measured, and its usd and tokens are null, never 0. Sessions no run claims are counted apart as outside the pipeline. Prices come from cost-table.json; a cache write is priced at 1.25 times input. Every amount names its source. */ export interface Ledger { contractVersion: string; generatedAt: string; prices: { table: "cost-table.json"; verifiedAt: string | null; ageDays: number | null; stale: boolean; warning: string | null; }; windows: { today: LedgerWindow; week: LedgerWindow; month: LedgerWindow; }; } /** tracker-state: the pipeline's own ledger; transcript: derived from the host's usage records; mixed: a sum of both kinds; not-measured: nothing could be read, so the numbers are null. */ export type LedgerSource = "tracker-state" | "transcript" | "mixed" | "not-measured"; export type LedgerTokens = { in: number; out: number; cacheRead: number; cacheWrite: number; } | null; export interface LedgerAmount { tokens: LedgerTokens; usd: number | null; source: LedgerSource; /** Usage records whose model has no price; their tokens are counted, their cost is not. */ unpriced: number; } export interface LedgerRow { key: string; /** On byRun rows: the run repository. */ repo?: string | null; tokens: LedgerTokens; usd: number | null; source: LedgerSource; unpriced: number; } export interface LedgerWindow { since: string; total: LedgerAmount; outsidePipeline: LedgerAmount; /** Task ids of runs active in the window whose cost could not be measured. */ notMeasured: Array; byRun: Array; byRepo: Array; byModel: Array; byPhase: Array; } /** What GET /v1/learning-curve returns and `learning-curve.mjs --json` prints: the metrics log folded per task and bucketed by the day each task first appeared, with the first-to-last trend of the headline numbers. A rate or ratio is null when nothing was recorded, never 0. ok is false, with a code, when there is no metrics log or no events in it; the CLI adds a reason, the server does not. */ export interface LearningCurve { contractVersion: string; ok: boolean; code?: "no-metrics" | "no-events" | "too-large"; reason?: string; /** The log generations left out because they were over the size cap. Absent when every generation was read. */ skipped?: (Array<"previous" | "current">); bucketDays?: number; buckets: Array<{ bucketStart: string; tasks: number; firstPassCleanRate?: LearningCurveRate; avgReviewCycles?: LearningCurveRate; reworkPerTask: number; tokensPerTask: number; cacheRatio?: LearningCurveRate; memoryPrecision?: LearningCurveRate; minedLessonsPerTask?: LearningCurveRate; offloadBytesSavedPerTask?: LearningCurveRate; }>; trend?: { from: string; to: string; firstPassCleanRate?: LearningCurveRate; avgReviewCycles?: LearningCurveRate; tokensPerTask?: LearningCurveRate; cacheRatio?: LearningCurveRate; memoryPrecision?: LearningCurveRate; } | null; } export type LearningCurveRate = number | null; /** What GET /v1/system returns and `system-status.mjs --json` prints: CPU load, memory, free disk and what the pipeline itself uses. Numbers only: no path, process argument, user name or host name. A value that could not be measured is null, never 0. */ export interface SystemStatus { contractVersion: string; generatedAt: string; cpu: { cores: number; /** Busy share of all cores over a short sampling window. */ usage: number | null; /** Load average over 1, 5 and 15 minutes. */ load: Array; }; memory: { totalMb: number; /** Total minus what the OS reports free; on macOS that counts the file cache as used. */ usedMb: number; }; disk: { home: SystemStatusDisk; /** The disk the run logs live on, when it is not the home disk; null when it is the same disk. */ logs: SystemStatusDisk; }; pipeline: { /** Claude Code processes running. */ sessions: number | null; /** multi-agent-mcp server processes running. */ toolkit: number | null; /** Their resident memory together. */ rssMb: number | null; /** Size of the run log folder; null when it could not be measured in time. */ logsMb: number | null; }; /** disk-low: under 10 percent of the home disk is free. cpu-busy: the 5-minute load is above the core count. */ warnings: (Array<"disk-low" | "cpu-busy">); } export type SystemStatusDisk = { totalMb: number; freeMb: number; } | null; /** What GET /v1/credentials returns and `office-credentials.mjs --json` prints: for each credential the pipeline knows by logical name, whether the store holds it and, with probe, whether its service accepted it. Never a value: lib/credential-inventory.sh reads each through the store with stdout discarded. Renewal stays in the terminal (/multi-agent:setup). */ export interface OfficeCredentials { contractVersion: string; generatedAt: string; probed: boolean; /** False when the inventory could not run on this host. */ available: boolean; credentials: Array<{ logical: string; state: "present" | "mapped-but-missing" | "unmapped"; reachability: "not-probed" | "reachable" | "auth-rejected" | "unreachable" | "no-host-configured" | "well-formed" | "not-probeable" | "malformed" | "no-credential" | "probe-error" | "server-error" | "tier-1-ready" | "tier-2-ready" | "tier-1-no-grant" | "unknown"; capability: string | null; }>; } /** What GET /v1/memory returns and `office-memory.mjs --json` prints: per repository, the code graph's age and size and how many learnings, past review findings and session notes the learning loop holds, with the newest learnings redacted and cut short. An empty shelf is reported, never left out. */ export interface OfficeMemory { contractVersion: string; generatedAt: string; shelves: Array<{ repo: string; graph: null | { builtAt: string | null; ageDays: number; sizeKb: number; }; learnings: number; findings: number; sessionNotes: number; recent: Array<{ kind: string | null; statement: string; at: string | null; }>; lastWrite: string | null; }>; } /** What GET /v1/server-room returns and `office-server-room.mjs --json` prints: every Claude Code session from the activity document with its current work, last step, tokens, estimated cost and duration; today's tokens per model; the skills called in the last 30 days from the local skill-usage log; and health lights read from health-report.mjs's JSON (never probed). The rack status is the health report's worst section. Local only. */ export interface OfficeServerRoom { contractVersion: string; generatedAt: string; rack: { status: OfficeServerRoomStatus; red: OfficeServerRoomCount; yellow: OfficeServerRoomCount; }; lights: Array<{ id: "doctor" | "hooks" | "toolkit" | "gate" | "errors" | "autopilot"; status: OfficeServerRoomStatus; /** health-report's own fixed-shape reason, or a fixed phrase; never a message from a failed source. Always English. */ reason: string; /** The reason as a health-messages catalogue message: a stable id plus its parameters, the same shape health-report.mjs --json carries beside each section reason. Absent when the source section carried none the catalogue knows. */ message?: { id: string; params?: Record; }; /** The message rendered in the panel page's language (prefs outputLanguage, the one the page is stamped with), else the English reason. */ text: string; checks?: (Array<"hook-coverage" | "hook-reachability">); tags?: Array<{ tag: string; count: OfficeServerRoomCount; }>; }>; sessions: Array<{ id: string; sessionId: string | null; kind: string; repo: string; title: string | null; /** The task in progress, else the title, else the command. */ work: string | null; /** What the seat holding the work is doing, else the run's now line. */ lastStep: string | null; phase: string | null; tokens: { in: OfficeServerRoomCount; out: OfficeServerRoomCount; cached: OfficeServerRoomCount; } | null; estUsd: number | null; costSource: string; elapsedSeconds: number | null; live: boolean | null; waitingForYou: boolean; }>; today: null | { since: string | null; models: Array<{ model: string; input: OfficeServerRoomCount; output: OfficeServerRoomCount; cacheRead: OfficeServerRoomCount; cacheCreation: OfficeServerRoomCount; messages: OfficeServerRoomCount; usd: number | null; }>; totals: { input: OfficeServerRoomCount; output: OfficeServerRoomCount; cacheRead: OfficeServerRoomCount; cacheCreation: OfficeServerRoomCount; usd: number; }; unpricedModels: Array; truncatedFiles: OfficeServerRoomCount; estimated: true; }; /** The last 30 days of the local skill-usage log (skill-usage.mjs summary): calls and failed calls in total, the ten most used skills, and how many installed skills were not called at all. Null when the log cannot be read. Skill names only; the log holds no arguments, prompts or output. */ skills: null | { /** False when prefs turn the log off (skillUsage.enabled false or usageLog.optOut true); rows written earlier are still counted. */ enabled: boolean; windowDays: OfficeServerRoomCount; total: OfficeServerRoomCount; errors: OfficeServerRoomCount; top: Array<{ name: string; count: OfficeServerRoomCount; errors: OfficeServerRoomCount; lastUsed: string | null; }>; unused: OfficeServerRoomCount; /** Whether the log's first row is older than the window. While false, unused is not yet a prune list. */ coversWindow?: boolean; /** Time of the log's first row, or null when the log is empty. */ coverageStart?: string | null; }; health: null | { generatedAt: string | null; probed: false; status: OfficeServerRoomStatus; }; } export type OfficeServerRoomStatus = "green" | "yellow" | "red"; export type OfficeServerRoomCount = number; /** What GET /v1/mcp-health returns and `mcp-health.mjs --json` prints: per MCP server and tool, the calls, the server-side failures and the minute of the last failure over the last windowDays, from the local failure log and call counter the hooks write. Successful calls are counted only while usage counting is on: callsCounted is false when it is off or no counter file exists, and then calls holds only failed calls. A call that failed is a call, so calls includes failed ones; failures leaves out the errors that say nothing about the server (invalid input, a refusal, an interrupt). A server is named only from the shipped public list, any other is `private` with one `private` tool; a tool is named only from the shipped tool list of this product's own server, any other is `other`. skipped names a source left out because it was over the size cap or could not be read. Names, counts and minutes only. */ export interface McpHealth { contractVersion: string; generatedAt: string; ok: true; windowDays: number; callsCounted: boolean; servers: Array<{ server: "multi-agent" | "claude_ai_Figma" | "figma" | "XcodeBuildMCP" | "private"; calls: number; failures: number; lastFailure: null | string; tools: Array<{ tool: string; calls: number; failures: number; lastFailure: null | string; }>; }>; totals: { calls: number; failures: number; }; skipped: (Array<"calls" | "failures">); } /** What GET /v1/archive returns and `office-archive.mjs --json` prints: per repository, the newest decisions with their rationale, security notes and learnings from the learnings ledger (entries their feedback retired, and entries a later entry superseded, are left out and counted apart), and the hubs, clusters, surprising connections and questions of the code graph report when one exists. Learnings promoted across repositories sit apart under `global`. Every text is redacted and cut short. Local only: it never leaves this machine. */ export interface OfficeArchive { contractVersion: string; generatedAt: string; repos: Array; /** The global ledger (written only by learnings-ledger.mjs promote --accept) on a shelf of its own, in the same shape as a repository's with `repo` set to `_global` and `graph` null; null until a learning has been promoted. Never listed in `repos`. */ global?: null | OfficeArchiveShelf; } export type OfficeArchiveCount = number; export type OfficeArchiveText = string; export type OfficeArchiveCell = string; export type OfficeArchiveAt = string | null; export type OfficeArchiveScope = string | null; export interface OfficeArchiveEntry { statement: OfficeArchiveText; scope: OfficeArchiveScope; at: OfficeArchiveAt; } export interface OfficeArchiveShelf { repo: string; counts: { decisions: OfficeArchiveCount; securityNotes: OfficeArchiveCount; learnings: OfficeArchiveCount; /** Entries left out because their feedback retired them. */ retired: OfficeArchiveCount; /** Entries left out because a later entry names them in its supersedes list. An entry both retired and superseded counts as retired. */ superseded: OfficeArchiveCount; }; decisions: Array<{ statement: OfficeArchiveText; scope: OfficeArchiveScope; at: OfficeArchiveAt; rationale: string | null; confidence: "low" | "medium" | "high" | null; }>; securityNotes: Array; learnings: Array<{ kind: "fact" | "convention" | "rejected-preference"; statement: OfficeArchiveText; scope: OfficeArchiveScope; at: OfficeArchiveAt; }>; graph: null | { builtAt: OfficeArchiveAt; hubs: Array<{ name: OfficeArchiveCell; kind: OfficeArchiveCell; degree: number; path: OfficeArchiveCell; }>; clusters: Array<{ files: number; cohesion: number; around: OfficeArchiveCell; where: OfficeArchiveCell; }>; surprising: Array<{ from: OfficeArchiveCell; to: OfficeArchiveCell; kind: OfficeArchiveCell; links: number; }>; questions: Array; }; } /** What POST /v1/prune-logs returns. The preview (body {olderThanDays}) is prune-logs.sh's dry run for that age with a confirm token; the confirmation (body {confirmToken}) runs it again with the same age and --yes. The audit trail, the metrics corpus and task counters are never removed, and a folder written in the last minutes is spared. */ export interface PruneLogs { contractVersion: string; olderThanDays: 7 | 30 | 90; applied: boolean; count: number; freedMb: number; /** project/task folders, at most 200 listed. */ folders: Array; confirmToken?: string; expiresAt?: string; } /** The body of POST /v1/prune-logs. Step 1 names the age in days (7, 30 or 90); step 2 sends only the confirmToken step 1 returned. */ export interface PruneLogsRequest { contractVersion: string; olderThanDays?: 7 | 30 | 90; /** The confirmToken the preview returned. Single use, bound to the route. */ confirmToken?: string; } /** What POST /v1/disk-clean returns: the disk cleaner's report per category for a measure, a preview (with a confirm token) or an apply. Paths are real paths on this machine, so the route is local-only. */ export interface DiskClean { contractVersion: string; mode: "measure" | "preview" | "applied"; /** The server runs unattended: it measures the cleaner's unattended set only and refuses a preview and an apply. */ unattended: boolean; disk: { freeBytes: number | null; totalBytes: number | null; /** Free space now plus reclaimableBytes. */ expectedFreeBytes: number | null; /** Free space measured after an apply. */ afterFreeBytes?: number | null; }; /** What an apply of the listed categories would free; a category whose tool is running is measured but left out. */ reclaimableBytes: number; categories: Array<{ id: "derived-data" | "repo-build" | "xctest-devices" | "xcode-caches" | "archives" | "device-support" | "sim-unavailable" | "sim-caches" | "sim-device-caches" | "sim-runtimes" | "spm-cache" | "pods-cache" | "gradle-cache" | "js-caches" | "homebrew" | "tmp-builds" | "pipeline-scratch" | "claude-scratch" | "claude-jobs" | "agent-worktrees" | "dev-caches" | "old-logs" | "pipeline-logs" | "ds-store" | "trash" | "transcripts" | "test-artifacts"; label: string; items: number; bytes: number; /** The largest items, real paths and sizes. */ top: Array<{ path: string; bytes: number; }>; more: number; /** How many items were kept, per reason. */ kept: { [key: string]: number; }; /** Why the category is measured but not applied (its tool is running). */ blocked: string | null; note: string | null; /** The cleaner's unattended-safe set. */ safe: boolean; /** The request flag this category needs as well as its id. */ optIn: "trash" | "transcripts" | "test-artifacts" | null; }>; /** Leftover session processes found; information only, never stopped. */ orphans: number; applied?: { removed: number; failed: number; freedBytes: number | null; failures: Array<{ category: string; path: string; reason: string; }>; held: Array<{ category: string; reason: string; }>; }; confirmToken?: string; expiresAt?: string; } /** The body of POST /v1/disk-clean. With no other field it measures (the disk cleaner's dry run, no token). With categories it previews exactly those, each one from the cleaner's allow-list, and returns a confirm token; an opt-in category must also send its own flag as true. Step 2 sends only the confirmToken. */ export interface DiskCleanRequest { contractVersion: string; /** The categories to preview, by the disk cleaner's category id (disk-cleaner.mjs --list). */ categories?: (Array<"derived-data" | "repo-build" | "xctest-devices" | "xcode-caches" | "archives" | "device-support" | "sim-unavailable" | "sim-caches" | "sim-device-caches" | "sim-runtimes" | "spm-cache" | "pods-cache" | "gradle-cache" | "js-caches" | "homebrew" | "tmp-builds" | "pipeline-scratch" | "claude-scratch" | "claude-jobs" | "agent-worktrees" | "dev-caches" | "old-logs" | "pipeline-logs" | "ds-store" | "trash" | "transcripts" | "test-artifacts">); /** Required with the trash category: it holds files the user deleted, which cannot be recovered afterwards. */ trash?: true; /** Required with the transcripts category: resume and past-session search read them. */ transcripts?: true; /** Required with the test-artifacts category: a recording or a result bundle can be the only evidence of a failure anybody still has. */ "test-artifacts"?: true; /** The confirmToken the preview returned. Single use, bound to the route and the previewed categories. */ confirmToken?: string; } /** What GET /v1/runs/{id}/results returns (`run-results.mjs --json`): what a run produced, read from its own files. diff from agent-state diffRisk or .review-diff.txt; findings from triage-output.json or agent-state review; tests from the test-summary gate and uiTest; evidence the screenshot names under .pipeline/evidence; analysis the documents an analysis run wrote. A part with no source is null. Text is scrubbed and redacted; paths are reduced to file names. */ export interface RunResults { contractVersion: string; taskId: string; diff: { files: number; added: number | null; removed: number | null; maxScore: number | null; signals: Array; changed: Array; source: string; } | null; findings: { approved: boolean | null; items: Array<{ severity: string; file: string | null; line: number | null; issue: string; fix: string | null; reviewer: string | null; verdict: string; }>; total: number; source: string; } | null; tests: { status: string | null; passed: number | null; failed: number | null; skipped: number | null; uiTest: { ran: boolean; status: string | null; notRunReason: string | null; } | null; source: string; } | null; evidence: Array<{ name: string; phase: "before" | "after" | null; }>; analysis: { documents: Array<{ name: string; text: string | null; }>; confluencePages: number; jiraIssueKey: string | null; } | null; } /** What GET /v1/runs/{id}/evidence/{name} returns (`run-results.mjs --evidence `): one screenshot from the run's .pipeline/evidence directory, base64. name is a bare png or jpg file name; one that resolves outside the directory is not found. */ export interface RunEvidence { contractVersion: string; taskId: string; name: string; mime: "image/png" | "image/jpeg"; data: string; } /** What GET /v1/issues/{key}/maturity returns (`work-items.mjs maturity `, from lib/issue-fetcher.sh): the maturity check the pipeline runs before it starts on an issue. key is a Jira key, owner/repo#N or #N. Blockers stop a run; warnings are asked about. Text is redacted. */ export interface IssueMaturity { contractVersion: string; key: string; kind: "jira" | "github" | "freetext"; title: string; type: string | null; status: string | null; maturity: { score: number | null; blockers: Array; warnings: Array; summary: string | null; }; description: string | null; } /** What GET /v1/prs returns (`work-items.mjs prs`): open pull requests where you are asked to review or are the author. sources says per host whether it was read; Bitbucket listing is not implemented and says so rather than showing an empty list. url is dropped under redact. */ export interface Prs { contractVersion: string; items: Array<{ source: "github" | "bitbucket"; /** The GitHub login the pull request was listed under, when gh is logged in to more than one account (personal and corporate). Null for Bitbucket. */ account?: string | null; repo: string; number: number; title: string; url: string | null; author: string | null; updatedAt: string | null; role: "reviewer" | "author"; }>; sources: Array<{ source: string; ok: boolean; count: number; reason?: string; }>; } /** What GET /v1/prs/reach returns (`work-items.mjs reach`): for each open GitHub pull request (at most 20), how many files in the repository's own code graph depend on what it changes, widest first. Changed paths serve only as keys into the local graph and are never returned. A pull request that cannot be measured carries reach null and its reason. */ export interface PrReach { contractVersion: string; /** Reverse-dependency depth the count was taken at. */ depth: number; items: Array<{ source: "github" | "bitbucket"; repo: string; number: number; /** The knowledge-folder project whose graph answered, or null. */ project: string | null; /** Files the pull request changes. */ changed?: number; /** Of those, files the graph knows. */ inGraph?: number; /** Files that depend on the changed ones, within depth. Null when not measured. */ reach: number | null; /** Why reach is null. */ reason?: string; }>; } /** The body of POST /v1/runs/{id}/review-verdict: empty for the preview, confirmToken to post. The verdict is never chosen by the request; it follows from the review's recorded findings. */ export interface ReviewVerdictRequest { contractVersion: string; confirmToken?: string; } /** What POST /v1/runs/{id}/review-verdict returns (`work-items.mjs verdict [--post]`). Only a finished review whose every finding is triaged (accepted, rejected or deferred) is previewed (409 review-incomplete otherwise). The preview carries findingsDigest, the hash of the findings it was made from, and the decision lib/post-pr-review.sh would post (approve with no accepted blocking or important finding, else needs-work), a confirmToken bound to that decision and digest, and expiresAt; a confirmation after either changed is 409 confirm-mismatch; the confirmation runs post-pr-review.sh, which posts the comments and the verdict with the user's own credential, and says posted. */ export interface ReviewVerdict { contractVersion: string; taskId: string; provider: "github" | "bitbucket-server" | null; prNumber: number | null; decision: "approve" | "needs-work"; acceptedBlocking: number; acceptedImportant: number; findings: number; posted?: boolean; confirmToken?: string; expiresAt?: string; findingsDigest: string; } /** What GET /v1/tools returns (`toolkit-tools.mjs list`): every tool the registered multi-agent MCP server serves, with its category (the name's prefix), risk from its own annotations (readOnlyHint read, destructiveHint high, else low) and its inputSchema, from which a client builds the form. Calls are denied by default; allowed says which tools can be called and reason why the others cannot. */ export interface Tools { contractVersion: string; tools: Array<{ name: string; title: string | null; category: string; description: string; risk: "read" | "low" | "high"; inputSchema: Record; /** Whether POST /v1/tools/{name}/call accepts this tool: only a readOnlyHint tool whose inputSchema takes no location (path, URL, file, directory, output, project, root) and that is not in the web or context family. */ allowed: boolean; reason: string | null; }>; /** The exact toolkit version the panel starts: the registration's own when it names one, else the version the install recorded from the release. */ version?: string | null; } /** The body of POST /v1/tools/{name}/call: the tool's arguments, which must satisfy its inputSchema. At most 64 KiB. */ export interface ToolCallRequest { contractVersion: string; arguments?: Record; } /** What POST /v1/tools/{name}/call returns (`toolkit-tools.mjs call`): the tool's result as text, JSON (as text) and images (base64, image types only). Every text is redacted. */ export interface ToolCall { contractVersion: string; tool: string; risk: "read" | "low" | "high"; isError: boolean; content: Array<{ kind: "text" | "json" | "image"; text?: string; mime?: string; data?: string; }>; } /** What GET /v1/services/confluence, /crashlytics and /figma return (`service-read.mjs`): one Confluence page, one Crashlytics issue or one Figma frame render, through the pipeline's own clients. Text is redacted; a frame comes back as base64 PNG. */ export interface ServiceRead { contractVersion: string; service: "confluence" | "crashlytics" | "figma"; pageId?: string | null; title?: string; body?: string; apiContracts?: number; type?: string | null; occurrences?: number | null; impactedUsers?: number | null; stackTrace?: Array; fileKey?: string; nodeId?: string; mime?: "image/png"; data?: string; } /** What GET /v1/permissions returns: the host permission prompts waiting on the user. available is false while the host records none where another process can read them; requests is then empty and reason says so. When available, each request names its session, the tool and a redacted summary. */ export interface Permissions { contractVersion: string; available: boolean; reason: string | null; requests: Array<{ id: string; sessionId: string; tool: string; summary: string; at: string; }>; } /** Every non-2xx body contract-server.mjs sends. `error` is a fixed code a client switches on; `message` is for a person and names no path, host or token. `errors` lists schema or rule violations for invalid-body and invalid-request; `supported` lists the majors ?v= accepts for unsupported-version. run-active and not-resumable answer POST /v1/runs/{id}/resume; confirm-expired and confirm-mismatch answer the confirming request of a kill or gc. */ export interface ContractError { contractVersion: string; error: "unauthorized" | "forbidden-host" | "forbidden-origin" | "not-found" | "method-not-allowed" | "invalid-query" | "unsupported-version" | "unsupported-media-type" | "invalid-body" | "invalid-request" | "no-launch-shape" | "not-waiting" | "wrong-question" | "wrong-arity" | "not-an-option" | "state-moved" | "launch-disabled" | "repo-not-allowed" | "run-active" | "not-resumable" | "confirm-expired" | "confirm-mismatch" | "unattended-profile-missing" | "workspace-not-trusted" | "no-selection" | "repo-not-configured" | "invalid-config" | "not-installed" | "repo-ambiguous" | "unreadable-settings" | "not-removable" | "not-steerable" | "too-many-streams" | "no-review" | "upstream-failed" | "tool-not-allowed" | "busy" | "review-incomplete" | "host-not-allowed" | "internal" | "unknown-job" | "command-not-installed" | "invalid-repo" | "invalid-args" | "room-busy" | "sandbox-unavailable" | "launch-failed" | "guard-missing" | "name-taken" | "already-registered" | "not-registered" | "unattended-refused" | "not-applied" | "changed"; message: string; errors?: Array; supported?: Array; /** What fixes the refusal: for unattended-profile-missing the installer step that writes the unattended permission profile; for workspace-not-trusted opening Claude Code once in the repository to accept the trust prompt (the path is left out under redact). */ remedy?: string; } /** What GET /v1/settings returns and POST /v1/settings returns after a change: the output language, the fable rung and model routing. A preview (the first POST) adds the change it would make and a confirmToken. */ export interface OfficeSettings { contractVersion: string; language: "en" | "tr"; /** Whether the fable rung is in play. */ model: "on" | "off"; /** Whether model routing is on. */ route: "on" | "off"; change?: { setting: "language" | "model" | "route"; from: string; to: string; /** Present when turning routing on brings back a saved free provider chain: the confirmation names it. */ freeChain?: { enabled: true; allowTraining: boolean; }; }; confirmToken?: string; expiresAt?: string; } /** The body of POST /v1/settings. Step 1 names the setting and its new value; step 2 sends only the confirmToken step 1 returned. */ export interface OfficeSettingsRequest { contractVersion: string; setting?: "language" | "model" | "route"; value?: "en" | "tr" | "on" | "off"; /** The confirmToken the preview returned. Single use, bound to the route. */ confirmToken?: string; }