import type { ArtifactSyncExecutionOptions, EndpointManifestDefinition, EndpointManifestEndpointDefinition } from '@wp-typia/block-runtime/metadata-core'; import type { ILlmFunction, ILlmSchema, ILlmStructuredOutput } from 'typia'; import type { EndpointAuthIntent, EndpointWordPressAuthDefinition, OpenApiDocument } from './schema-core.js'; /** * Method-level descriptor projected from an endpoint manifest for a generated * `typia.llm` controller interface. */ export interface TypiaLlmEndpointMethodDescriptor { /** Normalized auth intent derived from the endpoint manifest. */ authIntent: EndpointAuthIntent; /** Optional auth mode propagated from legacy manifest metadata. */ authMode?: EndpointManifestEndpointDefinition['authMode']; /** Human-readable operation summary. */ description?: string; /** Input type used by the generated controller method, or null for no input. */ inputTypeName: string | null; /** Type names that must be imported when inputTypeName is an inline composite. */ inputTypeImportNames?: readonly string[]; /** HTTP method from the source endpoint manifest. */ method: EndpointManifestEndpointDefinition['method']; /** Stable operation identifier used as the generated method name. */ operationId: string; /** Output type used by the generated controller method. */ outputTypeName: string; /** REST path from the source endpoint manifest. */ path: string; /** Tags copied from the source endpoint manifest. */ tags: readonly string[]; /** Optional WordPress auth overlay preserved for downstream adapters. */ wordpressAuth?: EndpointWordPressAuthDefinition; } /** * Configures the generated TypeScript module that asks `typia.llm` to derive * function-calling and structured-output artifacts from canonical contracts. */ export interface RenderTypiaLlmModuleOptions { /** Export name for the generated `typia.llm.application<...>()` value. */ applicationExportName: string; /** Generated controller interface name. */ interfaceName: string; /** Endpoint manifest that owns REST operation metadata and source type names. */ manifest: EndpointManifestDefinition; /** Export name for the generated `typia.llm.structuredOutput<...>()` value. */ structuredOutputExportName: string; /** TypeScript output type used for structured-output projection. */ structuredOutputTypeName: string; /** Import path from the generated module to the canonical TypeScript contracts. */ typesImportPath: string; } /** * Configures writing or checking the generated `typia.llm` adapter module. */ export interface SyncTypiaLlmAdapterModuleOptions extends ArtifactSyncExecutionOptions, RenderTypiaLlmModuleOptions { /** Destination path for the generated TypeScript adapter module. */ generatedSourceFile: string; } /** * Describes the generated adapter module and where it was written or checked. */ export interface SyncTypiaLlmAdapterModuleResult { /** True when the source file was only verified, false when it was written. */ check: boolean; /** Generated endpoint method descriptors used by the module renderer. */ methodDescriptors: TypiaLlmEndpointMethodDescriptor[]; /** Rendered TypeScript module source. */ source: string; /** Destination path for the generated TypeScript adapter module. */ sourceFile: string; } /** * Function schema shape projected from a compiled `typia.llm.application(...)` * result. */ export interface TypiaLlmFunctionLike extends Pick { /** Function description generated by `typia.llm`. */ description?: string; /** Function name generated by `typia.llm`. */ name: string; /** Optional output schema generated by `typia.llm`. */ output?: ILlmSchema.IParameters; /** Function parameter schema generated by `typia.llm`. */ parameters: ILlmSchema.IParameters; /** Optional tags generated by `typia.llm`. */ tags?: readonly string[]; } /** * Application shape projected from a compiled `typia.llm.application(...)` * result. */ export interface TypiaLlmApplicationLike { /** Function schemas generated by `typia.llm`. */ functions: readonly TypiaLlmFunctionLike[]; } /** * Structured-output shape projected from a compiled * `typia.llm.structuredOutput(...)` result. */ export interface TypiaLlmStructuredOutputLike extends Pick { /** Structured output parameters generated by `typia.llm`. */ parameters: ILlmStructuredOutput['parameters']; } /** * JSON-friendly function artifact for downstream adapter consumers. */ export interface ProjectedTypiaLlmFunctionArtifact { /** Function description generated by `typia.llm`. */ description?: string; /** Function name generated by `typia.llm`. */ name: string; /** Optional output schema generated by `typia.llm`. */ output?: ILlmSchema.IParameters; /** Function parameter schema generated by `typia.llm`. */ parameters: ILlmSchema.IParameters; /** Optional tags generated by `typia.llm`. */ tags?: string[]; } /** * JSON-friendly application artifact for downstream adapter consumers. */ export interface ProjectedTypiaLlmApplicationArtifact { /** Function-calling artifacts generated by `typia.llm`. */ functions: ProjectedTypiaLlmFunctionArtifact[]; /** Source metadata that keeps the artifact tied to canonical contracts. */ generatedFrom: { baselineOpenApiPath?: string; blockSlug: string; manifestSource: 'endpoint-manifest+typescript'; }; } /** * JSON-friendly structured-output artifact for downstream adapter consumers. */ export interface ProjectedTypiaLlmStructuredOutputArtifact { /** Source metadata that keeps the artifact tied to canonical contracts. */ generatedFrom: { aiSchemaPath?: string; blockSlug: string; outputTypeName: string; }; /** Structured output parameters generated by `typia.llm`. */ parameters: ILlmStructuredOutput['parameters']; } /** * Configures optional OpenAPI-backed constraint restoration for projected * `typia.llm` function artifacts. */ export interface ProjectTypiaLlmOpenApiProjectionOptions { /** Canonical endpoint-aware OpenAPI document for the projected contracts. */ openApiDocument: OpenApiDocument; /** Optional override for resolving one function schema to an operation id. */ resolveOperationId?: (functionSchema: TypiaLlmFunctionLike, functionArtifact: ProjectedTypiaLlmFunctionArtifact) => string; } /** * Configures projection of a compiled `typia.llm.application(...)` result into * the JSON-friendly adapter artifact. */ export interface ProjectTypiaLlmApplicationArtifactOptions { /** Compiled application value produced by `typia.llm.application(...)`. */ application: TypiaLlmApplicationLike; /** Source metadata for the generated JSON artifact. */ generatedFrom: ProjectedTypiaLlmApplicationArtifact['generatedFrom']; /** Optional OpenAPI projection that restores canonical schema constraints. */ openApiProjection?: ProjectTypiaLlmOpenApiProjectionOptions; /** Optional hook for adapter-specific function schema normalization. */ transformFunction?: (functionArtifact: ProjectedTypiaLlmFunctionArtifact, functionSchema: TypiaLlmFunctionLike) => ProjectedTypiaLlmFunctionArtifact; } /** * Configures direct OpenAPI-backed constraint restoration for one projected * function artifact. */ export interface ApplyOpenApiConstraintsToTypiaLlmFunctionArtifactOptions { /** Projected function artifact to enrich with canonical constraints. */ functionArtifact: ProjectedTypiaLlmFunctionArtifact; /** Canonical endpoint-aware OpenAPI document. */ openApiDocument: OpenApiDocument; /** Operation id that owns the request/response contract for this function. */ operationId: string; } /** * Configures projection of a compiled `typia.llm.structuredOutput(...)` result * into the JSON-friendly adapter artifact. */ export interface ProjectTypiaLlmStructuredOutputArtifactOptions { /** Source metadata for the generated JSON artifact. */ generatedFrom: ProjectedTypiaLlmStructuredOutputArtifact['generatedFrom']; /** Compiled structured-output value produced by `typia.llm.structuredOutput(...)`. */ structuredOutput: TypiaLlmStructuredOutputLike; } /** * Generated Typia LLM artifact payload and destination. */ export type GeneratedTypiaLlmArtifactFile = { /** File contents to write or compare. */ content: string; /** Destination path for the generated artifact file. */ filePath: string; };