What the server publishes into a workbench tree as module Host.
API
@Interface()
export abstract class WorkbenchHost {
abstract readonly pageId: string;
abstract listAgents(): { agentId: string }[];
abstract createSession(opts?: {
agentId?: string;
/** Choose a project model for this Session. Omit it to use the Project default. */
model?: { provider: string; modelId: string };
/**
* `allow-all` (the default) runs every tool call, as a scheduled run does. `deny-all`
* denies every tool call in the Session: the mode for a Session that only talks, so
* nothing the person types and nothing the workbench inlines can run a command.
*/
approvalMode?: WorkbenchApprovalMode;
}): Promise<{ sessionId: string }>;
abstract run(
sessionId: string,
input: WorkbenchInput[],
): Promise<{ sessionId: string; queued: boolean }>;
abstract sessionStatus(sessionId: string): string;
abstract sessionTitle(sessionId: string): string | null;
abstract sessionResult(sessionId: string): Promise<WorkbenchResult>;
abstract subscribe(sessionId: string, listener: (record: WorkbenchRecord) => void): () => void;
abstract dataPaths(level?: WorkbenchDataLevel): WorkbenchDataPaths;
abstract socketPath(name: string, level?: WorkbenchDataLevel): string;
abstract getState(): unknown;
abstract setState(state: unknown): Promise<void>;
abstract log(message: string): void;
}Members (13)
pageId
readonly pageId: stringThis workbench's page id (page-YYYY-MM-DD-HH-mm-ss-<8 hex>), which its Sessions record as
their source (PageSource).
listAgents
listAgents(): { agentId: string }[]The Agents of this Project — who createSession can be asked to open a Session of. The
system Agent, which runs none, is not one of them.
{ agentId: string }[]createSession
createSession(opts?: { agentId?: string; model?: { provider: string; modelId: string }; approvalMode?: WorkbenchApprovalMode; }): Promise<{ sessionId: string }>Opens a Session of an Agent of this Project — the workbench's own Agent when agentId
is absent. The SDK's agent.createSession. The Session's approval mode is approvalMode,
allow-all when absent; any other value is refused by name.
{ agentId?: string; model?: { provider: string; modelId: string }; approvalMode?: WorkbenchApprovalMode; }Promise<{ sessionId: string }>run
run(sessionId: string, input: WorkbenchInput[]): Promise<{ sessionId: string; queued: boolean }>Runs one turn in a Session of this Project, new or existing — the SDK's session.run.
input is a list of items like the SDK's, each one { text } today; it reaches the
Agent as a message from the server, not from a person. A Session that is busy takes it as a queued follow-up
(queued: true) instead of refusing it. Resolves once the turn has started; watch it
with sessionResult.
stringWorkbenchInput[]Promise<{ sessionId: string; queued: boolean }>sessionStatus
sessionStatus(sessionId: string): stringidle / running / … of a Session of this Project.
stringstringsessionTitle
sessionTitle(sessionId: string): string | nullThe Session's generated or user-edited title; null until one is available.
stringstring | nullsessionResult
sessionResult(sessionId: string): Promise<WorkbenchResult>A snapshot, not a wait: running until the latest task ends, then its final answer or failure. No tool or thinking messages.
stringPromise<WorkbenchResult>subscribe
subscribe(sessionId: string, listener: (record: WorkbenchRecord) => void): () => voidFollows a Session of this Project live: listener receives each record the Session
publishes from now on — exactly the records GET /api/sessions/:id/amsp streams, partial
deltas and a subagent's (origin) included. Nothing is replayed, so subscribe before
run. Returns the unsubscribe function; calling it again does nothing. A listener runs
after the publish, never inside it, records in order; one that throws is logged and the
subscription carries on. A main task_end (no origin) arrives before the Session reads
idle, and sessionResult answers running until it does. Every subscription ends with the
workbench's tree (a reload, a removal), and one whose Session has sat idle with nothing
published for the channel hub's idle window ends by itself.
string(record: WorkbenchRecord) => void() => voiddataPaths
dataPaths(level?: WorkbenchDataLevel): WorkbenchDataPathsWhere this workbench's data, cache and state folders are at level (agent when left
out). All three exist once this returns, and a link where one of them belongs is refused.
At the agent level the Agent's commands may write them even in a workspace-write sandbox,
so a path in them can be handed to the Agent. The server and machine levels are for an
app installed from a plugin, and throw for a workbench made in place.
WorkbenchDataLevelWorkbenchDataPathssocketPath
socketPath(name: string, level?: WorkbenchDataLevel): stringWhat to listen on for a local socket called name at level (agent when left out):
<stateDir>/<name>, or on Windows a named pipe (\\.\pipe\penguin-…-<name>), which is no
path on disk. Throws, naming the limit, when the path would pass the 103 bytes a Unix socket
path holds.
stringWorkbenchDataLevelstringgetState
getState(): unknownThe workbench's own document (state.json, kept by the server across reloads and rollbacks).
unknownsetState
setState(state: unknown): Promise<void>unknownPromise<void>log
log(message: string): voidstringvoid