/** * module: llm —— 本模块要外界提供的能力(编码规范 §10.1 / §5.3)。 */ import type { ModelBinding } from './internal/domain/model-binding.ts'; import type { ModelCall, ModelResult, ModelUsage } from './contract.ts'; export type Clock = { now(): Date; }; export type IdGenerator = { next(): string; }; /** 凭证密封 —— 明文永不进 domain(ADR-009) */ export type SecretBox = { seal(plaintext: string): string; open(cipher: string): string; }; export type LlmInstanceRepository = { list(): Promise; findByName(name: string): Promise; findById(id: string): Promise; upsert(binding: ModelBinding): Promise; remove(id: string): Promise; }; /** 录制回放存储:按任务 × 步序号(§7.3) */ export type ReplayRecord = { readonly key: string; readonly call: ModelCall; readonly result: { readonly text: string; readonly object?: unknown; readonly usage: ModelUsage; }; readonly recordedAt: Date; }; export type ReplayStore = { put(record: ReplayRecord): Promise; get(key: string): Promise; }; /** * Provider 工厂 —— Vercel AI SDK 只准出现在 adapter(§6.2 / §11.4)。 * usecase 只见本端口,拿不到任何 SDK 类型。 */ export type ProviderInvoker = { invoke(input: { readonly binding: ModelBinding; readonly apiKey: string; readonly call: ModelCall; }): Promise<{ text: string; object?: unknown; reasoning?: string; usage: ModelUsage; }>; }; export type { ModelCall, ModelResult };