/** * Core types for the MiniMax adapter. * * These types are intentionally narrow — they describe only what the * adapter itself uses. The full Paperclip Agent / Run / Issue types live * in `@paperclipai/server`; we keep this file dependency-free so the * adapter builds standalone. */ export type JsonValue = | string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue }; export type JsonObject = { [key: string]: JsonValue }; export interface AdapterConfig { apiKey: string; baseUrl: string; model: string; priceInputPer1M: number; priceOutputPer1M: number; paperclipApiKey: string; paperclipApiUrl: string; maxToolCallsPerTurn: number; maxTurns: number; enableStreaming: boolean; skillsDir: string; approvalGated: boolean; workspacePath: string; } export interface AgentContext { id: string; name: string; role: string; workspacePath?: string; capabilities?: string; metadata?: JsonObject; } export interface IssueRef { id: string; identifier?: string; title?: string; status?: string; } export interface RunContext { id: string; agentId: string; issueId: string; companyId: string; wakeReason: string; /** When set, the heartbeat dispatcher has already locked the issue. */ issueAlreadyCheckedOut?: boolean; metadata?: JsonObject; } export interface ToolDefinition { type: "function"; function: { name: string; description: string; parameters: { type: "object"; properties: Record; required?: string[]; }; }; } export interface ToolCall { id: string; type: "function"; function: { name: string; arguments: string; }; } export interface ChatMessage { role: "system" | "user" | "assistant" | "tool"; content?: string | null; name?: string; tool_call_id?: string; tool_calls?: ToolCall[]; /** Provider-specific extensions, e.g. reasoning traces. */ reasoning?: string; } export interface Usage { inputTokens: number; outputTokens: number; cachedInputTokens?: number; totalTokens?: number; } export interface CostSummary { inputUsd: number; outputUsd: number; totalUsd: number; } export interface AdapterResult { status: "succeeded" | "failed"; result?: string; errorMessage?: string; usage?: Usage; costUsd?: number; model?: string; provider?: string; /** Human-readable transcript events for the Working panel. */ transcript?: TranscriptEvent[]; /** Session state to persist (a plain JSON object via sessionCodec.serialize). */ sessionState?: Record; } export type TranscriptEvent = | { kind: "init"; ts: string; model: string; sessionId: string } | { kind: "user"; ts: string; content: string } | { kind: "assistant"; ts: string; content?: string; reasoning?: string } | { kind: "tool_call"; ts: string; name: string; input?: JsonValue; callId: string } | { kind: "tool_result"; ts: string; callId: string; output: JsonValue; isError: boolean } | { kind: "result"; ts: string; subtype: "completed" | "error"; isError: boolean; costUsd: number; inputTokens: number; outputTokens: number; reason?: string } | { kind: "warning"; ts: string; message: string }; export interface SkillDoc { name: string; description: string; body: string; path: string; }