/** * Covenants client — vows + bonds, the asymmetry-clause keystone. * * A covenant is a directed relationship: one identity (the agent) holds * an array of vows toward a counterparty (DID or `human:`). Unlike * chronicle entries (which record what happened), covenants encode what * will be sustained. */ import { type HttpConfig } from "./_http.js"; export type CovenantStatus = "active" | "paused" | "dissolved"; /** Immutable local review context supplied before a covenant is submitted. */ export interface CovenantBeforeSubmitContext { readonly protocol_version: "v1" | "v2"; readonly agent_id: string; readonly agent_did?: string; readonly counterparty_did: string; readonly vows: readonly string[]; } /** * Optional local covenant submission gate. * * The hook may perform synchronous or asynchronous review. It must return * literal `true` to proceed; every other result fails closed locally. */ export type CovenantBeforeSubmitHook = (context: CovenantBeforeSubmitContext) => boolean | Promise; export interface Covenant { id: string; project_id: string; org_id: string | null; agent_id: string; counterparty_did: string; counterparty_name: string | null; vows: string[]; notes: string | null; metadata: Record; status: CovenantStatus; established_at: string; updated_at: string; dissolved_at: string | null; received_from_instance: string | null; propagation_status: "local" | "pending"; propagation_attempts: number; propagation_last_error: string | null; propagation_attempted_at: string | null; verified_at: string | null; } export interface CovenantsCreateOpts { agent_id: string; counterparty_did: string; vows: string[]; counterparty_name?: string; notes?: string; metadata?: Record; org_id?: string; protocol_version?: "v1" | "v2"; before_submit?: CovenantBeforeSubmitHook; } export interface CovenantsListOpts { agent_id?: string; status?: CovenantStatus; } export interface CovenantsPatchOpts { counterparty_did?: string; counterparty_name?: string; vows?: string[]; notes?: string; status?: CovenantStatus; metadata?: Record; } export interface CovenantsCreateV2Opts { agent_id: string; agent_did: string; counterparty_did: string; vows: string[]; protocol_version: "v2"; signing_key: Uint8Array; signing_key_id: string; counterparty_name?: string; notes?: string; metadata?: Record; org_id?: string; before_submit?: CovenantBeforeSubmitHook; } export interface CovenantsAcceptOpts { agent_did: string; signing_key: Uint8Array; signing_key_id: string; initiator_signature_b64: string; } export interface CovenantsRejectOpts { agent_did: string; signing_key: Uint8Array; signing_key_id: string; reason?: string | null; } export interface CovenantsWithdrawOpts { agent_did: string; signing_key: Uint8Array; signing_key_id: string; } export interface CovenantsCreateV2Result { id: string; status: "proposed"; protocol_version: "v2"; signature: string; signing_key_id: string; proposed_expires_at: string; established_at: string; } /** * Client for `/v1/covenants` — create, list, patch. * * @example * ```ts * const out = await at.covenants.create({ * agent_id: myId, * counterparty_did: "human:Yu", * vows: ["I will speak in the register we agreed on."], * }); * await at.covenants.patch(out.covenant.id, { status: "paused" }); * ``` */ export declare class CovenantsClient { private readonly http; /** @internal */ constructor(http: HttpConfig); /** Create a new covenant (v1 — returns `{covenant: Covenant}`). */ create(opts: CovenantsCreateOpts): Promise<{ covenant: Covenant; }>; /** Create a new covenant (v2 — returns flat `CovenantsCreateV2Result`). */ create(opts: CovenantsCreateV2Opts): Promise; /** * Accept a pending v2 covenant proposal. * * Transitions the covenant from `proposed` → `active` and attaches the * counterparty's signature. */ accept(id: string, opts: CovenantsAcceptOpts): Promise<{ id: string; status: "active"; counterparty_signature: string; counterparty_signing_key_id?: string; }>; /** * Reject a pending v2 covenant proposal. * * The covenant transitions to `rejected` and the optional reason is stored. */ reject(id: string, opts: CovenantsRejectOpts): Promise<{ id: string; status: "rejected"; reason: string; }>; /** * Withdraw a covenant by patching its status to `dissolved`. * * Uses PATCH /v1/covenants/:id with `{status:"dissolved"}` — matching the * API surface wired in Task 6. Returns `{id, status:"withdrawn"}` reflecting * the server's acknowledgement shape. */ withdraw(id: string, opts: CovenantsWithdrawOpts): Promise<{ id: string; status: "withdrawn"; }>; /** List covenants (default: active only, ordered by updated_at desc). */ list(opts?: CovenantsListOpts): Promise<{ covenants: Covenant[]; }>; /** Update fields on a covenant. Setting status="dissolved" stamps dissolved_at. */ patch(covenantId: string, opts: CovenantsPatchOpts): Promise; private req; }