@phren/cli
Version:
Knowledge layer for AI agents - CLI, MCP server, and data layer
187 lines (186 loc) • 6.68 kB
TypeScript
import { z } from "zod";
import { type WindowRoom } from "./account-choice.js";
import { type Json, type Target } from "./protocol.js";
import { computerLabel, type PeerFacts } from "./computer-identity.js";
export { computerLabel };
export declare const handOffSchema: z.ZodObject<{
computer: z.ZodOptional<z.ZodString>;
target: z.ZodOptional<z.ZodObject<{
server: z.ZodString;
workspace: z.ZodString;
tab: z.ZodString;
pane: z.ZodString;
source: z.ZodEnum<{
claude: "claude";
codex: "codex";
copilot: "copilot";
opencode: "opencode";
phren: "phren";
}>;
session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
}, z.core.$strip>>;
session: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
project: z.ZodOptional<z.ZodString>;
account: z.ZodOptional<z.ZodString>;
deliveryId: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodBoolean>;
text: z.ZodOptional<z.ZodString>;
}, z.core.$strict>;
export type HandOffInput = z.infer<typeof handOffSchema>;
export declare function handOff(input: unknown, options?: {
deliveryId?: string;
notifySender?: boolean;
bypassConductor?: boolean;
}): Promise<{
ok: boolean;
delivered: boolean;
target: Target;
queued?: boolean;
deliveryId?: string;
state?: string;
deliveryUncertain?: boolean;
unsubmitted?: boolean;
label?: string;
granted?: string;
}>;
export declare const moveSessionSchema: z.ZodObject<{
computer: z.ZodOptional<z.ZodString>;
target: z.ZodOptional<z.ZodObject<{
server: z.ZodString;
workspace: z.ZodString;
tab: z.ZodString;
pane: z.ZodString;
source: z.ZodEnum<{
claude: "claude";
codex: "codex";
copilot: "copilot";
opencode: "opencode";
phren: "phren";
}>;
session: z.ZodUnion<readonly [z.ZodString, z.ZodString]>;
}, z.core.$strip>>;
session: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
pane: z.ZodOptional<z.ZodString>;
harness: z.ZodEnum<{
claude: "claude";
codex: "codex";
copilot: "copilot";
opencode: "opencode";
}>;
account: z.ZodOptional<z.ZodString>;
model: z.ZodOptional<z.ZodString>;
effort: z.ZodOptional<z.ZodEnum<{
high: "high";
low: "low";
max: "max";
medium: "medium";
minimal: "minimal";
xhigh: "xhigh";
}>>;
id: z.ZodOptional<z.ZodString>;
status: z.ZodOptional<z.ZodBoolean>;
wait: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strict>;
/**
* Moves a live session to another harness on its own computer (session-move.ts):
* the agent writes a hand-off and exits, and the new agent starts in its pane
* with it. Answers with the move record; a dispatched worker's receipt follows
* the move on its next poll.
*/
export declare function moveSession(input: unknown, options?: {
waitMs?: number;
pollMs?: number;
agent?: boolean;
}): Promise<{
ok: boolean;
move: Json;
settled: boolean;
}>;
/** One live agent pane, on this computer or an enrolled one. */
export interface LiveSession {
computer: string;
local: boolean;
project?: string;
label?: string;
title?: string;
agent?: string;
status?: string;
role?: string;
branch?: string;
model?: string;
target?: Target;
/** Claude account id, when the Hook knows it; absent means the default account or an unknown one. */
account?: string;
/** Seconds since the tab last changed, when the Hook has seen it change. */
idleFor?: number;
/** Set when the main turn ended and this many background tasks keep the session `working`. */
backgroundTasks?: number;
stalled?: boolean;
stallFor?: number;
stalledSince?: string;
/** A Claude session's account room: its 5-hour and weekly windows. */
quota?: ClaudeQuota;
}
/** One window's room as live_sessions shows it. */
export type QuotaWindow = WindowRoom & {
resetsIn?: string;
};
export interface ClaudeQuota {
fiveHour?: QuotaWindow;
week?: QuotaWindow;
}
/** One signed-in Claude account on one computer, with its room. */
export interface ClaudeAccountRoom extends ClaudeQuota {
computer: string;
account: string;
label?: string;
email?: string;
}
/** Each Claude account's room in one computer's usage answer. */
export declare function claudeAccountRooms(answer: Json, computer: string, now?: number): ClaudeAccountRoom[];
/** Owner-visible login metadata and remaining allowance for continuation.
* Config paths, identity hashes and provider credentials stay on the Hook. */
export declare function claudeMoveAccounts(answer: Json): Array<{
id: string;
email?: string;
plan?: string;
fiveHourLeft?: number;
weekLeft?: number;
resetsAt?: string;
fiveHourResetsAt?: string;
weekResetsAt?: string;
}>;
/** A registered computer this Hook cannot see, with the other names the store
* registers it under. */
export interface NotLinkedComputer {
name: string;
aliases?: string[];
}
/** Computers the store registers (machines.yaml) that this Hook has no
* verified connection to, so their sessions cannot be listed from here: the
* unlinked rows of `foldComputers`, which folds names by first label and by
* shared profile into the computers it can see. */
export declare function notLinkedFrom(store: string | null, here: string, peers: readonly PeerFacts[]): NotLinkedComputer[];
/** As `notLinkedFrom` for a flat list of names the linked computers answer
* to, each standing for its own computer. */
export declare function notLinkedComputers(store: string | null, here: string, linked: readonly string[]): NotLinkedComputer[];
export interface LiveSessions {
sessions: LiveSession[];
unreachable: {
computer: string;
error: string;
code?: string;
}[];
/** Registered in the store but not linked in hooks.yaml: unknown, not idle. */
notLinked: NotLinkedComputer[];
enrolled: number;
/** Every signed-in Claude account on each computer that answered, with its 5-hour and weekly room. */
claudeAccounts?: ClaudeAccountRoom[];
peerError?: string;
}
/** Every live agent the conductor could hand work to: this computer's Herdr
* overview plus each enrolled computer's, read through its verified Hook.
* An unreachable computer is reported, never silently dropped. */
export declare function listLiveSessions(options?: {
store?: string | null;
}): Promise<LiveSessions>;