Foundations
Core
The data every Loom component renders (messages, parts, tool calls, interactions), LoomProvider for labels, answers, tool renderers and message actions, and small utilities.
npx shadcn@latest add https://loom.mkhonta.com/r/core.json/** * The data Loom components render. These mirror eve's client types (`EveMessage`, * `EveMessagePart`, `Interaction`) so eve's messages pass through unchanged, but nothing here * imports eve: components stay renderable from plain data in docs, tests and previews. * * eve can add interaction kinds, call states and outcomes in newer versions, so those unions keep * a `string` fallback and every component handles an unknown value from the common fields. */ export type LoomRole = "user" | "assistant"; export type LoomMessageStatus = "submitted" | "streaming" | "complete" | "failed"; export interface LoomMessage { readonly id: string; readonly role: LoomRole; readonly parts: readonly LoomPart[]; readonly metadata?: { readonly status?: LoomMessageStatus; readonly turnId?: string; readonly optimistic?: true; }; } export type LoomPart = LoomTextPart | LoomReasoningPart | LoomFilePart | LoomToolPart | LoomInteractionPart; export interface LoomTextPart { readonly type: "text"; readonly id?: string; readonly text: string; readonly state?: "streaming" | "done"; } export interface LoomReasoningPart { readonly type: "reasoning"; readonly id?: string; readonly text: string; readonly state?: "streaming" | "done"; } export interface LoomFilePart { readonly type: "file"; readonly mediaType: string; readonly filename?: string; readonly size?: number; readonly url?: string; } export type LoomCallState = | "requested" | "approval" | "running" | "blocked" | "completed" | "failed" | "rejected" | "cancelled" | (string & {}); export interface LoomError { readonly code: string; readonly message: string; readonly hint?: string; readonly id?: string; } /** A call the agent made: a tool, a subagent, a skill. Input streams as text first. */ export type LoomToolPart = { readonly type: "tool"; readonly callId: string; readonly kind: "tool" | "agent" | "skill" | "control" | (string & {}); readonly name: string; /** A readable label for the call, from the tool or derived from its name. */ readonly label: string; /** The tool asked to stay out of activity displays. */ readonly hidden?: true; /** An approval or question about this call. */ readonly interaction?: LoomInteraction; } & ( | { readonly state: "streaming"; readonly inputText: string; readonly input?: never; readonly output?: never; readonly error?: never; } | { readonly state: Exclude<LoomCallState, "streaming">; readonly inputText?: never; readonly input?: unknown; readonly output?: unknown; readonly error?: LoomError; } ); export type LoomInteractionKind = "approval" | "question" | "sign-in" | "budget" | (string & {}); export type LoomInteractionOutcome = | "accepted" | "declined" | "invalid" | "failed" | "withdrawn" | "interrupted" | "abandoned" | "expired" | (string & {}); export interface LoomInteractionOption { readonly id: string; readonly label: string; readonly description?: string; readonly style?: "primary" | "danger" | "default" | (string & {}); } /** Something the agent asked a person: approve a call, answer a question, sign in. */ export interface LoomInteraction { readonly interactionId: string; readonly status: "open" | "settled"; readonly request: { readonly kind: LoomInteractionKind; readonly prompt: string; readonly title?: string; readonly options?: readonly LoomInteractionOption[]; readonly allowFreeform?: boolean; readonly display?: "confirmation" | "select" | "text" | (string & {}); readonly initialOptionId?: string; readonly link?: { readonly url: string; readonly label?: string }; readonly signIn?: { readonly name: string; readonly displayName?: string; readonly url?: string; readonly userCode?: string; readonly expiresAt?: string; readonly instructions?: string; }; }; /** The call an approval or question is about. */ readonly call?: { readonly callId: string; readonly name: string; readonly input?: unknown }; readonly outcome?: LoomInteractionOutcome; readonly reason?: string; readonly answer?: { readonly optionId?: string; readonly text?: string }; } /** An interaction no call carries, shown where the turn asked it. */ export type LoomInteractionPart = LoomInteraction & { readonly type: "interaction" }; /** A person's answer to an open interaction: an option, free text, or both. */ export interface LoomAnswer { readonly interactionId: string; readonly optionId?: string; readonly text?: string; } /** What a person sends: text, or text and files. */ export type LoomMessageInput = | string | readonly ( | { readonly type: "text"; readonly text: string } | { readonly type: "file"; readonly mediaType: string; readonly filename?: string; readonly data: string | Uint8Array | ArrayBuffer | URL } )[]; /** A JSON value, as eve's `clientContext` takes it. */ export type LoomJson = string | number | boolean | null | readonly LoomJson[] | { readonly [key: string]: LoomJson }; /** * Context for one turn only (eve's `clientContext`). The model reads it with the message; it is * never saved to the conversation. The composer uses it for mentions and slash commands. */ export type LoomClientContext = string | readonly string[] | { readonly [key: string]: LoomJson }; export interface LoomSendOptions { /** While a turn runs, `queue` waits for it and `steer` redirects it. */ readonly turnPolicy?: "queue" | "steer"; readonly clientContext?: LoomClientContext; } /** Something a person can mention with `@`: a person, a file, a record. */ export interface LoomMention { readonly id: string; /** Inserted after `@` and matched as they type. */ readonly label: string; readonly description?: string; } /** An argument a slash command asks for once chosen, like `<name>` in `/assign <name>`. */ export interface LoomCommandArgument { readonly name: string; /** Ghost text until it's typed. Defaults to `<name>`. */ readonly hint?: string; readonly required?: boolean; /** Suggestions for it. Without them, it's free text. */ readonly options?: readonly string[]; } /** A slash command: sent to the agent with the message, or run by the app with `run`. */ export interface LoomCommand { /** Typed after `/`, like `summarize`. */ readonly name: string; readonly description?: string; readonly arguments?: readonly LoomCommandArgument[]; /** Runs it in the app instead of sending it, e.g. `/clear`. */ readonly run?: (args: Readonly<Record<string, string>>) => unknown; } /** A past conversation, for `LoomSessionList`. */ export interface LoomSessionSummary { readonly id: string; readonly title: string; /** When it last changed: a `Date`, a timestamp in ms, or an ISO string. */ readonly updatedAt: Date | number | string; } /** An agent a person can talk to, for `LoomAgentPicker`. */ export interface LoomAgentOption { readonly id: string; readonly name: string; readonly description?: string; } /** What the agent is doing right now, for status lines. */ export type LoomActivity = | { readonly kind: "idle" | "thinking" | "compacting" } | { readonly kind: "calling"; readonly names: readonly string[] } | { readonly kind: "waiting-on-interaction"; readonly interactions: readonly LoomInteraction[] } | { readonly kind: "waiting-on-tasks" }; /** * Everything a Loom chat surface needs: data plus commands. The eve adapter (`useLoomEve`) * returns one; tests and previews can build one from plain objects. */ export interface LoomChat { readonly messages: readonly LoomMessage[]; /** `resuming` disables sending while an attached session catches up. */ readonly status: "idle" | "busy" | "resuming"; readonly activity: LoomActivity; readonly error: Error | undefined; /** A turn is running or waiting on a person, so it can be cancelled. */ readonly canCancel: boolean; /** Sends a message, with turn-only context if given. */ readonly send: (message: LoomMessageInput, options?: LoomSendOptions) => Promise<unknown>; readonly respond: (answers: readonly LoomAnswer[]) => Promise<unknown>; readonly cancel: () => Promise<unknown>; readonly newSession: () => void; }
Installs
- lib/loom/types.ts
- lib/loom/context.tsx
- lib/loom/utils.ts
- components/loom/shuttle.tsx