@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
233 lines (232 loc) • 8.78 kB
TypeScript
import type { BrowserRegistry } from "./browser-registry.js";
import type { TurnQueue } from "./turn-queue.js";
import type { ConductorSuccessionService } from "./conductor-succession.js";
import type { StorePulls } from "./store-pull.js";
import type { GitboyWebhooks } from "./gitboy-webhooks.js";
import { type SessionMover } from "./session-move.js";
import { type OwnerInbox } from "./owner-inbox.js";
import type { HandOffQueue } from "./hand-off-queue.js";
import type { IncomingMessage, ServerResponse } from "node:http";
import { z } from "zod";
import type { FanoutMessages } from "./fanout-messages.js";
import type { ModuleSnapshot } from "../modules/runtime.js";
import type { ActivityJournal } from "./activity.js";
import type { AgentHooks } from "./agent-hooks.js";
import type { WorkspaceContextUsage } from "./context.js";
import { type DispatchService } from "./dispatch.js";
import { type DispatchReturns } from "./dispatch-returns.js";
import type { LaunchLimiter } from "./limits.js";
import { type Json } from "./protocol.js";
import type { CodexQuestions } from "./questions.js";
import { type TabActivityStore } from "./tab-activity.js";
import type { ModelCatalog } from "./models.js";
import type { ModelSwitcher } from "./model-switch.js";
import type { PermissionModeSwitcher } from "./permission-mode.js";
import type { SettingsSwitcher } from "./settings-switch.js";
import type { SideQuestions } from "./side-questions.js";
import { type AccountUsageReader } from "./usage.js";
import type { ResourceMonitor } from "./resources.js";
import type { Housekeeper } from "./housekeeping/housekeeper.js";
import type { Scheduler } from "./schedules.js";
import type { TranscriptStreams } from "./server-stream.js";
/** The Hook's HTTP API over its Unix socket: module gating, the GET routes,
* the POST routes that are not bound to one pane, and grant deletion. */
/** What /v1/health reports about this computer and its Hook. */
export interface HookInfo {
product: string;
protocol: number;
version: string;
computer: {
id: string;
name: string;
aliases?: string[];
};
capabilities: Record<string, unknown>;
modules: Record<string, string>;
store: string;
profile: string;
generation: string;
readonly load: {
average: number;
cpus: number;
};
readonly gatewayMs: number | undefined;
}
export interface RouteContext {
browsers?: BrowserRegistry;
turnQueue?: TurnQueue;
version: string;
modules: ModuleSnapshot;
info: HookInfo;
computerID: string;
scheduleStore: string;
scheduler?: Scheduler;
storePulls?: StorePulls;
gitboyWebhooks?: GitboyWebhooks;
dispatches?: DispatchService;
returns?: DispatchReturns;
handOffs?: HandOffQueue;
inbox?: OwnerInbox;
mover?: SessionMover;
succession?: ConductorSuccessionService;
agentHooks: AgentHooks;
journal: ActivityJournal;
tabActivity: TabActivityStore;
contextUsage: WorkspaceContextUsage;
modelCatalog: ModelCatalog;
modelSwitcher: ModelSwitcher;
settingsSwitcher: SettingsSwitcher;
permissionModeSwitcher: PermissionModeSwitcher;
sideQuestions: SideQuestions;
accountUsage: AccountUsageReader;
resources: ResourceMonitor;
/** Housekeeping reports (housekeeping/); absent in route tests that do not need it. */
housekeeper?: Housekeeper;
codexQuestions: CodexQuestions;
launches: LaunchLimiter;
locatedDirectories: Set<string>;
fanoutMessages: FanoutMessages;
canary: (trigger: "manual" | "daily") => Promise<unknown>;
streams: TranscriptStreams;
}
/** How long the overview waits for per-tab git and transcript reads; the phone gives up at 20 s. */
export declare const OVERVIEW_ENRICH_BUDGET_MS = 5000;
type StatusRow = {
workspace: unknown;
tab: unknown;
status: unknown;
};
/** How long activity sampling may spend resolving background work before it
* leaves an unresolved row at its last known status. */
export declare const STATUS_ENRICH_BUDGET_MS = 2000;
/** The status each tab's row sends after the same background-work rules the
* overview applies: an idle or done tab whose ended turn still awaits shells or
* running children is working. The activity timer uses this while no overview
* is open, so its status clock still moves. A row whose background reads do not
* finish inside `budgetMs` is left out, which preserves its last known status. */
export declare function effectiveStatusRows(server: string, s: Json, budgetMs?: number, hooks?: AgentHooks): Promise<StatusRow[]>;
/**
* `POST /v1/owner-inbox/close`: a signed phone decision on one row, guarded by
* the exact revision the phone read (`ifUpdatedAt` is compared as the wire
* string). Resolve means handled; dismiss removes the row from the shared list.
*/
export declare const ownerInboxCloseSchema: z.ZodObject<{
id: z.ZodString;
ifUpdatedAt: z.ZodString;
decision: z.ZodEnum<{
dismiss: "dismiss";
resolve: "resolve";
}>;
}, z.core.$strict>;
export declare const capabilities: {
browsers: boolean;
turnCheckpoints: boolean;
transcript: boolean;
progress: boolean;
images: boolean;
prompt: boolean;
stop: boolean;
terminal: string;
shell: string;
paneTerminal: string;
paneLayout: boolean;
deskPresence: boolean;
herdr: boolean;
sessionRename: boolean;
sessionSeen: boolean;
diff: boolean;
webServers: boolean;
webPreview: string;
activity: boolean;
approvals: boolean;
questions: boolean;
accountUsage: boolean;
providers: string[];
files: boolean;
repositoryFiles: boolean;
fileResolution: boolean;
chatFileCandidates: boolean;
subagents: boolean;
sideQuestions: boolean;
dispatch: boolean;
conductorSets: boolean;
setLink: boolean;
ownerInbox: boolean;
workerReports: boolean;
queuedHandOff: boolean;
ciFailureHandoff: number;
approvalPush: string;
simulators: boolean;
simulatorStream: boolean;
simulatorDevices: boolean;
simulatorDrag: boolean;
macWindows: number | undefined;
macWindowStream: number | undefined;
code: boolean;
codeFiles: boolean;
overviewStream: boolean;
speech: boolean;
speechTimestamps: boolean;
speechTimestampStream: boolean;
speechLive: boolean;
speechVoices: boolean;
speechFormats: ("mp3_44100_128" | "mp3_44100_192" | "pcm_24000" | "pcm_44100")[];
transcribe: boolean;
memoryStore: boolean;
promptOnce: boolean;
promptStatus: boolean;
afterTurnQueue: boolean;
queuedMessageActions: string[];
deliveryFrames: boolean;
paneDeliveries: boolean;
resources: boolean;
sudo: boolean;
sudoOutcome: boolean;
secretExec: boolean;
ownerProof: number;
ownerConfirm: number;
previewDeltas: boolean;
quickChat: boolean;
agentFolder: boolean;
launchPermissionMode: boolean;
sessionMove: boolean;
moveNewChat: boolean;
moveConductor: boolean;
moveToComputer: boolean;
moveConductorToComputer: boolean;
moveResume: boolean;
moveSummaryByTarget: boolean;
moveConversationCopy: boolean;
claudeAccountAdd: boolean;
accountPools: boolean;
workerRelocation: number;
projectMemory: boolean;
fileWrite: boolean;
fileSearch: boolean;
gitReview: boolean;
memoryStoreBatch: boolean;
gitHosts: boolean;
projectHostToken: boolean;
gitRemoteIdentity: boolean;
gitWatch: boolean;
worktreeRemove: boolean;
terminalResolve: boolean;
terminalAddresses: boolean;
conversationSearch: boolean;
housekeeping: number;
housekeepingInventory: number;
issues: number;
};
export declare function capabilitiesForModules(snapshot: ModuleSnapshot): Record<string, unknown>;
export declare function requireRoute(snapshot: ModuleSnapshot, method: string, route: string): void;
export declare function selectedServer(url: URL): string;
/**
* The overview a phone draws for one Herdr server: every tab with its agent,
* target, branch, model, running children and current step, from one
* `session.snapshot`. `GET /v1/workspaces` passes a fresh snapshot; the
* `/v1/overview` stream passes the shared one it already holds.
*/
export type WorkspacesReader = (server: string, s: Json, watchApprovals: boolean, live?: () => boolean) => Promise<Json>;
export declare function workspacesReader(ctx: Pick<RouteContext, "modules" | "info" | "agentHooks" | "journal" | "tabActivity" | "contextUsage" | "turnQueue">): WorkspacesReader;
export declare function createRouteHandler(ctx: RouteContext): (request: IncomingMessage, response: ServerResponse) => Promise<void>;
export {};