import { type IncomingMessage, type ServerResponse } from 'node:http'; import { applyExactChatGrantRequest } from '../services/exact-chat-grant.js'; import { type SupervisorShutdownIdentity } from './supervisor-shutdown-ipc.js'; /** Test seam: replace the exact-grant service without touching live Feishu/config state. */ export declare function setExactChatGrantHandler(handler: typeof applyExactChatGrantRequest | null): void; export type BotRenameOutcome = { ok: true; name: string; } | { ok: false; reason: string; message: string; }; export declare function setBotRenamer(fn: ((newName: string) => Promise) | null): void; export type BotAvatarOutcome = { ok: true; avatarUrl: string; versionId?: string; } | { ok: false; reason: string; message: string; }; export declare function setBotAvatarChanger(fn: ((image: Buffer) => Promise) | null): void; type SupervisorShutdownRegistration = SupervisorShutdownIdentity & { shutdown: () => Promise; }; export declare function setSupervisorShutdownHandler(registration: SupervisorShutdownRegistration | null): void; import { composeRowFromActive, composeRowFromClosed, composeRowFromPersistedActive, type SessionRow } from './dashboard-rows.js'; import type { ParsedSchedule, ScheduleExecutionPosition } from '../types.js'; export interface IpcServerHandle { port: number; close: () => Promise; } export type Handler = (req: IncomingMessage, res: ServerResponse, params: Record) => Promise | void; export declare function isTrustedHostIpcRequest(req: IncomingMessage): boolean; /** Register a handler. Path supports `:name` segments captured into the params object. */ export declare function ipcRoute(method: string, path: string, handler: Handler): void; export declare function jsonRes(res: ServerResponse, status: number, body: unknown): void; export declare class JsonBodyTooLargeError extends Error { readonly maxBytes: number; constructor(maxBytes: number); } export declare class AbortDeadlineError extends Error { readonly label: string; readonly timeoutMs: number; constructor(label: string, timeoutMs: number); } /** 校验跨进程 JSON envelope,只接受普通对象和完整、精确的自有字段集合。 */ export declare function hasExactSafeJsonKeys(value: unknown, expectedKeys: readonly string[]): value is Record; /** * 为支持 AbortSignal 的底层操作设置硬截止时间。Promise.race 保证调用方按时释放 * in-flight 状态,AbortController 同时取消仍在执行的网络或子进程操作。 */ export declare function runWithAbortDeadline(label: string, timeoutMs: number, task: (signal: AbortSignal, deadlineAt: number) => Promise): Promise; export declare function readJsonBody(req: IncomingMessage, maxBytes?: number): Promise; /** Test seam: override the secret used to verify token-route HMAC. */ export declare function setIpcAuthSecret(secret: string | null): void; /** Authenticate legacy terminal-token routes with the machine-local dashboard * secret. Workflow v3 mutations intentionally use their separate, full-request * protocol (`workflows/v3/daemon-ipc-auth`) and must never call this bare * ts:nonce verifier. */ export declare function ipcHmacAuthorized(req: IncomingMessage, bind?: string): boolean; export declare function armCoreOnlyReadinessGate(): void; export declare function setCoreOnlyReady(): void; /** @internal test-only: reset the core-only readiness gate between cases. */ export declare function __testOnly_resetCoreOnlyReadiness(): void; export type { SessionRow }; export { composeRowFromActive, composeRowFromClosed, composeRowFromPersistedActive }; export declare function setBotName(name: string): void; export declare function setLarkAppId(id: string): void; export interface ScheduleRow { id: string; name: string; schedule: string; parsed: ParsedSchedule; prompt: string; workingDir: string; chatId: string; rootMessageId?: string; scope?: 'thread' | 'chat'; executionPosition?: ScheduleExecutionPosition; topicTitle?: string; larkAppId?: string; botName?: string; enabled: boolean; createdAt: string; lastRunAt?: string; nextRunAt?: string; lastStatus?: 'ok' | 'error'; lastError?: string; repeat?: { times: number | null; completed: number; }; deliver?: 'origin' | 'local' | 'new-topic'; silent?: boolean; feishuChatLink: string; } export declare function startIpcServer(opts: { port: number; host: string; /** Enable the production trusted-host boundary. The verifier reloads the * tiny secret file for each request so concurrent fleet bootstrap or a * deliberate secret repair cannot strand a daemon on a stale cached key. * Tests that omit this option retain the lightweight in-process server. */ authRequired?: boolean; /** Daemon restore barrier. The socket/health route may come up early so its * descriptor is discoverable, but every state-bearing route waits until all * durable session owners have been registered. */ ready?: Promise; /** Upward-probe span on EADDRINUSE. Default DEFAULT_PROBE_SPAN (fleet daemons * step to the next free port so a port race can't crash boot). Core-only * (single in-sandbox service) sets 0 to BIND-OR-FAIL on the exact requested * port — riff's task-runner is told a fixed port and must not have the service * silently drift to another one. */ maxProbe?: number; /** Core-only: additionally treat the tight riff-facing route allowlist * (routeIsCoreOnlyPublic) as public (no HMAC). Every OTHER route still requires * the trusted-host HMAC — this does NOT disable auth wholesale (codex P1). */ coreOnlyPublicRoutes?: boolean; }): Promise; //# sourceMappingURL=dashboard-ipc-server.d.ts.map