import type { SignalEntryData } from './types.js';
/**
* DeliveredMessage — the single unified input shape for everything that
* enters a persistent agent's session: direct HTTP prompts, dispatch,
* channels/webhooks, Databricks events, SDK clients, and tests.
*
* `kind: 'user'` is a direct user talking to the assistant (1:1 chat
* surface), optionally carrying attachments.
*
* `kind: 'signal'` models everything beyond that direct exchange — a Slack
* thread or a Lakeflow job event is activity the agent observes, not the
* assistant's own user speaking. Sender identity and structured metadata go
* in `attributes`; the message itself in `body`. Signals render into model
* context as an XML envelope (`body`).
*
* `body` (not `text`/`content`) is named for headroom — a future revision may
* accept a real JSON value and stringify internally without a field rename.
*/
export type DeliveredMessage = {
kind: 'user';
body: string;
attachments?: DeliveredAttachment[];
} | {
kind: 'signal';
/** Caller-defined event/signal type, e.g. `'slack.message'` or `'databricks.job_run'`. */
type: string;
body: string;
attributes?: Record;
tagName?: string;
};
/**
* One attachment on a `kind: 'user'` message. Today the only supported
* attachment is an image, carried either inline (`data`, base64) or as a
* durable content-addressed reference (`ref`) once an attachment store is
* configured — admission materializes inline bytes into refs. An attachment
* must carry `data` or `ref` (or both, transiently during materialization).
*/
export interface DeliveredAttachment {
type: 'image';
/** Base64-encoded bytes (inline form). */
data?: string;
mimeType: string;
/** Uploader-provided display name; not part of byte identity. */
filename?: string;
/** Durable content-addressed reference (materialized form). */
ref?: DeliveredAttachmentRef;
}
/** Durable reference to attachment bytes in an attachment store. */
export interface DeliveredAttachmentRef {
/** Attachment id assigned at materialization. */
id: string;
/** Lowercase hex SHA-256 of the bytes — the content address. */
digest: string;
sizeBytes: number;
}
/** Maximum accepted base64 length for a single inline attachment. */
export declare const MAX_ATTACHMENT_DATA_LENGTH: number;
/** Thrown by {@link parseDeliveredMessage} on malformed input. */
export declare class InvalidDeliveredMessageError extends Error {
readonly code = "INVALID_DELIVERED_MESSAGE";
constructor(reason: string);
}
/**
* Validate a raw value as a {@link DeliveredMessage}. Shared by dispatch
* admission and the direct HTTP route so every transport produces the same
* structured error on bad input.
*/
export declare function parseDeliveredMessage(value: unknown): DeliveredMessage;
/** True when a raw value already looks like a {@link DeliveredMessage} (has a valid `kind`). */
export declare function isDeliveredMessageShape(value: unknown): boolean;
/**
* Normalize legacy inputs into a {@link DeliveredMessage}:
* - a string → a user message with that body
* - a value with a `kind` discriminator → validated as a DeliveredMessage
* - any other JSON value → a user message with the JSON-stringified body
* (matching the historical dispatch rendering, so behavior is unchanged
* for pre-DeliveredMessage callers)
*/
export declare function normalizeDeliveredMessage(input: unknown): DeliveredMessage;
/**
* Render a delivered message to the prompt text form. User messages pass
* their body through verbatim; signals render as their XML envelope via the
* shared {@link renderSignalMessage} machinery.
*/
export declare function renderDeliveredMessage(message: DeliveredMessage): string;
/** Map a signal-kind message onto the persisted `signal` entry's data shape. */
export declare function deliveredSignalToEntryData(message: Extract): SignalEntryData;
//# sourceMappingURL=delivered-message.d.ts.map