import { BridgeState, SessionFrame } from "./session.mjs"; //#region src/types/hub.d.ts /** * Wire vocabulary between the hub and its pages. * * One WebSocket carries every session: hub-level frames describe the set of * sessions, and session-scoped traffic travels enveloped with the session id. * Field naming follows @earendil-works/pi-protocol so a future swap to the * upstream session server stays a transport change, not a rename. */ export declare const HUB_PROTOCOL_VERSION = 2; /** Role marker in the health payload; po-server probes for it before binding the port. */ export declare const HUB_ROLE = "hub"; /** REST endpoint for admitting and listing durable workspaces. */ export declare const WORKSPACES_API_ROUTE = "/api/workspaces"; /** REST endpoint for creating sessions and browsing resumable Pi history. */ export declare const SESSIONS_API_ROUTE = "/api/workspaces/:workspaceId/sessions"; /** One durable repository workspace shown in the rail, even while it has no sessions. */ export interface WorkspaceSummary { /** Server-owned backing scope for sessions shown without a workspace. */ kind?: 'session'; /** HTTP-only metadata, not sent on the v1 hub wire. */ instructions?: string; id: string; root: string; /** Display name chosen when the workspace was added; the folder basename stands in when absent. */ name?: string; /** A remembered workspace whose root could not be mounted on this server start. */ available?: boolean; /** The sandbox provider id that runs this workspace; absent means it runs on this host. */ sandbox?: string; /** * The container's lifecycle as the host reports it. On a workspace that is not sandboxed, * `unavailable` means the container provider cannot run here, with the cause in `sandboxReason`. */ sandboxState?: WorkspaceSandboxState; /** Plain-language cause for an unavailable or failed container. */ sandboxReason?: string; error?: string; } export declare const WORKSPACE_SANDBOX_STATES: readonly ['starting', 'running', 'stopping', 'unavailable', 'failed']; export type WorkspaceSandboxState = (typeof WORKSPACE_SANDBOX_STATES)[number]; /** One inactive Pi thread available to resume in a live session's workspace. */ export interface PiSessionHistoryItem { id: string; name?: string; firstMessage: string; createdAt: string; updatedAt: string; } /** A session removed from History that can still be restored until `purgeAt` (both ISO 8601). */ export interface RemovedSessionItem extends PiSessionHistoryItem { removedAt: string; purgeAt: string; } /** * REST endpoint behind the new-session directory picker; the page sends the * typed path as ?q= and receives {directories}: the children of the parent * directory whose names match the trailing segment as a regular expression. */ export declare const DIRECTORIES_API_ROUTE = "/api/directories"; /** Lists the visible child folders of ?path= (home when absent) for the workspace folder browser. */ export declare const DIRECTORY_CHILDREN_API_ROUTE = "/api/directories/children"; /** Folders under home that already hold a `.po` folder, offered as workspaces during onboarding. */ export declare const PO_FOLDERS_API_ROUTE = "/api/directories/po"; /** One folder's visible child directories, as absolute paths. */ export interface DirectoryListing { path: string; parent?: string; directories: string[]; } /** * Query parameter that routes a package API request to one session's server. * Without it the request is answered by a hub-scoped API in this process. */ export declare const API_SESSION_QUERY_PARAM = "session"; /** What the agent is doing right now, derived from its frame stream. */ export type SessionPhase = 'idle' | 'turn' | 'compaction' | 'retry'; export interface SessionProfile { name: string; displayName?: string; /** Changes whenever the icon does; absent when the profile has no icon. */ iconVersion?: string; } export interface SessionGitStatus { branch: string; /** True when the working tree has uncommitted changes; rendered as a star. */ dirty: boolean; } /** One immutable, signed client composition resolved for a session. */ export interface SessionWebComposition { /** Stable identity of the synchronized root and generation. */ id: string; /** Monotonic signing revision advertised by the manifest. */ revision: number; /** Same-origin signed-manifest route read by the trusted service worker. */ manifestUrl: string; /** Same-origin prefix for the untrusted source bytes verified by the worker. */ rawAssetBaseUrl: string; /** Worker-owned prefix from which the page may execute verified bytes. */ verifiedAssetBaseUrl: string; /** `[slot, entry]` per plugin copy this mount runs, each entry an absolute path below both asset prefixes. */ pluginEntries: [string, string][]; /** Absolute paths below both asset prefixes of every file this mount's slots can load. */ assetPaths: string[]; /** Absolute paths below both asset prefixes, replaced when this session is focused. */ stylePaths: string[]; /** Frame types owned by the matching session-local hub composition. */ channels: string[]; /** * The slots this mount runs out of a shared build. Absent means the composition * holds only this mount's plugins, as in-memory test hosts publish it. */ plugins?: string[]; } /** One immutable, signed native composition resolved for a session; read by po-native, ignored by the web. */ export interface SessionNativeComposition { /** Stable identity of the synchronized root and generation. */ id: string; scope: 'host' | 'workspace' | 'session'; /** Monotonic signing revision advertised by the manifest. */ revision: number; manifestUrl: string; rawAssetBaseUrl: string; /** `[pluginId, modulePath]` for each plugin of this mount that built; the shell loads each on its own. */ pluginEntries: [string, string][]; /** Shared host UI entry in the same signed generation; absent on legacy hosts. */ uiEntry?: string; channels: string[]; /** The `poNative.pluginId` values resolved for this mount; the shell installs only these. */ plugins: string[]; } /** * Everything the rail needs to render one session without subscribing to it. */ export interface SessionSummary { workspaceId?: string; id: string; name: string; cwd: string; /** ISO 8601, from the session's registry record. */ createdAt: string; /** ISO 8601, bumped whenever the session's frame stream moves. */ updatedAt: string; phase: SessionPhase; /** ISO 8601 timestamp of the last phase change; drives "running ยท 12m". */ phaseSince: string; /** The hub's own attachment to the session socket. */ attach: BridgeState; /** Human-readable cause, present when attach is refused or closed. */ attachReason?: string; pendingMessageCount: number; /** True once prior work is observed; false may also mean unavailable history. */ everPrompted: boolean; /** True while the agent waits on a dialog answer; "waiting for your input". */ awaitingInput: boolean; /** ISO 8601 of the last settled run, once one finished. */ lastSettledAt?: string; /** Authoritative owned work; null is unknown, absent is a legacy host. */ backgroundWorkActive?: boolean | null; /** Omitted when the cwd is not a git repository or git is unavailable. */ git?: SessionGitStatus; /** Selected profile; the icon itself is served by the session avatar route. */ profile?: SessionProfile; /** Signed plugin composition independently resolved for this session. */ webComposition?: SessionWebComposition; /** Signed native composition for this session, when native targets were built. */ nativeComposition?: SessionNativeComposition; /** * The session this one was spawned from, recorded by the hub when it opened the session. * The rail nests a session under its parent; absent means a top-level row. */ parentSessionId?: string; /** * The spawning package's own label for the relationship, such as "worktree". * The hub does not interpret it; the rail uses it to pick an affordance. */ sessionProvenance?: string; /** User-assigned groups; sessions sharing one may message each other. Absent means none. */ groups?: string[]; /** Host reservations awaiting a durable child runtime, not live sessions. */ pendingSetups?: Array<{ id: string; name: string; createdAt: string; cwd?: string; status?: 'provisioning' | 'failed' | 'interrupted'; setupKind?: 'managed-worktree' | 'existing-directory'; errorCode?: 'SESSION_WORKTREE_PROVISION_FAILED' | 'SESSION_UNAVAILABLE'; }>; /** * One line an extension published about background work it runs for this * session, such as a workflow; the rail shows it in place of the idle copy. */ activity?: { label: string; attention?: boolean; since?: string; }; /** Tool calls waiting for the person's approval in the Activity rail. */ pendingApprovalCount?: number; /** * The hub recorded this session but has not reopened it since its last * restart. Its journal is on disk; nothing is running behind the card until * the page asks for it. */ dormant?: boolean; } export declare const HUB_HELLO_TYPE = "hub_hello"; /** Hub-synthesized close for an answered dialog; Pi itself never announces one. */ export declare const DIALOG_ANSWERED_TYPE = "extension_ui_answered"; /** * The custom session entry the Po runtime journals with its mode * catalog projection; it arrives inside Pi's entry_appended frames. The shape * mirrors ModeProjection in po-mode. */ export declare const MODE_ENTRY_TYPE = "po-modes"; /** * The custom session entry the Po runtime journals when the agent's model * changes without a client having asked for it. The shape mirrors * AgentModelProjection in po-core. * * Pi reports a thinking-level switch on the wire, so that field follows from * the frame alone. It has no wire event for the model, so plan mode applying * its configured planning model would otherwise leave the chip naming the * model the session left behind. */ export declare const AGENT_MODEL_ENTRY_TYPE = "po-agent-model"; /** * The custom session entry Po journals describing what the session is * composed of: which mode admitted each tool and skill, and what each costs. * * Schemas are deliberately absent. Only names, kinds, owners and integer token * counts travel, so republishing the whole composition stays cheap. */ export declare const CONTEXT_ENTRY_TYPE = "po-context"; /** * The custom session entry po-profile journals naming the persona the * session speaks as. The shape mirrors ProfileIdentityProjection in * po-core. * * Unlike the entries above, this one is transcript rather than projection: it * stays in journal order and is never collapsed to the latest record, because a * message keeps the persona it was written under. Adding it to * PROJECTION_ENTRY_TYPES would repaint the whole transcript on every switch. */ export declare const PROFILE_IDENTITY_ENTRY_TYPE = "po-profile-identity"; /** * The custom session entry po-domain journals once Pi has rebuilt its * resource catalog for a reload; it mirrors PO_RESOURCE_CATALOG_ENTRY_TYPE in * po-core. * * A reload is what changes the skills the composer offers under `$`, and Pi * reports nothing else for one, so this entry is the cockpit's only notice that * the command list it cached belongs to the previous selection. */ export declare const RESOURCE_CATALOG_ENTRY_TYPE = "po-resource-catalog"; export interface ModeActionProjection { id: string; label: string; description: string; enabled: boolean; disabledReason?: string; needsInput: boolean; } export interface ModeRecordProjection { id: string; label: string; description: string; order: number; activation: 'inactive' | 'activating' | 'active' | 'deactivating'; condition: string; detail?: string; actions: ModeActionProjection[]; } export interface ModeProjection { version: 1; revision: number; modes: ModeRecordProjection[]; } export type ContextGroupKind = 'preset' | 'mode' | 'domain' | 'shared' | 'core'; export type ContextItemSource = 'extension' | 'mcp' | 'plugin' | 'core'; export interface ContextItemProjection { name: string; itemKind: 'tool' | 'skill'; source: ContextItemSource; owner: string; tokens: number; active: boolean; } export interface ContextGroupProjection { id: string; label: string; kind: ContextGroupKind; items: ContextItemProjection[]; /** What the group costs now: active items only. */ tokens: number; /** What its gated items would add if switched on. */ inactiveTokens: number; } export interface ContextProjection { version: 1; revision: number; selection?: { preset: string; domains: string[]; profile?: string; }; groups: ContextGroupProjection[]; totalTokens: number; inactiveTokens: number; /** * What the assembled system prompt costs, deliberately outside the groups. * * Every tool's prose and every skill's listing already count inside * `totalTokens`, and those are slices of this same text, so the two figures * overlap and must not be added. `stage` is `base` when the session has sent * nothing yet and the prompt shown is the one before packages patch it. */ systemPrompt?: { tokens: number; stage: 'base' | 'effective'; }; /** Names the tokenizer, because the figures are indicative, not billed. */ estimator: string; } export declare const SESSION_COMMAND_TYPE = "session_command"; /** A page asks for the transcript before what it already holds. */ export declare const HISTORY_REQUEST_TYPE = "history_request"; /** One older window, oldest first, answering a history_request. */ export declare const HISTORY_PAGE_TYPE = "history_page"; /** * How many journalled messages one page carries. Small enough that prepending * a window never blocks the reader's scroll, large enough that a flick through * a long transcript does not turn into a hundred round trips. */ export declare const HISTORY_PAGE_SIZE = 100; export interface HistoryRequestFrame { type: typeof HISTORY_REQUEST_TYPE; sessionId: string; /** Journal id of the oldest entry the page holds; absent asks for the newest window. */ before?: string; limit?: number; } export interface HistoryPageFrame { type: typeof HISTORY_PAGE_TYPE; sessionId: string; /** Entry frames, oldest first, to prepend above what the page holds. */ frames: Record[]; /** The cursor for the next older window; null when the transcript starts here. */ cursor: string | null; /** Whether anything older than this window exists. */ hasMore: boolean; /** Echoed so a page can drop an answer to a question it has since abandoned. */ before?: string; } /** First frame on every page socket, before the snapshot. */ export interface HubHelloFrame { type: typeof HUB_HELLO_TYPE; protocol: number; /** Frame types of the hub's loaded data channels; lets a panel tell "plugin server not installed" from "no data". */ channels: string[]; } /** One command frame from the page, addressed to a session's agent. */ export interface SessionCommandFrame { type: typeof SESSION_COMMAND_TYPE; sessionId: string; frame: SessionFrame; } export declare function hubHello(channels: string[]): HubHelloFrame; export declare function sessionCommand(sessionId: string, frame: SessionFrame): SessionCommandFrame; //#endregion //# sourceMappingURL=hub.d.mts.map