import type { Schema } from 'effect' /** Read-only Model state that can be requested separately from the default context. */ export interface Resource { readonly name: string readonly description: string readonly schema: Schema.Codec readonly read: (model: Model) => Value } export type ResourceOptions = Omit, 'name'> /** * Defines a named read-only projection of Model state. * * External MCP maps this onto a resource such as `app://todos`. WebMCP's * producer API is tool-oriented, so a WebMCP adapter may leave resources out or * project them as read-only tools. * * @example * ```ts * const TodosResource = Agent.resource('todos', { * description: "The user's current todos", * schema: Schema.Array(Todo), * read: model => model.todos, * }) * ``` */ export const resource = ( name: string, options: ResourceOptions, ): Resource => ({ name, description: options.description, schema: options.schema, read: options.read, })