/** * CapabilityRequestResult content type — device → agent reply to a * CapabilityRequest. Always emitted, even on cancel/deny, so the * agent can correlate by `requestId` and stop waiting. * * Mirrors the iOS `CapabilityRequestResultCodec` (PR #771): * - Content type: convos.org/capability_request_result:1.0 * - Payload: JSON-encoded `CapabilityRequestResult` * - Fallback: status-aware ("Approved …", "Declined …", "Cancelled …") * - shouldPush: false */ import type { ContentTypeId, EncodedContent } from "@xmtp/node-bindings"; import type { ContentCodec } from "@xmtp/content-type-primitives"; import type { DecodedMessage } from "@xmtp/node-sdk"; import type { CapabilitySubject, ProviderID } from "./capabilityTypes.js"; import type { ConnectionCapability, ConnectionKind } from "./connectionTypes.js"; export declare const ContentTypeCapabilityRequestResult: ContentTypeId; /** Highest schema version this codec understands. */ export declare const CAPABILITY_REQUEST_RESULT_SUPPORTED_VERSION = 1; /** Cap on the providers array. Anything longer is truncated on encode and decode. */ export declare const CAPABILITY_REQUEST_RESULT_MAX_PROVIDERS = 16; /** Cap on the availableActions array. Anything longer is truncated on encode and decode. */ export declare const CAPABILITY_REQUEST_RESULT_MAX_AVAILABLE_ACTIONS = 64; export type CapabilityRequestResultStatus = "approved" | "denied" | "cancelled"; export declare const ALL_CAPABILITY_REQUEST_RESULT_STATUSES: readonly CapabilityRequestResultStatus[]; /** * Single I/O parameter on an `AvailableAction` schema. Keys mirror the * iOS `CapabilityRequestResult.Parameter` (note `isRequired`, not * `required`). */ export interface AvailableActionParameter { name: string; /** * Schema type as a free-form string. iOS encodes whatever string the * source `ActionSchema.parameter.type` produced (e.g. `"string"`, * `"int"`, `"date"`, `"array"`). The CLI doesn't constrain * the value; consumers should treat it as a hint. */ type: string; description: string; isRequired: boolean; } /** * Action schema entry returned alongside an approved capability so the * agent knows what verbs it can invoke without round-tripping a probe. * * Mirrors iOS `CapabilityRequestResult.AvailableAction`: * { providerId, kind, actionName, summary, inputs, outputs }. */ export interface AvailableAction { /** Routes this action to a specific provider in the resolution. */ providerId: ProviderID; /** Device kind that owns the action. Cloud providers reuse this for routing. */ kind: ConnectionKind; actionName: string; summary: string; inputs: AvailableActionParameter[]; outputs: AvailableActionParameter[]; } export interface CapabilityRequestResult { /** Schema version. Must equal `CAPABILITY_REQUEST_RESULT_SUPPORTED_VERSION` (1) for now. */ version: number; /** Echoes the request's `requestId` for correlation. */ requestId: string; status: CapabilityRequestResultStatus; subject: CapabilitySubject; capability: ConnectionCapability; /** * Empty for `denied` / `cancelled`. For `approved`, size is 1 for * non-federating subjects and write verbs, ≥ 1 for federating-subject * reads. Reflects what the resolver actually persisted — agents that * supplied a `preferredProviders` hint should compare against this * to confirm whether their hint was honored. */ providers: ProviderID[]; /** * Action schemas compatible with the approved capability, filtered to * the providers above. Empty for `denied` / `cancelled`. Truncated to * `CAPABILITY_REQUEST_RESULT_MAX_AVAILABLE_ACTIONS` on encode/decode. * * Always emitted as an array on the wire (iOS encodes empty arrays); * decoders also accept missing keys for forward-compat. */ availableActions: AvailableAction[]; } export declare class CapabilityRequestResultCodec implements ContentCodec { get contentType(): ContentTypeId; encode(content: CapabilityRequestResult): EncodedContent; decode(content: EncodedContent): CapabilityRequestResult; fallback(content: CapabilityRequestResult): string | undefined; shouldPush(_content: CapabilityRequestResult): boolean; } export declare function isCapabilityRequestResultMessage(message: DecodedMessage): boolean; export declare function getCapabilityRequestResultContent(message: DecodedMessage): CapabilityRequestResult | undefined;