/** * Global type definitions for local-server. */ import type { ContentFormat } from './relay/types.js'; /** Valid Teams conversation types */ export type ConversationType = 'personal' | 'channel' | 'groupChat'; /** Image attachment persisted to disk. */ export interface PersistedImage { /** Unique ID for this image. */ id: string; /** Absolute file path on disk. */ filePath: string; /** MIME type (e.g. 'image/png'). */ mediaType: string; /** File size in bytes. */ sizeBytes: number; } /** Incoming message from the Gateway via WSS relay */ export interface IncomingMessage { text: string; conversationId: string; fromId: string; fromName?: string; fromAadObjectId?: string; conversationType?: ConversationType; channelId?: string; threadRootMessageId?: string; activityId?: string; /** Persisted image attachments (already saved to disk). */ images?: PersistedImage[]; } /** A message row stored in SQLite */ export interface StoredMessage { id: string; conversation_id: string; from_id: string; from_name: string | null; text: string; timestamp: string; is_bot_message: number; conversation_type: string | null; channel_id: string | null; thread_root_message_id: string | null; } /** A scheduled task row from SQLite */ export interface ScheduledTask { id: string; conversation_key: string; conversation_id: string; name: string; prompt: string; schedule_type: 'cron' | 'interval' | 'once'; schedule_value: string; context_mode: 'conversation' | 'isolated'; next_run: string | null; last_run: string | null; last_result: string | null; status: 'active' | 'paused' | 'completed'; created_at: string; conversation_type?: ConversationType; channel_id?: string; thread_root_message_id?: string; target_channel_id?: string; user_name?: string; } /** A task execution log entry */ export interface TaskRunLog { id?: number; task_id: string; run_at: string; duration_ms: number; status: 'success' | 'error'; result: string | null; error: string | null; } /** Thread message from Graph API */ export interface ThreadMessage { id: string; from: string; text: string; createdDateTime: string; /** true when the message was sent by an application (bot), not a user */ isApplication?: boolean; } /** Structured result from processMessage, distinguishing success from error. */ export interface AgentResult { text: string; isError: boolean; /** * Set when the turn was hard-stopped by a user `#stop`. Signals * process-background to suppress this turn's own delivery + DB store, * because the `#stop` command handler already sent the acknowledgement. */ stopped?: boolean; } /** Delivery strategy for agent/scheduler results. */ export type ReplyStrategy = { mode: 'response'; channelId: string; } | { mode: 'push'; sessionKey?: string; targetChannelId?: string; }; /** Dependencies injected into the scheduler */ export interface SchedulerDependencies { processMessage: (incoming: IncomingMessage, conversationKey: string, replyStrategy: ReplyStrategy) => Promise; pushMessage: (content: string, opts?: { format?: ContentFormat; title?: string; sessionKey?: string; targetChannelId?: string; mentionOid?: string; mentionName?: string; }) => Promise; }