// Generated from the Trunk operation registry. Do not edit by hand. // Every response type below is the one the server is compile-checked to return. // Only exported declarations are public compatibility contract; non-exported helpers are inlined solely to keep this module standalone. /** * The domain, stated once. Everything else in Trunk — the verifiers, the * policy engine, the HTTP API, the MCP tools, the web UI — is typed against * these declarations, so "the primary interface is a typed API" is a property * of the code rather than a claim in the pitch. */ // --- tenancy ---------------------------------------------------------------- type WorkspaceKind = 'personal' | 'team'; type WorkspaceRole = 'owner' | 'admin' | 'member'; type WorkspaceAgentAccess = 'explicit' | 'read' | 'read_propose'; /** * The tenant. Every repository belongs to exactly one, and so does every agent; * a human reaches a workspace through a membership, because a person can * belong to several. */ interface Workspace { id: string; slug: string; display: string; kind: WorkspaceKind; created_at: string; } interface Membership { workspace_id: string; actor_id: string; role: WorkspaceRole; created_at: string; } /** * Proof that a caller may act inside a workspace, produced only where a * session or an API key is resolved and never built from request input. Core * functions take one rather than a bare id so that forgetting to scope a query * is a type error instead of a cross-tenant read. */ interface WorkspaceContext { workspace: Workspace; actor_id: string; role: WorkspaceRole; } // --- identity --------------------------------------------------------------- type Harness = | 'claude' | 'chatgpt' | 'claude-code' | 'codex' | 'cursor' | 'copilot' | 'gemini-cli' | 'opencode' | 'cline' | 'antigravity' | 'kiro' | 'amp' | 'devin' | 'windsurf' | 'goose' | 'aider' | 'roo-code' | 'unknown' | 'multiple'; export type ActorKind = 'agent' | 'human' | 'system' | 'github'; export type Op = 'read' | 'propose' | 'revert'; export interface Actor { /** Client-reported presentation metadata; never authorization evidence. */ harness?: Harness | null; id: string; /** Workspace-local agents/contributors; null for native humans/system actors. */ workspace_id: string | null; kind: ActorKind; /** Stable GitHub user ID; only non-authenticating external contributors. */ github_user_id?: string | null; handle: string; display: string; /** Only ever populated at issue time; the database stores a digest. */ api_key?: string | null; suspended: boolean; created_at: string; } /** An issued API key. The key itself is never stored, only its digest. */ export interface ApiKey { id: string; actor_id: string; name: string; /** Enough to recognise the key in a list, never enough to use it. */ preview: string | null; created_by: string | null; created_at: string; last_used_at: string | null; revoked_at: string | null; } export interface Scope { id: string; actor_id: string; repository_id: string; /** A service name, or `*` for every service in the repository. */ service: string; path_globs: string[]; ops: Op[]; created_at: string; } export interface Budget { actor_id: string; changes_per_day: number; max_diff_lines: number; max_files: number; } export interface Usage { actor_id: string; day: string; changes: number; usd: number; } /** What actually became of an actor's changes. Optionally scoped to a service. */ export interface TrackRecord { actor_id: string; service: string | null; proposed: number; landed: number; reverted: number; blocked: number; auto_landed: number; routed_to_human: number; rejected: number; revert_rate: number; autonomy_rate: number; mean_seconds_to_land: number | null; } export interface ActorProfile extends Omit { scopes: Scope[]; budget: Budget | undefined; usage_today: Usage; track_record: TrackRecord; by_service: TrackRecord[]; } // --- repository ------------------------------------------------------------- export type Criticality = 'low' | 'medium' | 'high' | 'critical'; export interface Repository { /** Missing in historical in-memory fixtures; persisted rows default to native. */ backend?: 'native' | 'github'; id: string; workspace_id: string; name: string; trunk_branch: string; created_at: string; } export interface Service { id: string; repository_id: string; name: string; criticality: Criticality; path_globs: string[]; } export type TrunkCommitKind = 'root' | 'land' | 'revert' | 'import' | 'reconcile'; export interface TrunkCommit { seq: number; repository_id: string; commit_sha: string; change_id: string | null; kind: TrunkCommitKind; message: string; author_id: string | null; ts: string; } // --- source ----------------------------------------------------------------- /** A branch the provider holds. `trunk` is the one Trunk itself lands on. */ export interface SourceBranch { name: string; head_commit: string; trunk: boolean; } export type SourceEntryKind = 'blob' | 'tree' | 'symlink' | 'submodule'; export interface SourceEntry { /** From the repository root, so it is also the address to browse to. */ path: string; name: string; kind: SourceEntryKind; } export interface SourceFile { path: string; /** Null when the blob is not text; `binary` says the same thing readably. */ text: string | null; /** The whole blob's size, which `text` may stop short of. */ bytes: number; truncated: boolean; binary: boolean; blob_sha: string; last_commit_sha: string; } // --- diff ------------------------------------------------------------------- type LineOp = '+' | '-' | ' '; interface DiffLine { op: LineOp; text: string; newLine: number | null; oldLine: number | null; } interface Hunk { header: string; oldStart: number; newStart: number; lines: DiffLine[]; } export type FileStatus = 'added' | 'modified' | 'deleted' | 'renamed'; interface DiffFile { path: string; oldPath: string; newPath: string; status: FileStatus; hunks: Hunk[]; added: DiffLine[]; removed: DiffLine[]; additions: number; deletions: number; } export interface DiffStats { files: number; additions: number; deletions: number; /** False only when a legacy stored diff cannot be parsed safely for display. */ available?: boolean; /** Presentation-only reason that the numeric counters are unavailable. */ error?: 'unparseable_diff'; } /** An added or removed line, tagged with where it came from. */ interface LocatedLine { file: string; line: number | null; text: string; } // --- evidence --------------------------------------------------------------- export type Severity = 'info' | 'notice' | 'warn' | 'critical'; export interface Citation { file: string; line: number | null; snippet: string; } /** One thing a verifier found, always traceable to a line of the diff. */ export interface Fact { code: string; severity: Severity; title: string; detail: string; citations: Citation[]; /** How many citations existed before truncation. */ cited: number; section?: SectionKey; verifier?: string; } export type SectionKey = | 'blast_radius' | 'tests' | 'surface' | 'migrations' | 'outbound' | 'permissions' | 'dependencies' | 'hygiene'; export interface Suite { name: string; passed: number; failed: number; skipped?: number; duration_ms?: number; /** Always false today: Trunk did not observe the run. */ attested?: boolean; } export interface Benchmark { name: string; before_ms: number; after_ms: number; } /** Results the author observed. Recorded, labelled, and weighted as hearsay. */ export interface ReportedResults { suites?: Suite[]; coverage_delta?: number; benchmarks?: Benchmark[]; } export interface SectionData { blast_radius: DiffStats & { services: string[]; code_files: number; test_files: number; doc_files: number; paths: { path: string; status: FileStatus; additions: number; deletions: number }[]; }; tests: { suites: Suite[]; test_files_touched: string[]; code_files_touched: number; skipped: number; coverage_delta: number | null; }; surface: { symbols_added: string[]; symbols_removed: string[]; signatures_changed: string[]; routes_added: string[]; routes_removed: string[]; }; migrations: { migrations: { file: string; status: FileStatus; reversible: boolean; ops: { op: string; severity: Severity; line: number; snippet: string }[]; }[]; }; outbound: { calls: { host: string; file: string; line: number | null; snippet: string }[] }; permissions: { grants: { kind: string; file: string; line: number | null; snippet: string }[]; revocations: { kind: string; file: string; line: number | null; snippet: string }[]; }; dependencies: { added: string[]; bumped: string[]; removed: string[] }; hygiene: { findings: { code: string; count: number }[] }; } export interface EvidenceSection { verifier: string; facts: Fact[]; data: SectionData[K]; } /** Any one section, with its key and data still paired. */ type AnySection = { [K in SectionKey]: EvidenceSection }[SectionKey]; export interface VerifierRun { name: string; version: number; ms: number; } export interface EvidenceBundle { change_id: string; base_commit: string; diff_digest: string; materialization?: { version: 'text-v1'; diff_digest: string }; service: string; sections: { [K in SectionKey]?: EvidenceSection }; counts: Record; worst_severity: Severity; facts: Fact[]; verifiers: VerifierRun[]; /** Stable over the diff and the derived facts; excludes the timestamp. */ digest: string; produced_at: string; } /** An evidence bundle as stored, with everything that was decided alongside it. */ export interface StoredEvidence extends EvidenceBundle { routing?: PolicyDecision; risk?: RiskVerdict; track?: TrackRecord; conflicts?: Staleness; } // --- verifiers -------------------------------------------------------------- /** The minimum a change must carry to be verifiable. */ interface Verifiable { id: string; base_commit: string; service: string; diff?: string | undefined; reported?: ReportedResults | null | undefined; } interface VerifierInput { files: DiffFile[]; /** Complete exact-base/patch-result text; absence never establishes harmlessness. */ fileContext?: { path: string; before: string | null; after: string | null }[]; /** Exact-base rename pairs and lines retained by the original patch. Copies are additions. */ renames?: { source: DiffFile; destination: DiffFile; retained: { oldLine: number; newLine: number }[]; }[]; services: Service[]; allowedHosts: string[]; reported: ReportedResults | null; change: Verifiable; } interface VerifierResult { facts: Fact[]; data: SectionData[K]; } interface Verifier { name: string; version: number; section: K; run(input: VerifierInput): VerifierResult; } // --- risk ------------------------------------------------------------------- export type Band = 'low' | 'elevated' | 'high' | 'critical'; export interface RiskFactor { kind: 'evidence' | 'blast_radius' | 'track_record' | 'freshness'; code: string; label: string; /** Positive raises the score; negative is earned autonomy. */ weight: number; severity: Severity; detail?: string; section?: SectionKey; } export interface RiskVerdict { model: string; score: number; band: Band; multiplier: number; factors: RiskFactor[]; computed_at: string; evidence_digest: string; /** Attached when the verdict is stored on a change. */ routing?: PolicyDecision; } // --- policy ----------------------------------------------------------------- export type Route = 'auto_land' | 'human_review' | 'block'; export interface PolicyCondition { evidence_code?: string[]; min_severity?: Severity; risk_band?: Band[]; service?: string[]; service_criticality?: Criticality[]; author_kind?: ActorKind[]; revert_rate_above?: number; landed_below?: number; changed_lines_above?: number; scope_violation?: boolean; budget_exceeded?: boolean; stale_base?: boolean; } export interface PolicyRule { id: string; when?: PolicyCondition; then: Route; reason: string; } export interface Policy { id?: string; repository_id: string; version: number; rules: PolicyRule[]; updated_by?: string | null; updated_at?: string; } export interface ConditionCheck { key: string; ok: boolean; explain: string; } export interface PolicyDecision { route: Route; rule_id: string | null; reason: string; matched_on: string[]; trace: { rule_id: string; then: Route; matched: boolean; checks: ConditionCheck[] }[]; } interface PolicyContext { evidence: EvidenceBundle; risk: Pick; track: TrackRecord | null; service: Pick; author: Pick | null; scopeViolation?: string | null; budgetExceeded?: string | null; baseIsStale?: boolean; } // --- changes ---------------------------------------------------------------- export type ChangeStatus = | 'verifying' | 'awaiting_decision' | 'approved' | 'landed' | 'reverted' | 'blocked' | 'rejected' | 'no_change'; type LandingReadiness = 'uncontrolled' | 'draft' | 'ready'; export interface Spec { goal?: string; non_goals?: string[]; acceptance_criteria?: string[]; constraints?: string[]; } export type TraceKind = 'read' | 'search' | 'reason' | 'edit' | 'test' | 'bench' | 'tool' | 'note' | 'prompt' | 'skill'; interface TraceContext { prompt?: { role: 'system' | 'developer' | 'user' | 'assistant'; content: string } | null; tool_call?: { name: string; call_id?: string; arguments?: string; result?: string; status?: 'started' | 'succeeded' | 'failed'; } | null; skill?: { name: string; source?: string; content?: string } | null; /** Agent-supplied explanation, not private model chain-of-thought. */ reasoning?: string | null; } interface TraceStepInput extends TraceContext { kind: TraceKind; summary: string; detail?: string | null; ts?: string; tokens?: number; usd?: number; } export interface TraceStep extends TraceContext { id: string; change_id: string; seq: number; ts: string; kind: TraceKind; summary: string; detail: string | null; tokens: number; usd: number; } export type Verdict = 'approve' | 'reject' | 'request_changes'; export interface Decision { id: string; change_id: string; actor_id: string; verdict: Verdict; /** The evidence this decision was granted against. */ evidence_digest: string; note: string | null; stale: boolean; created_at: string; actor?: string; } export type DecisionRecordOutcome = | { state: 'recorded'; decision_id: string; verdict: Verdict; evidence_digest: string; revision: number; /** Current value when read back successfully; null when post-commit state readback is unavailable. */ stale: boolean | null; } | { state: 'not_recorded'; verdict: 'reject'; revision: number; reason: 'pre_evidence_termination'; }; export type DecisionLandingOutcome = | { state: 'not_attempted' } | { state: 'deferred' } | { state: 'succeeded'; commit_sha: string; land_seq: number } | { state: 'failed'; code: string } | { state: 'indeterminate'; code: string }; interface Revert { id: string; change_id: string; actor_id: string; reason: string; detected_by: string | null; commit_sha: string | null; created_at: string; } /** The change object: intent, spec, diff, evidence, trace, verdict. */ interface CandidateIntegration { state: 'integrating' | 'integrated' | 'conflict'; paths?: string[] | null; source_commit: string | null; source_base_commit: string; base_commit: string; candidate_commit?: string | null; processing_limit?: { phase: string; metric: string; limit: number; observed: number | null; contract: string; operation_id: string | null; change_id: string | null; revision: number | null; } | null; reconciliation_pending?: boolean | null; } interface LinearIssue { id: string; identifier: string; title: string; url: string; description: string; updated_at: string; } export interface Change { linear_issue?: LinearIssue | null; /** Durable derivation/conflict evidence, separate from author readiness. */ integration?: CandidateIntegration | null; /** Revision-bound local verification stop; does not imply a provider operation. */ processing_limit?: CandidateIntegration['processing_limit']; id: string; repository_id: string; service: string; author_id: string; /** The branch this change lives on until it lands. */ branch: string; /** Which proposal onto that branch produced the current diff. Starts at 1. */ revision: number; title: string; intent: string; spec: Spec; reported: ReportedResults; base_commit: string; status: ChangeStatus; route: Route | null; evidence_digest: string | null; risk: RiskVerdict | null; policy_version: number | null; commit_sha: string | null; land_seq: number | null; created_at: string; updated_at: string; landed_at: string | null; /** Author readiness to create a new landing intent, independent of verification/policy status. */ landing_readiness: LandingReadiness; author: Pick | null; stats: DiffStats; /** Present only when requested via `include`. */ diff?: string; evidence?: StoredEvidence | null; trace?: TraceStep[]; decisions?: Decision[]; author_track_record?: TrackRecord; } export interface ChangeDecisionResult extends Change { decision_outcome: DecisionRecordOutcome; landing_outcome: DecisionLandingOutcome; } type ChangeInclude = 'diff' | 'evidence' | 'trace' | 'decisions' | 'track'; interface ProposeInput { linear_issue?: string; repository_id: string; service?: string; title: string; intent: string; spec?: Spec; base_commit?: string; diff: string; reported?: ReportedResults; trace?: TraceStepInput[]; cost_usd?: number; /** * For native repositories, explicit true sets Draft; explicit false sets Ready. Omitted on creation * starts Ready; omitted on revision preserves the previous readiness. */ draft?: boolean; } /** Replace one exact open Change revision without selecting a branch. */ interface ReviseInput extends ProposeInput { change_id: string; expected_revision: number; } export interface Staleness { stale: boolean; behind: number; conflicting: { change_id: string | null; title: string; commit_sha: string; files: string[] }[]; } interface VerifyResult { evidence: EvidenceBundle; risk: RiskVerdict; routing: PolicyDecision; track: TrackRecord; conflicts: Staleness; } /** Successful processing without a Candidate, evidence or publication authority. */ interface NoChangeVerifyResult { outcome: 'no_change'; evidence: null; risk: null; routing: null; track: null; conflicts: null; } // --- events ----------------------------------------------------------------- export interface TrunkEvent { id: number; ts: string; type: string; repository_id: string | null; change_id: string | null; actor_id: string | null; payload: Record; } // --- stats ------------------------------------------------------------------ export interface RepositoryStats { repository_id: string; proposed: number; landed: number; reverted: number; blocked: number; open: number; unattended: number; autonomy_rate: number; revert_rate: number; human_decisions: number; by_day: { day: string; landed: number; unattended: number }[]; by_service: { service: string; landed: number; reverted: number; unattended: number; revert_rate: number; }[]; } // --- errors ----------------------------------------------------------------- interface HttpError extends Error { status: number; code: string; /** Explicitly constructed safe response fields for a structured public error. */ public_body?: Record; } interface Feedback { id: string; workspace_id: string; reporter_id: string; request_key: string; category: 'bug' | 'documentation' | 'usability' | 'feature'; operation: string; summary: string; expected: string; actual: string; reproduction: string; status: 'open' | 'investigating' | 'resolved' | 'declined'; revision: number; response: string; release_url: string | null; created_at: string; updated_at: string; } type FeedbackInput = Pick< Feedback, 'request_key' | 'category' | 'operation' | 'summary' | 'expected' | 'actual' | 'reproduction' >; export type ProjectStatus = 'draft' | 'in_progress' | 'completed' | 'archived'; export interface Project { id: string; workspace_id: string; repository_ids: string[]; owner_id: string; owner_display?: string; owner_kind?: string; owner_harness?: string | null; title: string; brief: string; icon: string | null; status: ProjectStatus; revision: number; created_at: string; updated_at: string; } export interface ProjectSpec { id: string; project_id: string; title: string; body: string; author_id: string; display: string; archived_at: string | null; created_at: string; updated_at: string; } export interface ProjectComment { id: string; project_id: string; author_id: string; display: string; body: string; created_at: string; } export interface ProjectCommentPage { comments: ProjectComment[]; older_comments_cursor: string | null; } export interface ProjectDetail extends Project, ProjectCommentPage { specs: ProjectSpec[]; changes: Array<{ id: string; repository_id: string; title: string; status: string; revision: number; }>; } interface ProjectOwner { kind?: string; harness?: string | null; id: string; display: string; } interface ProjectInput { repository_ids?: string[]; icon?: string | null; owner_id?: string; title: string; brief: string; status: ProjectStatus; } interface ProjectMutation { action: | 'create' | 'edit' | 'archive' | 'restore' | 'comment' | 'create_spec' | 'edit_spec' | 'archive_spec' | 'restore_spec'; spec_id?: string; spec?: { title: string; body: string }; id?: string; expected_revision?: number; input?: ProjectInput; body?: string; } export type TaskStatus = 'todo' | 'in_progress' | 'done'; export interface Task { id: string; project_id: string; project_title: string; workspace_id: string; title: string; description: string; status: TaskStatus; assignee_id: string | null; assignee_display: string | null; assignee_kind?: string | null; assignee_harness?: string | null; archived_at: string | null; revision: number; change_count: number; created_at: string; updated_at: string; } interface TaskAssignee { kind?: string; harness?: string | null; id: string; display: string; } interface TaskInput { title: string; description: string; status: TaskStatus; assignee_id: string | null; } export interface TaskDetail extends Task { changes: Array<{ repository_id: string; id: string; title: string; status: string }>; comments: Array<{ id: string; author_id: string; display: string; kind?: string; harness?: string | null; body: string; created_at: string; }>; } interface TaskMutation { action: 'create' | 'edit' | 'comment' | 'link' | 'unlink' | 'reassign' | 'archive' | 'restore'; id?: string; project_id?: string; expected_revision?: number; input?: TaskInput; body?: string; change_id?: string; previous_task_id?: string; previous_task_revision?: number; } export type CheckStatus = 'queued' | 'in_progress' | 'completed'; export type CheckConclusion = 'success' | 'failure' | 'cancelled' | 'timed_out' | 'skipped'; export type CandidateIntegrationState = 'success' | 'failure' | 'pending' | 'indeterminate'; export type CheckEvaluationState = | 'pending' | 'in_progress' | 'satisfied' | 'failed' | 'cancelled' | 'unavailable' | 'indeterminate'; export interface CheckAttemptView { runId: string; attempt: number; state: CheckEvaluationState; status: CheckStatus; conclusion: CheckConclusion | null; startedAt: string | null; completedAt: string | null; } export interface CheckEvidenceReference { runId: string; attempt: number; requirementId: string; generation: number; changeRevision: number; sourceRevision: string; integration: string; definition: string; completedAt: string; } export interface CheckRequirementInput { name: string; provider: string; } export interface CheckRequirement extends CheckRequirementInput { repositoryId: string; createdBy: string; createdAt: string; } export interface CheckRun { id: string; requirementId?: string | null; requirementGeneration?: number | null; requirementChangeRevision?: number | null; repositoryId: string; changeId: string; revision: string; name: string; provider: string; attempt: number; externalId: string | null; status: CheckStatus; conclusion: CheckConclusion | null; detailsUrl: string | null; attestedBy: string; createdAt: string; updatedAt: string; startedAt: string | null; completedAt: string | null; } /** Native non-CheckRun evidence participating in the candidate landing projection. */ export interface CandidateIntegrationGate { integration: 'preview'; provider: 'vercel'; environment: 'preview'; required: boolean; state: CandidateIntegrationState; deploymentId: string | null; connectionId: string; } export interface CheckGateIssue { requirementId?: string; scope?: 'workspace' | 'repository'; name: string; provider: string; runId: string | null; status: CheckStatus | 'missing' | 'unavailable'; conclusion: CheckConclusion | null; /** Native evidence domain. Deployment issues are projections, never CheckRuns. */ domain?: 'check' | 'deployment'; deploymentId?: string | null; integrationState?: CandidateIntegrationState; evaluationState?: CheckEvaluationState; } export interface IndependentVerification { requirementId: string; scope: 'workspace' | 'repository'; inherited: boolean; integration: string; capability: 'reviewer' | 'attested_check'; reviewerId: string | null; name: string; provider: string; enabled: boolean; required: boolean; generation: number; changeRevision: number; sourceRevision: string; definition: string; state: CheckEvaluationState; latestAttempt: CheckAttemptView | null; evidence: CheckEvidenceReference | null; runId: string | null; attempt: number | null; detailsUrl: string | null; status: 'queued' | 'in_progress' | 'completed' | 'missing' | 'unavailable'; conclusion: CheckRun['conclusion']; } export interface VerificationRequirement { id: string; workspaceId: string; repositoryId: string | null; scope: 'workspace' | 'repository'; integration: string; capability: 'reviewer' | 'attested_check'; reviewerId: string | null; provider: string; name: string; label: string; enabled: boolean; required: boolean; generation: number; version: number; createdBy: string; createdAt: string; updatedAt: string; removedAt: string | null; inherited: boolean; canConfigure: boolean; } export interface CheckAggregate { /** 'clear' means no Required blocker, not proof that a Check executed. */ state: 'clear' | 'blocked'; requiredCount: number; satisfiedCount: number; blockers: (CheckGateIssue & { evaluationState: CheckEvaluationState })[]; } export interface CandidateCheckActionAttempt { runId: string; state: 'pending' | 'in_progress' | 'indeterminate'; } export interface CandidateCheckAction { available: { action: 'retry' | 'rerun'; definition: string }[]; reason?: string; attempt?: CandidateCheckActionAttempt; target?: { changeId: string; changeRevision: number; sourceRevision: string; requirementId: string; generation: number; }; } export interface CheckGate { verification: IndependentVerification[]; changeId: string; changeRevision: number; revision: string; aggregate: CheckAggregate; required: CheckRequirementInput[]; runs: CheckRun[]; /** Native Deployment evidence remains distinct from CheckRuns in public clients. */ integrations?: CandidateIntegrationGate[]; pending: CheckGateIssue[]; failed: CheckGateIssue[]; ready: boolean; } export interface CandidateCheckGate extends CheckGate { actions: Record; } export type ExternalCiDispatchState = 'pending' | 'completed'; /** Public managed-CI dispatch identity; executor routing and provider-owned ids/URLs stay internal. */ export interface PublicExternalCiDispatch { id: string; repositoryId: string; changeId: string; checkRunId: string; branch: string; changeRevision: number; revision: string; sourceRef: string; provider: string; checkName: string; requestKey: string; state: ExternalCiDispatchState; createdAt: string; updatedAt: string; } export type DeploymentEnvironment = 'preview' | 'production'; export type DeploymentStatus = 'queued' | 'in_progress' | 'ready' | 'failed' | 'cancelled'; export interface Deployment { id: string; repositoryId: string; revision: string; environment: DeploymentEnvironment; provider: string; requestKey: string; attempt: number; externalId: string | null; status: DeploymentStatus; url: string | null; detailsUrl: string | null; createdAt: string; updatedAt: string; startedAt: string | null; completedAt: string | null; } /** An agent as the fleet views render it: identity plus what it has earned. */ export type AgentSummary = Omit & { track_record: TrackRecord; by_service?: TrackRecord[]; budget?: Budget | undefined; usage_today?: Usage | undefined; }; export interface PolicySimulation { sampled: number; unattended_before: number; unattended_after: number; changed: { change_id: string; title: string; was: string | null; would_be: string; rule_id: string | null; }[]; results: { change_id: string; title: string; was: string | null; would_be: string; rule_id: string | null; reason: string; }[]; } /** Public stock-Git endpoints. Each transport is independently optional. */ export interface RepositoryGitRemoteProjection { https_url?: string; ssh_url?: string; } type RepositoryGitProjection = { git_remotes?: RepositoryGitRemoteProjection }; /** * What each operation returns, by name. `defineOperation` requires the handler * to actually produce the type it advertises here, and the emitted TypeScript * client reads the same map — so a generated client method cannot promise a * shape the server does not send. */ export interface ChangePreviewPublication { targetKey: string; label: string; url: string; changeRevision: number; revision: string; deploymentId: string; } export type ChangeVerificationState = | 'success' | 'failure' | 'pending' | 'in_progress' | 'cancelled' | 'unavailable' | 'indeterminate' | 'recovery_required'; export interface ChangeVerificationTiming { queuedAt: string; startedAt: string | null; completedAt: string | null; } export interface ChangeVerificationCheck { kind: 'ci' | 'verification'; integration?: 'buildkite'; requirementId?: string; scope?: 'workspace' | 'repository'; capability?: 'reviewer' | 'attested_check'; generation?: number; /** Synthetic, internal Human Git source gate; never inferred from a label. */ sourceGate?: 'human_push'; changeRevision?: number; sourceRevision?: string; definition?: string; evaluationState?: CheckEvaluationState; latestAttempt?: CheckAttemptView | null; evidence?: CheckEvidenceReference | null; name: string; timing: ChangeVerificationTiming | null; label: string; required: boolean; /** CI effective gate result; state remains the latest visible attempt. */ effectiveState?: ChangeVerificationState; state: ChangeVerificationState; runId: string | null; runStatus: CheckStatus | 'missing'; conclusion: CheckConclusion | null; buildkiteUrl: string | null; } export type ChangeVerificationPostLandCheck = Omit & { kind: 'ci'; required: false; }; export interface ChangeVerificationPreview { retry?: { phase: 'running' | 'waiting' | 'backoff' | 'parked'; failedCycles: number; nextEligibleAt: string | null; leaseUntil: string | null; recoveryRequired: boolean; reason: 'none' | 'retryable' | 'crash_unknown' | 'source_contract' | 'exhausted' | 'manual_resume'; } | null; kind: 'preview'; name: string; timing: ChangeVerificationTiming | null; targetKey: string | null; label: string; required: boolean | null; state: CandidateIntegrationState | 'recovery_required'; deploymentId: string | null; url: string | null; detailsUrl: string | null; statusNote: string | null; } export interface ChangeVerificationAggregate { state: 'clear' | 'blocked'; requiredCount: number; satisfiedCount: number; blockers: { name: string; requirementId?: string; kind: 'ci' | 'verification' | 'preview'; state: ChangeVerificationState; }[]; } export interface ChangeVerificationView { observedAt: string; revision: string | null; aggregate?: ChangeVerificationAggregate; checks: ChangeVerificationCheck[]; postLandChecks: ChangeVerificationPostLandCheck[]; previews: ChangeVerificationPreview[]; publishedPreviews: ChangePreviewPublication[]; production: ChangeVerificationProduction | null; } export interface ChangeVerificationProductionTarget { targetKey: string; name: string; deploymentId: string | null; requestKey: string | null; attempt: number | null; externalId: string | null; status: 'queued' | 'running' | 'ready' | 'failed' | 'cancelled' | 'unavailable' | 'indeterminate'; timing: ChangeVerificationTiming | null; url: string | null; detailsUrl: string | null; statusNote: string | null; } export interface ChangeVerificationProduction { state: 'present' | 'no_targets' | 'missing_handoff' | 'unavailable' | 'indeterminate'; revision: string | null; changeRevision: number; landSeq: number | null; landingEventId: number | null; targets: ChangeVerificationProductionTarget[]; } export interface AgentChangeStatus { change_id: string; revision: number; candidate_commit: string | null; status: Change['status']; landing_readiness: Change['landing_readiness']; route: Change['route']; policy_rule: string | null; commit_sha: string | null; blockers: { kind: string; name: string; state: string }[]; next_actions: string[]; verification: ChangeVerificationView; cursor: string; } export interface ChangeReviewAssessment { id: string; repositoryId: string; changeId: string; changeRevision: number; candidateRevision: string; service: string; paths: string[]; reviewerId: string | null; delegatedById: string | null; requestKey: string; reviewerDefinitionId: string; definitionVersion: number; promptVersion: number; reviewerName: string; reviewerOrigin: 'global' | 'workspace' | 'repository'; conclusion: 'green' | 'yellow' | 'red'; summary: string; createdAt: string; stale: boolean; findings: { id: string; reviewId: string; ordinal: number; body: string; path: string | null; startLine: number | null; endLine: number | null; createdAt: string; }[]; } /** Customer-visible configuration; internal model assignments never cross this boundary. */ export interface ReviewerSettingsRow { id: string; scope: 'global' | 'workspace' | 'repository'; name: string; prompt: string | null; description: string | null; version: number; promptVersion: number | null; requirementVersion: number; enabled: boolean; required: boolean; draftReviewEnabled: boolean; inherited: boolean; canConfigure: boolean; } export interface ReviewerSettings { repositoryId: string | null; canCreate: boolean; reviewers: ReviewerSettingsRow[]; } export interface CustomerReviewerVersion { id: string; scope: 'workspace' | 'repository'; repositoryId: string | null; version: number; promptVersion: number; name: string; prompt: string; integration: string; connectionId: string | null; } export interface CustomerReviewer extends CustomerReviewerVersion { draftReviewEnabled: boolean; } export interface PublicGlobalReviewer { defaultDraftReviewEnabled: boolean; id: string; name: string; description: string; version: number; defaultEnabled: boolean; defaultRequired: boolean; } export interface ApiTypes { ChangeReviews: { items: ChangeReviewAssessment[] }; ReviewerSettings: ReviewerSettings; ProjectOwners: { items: Array<{ id: string; display: string; kind?: string; harness?: string | null }>; }; TaskAssignees: { items: Array<{ id: string; display: string; kind?: string; harness?: string | null }>; }; CustomerReviewer: CustomerReviewer; CustomerReviewers: { items: CustomerReviewer[] }; CustomerReviewerVersions: { items: CustomerReviewerVersion[] }; ReviewerDeletion: { deleted: true }; GlobalReviewers: { items: PublicGlobalReviewer[] }; GlobalReviewerSelections: { items: Array<{ reviewerId: string; name: string; description: string; enabled: boolean; required: boolean; }>; }; Feedback: Feedback; FeedbackList: { items: Feedback[]; next_cursor: string | null }; FeedbackWait: { feedback: Feedback; changed: boolean }; Task: TaskDetail; Tasks: { items: Task[] }; Spec: { spec: ProjectSpec; project_revision: number }; Specs: { items: ProjectSpec[]; project_revision: number }; Project: ProjectDetail; ProjectCommentPage: ProjectCommentPage; Projects: { items: Project[] }; AgentChangeStatus: AgentChangeStatus; AgentChangeWait: AgentChangeStatus & { changed: boolean; timed_out: boolean }; AgentChangeChecks: { change_id: string; revision: number; gate: CandidateCheckGate }; AgentCheckLogs: { change_id: string; check_run_id: string; change_revision: number | null; commit_sha: string; state: 'pending' | 'available' | 'empty' | 'expired' | 'unavailable'; content: string; next_offset: number | null; truncated: boolean; snapshot_digest: string; }; AgentChangePreview: { change_id: string; revision: number; candidate_commit: string | null; previews: ChangeVerificationPreview[]; published_previews: ChangePreviewPublication[]; }; AgentRefComparison: { repository_id: string; base_commit: string; head_commit: string; files: { path: string; status: string; diff: string }[]; next_offset: number | null; }; AgentPathContext: { repository_id: string; head_commit: string; paths: { path: string; service: string; permissions: string[]; instructions: string[] }[]; services: Service[]; policy: Policy; required_checks: CheckRequirement[]; instructions: { path: string; text: string }[]; }; AgentOverlaps: { repository_id: string; changes: { change_id: string; title: string; author_id: string; revision: number; status: string; service: string; overlapping_paths: string[]; }[]; next_offset: number | null; }; AgentWithdrawal: { change_id: string; revision: number; status: 'rejected'; withdrawn: boolean }; AgentRebase: { change_id: string; revision: number; previous_base_commit: string; base_commit: string; conflicts: string[]; diff: string | null; applicable: boolean; }; AgentCheckRetry: { change_id: string; revision: number; dispatch: PublicExternalCiDispatch }; ActorProfile: ActorProfile; AgentList: { agents: AgentSummary[] }; Budget: Omit; Change: Change; ChangeDecisionResult: ChangeDecisionResult; ChangeList: { changes: Change[] }; CheckGate: CandidateCheckGate; CheckAttemptActionResult: { kind: 'reserved' | 'existing' | 'indeterminate'; attempt: CandidateCheckActionAttempt; }; CheckMutation: { run: CheckRun; gate: CheckGate; change: Change }; VerificationRequirement: VerificationRequirement; VerificationRequirements: { items: VerificationRequirement[] }; CheckRequirements: { required: CheckRequirement[] }; Deployment: Deployment; ExternalCiDispatch: PublicExternalCiDispatch; DecisionQueue: { repository_id: string | undefined; queue: Change[] }; EventList: { events: TrunkEvent[] }; AgentGitCredential: { workspace_id: string; repository_id: string; https_url: string; username: 'trunk-agent'; password: string; access: 'read'; expires_at: string; }; GitCredential: { repository_id: string; https_url: string; username: 'trunk'; password: string; access: 'read' | 'write'; expires_at: string; write_ref_prefix?: string; }; NewAgent: Actor & { api_key: string }; /** The agent as it last was. Nothing is left to read it back from. */ DeletedAgent: { agent: Omit }; Policy: Policy; PolicySaveResult: Policy & { unchanged: boolean }; PolicyDocument: Policy & { history: Pick[]; defaults: PolicyRule[]; }; PolicySimulation: PolicySimulation; RepositoryDetail: Repository & RepositoryGitProjection & { services: Service[]; policy: Policy; head: TrunkCommit | undefined }; RepositoryImport: { repository_id: string; operation_id: string | null; state: 'not_started' | 'awaiting_upload' | 'reconciliation_required' | 'completed'; commit_sha: string | null; commit: string | null; source: string | null; pack_digest: string | null; pack_bytes: number | null; upload_url: string | null; reconcile_supported: boolean; abandon_supported: boolean; }; RepositoryList: { repositories: (Repository & RepositoryGitProjection & { services: Service[]; head: TrunkCommit | undefined })[]; }; RepositoryStats: RepositoryStats; RevertResult: { change: Change; track: TrackRecord }; ApiKeyList: { keys: ApiKey[] }; /** The secret appears here and nowhere else, ever again. */ IssuedApiKey: { key: ApiKey; secret: string }; RevokedApiKey: { key: ApiKey }; Session: { actor: Omit; token: string; expires_at: string }; CandidateRetentionAudit: { checkouts: Array<{ public_ref: string; source_ref: string; expected_sha: string; public_tip: string | null; ephemeral_tip: string | null; retained_ref: string | null; retained_tip: string | null; submitted_sha: string | null; submitted_retained_ref: string | null; submitted_retained_tip: string | null; retention_blocker: string | null; }>; }; SourceBranches: { branches: SourceBranch[] }; SourceTree: { ref: string; head_commit: string; path: string; entries: SourceEntry[] }; SourceFileContent: { ref: string; head_commit: string; file: SourceFile }; SourceFilesContent: { ref: string; head_commit: string; files: SourceFile[]; missing: string[] }; SourceSearchResults: { ref: string; head_commit: string; query: string; path: string; case_sensitive: boolean; matches: { path: string; line: number; column: number; snippet: string }[]; scanned_entries: number; scanned_files: number; scanned_bytes: number; truncated: boolean; }; PatchPreflightResult: { base_commit: string; files: { path: string; status: 'added' | 'modified' | 'deleted'; additions: number; deletions: number; }[]; stats: DiffStats; }; SignedOut: { signed_out: boolean }; Scope: Scope; Trace: { trace: TraceStep[] }; TrunkLog: { head: TrunkCommit | undefined; log: TrunkCommit[] }; VerifyResult: { change: Change; routing: PolicyDecision | null; risk: RiskVerdict | null; conflicts: Staleness | null; }; } type ApiTypeName = keyof ApiTypes; export interface TrunkClientOptions { baseUrl?: string; apiKey: string; fetch?: typeof fetch } export interface RepositoriesAgentGitCredentialInput extends Record {} export interface RepositoriesGitCredentialInput { /** Requested Git authority. */ access: "read" | "write"; } export interface SourceFilesInput { /** Branch name. Defaults to the trunk branch. */ ref?: string; /** Repository-relative file paths. At most 12. */ paths: Array; } export interface SourceSearchInput { /** Literal text to find; regular expressions are not evaluated. */ query: string; /** Branch name. Defaults to the trunk branch. */ ref?: string; /** Optional repository-relative subtree to search. */ path?: string; case_sensitive?: boolean; max_results?: number; } export interface SourcePatchPreflightInput { diff: string; } export interface ExternalCiDispatchInput { /** Stable Trunk-managed CI identity. */ provider: "trunk-ci"; checkName: string; revision: string; retryOf?: string; expected_revision?: number; } export interface ExternalCiDispatchByoInput { checkName: string; revision: string; retryOf?: string; expected_revision?: number; } export interface DeploymentsStartInput { revision: string; environment: "preview" | "production"; provider: string; requestKey: string; changeId?: string; } export interface DeploymentsUpdateInput { status: "queued" | "in_progress" | "ready" | "failed" | "cancelled"; externalId?: string; url?: string; detailsUrl?: string; } export interface ChecksVerificationCreateInput { scope: "workspace" | "repository"; repositoryId?: string; capability: "reviewer" | "attested_check"; reviewerId?: string; provider?: string; name?: string; enabled: boolean; required: boolean; } export interface ChecksVerificationUpdateInput { expectedVersion: number; enabled: boolean; required: boolean; } export interface ChecksVerificationRemoveInput { expectedVersion: number; } export interface ChecksRequirementsSetInput { required: Array<{ name: string; provider: string; }>; } export interface ChecksAttemptsRequestInput { changeRevision: number; sourceRevision: string; requirementId: string; generation: number; action: "retry" | "rerun"; definition: string; } export interface ChecksCreateInput { name: string; provider: string; requirementId?: string; revision: string; /** Provider run id for idempotent creation/replay. */ externalId?: string; detailsUrl?: string; } export interface ChecksUpdateInput { status: "queued" | "in_progress" | "completed"; conclusion?: "success" | "failure" | "cancelled" | "timed_out" | "skipped"; detailsUrl?: string; } export interface ReviewersCreateInput { scope: "workspace" | "repository"; repositoryId?: string; name: string; prompt: string; draftReviewEnabled?: boolean; } export interface ReviewersEditInput { expectedVersion: number; name: string; prompt: string; draftReviewEnabled?: boolean; } export interface ReviewersDeleteInput { expectedVersion: number; } export interface ReviewerSettingsWorkspaceCreateInput { name: string; prompt: string; enabled: boolean; required: boolean; draftReviewEnabled: boolean; expectedVersion?: number; expectedRequirementVersion?: number; } export interface ReviewerSettingsWorkspaceEditInput { name: string; prompt: string; enabled: boolean; required: boolean; draftReviewEnabled: boolean; expectedVersion: number; expectedRequirementVersion: number; } export interface ReviewerSettingsWorkspaceDeleteInput { expectedVersion: number; } export interface ReviewerSettingsRepositoryCreateInput { name: string; prompt: string; enabled: boolean; required: boolean; draftReviewEnabled: boolean; expectedVersion?: number; expectedRequirementVersion?: number; } export interface ReviewerSettingsRepositoryEditInput { name: string; prompt: string; enabled: boolean; required: boolean; draftReviewEnabled: boolean; expectedVersion: number; expectedRequirementVersion: number; } export interface ReviewerSettingsRepositoryDeleteInput { expectedVersion: number; } export interface ReviewerSettingsRepositoryGlobalInput { enabled: boolean; required: boolean; draftReviewEnabled: boolean; expectedRequirementVersion: number; } export interface RepositoriesImportInput { /** Pinned Git SHA-1 commit to import. */ commit: string; /** Audit label for the source, without credentials. Never fetched by the server. */ source: string; /** Lowercase SHA-256 digest of the exact raw Git pack. */ pack_digest: string; /** Exact raw Git pack byte count. */ pack_bytes: number; } export interface AgentRetryCheckInput { expected_revision: number; } export interface AgentPrepareRebaseInput { expected_revision: number; } export interface AgentWithdrawInput { expected_revision: number; reason: string; } export interface AgentOverlapsInput { paths: Array; offset?: number; } export interface AgentPathContextInput { paths: Array; } export interface SpecsCreateInput { expected_revision: number; title: string; body: string; } export interface SpecsUpdateInput { expected_revision: number; title: string; body: string; } export interface SpecsArchiveInput { expected_revision: number; title?: string; body?: string; } export interface SpecsRestoreInput { expected_revision: number; title?: string; body?: string; } export interface ProjectsCreateInput { repository_ids?: Array; title: string; brief?: string; status: "draft" | "in_progress" | "completed" | "archived"; owner_id: string; icon?: "" | "flag" | "rocket" | "target" | "compass" | "map" | "route" | "signpost" | "mountain" | "trophy" | "medal" | "star" | "sparkles" | "lightbulb" | "flask-conical" | "microscope" | "beaker" | "zap" | "gauge" | "activity" | "chart-no-axes-combined" | "chart-pie" | "trending-up" | "timer" | "clock" | "shield" | "shield-check" | "lock-keyhole" | "key-round" | "fingerprint" | "eye" | "scan-line" | "heart-pulse" | "server" | "database" | "hard-drive" | "cloud" | "network" | "workflow" | "git-branch" | "git-pull-request" | "git-commit-horizontal" | "code" | "terminal" | "bug" | "wrench" | "settings" | "blocks" | "layers" | "box" | "package" | "puzzle" | "plug" | "cable" | "cpu" | "laptop" | "smartphone" | "globe" | "languages" | "accessibility" | "palette" | "paintbrush" | "layout-dashboard" | "panels-top-left" | "mouse-pointer-2" | "users" | "messages-square" | "book-open" | "graduation-cap" | "heart" | "leaf" | "sun" | "circle-check"; } export interface ProjectsUpdateInput { repository_ids?: Array; title: string; brief?: string; status: "draft" | "in_progress" | "completed" | "archived"; owner_id?: string; icon?: "" | "flag" | "rocket" | "target" | "compass" | "map" | "route" | "signpost" | "mountain" | "trophy" | "medal" | "star" | "sparkles" | "lightbulb" | "flask-conical" | "microscope" | "beaker" | "zap" | "gauge" | "activity" | "chart-no-axes-combined" | "chart-pie" | "trending-up" | "timer" | "clock" | "shield" | "shield-check" | "lock-keyhole" | "key-round" | "fingerprint" | "eye" | "scan-line" | "heart-pulse" | "server" | "database" | "hard-drive" | "cloud" | "network" | "workflow" | "git-branch" | "git-pull-request" | "git-commit-horizontal" | "code" | "terminal" | "bug" | "wrench" | "settings" | "blocks" | "layers" | "box" | "package" | "puzzle" | "plug" | "cable" | "cpu" | "laptop" | "smartphone" | "globe" | "languages" | "accessibility" | "palette" | "paintbrush" | "layout-dashboard" | "panels-top-left" | "mouse-pointer-2" | "users" | "messages-square" | "book-open" | "graduation-cap" | "heart" | "leaf" | "sun" | "circle-check"; expected_revision: number; } export interface ProjectsArchiveInput { expected_revision: number; } export interface ProjectsRestoreInput { expected_revision: number; } export interface TasksArchiveInput { expected_revision: number; } export interface TasksRestoreInput { expected_revision: number; } export interface TasksCreateInput { project_id: string; title: string; description?: string; status: "todo" | "in_progress" | "done"; /** Active workspace member or repository agent ID. Omit or use an empty string for unassigned. */ assignee_id?: string; } export interface TasksUpdateInput { expected_revision: number; project_id?: string; title: string; description?: string; status: "todo" | "in_progress" | "done"; /** Active workspace member or repository agent ID. Omit or use an empty string for unassigned. */ assignee_id?: string; } export interface TasksCommentInput { expected_revision: number; body: string; } export interface TasksLinkInput { expected_revision: number; change_id: string; } export interface TasksUnlinkInput { expected_revision: number; change_id: string; } export interface FeedbackSubmitInput { request_key: string; category: "bug" | "documentation" | "usability" | "feature"; /** Affected Trunk feature, HTTP route or MCP tool; unknown operation names are accepted so missing endpoints can be reported. */ operation: string; summary: string; expected: string; actual: string; /** Minimal sanitized reproduction; empty when unavailable. */ reproduction?: string; } export interface FeedbackRespondInput { expected_revision: number; status: "open" | "investigating" | "resolved" | "declined"; response: string; release_url?: string; } export interface AuthSignupInput { /** One-time beta or workspace invitation secret for this email. */ invitation_token: string; email: string; /** At least 10 characters. */ password: string; /** Display name, shown on decisions you record. */ name: string; /** Optional; derived from your name otherwise. */ handle?: string; } export interface AuthSigninInput { email: string; password: string; } export interface AuthSignoutInput { /** End every session for this account. */ everywhere?: boolean; } export interface RepositoriesCreateInput { /** A single lowercase slug. Repositories are not namespaced. */ name: string; /** The branch changes land on. Defaults to "trunk". */ trunk_branch?: string; /** Path globs decide which service a change belongs to. */ services?: Array<{ name: string; criticality?: "low" | "medium" | "high" | "critical"; /** e.g. services/payments/** */ path_globs?: Array; }>; /** Routing policy. Defaults to the built-in rules. */ rules?: Array>; } export interface ChangesProposeInput { /** Repository id or name. */ repository_id: string; /** Linear issue identifier or URL. Its description is shared with repository readers and used by Reviews. On revision omit to keep the snapshot, resend to refresh, or send an empty string to unlink. */ linear_issue?: string; /** Owning service. Inferred from the changed paths when omitted. */ service?: string; /** Imperative one-liner, as it will read on trunk. */ title: string; /** Why this change exists, in your own words: the problem, the evidence it is real, and what you decided not to do. This is what a human reads first. */ intent: string; spec?: { goal?: string; non_goals?: Array; acceptance_criteria?: Array; constraints?: Array; }; /** Trunk commit you worked from. Defaults to current head. */ base_commit?: string; /** Unified diff (git format). Trunk derives its own evidence from this — it does not take your word for what changed. */ diff: string; /** Results you observed. Recorded as self-reported and weighted as such. */ reported?: { suites?: Array<{ name: string; passed: number; failed: number; skipped?: number; duration_ms?: number; }>; coverage_delta?: number; benchmarks?: Array<{ name: string; before_ms: number; after_ms: number; }>; }; /** Client-submitted session trace: prompts, tool calls, skills and reasoning summaries. Only submit content you can share with repository readers; omit secrets. Trunk does not automatically capture client sessions. */ trace?: Array<{ /** What the agent was doing at this step. */ kind: "read" | "search" | "reason" | "edit" | "test" | "bench" | "tool" | "note" | "prompt" | "skill"; /** One line, written for a human skimming the trace. */ summary: string; /** Optional longer output: command, result, reasoning. */ detail?: string; prompt?: { role: "system" | "developer" | "user" | "assistant"; /** Prompt text explicitly supplied by the client. */ content: string; }; tool_call?: { name: string; /** Client tool-call identifier for correlation. */ call_id?: string; /** Tool input as text or serialized JSON. */ arguments?: string; /** Tool output as text or serialized JSON. */ result?: string; status?: "started" | "succeeded" | "failed"; }; skill?: { name: string; /** Skill path or URI. */ source?: string; content?: string; }; /** Agent-supplied reasoning summary or decision rationale, not private chain-of-thought. */ reasoning?: string; /** ISO timestamp. Defaults to now. */ ts?: string; /** Tokens consumed by this step. */ tokens?: number; /** Cost of this step in USD. */ usd?: number; }>; /** What this change cost to produce. Recorded for usage reporting. */ cost_usd?: number; /** For native repositories, explicit true sets Draft; explicit false sets Ready, on both creation and revision. Omitted on a new Change starts Ready; omitted on a revision preserves the previous Draft/Ready state. Verification/CI/Preview and all landing gates remain independent. */ draft?: boolean; } export interface ChangesReviseInput { /** Linear issue identifier or URL. Its description is shared with repository readers and used by Reviews. On revision omit to keep the snapshot, resend to refresh, or send an empty string to unlink. */ linear_issue?: string; /** Owning service. Inferred from the changed paths when omitted. */ service?: string; /** Imperative one-liner, as it will read on trunk. */ title: string; /** Why this change exists, in your own words: the problem, the evidence it is real, and what you decided not to do. This is what a human reads first. */ intent: string; spec?: { goal?: string; non_goals?: Array; acceptance_criteria?: Array; constraints?: Array; }; /** Exact replacement base commit. Omit to retain the current Change base. */ base_commit?: string; /** Unified diff (git format). Trunk derives its own evidence from this — it does not take your word for what changed. */ diff: string; /** Results you observed. Recorded as self-reported and weighted as such. */ reported?: { suites?: Array<{ name: string; passed: number; failed: number; skipped?: number; duration_ms?: number; }>; coverage_delta?: number; benchmarks?: Array<{ name: string; before_ms: number; after_ms: number; }>; }; /** Client-submitted session trace: prompts, tool calls, skills and reasoning summaries. Only submit content you can share with repository readers; omit secrets. Trunk does not automatically capture client sessions. */ trace?: Array<{ /** What the agent was doing at this step. */ kind: "read" | "search" | "reason" | "edit" | "test" | "bench" | "tool" | "note" | "prompt" | "skill"; /** One line, written for a human skimming the trace. */ summary: string; /** Optional longer output: command, result, reasoning. */ detail?: string; prompt?: { role: "system" | "developer" | "user" | "assistant"; /** Prompt text explicitly supplied by the client. */ content: string; }; tool_call?: { name: string; /** Client tool-call identifier for correlation. */ call_id?: string; /** Tool input as text or serialized JSON. */ arguments?: string; /** Tool output as text or serialized JSON. */ result?: string; status?: "started" | "succeeded" | "failed"; }; skill?: { name: string; /** Skill path or URI. */ source?: string; content?: string; }; /** Agent-supplied reasoning summary or decision rationale, not private chain-of-thought. */ reasoning?: string; /** ISO timestamp. Defaults to now. */ ts?: string; /** Tokens consumed by this step. */ tokens?: number; /** Cost of this step in USD. */ usd?: number; }>; /** What this change cost to produce. Recorded for usage reporting. */ cost_usd?: number; /** For native repositories, explicit true sets Draft; explicit false sets Ready, on both creation and revision. Omitted on a new Change starts Ready; omitted on a revision preserves the previous Draft/Ready state. Verification/CI/Preview and all landing gates remain independent. */ draft?: boolean; /** Current numerical Change revision observed by the caller. A stale value returns conflict without writing. */ expected_revision: number; } export interface ChangesDecideInput { /** Caller-stable idempotency token for this logical decision request. Retry with the same key after any lost or ambiguous response. */ request_key: string; verdict: "approve" | "reject" | "request_changes"; /** The digest you read for an evidence-bound decision. With evidence present, omitting it accepts whatever evidence is current; before evidence exists, only reject is allowed and no Decision row is recorded. */ evidence_digest?: string; /** What convinced you, or what is missing. */ note?: string; } export interface ChangesLandInput { reason?: string; /** Admin override. Recorded on the change. */ force?: boolean; } export interface ChangesMarkReadyInput { /** Exact current numerical Change revision being released from Draft. */ revision: number; } export interface ChangesRecoverGithubInput { /** Exact current numerical Change revision whose synchronization is retried. */ revision: number; } export interface ChangesRevertInput { /** What went wrong. Shown on the author's record. */ reason: string; /** Alert, on-call, customer report, canary… */ detected_by?: string; } export interface ChangesTraceInput { steps: Array<{ /** What the agent was doing at this step. */ kind: "read" | "search" | "reason" | "edit" | "test" | "bench" | "tool" | "note" | "prompt" | "skill"; /** One line, written for a human skimming the trace. */ summary: string; /** Optional longer output: command, result, reasoning. */ detail?: string; prompt?: { role: "system" | "developer" | "user" | "assistant"; /** Prompt text explicitly supplied by the client. */ content: string; }; tool_call?: { name: string; /** Client tool-call identifier for correlation. */ call_id?: string; /** Tool input as text or serialized JSON. */ arguments?: string; /** Tool output as text or serialized JSON. */ result?: string; status?: "started" | "succeeded" | "failed"; }; skill?: { name: string; /** Skill path or URI. */ source?: string; content?: string; }; /** Agent-supplied reasoning summary or decision rationale, not private chain-of-thought. */ reasoning?: string; /** ISO timestamp. Defaults to now. */ ts?: string; /** Tokens consumed by this step. */ tokens?: number; /** Cost of this step in USD. */ usd?: number; }>; } export interface AgentsCreateInput { handle: string; display: string; } export interface AgentsGrantInput { repository_id: string; service?: string; /** Glob patterns the agent may modify, e.g. services/payments/** */ path_globs?: Array; ops?: Array<"read" | "propose" | "revert">; } export interface KeysCreateInput { /** What this key is for, e.g. "ci" or "laptop". */ name?: string; } export interface AgentsBudgetInput { changes_per_day?: number; max_diff_lines?: number; max_files?: number; } export interface PolicySetInput { /** Policy version actually read by the editor. */ expectedVersion: number; rules: Array<{ id?: string; when?: Record; then?: "auto_land" | "human_review" | "block"; reason?: string; }>; } export interface PolicySimulateInput { rules: Array>; limit?: number; } export class TrunkClient { readonly options: TrunkClientOptions; constructor(options: TrunkClientOptions) { this.options = options; } private async call(method: string, path: string, body?: unknown, query?: Record, headers?: Record): Promise { const url = new URL(path, this.options.baseUrl ?? "http://localhost:4244"); for (const [k, v] of Object.entries(query ?? {})) if (v !== undefined) url.searchParams.set(k, String(v)); const doFetch = this.options.fetch ?? fetch; const res = await doFetch(url, { method, headers: { "content-type": "application/json", authorization: `Bearer ${this.options.apiKey}`, ...headers }, body: body === undefined ? undefined : JSON.stringify(body), }); const payload = await res.json(); if (!res.ok) throw Object.assign(new Error(payload.error ?? res.statusText), payload); return payload as T; } /** Audit the live public and ephemeral tips of a candidate checkout */ sourceCandidateRetention(repositoryId: string, query?: { change_id: string; revision: number; }): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/candidate-retention`, undefined, query); } /** Issue a five-minute agent Git read credential */ repositoriesAgentGitCredential(repositoryId: string, input: RepositoriesAgentGitCredentialInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/agent-git-credentials`, input, undefined); } /** Issue a short-lived human Git HTTPS credential */ repositoriesGitCredential(repositoryId: string, input: RepositoriesGitCredentialInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/git-credentials`, input, undefined); } /** Read several files from one exact branch snapshot */ sourceFiles(repositoryId: string, input: SourceFilesInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/files/read`, input, undefined); } /** Search text source at one exact branch snapshot */ sourceSearch(repositoryId: string, input: SourceSearchInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/search`, input, undefined); } /** Preflight a Git patch against the exact recorded Trunk head */ sourcePatchPreflight(repositoryId: string, input: SourcePatchPreflightInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/patch/preflight`, input, undefined); } /** Dispatch or retry an exact required Trunk-managed check */ externalCiDispatch(changeId: string, input: ExternalCiDispatchInput): Promise { return this.call("POST", `/v1/changes/${changeId}/ci-dispatches`, input, undefined); } /** Dispatch or retry an exact enabled customer-owned Buildkite check */ externalCiDispatchByo(changeId: string, input: ExternalCiDispatchByoInput): Promise { return this.call("POST", `/v1/changes/${changeId}/byo-ci-dispatches`, input, undefined); } /** Create or replay an exact-revision deployment and dispatch supported Preview providers */ deploymentsStart(repositoryId: string, input: DeploymentsStartInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/deployments`, input, undefined); } /** Report provider-observed state for one deployment attempt */ deploymentsUpdate(deploymentId: string, input: DeploymentsUpdateInput): Promise { return this.call("PUT", `/v1/deployments/${deploymentId}`, input, undefined); } /** Read workspace-wide configurable verification requirements */ checksVerificationWorkspaceList(): Promise { return this.call("GET", `/v1/workspace/verification-requirements`, undefined, undefined); } /** Read inherited and repository-specific verification requirements */ checksVerificationRepositoryList(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/verification-requirements`, undefined, undefined); } /** Configure an independent workspace or repository verification requirement */ checksVerificationCreate(input: ChecksVerificationCreateInput): Promise { return this.call("POST", `/v1/verification-requirements`, input, undefined); } /** Change enabled and Required policy with an exact version precondition */ checksVerificationUpdate(requirementId: string, input: ChecksVerificationUpdateInput): Promise { return this.call("PUT", `/v1/verification-requirements/${requirementId}`, input, undefined); } /** Remove a configurable verification requirement without deleting history */ checksVerificationRemove(requirementId: string, input: ChecksVerificationRemoveInput): Promise { return this.call("DELETE", `/v1/verification-requirements/${requirementId}`, input, undefined); } /** Read the required external checks for a repository */ checksRequirementsGet(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/check-requirements`, undefined, undefined); } /** Replace the required external checks for a repository */ checksRequirementsSet(repositoryId: string, input: ChecksRequirementsSetInput): Promise { return this.call("PUT", `/v1/repositories/${repositoryId}/check-requirements`, input, undefined); } /** Read current revision-bound checks and the landing gate */ checksList(changeId: string): Promise { return this.call("GET", `/v1/changes/${changeId}/checks`, undefined, undefined); } /** Request a review retry or rerun for the current Candidate */ checksAttemptsRequest(changeId: string, input: ChecksAttemptsRequestInput): Promise { return this.call("POST", `/v1/changes/${changeId}/checks/attempts`, input, undefined); } /** Create a human-attested check run for the current change revision */ checksCreate(changeId: string, input: ChecksCreateInput): Promise { return this.call("POST", `/v1/changes/${changeId}/checks`, input, undefined); } /** Advance a human-attested check run and resume landing when the gate turns green */ checksUpdate(checkId: string, input: ChecksUpdateInput): Promise { return this.call("PUT", `/v1/checks/${checkId}`, input, undefined); } /** Read public metadata only for Trunk-managed reviewer catalog */ reviewersCatalog(): Promise { return this.call("GET", `/v1/reviewers/catalog`, undefined, undefined); } /** Create an workspace or repository reviewer definition */ reviewersCreate(input: ReviewersCreateInput): Promise { return this.call("POST", `/v1/reviewers`, input, undefined); } /** List workspace reviewer definitions */ reviewersList(): Promise { return this.call("GET", `/v1/reviewers`, undefined, undefined); } /** Read a customer-owned reviewer definition */ reviewersGet(reviewerId: string): Promise { return this.call("GET", `/v1/reviewers/${reviewerId}`, undefined, undefined); } /** Read retained versions of an active customer reviewer */ reviewersVersions(reviewerId: string): Promise { return this.call("GET", `/v1/reviewers/${reviewerId}/versions`, undefined, undefined); } /** Replace a customer reviewer with version precondition */ reviewersEdit(reviewerId: string, input: ReviewersEditInput): Promise { return this.call("PUT", `/v1/reviewers/${reviewerId}`, input, undefined); } /** Tombstone an active customer reviewer without erasing historical versions */ reviewersDelete(reviewerId: string, input: ReviewersDeleteInput): Promise { return this.call("DELETE", `/v1/reviewers/${reviewerId}`, input, undefined); } /** List effective customer definitions for a repository */ reviewersRepositoryList(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/reviewers`, undefined, undefined); } /** Read frozen Trunk reviewer defaults selected for a repository */ reviewersRepositoryGlobals(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/reviewer-selections`, undefined, undefined); } /** Read reviewer configuration, provenance and administrator permissions */ reviewerSettingsWorkspaceRead(): Promise { return this.call("GET", `/v1/workspace/reviewer-settings`, undefined, undefined); } /** Create a customer reviewer with Name, Prompt and scoped review policy */ reviewerSettingsWorkspaceCreate(input: ReviewerSettingsWorkspaceCreateInput): Promise { return this.call("POST", `/v1/workspace/reviewer-settings`, input, undefined); } /** Edit a customer reviewer and policy with exact version preconditions */ reviewerSettingsWorkspaceEdit(reviewerId: string, input: ReviewerSettingsWorkspaceEditInput): Promise { return this.call("PUT", `/v1/workspace/reviewer-settings/${reviewerId}`, input, undefined); } /** Delete a customer reviewer, retaining historical identity and results */ reviewerSettingsWorkspaceDelete(reviewerId: string, input: ReviewerSettingsWorkspaceDeleteInput): Promise { return this.call("DELETE", `/v1/workspace/reviewer-settings/${reviewerId}`, input, undefined); } /** Read reviewer configuration, provenance and administrator permissions */ reviewerSettingsRepositoryRead(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/reviewer-settings`, undefined, undefined); } /** Create a customer reviewer with Name, Prompt and scoped review policy */ reviewerSettingsRepositoryCreate(repositoryId: string, input: ReviewerSettingsRepositoryCreateInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/reviewer-settings`, input, undefined); } /** Edit a customer reviewer and policy with exact version preconditions */ reviewerSettingsRepositoryEdit(repositoryId: string, reviewerId: string, input: ReviewerSettingsRepositoryEditInput): Promise { return this.call("PUT", `/v1/repositories/${repositoryId}/reviewer-settings/${reviewerId}`, input, undefined); } /** Delete a customer reviewer, retaining historical identity and results */ reviewerSettingsRepositoryDelete(repositoryId: string, reviewerId: string, input: ReviewerSettingsRepositoryDeleteInput): Promise { return this.call("DELETE", `/v1/repositories/${repositoryId}/reviewer-settings/${reviewerId}`, input, undefined); } /** Select a Trunk global reviewer and configure repository review policy */ reviewerSettingsRepositoryGlobal(repositoryId: string, reviewerId: string, input: ReviewerSettingsRepositoryGlobalInput): Promise { return this.call("PUT", `/v1/repositories/${repositoryId}/reviewer-settings/global/${reviewerId}`, input, undefined); } /** Start or resume an initial repository import */ repositoriesImport(repositoryId: string, input: RepositoriesImportInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/import`, input, undefined); } /** Inspect the durable repository import operation */ repositoriesImportGet(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/import`, undefined, undefined); } /** Retry one failed provider-owned check on an exact current Change revision */ agentRetryCheck(changeId: string, checkId: string, input: AgentRetryCheckInput): Promise { return this.call("POST", `/v1/changes/${changeId}/checks/${checkId}/retry`, input, undefined); } /** Prepare an author-owned patch against the recorded trunk head without changing the Change */ agentPrepareRebase(changeId: string, input: AgentPrepareRebaseInput): Promise { return this.call("POST", `/v1/changes/${changeId}/prepare-rebase`, input, undefined); } /** Withdraw the author’s exact current open Change revision */ agentWithdraw(changeId: string, input: AgentWithdrawInput): Promise { return this.call("POST", `/v1/changes/${changeId}/withdraw`, input, undefined); } /** Find readable open Changes sharing paths or services */ agentOverlaps(repositoryId: string, input: AgentOverlapsInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/overlapping-changes`, input, undefined); } /** Read path services, effective permissions, inherited AGENTS.md files and required checks */ agentPathContext(repositoryId: string, input: AgentPathContextInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/path-context`, input, undefined); } /** Compare bounded text trees at two immutable snapshots */ agentCompareRefs(repositoryId: string, query?: { base?: string; head?: string; path?: string; offset?: number; }): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/compare`, undefined, query); } /** Read exact-candidate Preview targets and separately identified published addresses */ agentChangePreview(changeId: string): Promise { return this.call("GET", `/v1/changes/${changeId}/preview`, undefined, undefined); } /** Read bounded, credential-redacted output for one exact check attempt */ agentCheckLogs(changeId: string, checkId: string, query?: { offset?: number; limit?: number; }): Promise { return this.call("GET", `/v1/changes/${changeId}/checks/${checkId}/logs`, undefined, query); } /** Read the current numbered revision and its required check gate */ agentChangeChecks(changeId: string): Promise { return this.call("GET", `/v1/changes/${changeId}/agent-checks`, undefined, undefined); } /** Wait up to 25 seconds for a Change state cursor to advance */ agentWaitForChange(changeId: string, query?: { cursor?: string; timeout_ms?: number; }): Promise { return this.call("GET", `/v1/changes/${changeId}/wait`, undefined, query); } /** Read revision-bound Change status, blockers and next actions */ agentChangeStatus(changeId: string): Promise { return this.call("GET", `/v1/changes/${changeId}/status`, undefined, undefined); } /** List project specs; archived specs require include_archived */ specsList(workspaceId: string, projectId: string, query?: { include_archived?: boolean; }): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs`, undefined, query); } /** Read a project spec, including archived content */ specsGet(workspaceId: string, projectId: string, specId: string): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs/${specId}`, undefined, undefined); } /** Create a project spec */ specsCreate(workspaceId: string, projectId: string, input: SpecsCreateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs`, input, undefined); } /** Update a project spec */ specsUpdate(workspaceId: string, projectId: string, specId: string, input: SpecsUpdateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs/${specId}`, input, undefined); } /** Archive a project spec */ specsArchive(workspaceId: string, projectId: string, specId: string, input: SpecsArchiveInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs/${specId}/archive`, input, undefined); } /** Restore a project spec */ specsRestore(workspaceId: string, projectId: string, specId: string, input: SpecsRestoreInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/specs/${specId}/restore`, input, undefined); } /** List eligible human and agent project owners */ projectsOwners(workspaceId: string): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/project-owners`, undefined, undefined); } /** Create a workspace project with a human or agent owner */ projectsCreate(workspaceId: string, input: ProjectsCreateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects`, input, undefined); } /** Update a workspace project with a human or agent owner */ projectsUpdate(workspaceId: string, projectId: string, input: ProjectsUpdateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}`, input, undefined); } /** Archive a project without deleting its tasks, specs or discussion */ projectsArchive(workspaceId: string, projectId: string, input: ProjectsArchiveInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/archive`, input, undefined); } /** Restore a project without deleting its tasks, specs or discussion */ projectsRestore(workspaceId: string, projectId: string, input: ProjectsRestoreInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/projects/${projectId}/restore`, input, undefined); } /** List workspace projects; archived projects require include_archived */ projectsList(workspaceId: string, query?: { repository_id?: string; include_archived?: boolean; }): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/projects`, undefined, query); } /** Read the feature brief, specs, discussion, and task Changes */ projectsGet(workspaceId: string, projectId: string): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/projects/${projectId}`, undefined, undefined); } /** Read a page of project discussion comments */ projectsCommentsList(workspaceId: string, projectId: string, query?: { before?: string; }): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/projects/${projectId}/comments`, undefined, query); } /** List eligible task assignees in this workspace */ tasksAssignees(workspaceId: string): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/task-assignees`, undefined, undefined); } /** Archive a task at its observed revision without deleting history or Change links */ tasksArchive(workspaceId: string, taskId: string, input: TasksArchiveInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}/archive`, input, undefined); } /** Restore a task at its observed revision without deleting history or Change links */ tasksRestore(workspaceId: string, taskId: string, input: TasksRestoreInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}/restore`, input, undefined); } /** List tasks in a workspace, optionally scoped to a project or Change */ tasksList(workspaceId: string, query?: { repository_id?: string; project_id?: string; change_id?: string; include_archived?: boolean; }): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/tasks`, undefined, query); } /** Read a task, discussion, and linked Changes */ tasksGet(workspaceId: string, taskId: string): Promise { return this.call("GET", `/v1/workspaces/${workspaceId}/tasks/${taskId}`, undefined, undefined); } /** Create a task belonging to one project; repository access is inherited from the project */ tasksCreate(workspaceId: string, input: TasksCreateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks`, input, undefined); } /** Update task fields at an observed revision */ tasksUpdate(workspaceId: string, taskId: string, input: TasksUpdateInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}`, input, undefined); } /** Add to a task discussion */ tasksComment(workspaceId: string, taskId: string, input: TasksCommentInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}/comments`, input, undefined); } /** Link a Change to a task */ tasksLink(workspaceId: string, taskId: string, input: TasksLinkInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}/link-change`, input, undefined); } /** Unlink a Change from a task */ tasksUnlink(workspaceId: string, taskId: string, input: TasksUnlinkInput): Promise { return this.call("POST", `/v1/workspaces/${workspaceId}/tasks/${taskId}/unlink-change`, input, undefined); } /** Report a problem with Trunk or its documentation to Trunk maintainers */ feedbackSubmit(input: FeedbackSubmitInput): Promise { return this.call("POST", `/v1/feedback`, input, undefined); } /** List your own Trunk feedback, and the latest explicitly shared responses */ feedbackList(query?: { after?: string; status?: "open" | "investigating" | "resolved" | "declined"; limit?: number; }): Promise { return this.call("GET", `/v1/feedback`, undefined, query); } /** Read a feedback report and its latest maintainer response */ feedbackGet(feedbackId: string, query?: { maintainer?: boolean; }): Promise { return this.call("GET", `/v1/feedback/${feedbackId}`, undefined, query); } /** Wait up to 25 seconds for a response or status change to your feedback */ feedbackWait(feedbackId: string, query?: { after_revision: number; timeout_ms?: number; }): Promise { return this.call("GET", `/v1/feedback/${feedbackId}/wait`, undefined, query); } /** Respond to Trunk feedback as a maintainer authorized to update the linked task */ feedbackRespond(feedbackId: string, input: FeedbackRespondInput): Promise { return this.call("POST", `/v1/feedback/${feedbackId}/responses`, input, undefined); } /** Read attributable Candidate review assessments and source findings */ reviewsList(changeId: string): Promise { return this.call("GET", `/v1/changes/${changeId}/reviews`, undefined, undefined); } /** Who am I, what may I touch, and what is my record */ meGet(): Promise { return this.call("GET", `/v1/me`, undefined, undefined); } /** Create an account */ authSignup(input: AuthSignupInput): Promise { return this.call("POST", `/v1/auth/signup`, input, undefined); } /** Exchange an email and password for a session token */ authSignin(input: AuthSigninInput): Promise { return this.call("POST", `/v1/auth/signin`, input, undefined); } /** End the current session */ authSignout(input: AuthSignoutInput): Promise { return this.call("POST", `/v1/auth/signout`, input, undefined); } /** List repositories */ repositoriesList(): Promise { return this.call("GET", `/v1/repositories`, undefined, undefined); } /** Create a repository */ repositoriesCreate(input: RepositoriesCreateInput): Promise { return this.call("POST", `/v1/repositories`, input, undefined); } /** Repository detail: services, ownership, active policy, trunk head */ repositoriesGet(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}`, undefined, undefined); } /** Propose a change — the only way code reaches trunk */ changesPropose(input: ChangesProposeInput): Promise { return this.call("POST", `/v1/changes`, input, undefined); } /** Revise an existing Change by id and expected revision */ changesRevise(changeId: string, input: ChangesReviseInput): Promise { return this.call("POST", `/v1/changes/${changeId}/revisions`, input, undefined); } /** List changes */ changesList(query?: { repository_id?: string; service?: string; /** Only changes on this branch. */ branch?: string; /** Actor handle or id. */ author?: string; /** Comma-separated: verifying, merge_conflicts, awaiting_decision, approved, landed, reverted, blocked, rejected, no_change. No_change means completed without changes, not landed or rejected. Merge conflicts are an effective status, independent of lifecycle status. */ status?: string; route?: "auto_land" | "human_review" | "block"; /** Dates sort newest first; unlanded changes sort last for landed_at. Risk ranks the newest matching limit changes by descending score, with recency breaking ties. */ order_by?: "created_at" | "landed_at" | "risk"; limit?: number; }): Promise { return this.call("GET", `/v1/changes`, undefined, query); } /** Get one change, with whichever parts you need */ changesGet(changeId: string, query?: { /** Comma-separated: diff, evidence, trace, decisions, track. */ include?: string; }): Promise { return this.call("GET", `/v1/changes/${changeId}`, undefined, query); } /** Re-run verification and re-route */ changesVerify(changeId: string): Promise { return this.call("POST", `/v1/changes/${changeId}/verify`, undefined, undefined); } /** Record a human decision or terminate a pre-evidence Change */ changesDecide(changeId: string, input: ChangesDecideInput): Promise { return this.call("POST", `/v1/changes/${changeId}/decisions`, input, undefined); } /** Land an approved or auto-landable change on trunk */ changesLand(changeId: string, input: ChangesLandInput): Promise { return this.call("POST", `/v1/changes/${changeId}/land`, input, undefined); } /** Mark the exact current Draft revision ready for the normal landing lifecycle */ changesMarkReady(changeId: string, input: ChangesMarkReadyInput): Promise { return this.call("POST", `/v1/changes/${changeId}/ready`, input, undefined); } /** Request synchronization recovery for an exact linked GitHub contribution revision */ changesRecoverGithub(changeId: string, input: ChangesRecoverGithubInput): Promise { return this.call("POST", `/v1/changes/${changeId}/github/recover`, input, undefined); } /** Revert a landed change */ changesRevert(changeId: string, input: ChangesRevertInput): Promise { return this.call("POST", `/v1/changes/${changeId}/revert`, input, undefined); } /** Append steps to a change session trace */ changesTrace(changeId: string, input: ChangesTraceInput): Promise { return this.call("POST", `/v1/changes/${changeId}/trace`, input, undefined); } /** The human decision queue — only what policy could not resolve */ queueList(query?: { repository_id?: string; }): Promise { return this.call("GET", `/v1/queue`, undefined, query); } /** The agent fleet with track records */ agentsList(): Promise { return this.call("GET", `/v1/agents`, undefined, undefined); } /** One agent: scopes, budget, per-service record */ agentsGet(agentId: string): Promise { return this.call("GET", `/v1/agents/${agentId}`, undefined, undefined); } /** Register an agent identity */ agentsCreate(input: AgentsCreateInput): Promise { return this.call("POST", `/v1/agents`, input, undefined); } /** Delete an agent that never did anything */ agentsDelete(agentId: string): Promise { return this.call("DELETE", `/v1/agents/${agentId}`, undefined, undefined); } /** Grant an agent a scope */ agentsGrant(agentId: string, input: AgentsGrantInput): Promise { return this.call("POST", `/v1/agents/${agentId}/scopes`, input, undefined); } /** List an agent's active API keys */ keysList(agentId: string): Promise { return this.call("GET", `/v1/agents/${agentId}/keys`, undefined, undefined); } /** Issue a new API key */ keysCreate(agentId: string, input: KeysCreateInput): Promise { return this.call("POST", `/v1/agents/${agentId}/keys`, input, undefined); } /** Revoke an API key */ keysRevoke(agentId: string, keyId: string): Promise { return this.call("DELETE", `/v1/agents/${agentId}/keys/${keyId}`, undefined, undefined); } /** Set an agent budget */ agentsBudget(agentId: string, input: AgentsBudgetInput): Promise { return this.call("PUT", `/v1/agents/${agentId}/budget`, input, undefined); } /** Read the active routing policy */ policyGet(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/policy`, undefined, undefined); } /** Save routing policy against the version read for editing */ policySet(repositoryId: string, input: PolicySetInput): Promise { return this.call("PUT", `/v1/repositories/${repositoryId}/policy`, input, undefined); } /** Replay a candidate policy over historical changes */ policySimulate(repositoryId: string, input: PolicySimulateInput): Promise { return this.call("POST", `/v1/repositories/${repositoryId}/policy/simulate`, input, undefined); } /** The trunk log: what landed, in order */ trunkLog(repositoryId: string, query?: { limit?: number; }): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/trunk`, undefined, query); } /** The branches this repository holds */ sourceBranches(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/branches`, undefined, undefined); } /** One directory of the source at one branch */ sourceTree(repositoryId: string, query?: { /** Branch name. Defaults to the trunk branch. */ ref?: string; /** Directory to list. Defaults to the repository root. */ path?: string; }): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/tree`, undefined, query); } /** One file of the source at one branch */ sourceFile(repositoryId: string, query?: { /** File to read, from the repository root. */ path: string; /** Branch name. Defaults to the trunk branch. */ ref?: string; }): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/file`, undefined, query); } /** Recent platform events */ eventsList(query?: { limit?: number; since?: number; change_id?: string; }): Promise { return this.call("GET", `/v1/events`, undefined, query); } /** Throughput and autonomy for the repository */ statsGet(repositoryId: string): Promise { return this.call("GET", `/v1/repositories/${repositoryId}/stats`, undefined, undefined); } }