import 'reflect-metadata'; import { z } from 'zod'; import type { JsonValue, ClassConstructor, ResourceAnnotations, ToolAnnotations } from './types.js'; import type { TaskSupportLevel } from './task.js'; /** * Metadata keys for decorators */ export declare const TOOL_METADATA: unique symbol; export declare const WIDGET_METADATA: unique symbol; export declare const RESOURCE_METADATA: unique symbol; export declare const PROMPT_METADATA: unique symbol; export declare const GUARDS_METADATA: unique symbol; export declare const CONTROLLER_METADATA: unique symbol; /** * Example data for tools/resources */ export interface ExampleData { request?: JsonValue; response?: JsonValue; } /** * Tool invocation status messages (OpenAI Apps SDK) * Displayed to users during tool execution */ export interface ToolInvocationMessages { /** Message shown while tool is executing (e.g., "Adding todo...") */ invoking?: string; /** Message shown after tool completes (e.g., "Added todo") */ invoked?: string; } /** * Tool decorator options */ export interface ToolOptions { name: string; /** Optional human-readable title for display */ title?: string; description: string; inputSchema: z.ZodSchema; /** Optional JSON Schema for validating tool output */ outputSchema?: z.ZodSchema; /** Optional annotations describing tool behavior */ annotations?: ToolAnnotations; /** Optional invocation status messages for UI feedback (OpenAI Apps SDK) */ invocation?: ToolInvocationMessages; examples?: ExampleData; metadata?: { category?: string; tags?: string[]; rateLimit?: { maxCalls: number; windowMs: number; }; }; /** * Task support level for this tool. * - 'forbidden' (default): Tool cannot be invoked as a task * - 'optional': Tool can be invoked normally or as a task * - 'required': Tool MUST be invoked as a task */ taskSupport?: TaskSupportLevel; /** * Tool visibility. * - 'visible' (default): Tool is discoverable upon session start. * - 'hidden': Tool is excluded from catalog until dynamically enabled via ctx.enableTools(). */ visibility?: 'visible' | 'hidden'; /** * Convenience boolean alias for visibility. * Setting defaultVisible: false maps directly to visibility: 'hidden'. */ defaultVisible?: boolean; } /** * Resource decorator options */ export interface ResourceOptions { uri: string; name: string; /** Optional human-readable title for display */ title?: string; description: string; mimeType?: string; /** Optional size in bytes */ size?: number; /** Optional annotations for client hints */ annotations?: ResourceAnnotations; examples?: { response?: JsonValue; }; metadata?: { cacheable?: boolean; cacheMaxAge?: number; }; } /** * Prompt decorator options */ export interface PromptOptions { name: string; /** Optional human-readable title for display */ title?: string; description: string; arguments?: Array<{ name: string; description: string; required?: boolean; }>; } /** * Tool metadata stored on class */ interface ToolMetadataEntry { methodName: string; options: ToolOptions; } /** * Tool decorator - Marks a method as an MCP tool * * @example * ```typescript * @Tool({ * name: 'login', * description: 'Login with email and password', * inputSchema: z.object({ * email: z.string().email(), * password: z.string(), * }), * }) * async login(input: LoginInput, context: ExecutionContext) { * // Implementation * } * ``` */ export declare function Tool(options: ToolOptions): MethodDecorator; /** * CSP allowlists for widget iframes (OpenAI `openai/widgetCSP` / MCP Apps `_meta.ui.csp`). */ export interface WidgetCspOptions { connectDomains?: string[]; resourceDomains?: string[]; frameDomains?: string[]; } /** * Widget linking options (object form). `route` is required; other fields are optional. */ export interface WidgetRouteMetadata { route: string; csp?: WidgetCspOptions; /** OpenAI widget sandbox domain (HTTPS), e.g. `https://myapp.example.com` — maps to `openai/widgetDomain`. */ domain?: string; /** Maps to `openai/widgetPrefersBorder`. */ prefersBorder?: boolean; } /** * Widget decorator - Links a tool to a Next.js widget route * * @example String route (backward compatible) * ```typescript * @Widget('login-result') * ``` * * @example Object form — `route` is required * ```typescript * @Widget({ * route: 'card', * prefersBorder: true, * domain: 'https://myapp.example.com', * csp: { * resourceDomains: ['https://images.unsplash.com'], * connectDomains: ['https://api.example.com'], * frameDomains: ['https://*.example-embed.com'], * }, * }) * ``` */ export declare function Widget(routePath: string | WidgetRouteMetadata): MethodDecorator; /** * Controller decorator options */ export interface ControllerOptions { /** * Optional prefix applied to every @Tool name defined in this controller. * For example, `@Controller('github')` turns a tool named `create_issue` * into `github_create_issue`. */ prefix?: string; } /** * Controller decorator - Marks a class as a controller, auto-registers it in * the DI container, and optionally prefixes all of its @Tool names. * * @example * ```typescript * @Controller('github') * export class GitHubController { * @Tool({ name: 'create_issue', ... }) * async createIssue() { } // exposed as `github_create_issue` * } * ``` */ export declare function Controller(prefixOrOptions?: string | ControllerOptions): ClassDecorator; /** * Get the tool-name prefix declared via @Controller, if any */ export declare function getControllerPrefix(target: ClassConstructor): string | undefined; /** * Resource metadata stored on class */ interface ResourceMetadataEntry { methodName: string; options: ResourceOptions; } /** * Resource decorator - Marks a method as an MCP resource * * @example * ```typescript * @Resource({ * uri: 'db://users/schema', * name: 'User Schema', * description: 'Database schema for users', * }) * async getUserSchema(context: ExecutionContext) { * // Return schema * } * ``` */ export declare function Resource(options: ResourceOptions): MethodDecorator; /** * Prompt metadata stored on class */ interface PromptMetadataEntry { methodName: string; options: PromptOptions; } /** * Prompt decorator - Marks a method as an MCP prompt * * @example * ```typescript * @Prompt({ * name: 'authentication-help', * description: 'Help with authentication', * }) * async authHelp(args: PromptArgs, context: ExecutionContext) { * // Return prompt messages * } * ``` */ export declare function Prompt(options: PromptOptions): MethodDecorator; /** * Extract tool definitions from a decorated class */ export declare function extractTools(target: ClassConstructor): ToolMetadataEntry[]; /** * Extract resource definitions from a decorated class */ export declare function extractResources(target: ClassConstructor): ResourceMetadataEntry[]; /** * Extract prompt definitions from a decorated class */ export declare function extractPrompts(target: ClassConstructor): PromptMetadataEntry[]; /** * Get widget metadata for a specific method */ export declare function getWidgetMetadata(target: object, methodName: string): WidgetRouteMetadata | undefined; /** * Get guards metadata for a specific method */ export declare function getGuardsMetadata(target: object, methodName: string): ClassConstructor[]; /** * Initial tool decorator metadata key */ export declare const INITIAL_TOOL_METADATA: unique symbol; /** * InitialTool decorator - Marks a tool to be automatically called when the client starts * * @example * ```typescript * @Tool({ ... }) * @InitialTool() * async init(input: InitInput, context: ExecutionContext) { * // Implementation * } * ``` */ export declare function InitialTool(): MethodDecorator; /** * Get initial tool metadata for a specific method */ export declare function getInitialToolMetadata(target: object, methodName: string): boolean; export {}; //# sourceMappingURL=decorators.d.ts.map