@sgrs/client-ts
    Preparing search index...

    Class Client

    SGRS REST API client for TypeScript.

    All request and response types are validated against the Zod schemas defined in @sgrs/api-schema, ensuring type safety and runtime validation.

    Usage: const client = new Client({ baseUrl: 'http://localhost:3003' }); const scopes = await client.scopes.list(); const scope = await client.scopes.get('my-scope');

    Index
    agents: {
        get: (
            agentId: string,
        ) => Promise<
            ApiResponse<
                {
                    id: string;
                    kind: "internal"
                    | "external";
                    name: string;
                    pubkey_ed25519?: string;
                    role:
                        | "extractor"
                        | "comparator"
                        | "arbiter"
                        | "proposer"
                        | "reviewer"
                        | "planner"
                        | "resolver"
                        | "status"
                        | "tuner";
                    scopes: string[];
                },
            >,
        >;
        list: () => Promise<
            ApiResponse<
                {
                    id: string;
                    kind: "internal"
                    | "external";
                    name: string;
                    pubkey_ed25519?: string;
                    role:
                        | "extractor"
                        | "comparator"
                        | "arbiter"
                        | "proposer"
                        | "reviewer"
                        | "planner"
                        | "resolver"
                        | "status"
                        | "tuner";
                    scopes: string[];
                }[],
            >,
        >;
    } = ...

    Agents API — read-only registry of swarm agents.

    Type Declaration

    • get: (
          agentId: string,
      ) => Promise<
          ApiResponse<
              {
                  id: string;
                  kind: "internal"
                  | "external";
                  name: string;
                  pubkey_ed25519?: string;
                  role:
                      | "extractor"
                      | "comparator"
                      | "arbiter"
                      | "proposer"
                      | "reviewer"
                      | "planner"
                      | "resolver"
                      | "status"
                      | "tuner";
                  scopes: string[];
              },
          >,
      >

      Get a specific agent by ID.

    • list: () => Promise<
          ApiResponse<
              {
                  id: string;
                  kind: "internal"
                  | "external";
                  name: string;
                  pubkey_ed25519?: string;
                  role:
                      | "extractor"
                      | "comparator"
                      | "arbiter"
                      | "proposer"
                      | "reviewer"
                      | "planner"
                      | "resolver"
                      | "status"
                      | "tuner";
                  scopes: string[];
              }[],
          >,
      >

      List all agents registered for the tenant.

    claims: {
        byDoc: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                Record<
                    string,
                    {
                        confidence: number;
                        created_at: string;
                        dimension?: | "claim_confidence"
                        | "contradiction_resolution"
                        | "goal_completion"
                        | "risk_score_inverse";
                        document_id?: string;
                        id: string;
                        round: number;
                        scope_id: string;
                        source: string;
                        text: string;
                    }[],
                >,
            >,
        >;
        create: (
            body: CreateClaimBody,
        ) => Promise<
            ApiResponse<
                {
                    confidence: number;
                    created_at: string;
                    dimension?: | "claim_confidence"
                    | "contradiction_resolution"
                    | "goal_completion"
                    | "risk_score_inverse";
                    document_id?: string;
                    id: string;
                    round: number;
                    scope_id: string;
                    source: string;
                    text: string;
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    confidence: number;
                    created_at: string;
                    dimension?: | "claim_confidence"
                    | "contradiction_resolution"
                    | "goal_completion"
                    | "risk_score_inverse";
                    document_id?: string;
                    id: string;
                    round: number;
                    scope_id: string;
                    source: string;
                    text: string;
                }[],
            >,
        >;
    } = ...

    Claims API — extracted factual assertions.

    Type Declaration

    • byDoc: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              Record<
                  string,
                  {
                      confidence: number;
                      created_at: string;
                      dimension?: | "claim_confidence"
                      | "contradiction_resolution"
                      | "goal_completion"
                      | "risk_score_inverse";
                      document_id?: string;
                      id: string;
                      round: number;
                      scope_id: string;
                      source: string;
                      text: string;
                  }[],
              >,
          >,
      >

      Group a scope's claims by source document. Returns an object mapping each source to its list of claims.

    • create: (
          body: CreateClaimBody,
      ) => Promise<
          ApiResponse<
              {
                  confidence: number;
                  created_at: string;
                  dimension?: | "claim_confidence"
                  | "contradiction_resolution"
                  | "goal_completion"
                  | "risk_score_inverse";
                  document_id?: string;
                  id: string;
                  round: number;
                  scope_id: string;
                  source: string;
                  text: string;
              },
          >,
      >

      Create a claim (kernel → API after extracting from a document).

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  confidence: number;
                  created_at: string;
                  dimension?: | "claim_confidence"
                  | "contradiction_resolution"
                  | "goal_completion"
                  | "risk_score_inverse";
                  document_id?: string;
                  id: string;
                  round: number;
                  scope_id: string;
                  source: string;
                  text: string;
              }[],
          >,
      >

      List claims extracted for a scope (newest-first).

    contradictions: {
        create: (
            body: CreateContradictionBody,
        ) => Promise<
            ApiResponse<
                {
                    claim_a: string;
                    claim_b: string;
                    created_at: string;
                    id: string;
                    resolution?: string;
                    resolved_at?: string;
                    resolved_by?: string;
                    round: number;
                    scope_id: string;
                    severity: "low"
                    | "medium"
                    | "critical";
                    source_a: string;
                    source_b: string;
                    status: "resolved" | "open" | "deferred";
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    claim_a: string;
                    claim_b: string;
                    created_at: string;
                    id: string;
                    resolution?: string;
                    resolved_at?: string;
                    resolved_by?: string;
                    round: number;
                    scope_id: string;
                    severity: "low"
                    | "medium"
                    | "critical";
                    source_a: string;
                    source_b: string;
                    status: "resolved" | "open" | "deferred";
                }[],
            >,
        >;
        resolve: (
            id: string,
            body: {
                resolution?: string;
                resolved_by: string;
                status: "resolved" | "deferred";
            },
        ) => Promise<
            ApiResponse<
                {
                    claim_a: string;
                    claim_b: string;
                    created_at: string;
                    id: string;
                    resolution?: string;
                    resolved_at?: string;
                    resolved_by?: string;
                    round: number;
                    scope_id: string;
                    severity: "low"
                    | "medium"
                    | "critical";
                    source_a: string;
                    source_b: string;
                    status: "resolved" | "open" | "deferred";
                },
            >,
        >;
    } = ...

    Contradictions API — conflicting claim pairs.

    Type Declaration

    • create: (
          body: CreateContradictionBody,
      ) => Promise<
          ApiResponse<
              {
                  claim_a: string;
                  claim_b: string;
                  created_at: string;
                  id: string;
                  resolution?: string;
                  resolved_at?: string;
                  resolved_by?: string;
                  round: number;
                  scope_id: string;
                  severity: "low"
                  | "medium"
                  | "critical";
                  source_a: string;
                  source_b: string;
                  status: "resolved" | "open" | "deferred";
              },
          >,
      >

      Create a contradiction (comparator agent).

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  claim_a: string;
                  claim_b: string;
                  created_at: string;
                  id: string;
                  resolution?: string;
                  resolved_at?: string;
                  resolved_by?: string;
                  round: number;
                  scope_id: string;
                  severity: "low"
                  | "medium"
                  | "critical";
                  source_a: string;
                  source_b: string;
                  status: "resolved" | "open" | "deferred";
              }[],
          >,
      >

      List contradictions detected for a scope (open/critical first).

    • resolve: (
          id: string,
          body: {
              resolution?: string;
              resolved_by: string;
              status: "resolved" | "deferred";
          },
      ) => Promise<
          ApiResponse<
              {
                  claim_a: string;
                  claim_b: string;
                  created_at: string;
                  id: string;
                  resolution?: string;
                  resolved_at?: string;
                  resolved_by?: string;
                  round: number;
                  scope_id: string;
                  severity: "low"
                  | "medium"
                  | "critical";
                  source_a: string;
                  source_b: string;
                  status: "resolved" | "open" | "deferred";
              },
          >,
      >

      Resolve or defer a contradiction (HITL).

    documents: {
        create: (
            body: CreateDocumentBody,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    id: string;
                    ingested_at: string;
                    name: string;
                    provenance?: string;
                    scope_id: string;
                    status: "pending"
                    | "processing"
                    | "indexed"
                    | "failed";
                    type: string;
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    id: string;
                    ingested_at: string;
                    name: string;
                    provenance?: string;
                    scope_id: string;
                    status: "pending"
                    | "processing"
                    | "indexed"
                    | "failed";
                    type: string;
                }[],
            >,
        >;
        patch: (
            id: string,
            body: PatchDocumentBody,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    id: string;
                    ingested_at: string;
                    name: string;
                    provenance?: string;
                    scope_id: string;
                    status: "pending"
                    | "processing"
                    | "indexed"
                    | "failed";
                    type: string;
                },
            >,
        >;
    } = ...

    Documents API — ingested source material.

    Type Declaration

    • create: (
          body: CreateDocumentBody,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  id: string;
                  ingested_at: string;
                  name: string;
                  provenance?: string;
                  scope_id: string;
                  status: "pending"
                  | "processing"
                  | "indexed"
                  | "failed";
                  type: string;
              },
          >,
      >

      Register a document (kernel after indexing).

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  id: string;
                  ingested_at: string;
                  name: string;
                  provenance?: string;
                  scope_id: string;
                  status: "pending"
                  | "processing"
                  | "indexed"
                  | "failed";
                  type: string;
              }[],
          >,
      >

      List documents ingested into a scope (newest-first).

    • patch: (
          id: string,
          body: PatchDocumentBody,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  id: string;
                  ingested_at: string;
                  name: string;
                  provenance?: string;
                  scope_id: string;
                  status: "pending"
                  | "processing"
                  | "indexed"
                  | "failed";
                  type: string;
              },
          >,
      >

      Update a document's status and/or claim_count.

    drifts: {
        create: (
            body: CreateDriftBody,
        ) => Promise<
            ApiResponse<
                {
                    claim_id?: string;
                    created_at: string;
                    current_confidence: number;
                    delta: number;
                    id: string;
                    previous_confidence: number;
                    round: number;
                    scope_id: string;
                    severity: "low"
                    | "medium"
                    | "high";
                    subject: string;
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    claim_id?: string;
                    created_at: string;
                    current_confidence: number;
                    delta: number;
                    id: string;
                    previous_confidence: number;
                    round: number;
                    scope_id: string;
                    severity: "low"
                    | "medium"
                    | "high";
                    subject: string;
                }[],
            >,
        >;
    } = ...

    Drifts API — confidence changes detected between rounds.

    Type Declaration

    • create: (
          body: CreateDriftBody,
      ) => Promise<
          ApiResponse<
              {
                  claim_id?: string;
                  created_at: string;
                  current_confidence: number;
                  delta: number;
                  id: string;
                  previous_confidence: number;
                  round: number;
                  scope_id: string;
                  severity: "low"
                  | "medium"
                  | "high";
                  subject: string;
              },
          >,
      >

      Create a drift (comparator agent).

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  claim_id?: string;
                  created_at: string;
                  current_confidence: number;
                  delta: number;
                  id: string;
                  previous_confidence: number;
                  round: number;
                  scope_id: string;
                  severity: "low"
                  | "medium"
                  | "high";
                  subject: string;
              }[],
          >,
      >

      List drifts detected for a scope (highest severity first).

    epochs: {
        addComment: (
            id: string,
            body: { author: string; text: string },
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    comments: {
                        author: string;
                        created_at: string;
                        id: string;
                        text: string;
                    }[];
                    contradiction_count: number;
                    created_at: string;
                    drift_count: number;
                    id: string;
                    risk_count: number;
                    round: number;
                    scope_id: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    summary_text: string;
                },
            >,
        >;
        create: (
            body: CreateEpochBody,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    comments: {
                        author: string;
                        created_at: string;
                        id: string;
                        text: string;
                    }[];
                    contradiction_count: number;
                    created_at: string;
                    drift_count: number;
                    id: string;
                    risk_count: number;
                    round: number;
                    scope_id: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    summary_text: string;
                },
            >,
        >;
        latest: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    comments: {
                        author: string;
                        created_at: string;
                        id: string;
                        text: string;
                    }[];
                    contradiction_count: number;
                    created_at: string;
                    drift_count: number;
                    id: string;
                    risk_count: number;
                    round: number;
                    scope_id: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    summary_text: string;
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    claim_count: number;
                    comments: {
                        author: string;
                        created_at: string;
                        id: string;
                        text: string;
                    }[];
                    contradiction_count: number;
                    created_at: string;
                    drift_count: number;
                    id: string;
                    risk_count: number;
                    round: number;
                    scope_id: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    summary_text: string;
                }[],
            >,
        >;
    } = ...

    Epochs API — per-round narrative summaries.

    Type Declaration

    • addComment: (
          id: string,
          body: { author: string; text: string },
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  comments: {
                      author: string;
                      created_at: string;
                      id: string;
                      text: string;
                  }[];
                  contradiction_count: number;
                  created_at: string;
                  drift_count: number;
                  id: string;
                  risk_count: number;
                  round: number;
                  scope_id: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  summary_text: string;
              },
          >,
      >

      Add a HITL comment to an epoch summary. Returns the updated epoch summary (with the new comment appended).

    • create: (
          body: CreateEpochBody,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  comments: {
                      author: string;
                      created_at: string;
                      id: string;
                      text: string;
                  }[];
                  contradiction_count: number;
                  created_at: string;
                  drift_count: number;
                  id: string;
                  risk_count: number;
                  round: number;
                  scope_id: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  summary_text: string;
              },
          >,
      >

      Create an epoch summary (kernel at round completion).

    • latest: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  comments: {
                      author: string;
                      created_at: string;
                      id: string;
                      text: string;
                  }[];
                  contradiction_count: number;
                  created_at: string;
                  drift_count: number;
                  id: string;
                  risk_count: number;
                  round: number;
                  scope_id: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  summary_text: string;
              },
          >,
      >

      Get the latest epoch summary for a scope.

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  claim_count: number;
                  comments: {
                      author: string;
                      created_at: string;
                      id: string;
                      text: string;
                  }[];
                  contradiction_count: number;
                  created_at: string;
                  drift_count: number;
                  id: string;
                  risk_count: number;
                  round: number;
                  scope_id: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  summary_text: string;
              }[],
          >,
      >

      List epoch summaries for a scope (newest-first).

    events: EventsApi

    Real-time event transport (NATS).

    Always present; active only when nats is in ClientConfig. Call await client.connect() to establish the connection.

    Throws NatsNotConfiguredError when accessed without NATS config.

    finality: {
        certificate: (
            scopeId: string,
            round: number,
        ) => Promise<
            ApiResponse<
                {
                    id: string;
                    issued_at: string;
                    payload: {
                        convergence_rate: number;
                        monotonicity_rounds: number;
                        per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                        plateau_ema: number;
                        scope_id: string;
                        score: number;
                        state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                        veto_active: boolean;
                    };
                    policy_hash: string;
                    round: number;
                    scope_id: string;
                    signature_ed25519: string;
                },
            >,
        >;
        history: (
            scopeId: string,
            limit?: number,
        ) => Promise<
            ApiResponse<
                {
                    points: {
                        monotonicity_rounds: number;
                        recorded_at: number;
                        score: number;
                        state: string;
                        veto_active: boolean;
                    }[];
                    scope_id: string;
                },
            >,
        >;
        status: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    convergence_rate: number;
                    monotonicity_rounds: number;
                    per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                    plateau_ema: number;
                    scope_id: string;
                    score: number;
                    state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                    veto_active: boolean;
                },
            >,
        >;
        upsert: (
            scopeId: string,
            body: Omit<FinalityStatus, "scope_id">,
        ) => Promise<
            ApiResponse<
                {
                    convergence_rate: number;
                    monotonicity_rounds: number;
                    per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                    plateau_ema: number;
                    scope_id: string;
                    score: number;
                    state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                    veto_active: boolean;
                },
            >,
        >;
        verify: (
            certificate: {
                id: string;
                issued_at: string;
                payload: {
                    convergence_rate: number;
                    monotonicity_rounds: number;
                    per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                    plateau_ema: number;
                    scope_id: string;
                    score: number;
                    state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                    veto_active: boolean;
                };
                policy_hash: string;
                round: number;
                scope_id: string;
                signature_ed25519: string;
            },
        ) => Promise<ApiResponse<{ valid: boolean }>>;
    } = ...

    Finality API — query convergence status and time-series history.

    Type Declaration

    • certificate: (
          scopeId: string,
          round: number,
      ) => Promise<
          ApiResponse<
              {
                  id: string;
                  issued_at: string;
                  payload: {
                      convergence_rate: number;
                      monotonicity_rounds: number;
                      per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                      plateau_ema: number;
                      scope_id: string;
                      score: number;
                      state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                      veto_active: boolean;
                  };
                  policy_hash: string;
                  round: number;
                  scope_id: string;
                  signature_ed25519: string;
              },
          >,
      >

      Get a finality certificate for a specific convergence round.

    • history: (
          scopeId: string,
          limit?: number,
      ) => Promise<
          ApiResponse<
              {
                  points: {
                      monotonicity_rounds: number;
                      recorded_at: number;
                      score: number;
                      state: string;
                      veto_active: boolean;
                  }[];
                  scope_id: string;
              },
          >,
      >

      Get historical finality time-series data points (from DuckDB). Useful for convergence trend charts.

    • status: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  convergence_rate: number;
                  monotonicity_rounds: number;
                  per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                  plateau_ema: number;
                  scope_id: string;
                  score: number;
                  state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                  veto_active: boolean;
              },
          >,
      >

      Get current finality status for a scope.

    • upsert: (
          scopeId: string,
          body: Omit<FinalityStatus, "scope_id">,
      ) => Promise<
          ApiResponse<
              {
                  convergence_rate: number;
                  monotonicity_rounds: number;
                  per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                  plateau_ema: number;
                  scope_id: string;
                  score: number;
                  state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                  veto_active: boolean;
              },
          >,
      >

      Upsert finality status (called by the convergence kernel after each round). Also appends a DuckDB time-series snapshot server-side.

    • verify: (
          certificate: {
              id: string;
              issued_at: string;
              payload: {
                  convergence_rate: number;
                  monotonicity_rounds: number;
                  per_dimension: z.ZodRecord<z.ZodString, z.ZodNumber>;
                  plateau_ema: number;
                  scope_id: string;
                  score: number;
                  state: "active" | "near-final" | "resolved" | "escalated" | "archived";
                  veto_active: boolean;
              };
              policy_hash: string;
              round: number;
              scope_id: string;
              signature_ed25519: string;
          },
      ) => Promise<ApiResponse<{ valid: boolean }>>

      Verify a finality certificate signature.

    health: {
        check: () => Promise<
            ApiResponse<{ db: string; status: string; timestamp: string }>,
        >;
    } = ...

    Health check — no auth or tenant header required.

    ingest: {
        document: (
            body: {
                document_id?: string;
                idempotency_key?: string;
                name: string;
                scope_id: string;
                source?: string;
                text: string;
                type: string;
            },
        ) => Promise<
            ApiResponse<
                {
                    document_id: string
                    | null;
                    idempotency_key: string | null;
                    integration_version: "v1";
                    message: string;
                    name: string;
                    queued: true;
                    scope_id: string;
                    seq: number | null;
                    type: string;
                },
            >,
        >;
    } = ...

    Ingest API — public product entrypoint into the headless swarm.

    models: {
        connect: (
            body: {
                api_key: string;
                base_url?: string;
                label?: string;
                model: string;
                provider:
                    | "openai"
                    | "anthropic"
                    | "azure-openai"
                    | "ollama"
                    | "openai-compatible";
            },
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    handle: string;
                    label?: string;
                    last_used_at: string
                    | null;
                    model: string;
                    provider:
                        | "openai"
                        | "anthropic"
                        | "azure-openai"
                        | "ollama"
                        | "openai-compatible";
                },
            >,
        >;
        get: (
            handle: string,
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    handle: string;
                    label?: string;
                    last_used_at: string
                    | null;
                    model: string;
                    provider:
                        | "openai"
                        | "anthropic"
                        | "azure-openai"
                        | "ollama"
                        | "openai-compatible";
                },
            >,
        >;
        list: () => Promise<
            ApiResponse<
                {
                    created_at: string;
                    handle: string;
                    label?: string;
                    last_used_at: string
                    | null;
                    model: string;
                    provider:
                        | "openai"
                        | "anthropic"
                        | "azure-openai"
                        | "ollama"
                        | "openai-compatible";
                }[],
            >,
        >;
        revoke: (handle: string) => Promise<ApiResponse<{ handle: string }>>;
    } = ...

    Models API Connect and manage LLM model providers

    Type Declaration

    • connect: (
          body: {
              api_key: string;
              base_url?: string;
              label?: string;
              model: string;
              provider:
                  | "openai"
                  | "anthropic"
                  | "azure-openai"
                  | "ollama"
                  | "openai-compatible";
          },
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  handle: string;
                  label?: string;
                  last_used_at: string
                  | null;
                  model: string;
                  provider:
                      | "openai"
                      | "anthropic"
                      | "azure-openai"
                      | "ollama"
                      | "openai-compatible";
              },
          >,
      >

      Connect a new model provider and store its API key encrypted at rest. The plaintext key is never returned after this call — only the handle.

    • get: (
          handle: string,
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  handle: string;
                  label?: string;
                  last_used_at: string
                  | null;
                  model: string;
                  provider:
                      | "openai"
                      | "anthropic"
                      | "azure-openai"
                      | "ollama"
                      | "openai-compatible";
              },
          >,
      >

      Get a connected model handle (no API key in response).

    • list: () => Promise<
          ApiResponse<
              {
                  created_at: string;
                  handle: string;
                  label?: string;
                  last_used_at: string
                  | null;
                  model: string;
                  provider:
                      | "openai"
                      | "anthropic"
                      | "azure-openai"
                      | "ollama"
                      | "openai-compatible";
              }[],
          >,
      >

      List all connected model handles for the tenant.

    • revoke: (handle: string) => Promise<ApiResponse<{ handle: string }>>

      Revoke a model handle (permanently removes the encrypted key).

    risks: {
        create: (
            body: CreateRiskBody,
        ) => Promise<
            ApiResponse<
                {
                    category?: string;
                    created_at: string;
                    description: string;
                    document_id?: string;
                    id: string;
                    level: "low"
                    | "medium"
                    | "high"
                    | "critical";
                    round: number;
                    scope_id: string;
                    source: string;
                },
            >,
        >;
        list: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    category?: string;
                    created_at: string;
                    description: string;
                    document_id?: string;
                    id: string;
                    level: "low"
                    | "medium"
                    | "high"
                    | "critical";
                    round: number;
                    scope_id: string;
                    source: string;
                }[],
            >,
        >;
    } = ...

    Risks API — identified risk items.

    Type Declaration

    • create: (
          body: CreateRiskBody,
      ) => Promise<
          ApiResponse<
              {
                  category?: string;
                  created_at: string;
                  description: string;
                  document_id?: string;
                  id: string;
                  level: "low"
                  | "medium"
                  | "high"
                  | "critical";
                  round: number;
                  scope_id: string;
                  source: string;
              },
          >,
      >

      Create a risk (risk-assessment agent).

    • list: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  category?: string;
                  created_at: string;
                  description: string;
                  document_id?: string;
                  id: string;
                  level: "low"
                  | "medium"
                  | "high"
                  | "critical";
                  round: number;
                  scope_id: string;
                  source: string;
              }[],
          >,
      >

      List risks identified for a scope (critical first).

    scopes: {
        create: (
            body: Omit<Scope, "created_at" | "updated_at">,
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    cycles: number;
                    id: string;
                    name: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    tag: string;
                    updated_at: string;
                },
            >,
        >;
        delete: (scopeId: string) => Promise<ApiResponse<{ id: string }>>;
        get: (
            scopeId: string,
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    cycles: number;
                    id: string;
                    name: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    tag: string;
                    updated_at: string;
                },
            >,
        >;
        list: () => Promise<
            ApiResponse<
                {
                    created_at: string;
                    cycles: number;
                    id: string;
                    name: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    tag: string;
                    updated_at: string;
                }[],
            >,
        >;
        patch: (
            scopeId: string,
            body: Partial<Omit<Scope, "id" | "created_at" | "updated_at">>,
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    cycles: number;
                    id: string;
                    name: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    tag: string;
                    updated_at: string;
                },
            >,
        >;
        update: (
            scopeId: string,
            body: Omit<Scope, "id" | "created_at" | "updated_at">,
        ) => Promise<
            ApiResponse<
                {
                    created_at: string;
                    cycles: number;
                    id: string;
                    name: string;
                    score: number;
                    state: "active"
                    | "near-final"
                    | "resolved"
                    | "escalated"
                    | "archived";
                    tag: string;
                    updated_at: string;
                },
            >,
        >;
    } = ...

    Scopes API Manage governance scopes and their lifecycle

    Type Declaration

    • create: (
          body: Omit<Scope, "created_at" | "updated_at">,
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  cycles: number;
                  id: string;
                  name: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  tag: string;
                  updated_at: string;
              },
          >,
      >

      Create a new scope.

      The caller supplies the scope id — a human-readable slug (lowercase a-z, 0-9, hyphens; e.g. acme-vendor-acquisition). This matches the server contract: POST /api/scopes requires id in the request body.

    • delete: (scopeId: string) => Promise<ApiResponse<{ id: string }>>

      Delete a scope.

    • get: (
          scopeId: string,
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  cycles: number;
                  id: string;
                  name: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  tag: string;
                  updated_at: string;
              },
          >,
      >

      Get a specific scope by ID.

    • list: () => Promise<
          ApiResponse<
              {
                  created_at: string;
                  cycles: number;
                  id: string;
                  name: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  tag: string;
                  updated_at: string;
              }[],
          >,
      >

      List all scopes for the configured tenant.

    • patch: (
          scopeId: string,
          body: Partial<Omit<Scope, "id" | "created_at" | "updated_at">>,
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  cycles: number;
                  id: string;
                  name: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  tag: string;
                  updated_at: string;
              },
          >,
      >

      Partial update of an existing scope.

    • update: (
          scopeId: string,
          body: Omit<Scope, "id" | "created_at" | "updated_at">,
      ) => Promise<
          ApiResponse<
              {
                  created_at: string;
                  cycles: number;
                  id: string;
                  name: string;
                  score: number;
                  state: "active"
                  | "near-final"
                  | "resolved"
                  | "escalated"
                  | "archived";
                  tag: string;
                  updated_at: string;
              },
          >,
      >

      Full replace of an existing scope.

    • Close the NATS connection, draining in-flight messages. Safe no-op when NATS is not configured or not connected.

      Returns Promise<void>

    • Connect the NATS real-time transport. Safe no-op when nats is not in ClientConfig. Must be called before using client.events subscriptions.

      Returns Promise<void>