import type { ThinkingLevel } from "@earendil-works/pi-agent-core"; import { execFile } from "child_process"; declare const execFileAsync: typeof execFile.__promisify__; type ExecFileAsync = typeof execFileAsync; export type ConversationKind = "direct" | "shared"; export type PlatformName = "slack" | "discord" | "telegram"; export interface ConversationMessage { id: string; sessionKey: string; conversationKind: ConversationKind; userId: string; userName?: string; text: string; attachments?: { name: string; localPath: string; }[]; threadTs?: string; } export interface ChatToolResult { toolName: string; label?: string; args?: Record; result: string; isError: boolean; durationMs: number; } export interface ConversationResponder { respond(text: string): Promise; appendResponseDelta?(delta: string): Promise; finishResponse?(finalText?: string): Promise; replaceResponse(text: string, options?: { createOverflowLink?: () => string; }): Promise; respondDiagnostic(text: string, options?: { style?: "muted" | "error"; }): Promise; respondToolResult(result: ChatToolResult): Promise; setTyping(isTyping: boolean): Promise; setWorking(working: boolean): Promise; uploadFile(filePath: string, title?: string): Promise; deleteResponse(): Promise; } export interface MessagingInfo { name: string; formattingGuide: string; channels: { id: string; name: string; }[]; users: { id: string; userName: string; displayName: string; }[]; diagnostics?: { showUsageSummary?: boolean; }; } export interface ChatAdapter { start(): Promise; stop(): Promise; getMessagingInfo(): MessagingInfo; } export type AgentEventPayload = { kind: "sessionStart"; } | { kind: "responseDelta"; delta: string; } | { kind: "responseFinal"; text: string; } | { kind: "diagnostic"; text: string; } | { kind: "toolStart"; toolId: string; toolName: string; input?: unknown; } | { kind: "toolEnd"; toolId: string; } | { kind: "turnEnd"; awaitingInput?: boolean; } | { kind: "sessionEnd"; reason?: string; }; export interface AgentEventEnvelope { source: "mikan"; sessionId: string; actorName: string; event: AgentEventPayload; } /** * A platform-agnostic event (message/mention) that triggers the agent. */ export interface ConversationEvent { type: string; /** Platform-specific raw conversation/channel/chat identifier */ conversationId: string; /** Optional alternate conversation identity used for vault routing. */ vaultConversationId?: string; /** Cross-platform conversation shape: direct message vs shared space */ conversationKind: ConversationKind; /** Message timestamp or ID as string */ ts: string; /** Parent message ID for threaded replies (optional) */ thread_ts?: string; /** User ID */ user: string; /** Message text (already stripped of bot mentions) */ text: string; /** Downloaded attachments */ attachments?: { name: string; localPath: string; }[]; /** Platform-computed session key; overrides default conversationId:thread_ts computation */ sessionKey?: string; } /** * Minimum interface that every platform bot must implement, * used by the central handler in main.ts and by EventsWatcher. */ export interface MessagingBot { start(): Promise; postMessage(channel: string, text: string): Promise; updateMessage(channel: string, ts: string, text: string): Promise; enqueueEvent(event: ConversationEvent): boolean; getMessagingInfo(): MessagingInfo; postPrivate?(conversationId: string, userId: string, text: string): Promise; postPrivateDiagnostic?(conversationId: string, userId: string, text: string, options?: { style?: "muted" | "error"; }): Promise; } /** Normalized platform data and reply hook for one event. */ export interface ConversationContext { message: ConversationMessage; responder: ConversationResponder; platform: MessagingInfo; } export interface RunningSession { sessionKey: string; startedAt: number; lastActivityAt?: number; currentTool?: string; } export interface MessagingEventHandler { isRunning(sessionKey: string): boolean; getRunningSessions(): RunningSession[]; handleEvent(event: ConversationEvent, bot: MessagingBot, context: ConversationContext): Promise; handleStop(sessionKey: string, conversationId: string, bot: MessagingBot): Promise; forceStop(sessionKey: string): void; handleNewCommand(sessionKey: string, conversationId: string, bot: MessagingBot): Promise; } export interface PiAgentWrapper { syncChatHistory(currentMessageId?: string): void; run(message: ConversationMessage, responder: ConversationResponder, platform: MessagingInfo): Promise<{ stopReason: string; errorMessage?: string; }>; abort(): void; getCurrentStep(): { toolName?: string; label?: string; } | undefined; } export interface AgentConfig { provider: string; model: string; thinkingLevel: ThinkingLevel; sentryDsn?: string; sandboxCpus?: string; sandboxMemory?: string; sandboxBoostCpus?: string; sandboxBoostMemory?: string; sandboxImageWorkspaceMount?: "private" | "full"; defaultSharedVault?: string; slack?: { replyMode?: "top-level" | "thread"; }; } /** * @deprecated Auto-reply is kept for compatibility while its future is undecided. */ export interface AutoReplyConfig { enabled: boolean; rules: string[]; } export interface JudgeModelConfig { provider: string; model: string; } /** * Platform conversation history entry from log.jsonl. */ export interface ConversationLogMessage { date?: string; ts?: string; threadTs?: string; user?: string; userName?: string; text?: string; isMessagingBot?: boolean; } export interface ImmediateEvent { type: "immediate"; platform: string; conversationId: string; conversationKind: ConversationKind; userId?: string; text: string; } export interface OneShotEvent { type: "one-shot"; platform: string; conversationId: string; conversationKind: ConversationKind; userId?: string; text: string; at: string; } export interface PeriodicEvent { type: "periodic"; platform: string; conversationId: string; conversationKind: ConversationKind; userId?: string; text: string; schedule: string; timezone: string; } export type MikanEvent = ImmediateEvent | OneShotEvent | PeriodicEvent; export interface PeriodicEventInfo { filename: string; platform: string; conversationId: string; conversationKind: ConversationKind; text: string; schedule: string; timezone: string; nextRun: string | null; } export interface ActorContext { platform: string; userId: string; conversationId: string; } export type ImageWorkspaceMountMode = "private" | "full"; export interface LogContext { conversationId: string; userName?: string; conversationName?: string; sessionId?: string; } type PortalView = "admin" | "session" | "vault"; export interface PortalShellOptions { activeView: PortalView; pageTitle: string; identity?: { primary: string; secondary?: string; }; conversationSwitcher?: { currentId: string; options?: Array<{ id: string; label: string; running?: boolean; }>; }; navLinks?: Partial>; body: string; extraStyles?: string; inlineScript?: string; extraHead?: string; bodyAttributes?: Record; } export interface ContainerMount { source: string; target: string; } export interface ResourceLimits { cpus?: string; memory?: string; } export interface SandboxLimitStatus { limits?: ResourceLimits; boosted: boolean; } export interface ProvisionOptions { containerName?: string; mounts?: ContainerMount[]; conversationId?: string; } export interface DockerContainerManagerOptions { limits?: ResourceLimits; boostLimits?: ResourceLimits; execFileImpl?: ExecFileAsync; } export interface Attachment { original: string; localPath: string; } export interface LoggedMessage { date: string; ts: string; user: string; userName?: string; displayName?: string; text: string; attachments: Attachment[]; isMessagingBot: boolean; threadTs?: string; } export interface ChannelStoreConfig { workingDir: string; botToken: string; } export type TriggerIntent = "mention" | "direct" | "thread-continuation" | "auto-reply-candidate"; export type TriggerResult = { trigger: true; reason: string; } | { trigger: false; reason: string; }; /** * @deprecated Auto-reply is kept for compatibility while its future is undecided. */ export type AutoReplyJudge = (input: { event: ConversationEvent; rules: string[]; conversationDir: string; }) => Promise; export {}; //# sourceMappingURL=types.d.ts.map