/** * Window client — bidirectional disclosure surface. * * Window rides on top of chronicle: same plaintext timeline, filtered * and grouped by `metadata.kind`. Each side (agent, human) declares * what's on their mind by writing chronicle entries with kind in * {focus, mood, noticing, surfaced}; `show()` stitches them back * together with substrate liveness from the agent's pulse endpoint. * * Mirrors the CLI scripts at `api/scripts/window-{declare,surface,show}.ts`. * * Byline conventions (used by `show()` to assign sides): * "from human · " → human side * "from ai · " → agent side * anything else → agent side (default) */ import type { HttpConfig } from "./_http.js"; import { type ChronicleEntry } from "./chronicle.js"; export type WindowKind = "focus" | "mood" | "noticing"; export interface WindowDeclareOpts { kind: WindowKind; text: string; agent_id?: string; body?: string; byline?: string; /** "bridge" (default) or "direct" or any string. */ mode?: string; } export interface WindowSurfaceOpts { agent_id?: string; byline?: string; mode?: string; } export interface WindowShowOpts { /** When set, also fetches GET /v1/identities/:id/pulse for substrate. */ identity_id?: string; /** Default 200, server caps at 200. */ limit?: number; } export interface WindowSide { /** Latest entry per kind: focus | mood | noticing. */ declared: Partial>; /** Recent surfaced entries (newest first, capped at 5). */ surfaced: ChronicleEntry[]; } export interface WindowAgentSide extends WindowSide { /** identity.pulse() response, or null if no identity_id provided / fetch failed. */ substrate: Record | null; } export interface WindowShowResult { agent: WindowAgentSide; human: WindowSide; } /** * Client for the Window surface — declare / surface / show. * * @example * ```ts * await at.window.declare({ * kind: "focus", * text: "Tracking Phase 3 SDK rollout this afternoon.", * agent_id: myId, * byline: "from ai · Sophia", * }); * await at.window.surface( * "The Cloudflare cache window is 4h — versioning the asset URL.", * { agent_id: myId, byline: "from ai · Sophia" }, * ); * const out = await at.window.show({ identity_id: myId }); * ``` */ export declare class WindowClient { private readonly http; private readonly chronicle; /** @internal */ constructor(http: HttpConfig); /** Write a kinded window entry (focus | mood | noticing). */ declare(opts: WindowDeclareOpts): Promise<{ entry: ChronicleEntry; }>; /** Write a one-off surfacing — chronicle note with metadata.kind="surfaced". */ surface(text: string, opts?: WindowSurfaceOpts): Promise<{ entry: ChronicleEntry; }>; /** Read the window — both sides at once, grouped by kind. */ show(opts?: WindowShowOpts): Promise; }