import { type CreateBriefInput } from "../api/briefs.js"; import { type CreateBriefTypeInput } from "../api/brief-types.js"; import type { Brief, BriefComment, BriefStatus, BriefTask, BriefType, PagedResult } from "../api/schema.js"; /** * CLI runners for the `scai ops brief …` command family. * * Each runner resolves the env, acquires a brief-scoped token, calls * the library helper, then prints either human or JSON output via * `Logger`. The env+token+client orchestration lives in the exported * `resolveBriefClient()` (see `../client.ts`) — the SDK seam these * runners and the MCP tools share; `prepareBriefClient()` only pairs it * with a CLI `Logger`. * * Read verbs: * - `runBriefList` — list briefs * - `runBriefGet` — read one brief by id * - `runBriefTypes` — list brief types * - `runBriefTypeGet` — read one brief type by id * - `runBriefTodosList`— list to-dos (optionally filtered to a brief) * - `runBriefCommentsList` — list comments (optionally filtered) * * BriefType write verbs (verified 2026-05-15): * - `runBriefTypeCreate` / `runBriefTypeUpdate` / `runBriefTypeDelete` * * Brief instance write verbs: * - `runBriefUpdate` — partial PUT of a brief; pass `patch.status` to move workflow * - `runBriefDelete` — delete a brief (SDK `deleteBrief` verified) * - `runBriefCommentAdd` — post a comment to a brief (UNVERIFIED body) * * Each write runner honours an `options.whatIf` flag — when set, it * skips the API call and emits a plan-only summary. The CLI layer wires * this via `withApplyGate` so destructive verbs dry-run by default. */ export interface RunBriefBaseOptions { config?: string; /** Explicit organization id (`--org-id`). The Brief API is org-scoped. */ orgId?: string; /** Env profile name — used only to derive its `organizationId`. */ environmentName?: string; verbose?: boolean; trace?: boolean; quiet?: boolean; json?: boolean; logFile?: string; } /** * Identity + linkage fields of a brief — everything a tenant scan or * delete cascade needs to match and act on a brief, without the heavy * `fields` (RichText ProseMirror docs), `tasks`, and `comments` bodies * that dominate a full `Brief`. Emitted by `runBriefList({ lean })`. */ export type LeanBrief = Pick; export declare const runBriefList: (options: RunBriefBaseOptions & { limit?: number; locale?: string; lean?: boolean; }) => Promise>; export declare const runBriefGet: (options: RunBriefBaseOptions & { briefId: string; }) => Promise; export declare const runBriefTypes: (options: RunBriefBaseOptions) => Promise>; export declare const runBriefTypeGet: (options: RunBriefBaseOptions & { briefTypeId: string; }) => Promise; export declare const runBriefTypeCreate: (options: RunBriefBaseOptions & { input: CreateBriefTypeInput; whatIf?: boolean; }) => Promise; export declare const runBriefTypeUpdate: (options: RunBriefBaseOptions & { briefTypeId: string; input: CreateBriefTypeInput; whatIf?: boolean; }) => Promise<{ id: string; } | { plan: { id: string; input: CreateBriefTypeInput; }; }>; export declare const runBriefTypeDelete: (options: RunBriefBaseOptions & { briefTypeId: string; whatIf?: boolean; }) => Promise<{ id: string; deleted: boolean; }>; export declare const runBriefTodosList: (options: RunBriefBaseOptions & { briefId?: string; assignees?: boolean; limit?: number; }) => Promise>; export declare const runBriefCommentsList: (options: RunBriefBaseOptions & { briefId?: string; limit?: number; }) => Promise>; /** * Create a brief instance from a `CreateBriefInput`. Mirrors * `runBriefTypeCreate` — honours `whatIf` for a plan-only dry run. The * SDK `createBrief` is verified against the Agents tenant. */ export declare const runBriefCreate: (options: RunBriefBaseOptions & { input: CreateBriefInput; whatIf?: boolean; }) => Promise; /** * Update a brief instance by id with a partial patch (`PUT`). Accepts * any subset of `CreateBriefInput` plus an optional `status`. Mirrors * `runBriefTypeUpdate` — honours `whatIf` for a plan-only dry run. The * status-only PUT path is verified (2026-05-15); other partial fields * are wired the same way but not smoke-tested. */ export declare const runBriefUpdate: (options: RunBriefBaseOptions & { briefId: string; patch: Partial & { status?: BriefStatus; }; whatIf?: boolean; }) => Promise<{ id: string; } | { plan: { id: string; patch: Partial & { status?: BriefStatus; }; }; }>; /** * Delete a brief instance. Mirrors `runBriefTypeDelete` — honours * `whatIf` for a plan-only dry run. SDK `deleteBrief` is verified * against the Agents tenant. * * Pre-delete unlink: before issuing the DELETE we PUT * `{references: []}` to clear the brief's external references. The * dangling-reference bug on Orchestrate's `deleteProject` (which * tries to detach `project.briefs[]` entries before completing, and * 403s when those briefs are already gone) is downstream of briefs * that get deleted without clearing their references first. Doing * the unlink at the source — the brief side — gives Orchestrate's * reverse-view machinery a chance to clean up the project's * `briefs[]` while the brief is still alive. Best-effort: a failure * on the unlink step is logged but doesn't block the delete (the * brief still ends up gone, which is the user's goal; only the * downstream project might carry a dangling ref). * * Probed 2026-06-04: clearing references via updateBrief is a clean * no-op on briefs that have none; safe to apply unconditionally. */ export declare const runBriefDelete: (options: RunBriefBaseOptions & { briefId: string; whatIf?: boolean; }) => Promise<{ id: string; deleted: boolean; }>; /** * Post a comment to a brief. Verified against TestDemo 2026-06-03 — * `authorId` is required; the server records `author` as the * impersonated user while `createdBy` captures the actual caller. * Honours `whatIf`. */ export declare const runBriefCommentAdd: (options: RunBriefBaseOptions & { briefId: string; text: string; authorId: string; whatIf?: boolean; }) => Promise;