{"version":3,"file":"sessionProtocol.cjs","names":["defineService"],"sources":["../../src/schemas/sessionProtocol.ts"],"sourcesContent":["import { defineService, type Context, type ReplicatedState } from '@earendil-works/chord';\n\nexport const DOOM_SESSION_SERVICE_ID = 'doompi.session.v1';\nexport const DOOM_SESSION_MANAGEMENT_SERVICE_ID = 'doompi.session-management.v1';\nexport const DOOM_COCKPIT_SERVER_ID = '646f6f6d-7069-4000-8000-000000000001';\n\nexport type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };\nexport type ThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';\nexport type SessionPhase = 'idle' | 'turn' | 'compaction' | 'retry';\n\nexport interface ModelRef {\n  provider: string;\n  id: string;\n}\n\nexport interface TextContentPart {\n  type: 'text';\n  text: string;\n}\n\nexport interface ImageContentPart {\n  type: 'image';\n  data: string;\n  mimeType: string;\n}\n\nexport interface ThinkingContentPart {\n  type: 'thinking';\n  thinking: string;\n  redacted?: true;\n}\n\nexport interface ToolCallContentPart {\n  type: 'toolCall';\n  toolCallId: string;\n  toolName: string;\n  input: JsonValue;\n}\n\nexport interface UserTranscriptItem {\n  id: string;\n  role: 'user';\n  content: Array<TextContentPart | ImageContentPart>;\n  timestamp: number;\n}\n\nexport interface AssistantTranscriptItem {\n  id: string;\n  role: 'assistant';\n  content: Array<TextContentPart | ThinkingContentPart | ToolCallContentPart>;\n  model: ModelRef;\n  status: 'streaming' | 'complete' | 'aborted' | 'error';\n  stopReason?: 'stop' | 'length' | 'toolUse' | 'aborted' | 'error';\n  errorMessage?: string;\n  timestamp: number;\n}\n\nexport interface ToolTranscriptItem {\n  id: string;\n  role: 'tool';\n  toolCallId: string;\n  toolName: string;\n  input: JsonValue;\n  content: Array<TextContentPart | ImageContentPart>;\n  details?: JsonValue;\n  status: 'running' | 'complete' | 'error';\n  isError: boolean;\n  timestamp: number;\n}\n\nexport type TranscriptItem = UserTranscriptItem | AssistantTranscriptItem | ToolTranscriptItem;\n\nexport type TranscriptProgress =\n  | { type: 'item_started'; item: TranscriptItem }\n  | { type: 'item_updated'; item: TranscriptItem }\n  | { type: 'item_finished'; item: TranscriptItem };\n\nexport interface SessionSnapshot {\n  id: string;\n  cwd: string;\n  name?: string;\n  createdAt: number;\n  updatedAt: number;\n  phase: SessionPhase;\n  model: ModelRef;\n  thinkingLevel: ThinkingLevel;\n  attached: boolean;\n  locked: boolean;\n  revision: number;\n  transcript: TranscriptItem[];\n  queuedSteer: UserTranscriptItem[];\n  queuedSteerCount: number;\n}\n\nexport interface SessionServiceState {\n  snapshot: SessionSnapshot;\n  progress: TranscriptProgress | null;\n}\n\nexport interface SessionService {\n  readonly state: ReplicatedState<SessionServiceState>;\n  prompt(text: string, context: Context): Promise<void>;\n  steer(text: string, context: Context): Promise<void>;\n  abort(context: Context): Promise<void>;\n  setModel(model: ModelRef, context: Context): Promise<void>;\n  setThinking(thinkingLevel: ThinkingLevel, context: Context): Promise<void>;\n}\n\nexport interface SessionManagementService {\n  attach(sessionId: string, context: Context): Promise<void>;\n  detach(context: Context): Promise<void>;\n}\n\nexport const DoomSessionService = defineService<SessionService>(DOOM_SESSION_SERVICE_ID);\nexport const DoomSessionManagementService = defineService<SessionManagementService>(DOOM_SESSION_MANAGEMENT_SERVICE_ID);\n"],"mappings":"uCAEA,MAAa,EAA0B,oBAC1B,EAAqC,+BA8GrC,GAAA,EAAqBA,EAAAA,cAAAA,CAA8B,CAAuB,EAC1E,GAAA,EAA+BA,EAAAA,cAAAA,CAAwC,CAAkC"}