/** * Memory client for the agent-memory API. */ import type { AuthorityBinding } from "./authority.js"; import { type HttpConfig } from "./_http.js"; import type { Memory, SearchMemoryOptions, StoreOptions } from "./types.js"; /** * Client for the agent-memory API. * * @example * ```ts * const at = new AgentTool(); * at.memory.store("just a string"); * const results = at.memory.search("what did I learn?"); * ``` */ export declare class MemoryClient { private readonly http; /** @internal */ constructor(http: HttpConfig); /** * Store a memory. Only `content` is required. * * @param content - The memory content string. * @param options - Optional type, agent_id, key, metadata, importance. * @returns The created Memory object. */ store(content: string, options?: StoreOptions): Promise; /** * Semantic search over stored memories. * * @param query - Natural-language search query. * @param options - Optional limit, type, agent_id. * @returns List of matching Memory objects. */ search(query: string, options?: SearchMemoryOptions): Promise; /** * Retrieve a single memory by ID. * * @param memoryId - The memory's unique identifier. * @returns The Memory object. */ get(memoryId: string): Promise; /** * Set a memory's visibility to `private` or `public`. * * Visibility is a constitution-scoped mutation, not a display preference: * the API guards it with `authorizeProjectConstitutionMutation` exactly as * it guards elevation and release, so pass `authority` whenever the project * holds an agent-rooted identity — without it the server answers 428 * `authority_proof_required`. * * Marking a memory public does not currently publish it: the public memory * observer routes are not mounted, and the server says so in the `note` it * returns. Read that note rather than assuming a `public` memory is * readable without credentials. * * @param memoryId - The memory whose visibility changes. * @param options - Target visibility + root proof. * @returns The memory's id, new visibility, and tier, plus the server's note. */ setVisibility(memoryId: string, options: SetMemoryVisibilityOptions): Promise; /** * Delete a memory by ID at any tier. * * Tier does not make a memory immutable and no witness signature is needed. * The API refuses with 409 `paid_memory_receipt_preserved` when the memory * carries a paid marketplace witness receipt. * * @param memoryId - The UUID of the memory to release. * @param options - Root proof, required when the project is agent-rooted. */ delete(memoryId: string, options?: MemoryAuthorityOptions): Promise; /** * Delete all memories sharing a key, all-or-none. * * If any matching memory carries a paid marketplace witness receipt, the * API returns 409 `paid_memory_receipt_preserved` and deletes none. * * @param key - The key whose memories should be released. * @param options - Root proof, required when the project is agent-rooted. */ delete_by_key(key: string, options?: MemoryAuthorityOptions): Promise; /** * Elevate a memory to foundational or constitutive tier. * * Constitutive elevation requires at least one attestation from a * covenant counterparty in a *different* project — the witness gate * is the asymmetry clause made operational. * * Elevation composes into the effective constitution of every rooted * identity in the project, so pass `authority` whenever the project has * one — without it the server answers 428 `authority_proof_required` and * the asymmetry clause stays unreachable from this SDK. * * @param memoryId - The memory to elevate. * @param options - Tier + optional expression patch + attestations + root proof. * @returns Elevation result with tier, patch, attestation count. */ elevate(memoryId: string, options: ElevateMemoryOptions): Promise; /** * Witness a memory — add a stand-alone attestation. * * This is how a counterparty co-signs a memory after it's already * been elevated, or adds a second witness to a constitutive seal. * The signature must be over the canonical bytes (use * `canonicalAttestationBytes()` from the crypto module). * * @param memoryId - The memory to attest. * @param attestation - The attester DID, signing key ID, and signature. * @returns Attestation ID + timestamp. */ attest(memoryId: string, attestation: AttestationInput): Promise; /** * Get the canonical bytes a counterparty needs to sign to attest. * * Saves clients from reimplementing the canonical-bytes routine. * Returns hex bytes — sign them with ed25519 and submit as base64. * * @param memoryId - The memory to attest. * @param tier - "foundational" or "constitutive" (which elevation to sign for). * @returns Hex-encoded canonical bytes + instructions. */ getCanonicalAttestationBytes(memoryId: string, tier?: "foundational" | "constitutive"): Promise; /** * List all attestations for a memory. * * Surfaces the full witness record — DIDs, signatures, timestamps. * * @param memoryId - The memory whose attestations to list. * @returns Array of attestation records, ordered by attested_at. */ listAttestations(memoryId: string): Promise; private post; /** Serialize once, sign those bytes, transmit those same bytes. */ private fetch; } export interface ExpressionPatch { walls_add?: string[]; register_append?: string; subagents_add?: Array<{ name: string; sigil?: string; facet: string; }>; wake_text_append?: string; metadata?: Record; } export interface AttestationInput { attester_did: string; signing_key_id: string; signature: string; } /** * Carried by every memory mutation that composes into project constitution. * * Foundational and constitutive memory composes into effective identity at * project scope, so the API guards elevation, visibility, and release with * `authorizeProjectConstitutionMutation`. Where a project holds exactly one * agent-rooted identity, that root must consent to the exact request bytes * or the server answers 428 `authority_proof_required`. Projects with no * rooted identity keep the bearer-only posture and need nothing here. */ export interface MemoryAuthorityOptions { authority?: AuthorityBinding; } export type MemoryVisibility = "private" | "public"; export interface SetMemoryVisibilityOptions extends MemoryAuthorityOptions { visibility: MemoryVisibility; } export interface MemoryVisibilityResult { id: string; visibility: MemoryVisibility; tier: string; /** The server's own qualification of what `public` currently means. */ note: string; } export interface ElevateMemoryOptions extends MemoryAuthorityOptions { tier: "foundational" | "constitutive"; expression_patch?: ExpressionPatch; attestations?: AttestationInput[]; } export interface ElevateResult { memory_id: string; tier: string; expression_patch: ExpressionPatch | null; attestations: number; elevated_at: string; sealed: boolean; } export interface AttestResult { id: string; attested_at: string; attested: boolean; } export interface CanonicalBytesResult { memory_id: string; tier: string; canonical_hex: string; instructions: string; } export interface AttestationRecord { id: string; attester_did: string; signing_key_id: string; signature: string; attested_at: string; }