import { OursClient, type AttachOursClientOptions, type NotificationEvent } from '@ours.network/sdk/client'; /** Any failure of a daemon operation. Never carries a message body or a token. */ export declare class OursDaemonError extends Error { } /** * The daemon accepted the call and answered "not sent". The MCP surface reported * exactly these verdicts as tool errors, so they must keep throwing here: the * owner channel books a resolved send as delivered, and a silently-swallowed * refusal would be recorded as a delivered message that never left the host. */ export declare class OursSendRefusedError extends OursDaemonError { } type Res = OursClient[M] extends (...args: never[]) => infer R ? Awaited : never; export type OursContactsView = Res<'listContacts'>; export type OursInviteResult = Res<'generateInvite'>; export type OursAddContactResult = Res<'addContact'>; export type OursIncomingMessage = Res<'listIncomingMessages'>[number]; export type OursMessagesPayload = Res<'getMessages'>; export type OursInboundMessage = OursMessagesPayload['messages'][number]; export type OursHistoryMessage = NonNullable>; export type OursIncomingFile = Res<'listIncomingFiles'>[number]; export type OursRetrievedFiles = Res<'getFiles'>; export type OursRetrievedFile = OursRetrievedFiles['files'][number]; export type OursHistoryFile = NonNullable>; export type OursNotificationEvent = NotificationEvent; export type OursJsonValue = null | boolean | number | string | OursJsonValue[] | { [key: string]: OursJsonValue; }; export interface OursCommandContext { readonly sender_cid: string; readonly sender_name: string; readonly request_wire_id: string; } export interface OursRegisteredCommand { name: string; description?: string; input_schema: { [key: string]: OursJsonValue; }; handler(argumentsValue: OursJsonValue, context: Readonly): OursJsonValue | Promise; } export declare class OursWatchDeadlineError extends OursDaemonError { } /** * The daemon operations the owner channel needs, one typed method each. * * This interface deliberately has no generic `callTool(name, args): unknown` * escape hatch. The legacy MCP connector answered every * tool with `{content:[{type:'text',...}]}` and no `structuredContent`, the * transport fell back to returning the daemon's English sentence — which the * channel then pattern-matched (an invite blob sliced out of a prose sentence, * a bind conflict detected with /currently bound to another live session/i). * With no untyped result there is nothing left to pattern-match. */ export interface OursOps { /** Prepare the transport. Must be called before any operation. */ start(): Promise; /** Bind this session's identity. Throws `BOUND_ELSEWHERE` when it is held live. */ bindIdentity(name: string): Promise; /** Replace the bound identity's advertised typed-command catalog and handlers. */ registerCommands(commands: OursRegisteredCommand[]): Promise; listContacts(): Promise; generateInvite(name?: string): Promise; addContact(a: { invite: string; name?: string; }): Promise; listIncomingMessages(): Promise; getMessages(limit: number): Promise; getHistoryItem(wireId: string): Promise; watchNotifications(identity: string, options?: { since?: number | 'tip'; signal?: AbortSignal; }): AsyncGenerator; listIncomingFiles(): Promise; getFileInfo(wireId: string): Promise; getFiles(wireIds: string[]): Promise; /** * The bytes of an already-retrieved file. Transport only — the caller owns * where they land, so path safety stays with the attachment code that already * enforces it (`writeRecoveredAttachment`). */ fetchFile(wireId: string): Promise; sendMessage(a: { contact: string; text: string; replyToWireId?: string; }): Promise; sendFile(a: { contact: string; path: string; filename: string; replyToWireId?: string; }): Promise; /** Release the daemon lease and stop. Never throws. */ close(): Promise; } /** * The typed error code of a daemon operation, or undefined when the failure was * not one (transport, abort, programming error). `instanceof` is checked first; * the structural fallback keeps a duplicated SDK copy in a consumer's tree from * silently demoting a real daemon verdict to "unknown transport failure". */ export declare function oursErrorCode(error: unknown): string | undefined; /** The identity is bound by another live session; a predecessor may still be releasing it. */ export declare const OURS_BOUND_ELSEWHERE = "BOUND_ELSEWHERE"; export interface OursSdkClientDeps { /** Test seam; production uses the SDK's coherence-checking application attach path. */ attachClient?(options: AttachOursClientOptions): OursClient | Promise; /** Underlying transport and deadline seams for deterministic half-open tests. */ fetch?: typeof globalThis.fetch; notificationRequestDeadlineMs?: number; readFile?(path: string): Promise; } /** * The owner-channel's daemon client: one `OursClient` over the local ours HTTP * API, owning exactly one identity binding. * * Lease lifetime. The lease token IS the session, so each channel instance mints * its own and hands it back in `close()`. That replaces the connector proxy's * shell-PID fence, which existed because a supervised attempt had to make its * lease reclaimable while the supervisor itself stayed alive: an explicit * release does that deterministically, and `clientPid` still covers the case * where the whole supervisor dies without unwinding. */ export declare class OursSdkClient implements OursOps { private readonly env; private readonly log; private readonly deps; private client?; private readonly leaseToken; constructor(env?: Record, log?: (line: string) => void, deps?: OursSdkClientDeps); start(): Promise; bindIdentity(name: string): Promise; registerCommands(commands: OursRegisteredCommand[]): Promise; listContacts(): Promise; generateInvite(name?: string): Promise; addContact(a: { invite: string; name?: string; }): Promise; listIncomingMessages(): Promise; getMessages(limit: number): Promise; getHistoryItem(wireId: string): Promise; watchNotifications(identity: string, options?: { since?: number | 'tip'; signal?: AbortSignal; }): AsyncGenerator; listIncomingFiles(): Promise; getFileInfo(wireId: string): Promise; getFiles(wireIds: string[]): Promise; fetchFile(wireId: string): Promise; sendMessage(a: { contact: string; text: string; replyToWireId?: string; }): Promise; sendFile(a: { contact: string; path: string; filename: string; replyToWireId?: string; }): Promise; close(): Promise; private ops; } export {};