agent-control
Import
Section titled “Import”import * as api from "@fungi.computer/shiitake/agent-control";Exports
Section titled “Exports”| Kind | Export | Description |
|---|---|---|
| class | AgentArchiveRefused | A host’s refusal to archive or restore an Agent, or to work with one that is archived. It reaches the caller as a failure of the operation it refused. |
| class | AgentCreateRefused | A host’s refusal of an Agent creating an Agent: the creator asked to give the
created Agent more than it holds, the host cannot tell which Agent is creating,
or the request id belongs to another creating Agent or Session. It reaches the
caller as an agents.create failure. |
| type alias | AgentControlAnswerInput | Sender-authenticated submission for one child Session’s routed Ask. |
| type alias | AgentControlEscalateInput | Sender-authenticated escalation of one item a child Session left waiting. |
| type alias | AgentControlAnswerOutput | Typed outcome of a sender’s answer to a child Ask. |
| type alias | AgentControlEscalateOutput | Typed outcome of a sender’s escalation of a child’s item. |
| type alias | ArchiveRefusalReason | One reason in archiveRefusalReasons. |
| type alias | AgentControlAgent | One existing Agent visible within the caller’s authorized project or Team. |
| type alias | AgentControlModel | One host-offered model usable as an Agent’s create or setModel choice. |
| type alias | AgentDelegationInput | One host-authorized delegation, with the caller Session supplied by acquisition. |
| type alias | AgentRecallInput | Exact authorized destination and caller’s original send identity. |
| type alias | AgentDelegationInvocation | Host-only identity and admitted command metadata for one delegated send. |
| type alias | AgentControlDirectory | Host-owned discovery and per-operation access to ordinary Agents. |
| constant | answerOutput | Typed outcome of a sender’s answer to a child Ask. |
| constant | escalateOutput | Typed outcome of a sender’s escalation of a child’s item. |
| constant | archiveRefusalReasons | Why a host refuses an archive or restore: the caller did not create the Agent, is the Agent, the Agent has a running command or delegated work still waiting to report back, its store predates the current schema, or the Agent is archived. |
| function | waitForAgentSettlement() | Await one exact durable terminal without opening a transcript observation. |
| function | createAgentControlSource() | Compose one authorized Agent-control projection for a single run lease. |
AgentArchiveRefusedclass
Section titled “AgentArchiveRefused”A host’s refusal to archive or restore an Agent, or to work with one that is archived. It reaches the caller as a failure of the operation it refused.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AgentArchiveRefused(reason, message): AgentArchiveRefused;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reason |
| "running" | "pending" | "archived" | "not_creator" | "self" | "unreadable" |
message |
string |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;Properties
Section titled “Properties”readonly name: "AgentArchiveRefused" = "AgentArchiveRefused";Overrides
Section titled “Overrides”Error.name;reason
Section titled “reason”readonly reason: | "running" | "pending" | "archived" | "not_creator" | "self" | "unreadable";AgentCreateRefusedclass
Section titled “AgentCreateRefused”A host’s refusal of an Agent creating an Agent: the creator asked to give the
created Agent more than it holds, the host cannot tell which Agent is creating,
or the request id belongs to another creating Agent or Session. It reaches the
caller as an agents.create failure.
Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AgentCreateRefused(reason, message): AgentCreateRefused;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
reason |
"exceeds_creator" | "no_creator" | "request_conflict" |
message |
string |
Returns
Section titled “Returns”Overrides
Section titled “Overrides”Error.constructor;Properties
Section titled “Properties”readonly name: "AgentCreateRefused" = "AgentCreateRefused";Overrides
Section titled “Overrides”Error.name;reason
Section titled “reason”readonly reason: "exceeds_creator" | "no_creator" | "request_conflict";AgentControlAnswerInputtype alias
Section titled “AgentControlAnswerInput”type AgentControlAnswerInput = Readonly<{ agentId: string; sessionId: string; askId: string; requestId: string; answers: MyceliumJsonValue;}>;Sender-authenticated submission for one child Session’s routed Ask.
AgentControlEscalateInputtype alias
Section titled “AgentControlEscalateInput”type AgentControlEscalateInput = Readonly<{ agentId: string; sessionId: string; itemId: string; note?: string;}>;Sender-authenticated escalation of one item a child Session left waiting.
AgentControlAnswerOutputtype alias
Section titled “AgentControlAnswerOutput”type AgentControlAnswerOutput = z.infer<typeof answerOutput>;Typed outcome of a sender’s answer to a child Ask.
AgentControlEscalateOutputtype alias
Section titled “AgentControlEscalateOutput”type AgentControlEscalateOutput = z.infer<typeof escalateOutput>;Typed outcome of a sender’s escalation of a child’s item.
ArchiveRefusalReasontype alias
Section titled “ArchiveRefusalReason”type ArchiveRefusalReason = (typeof archiveRefusalReasons)[number];One reason in archiveRefusalReasons.
AgentControlAgenttype alias
Section titled “AgentControlAgent”type AgentControlAgent = Readonly<{ agentId: string; name: string; createdBy?: string | null; model?: ModelPreference; workingDirectory?: string;}>;One existing Agent visible within the caller’s authorized project or Team.
AgentControlModeltype alias
Section titled “AgentControlModel”type AgentControlModel = Readonly<{ address: string; name: string;}>;One host-offered model usable as an Agent’s create or setModel choice.
AgentDelegationInputtype alias
Section titled “AgentDelegationInput”type AgentDelegationInput = Readonly<{ agentId: string; text: string; requestId: string;}> & | Readonly<{ sessionId: string; delivery: "steer";}> | Readonly<{ sessionId?: string; delivery: "followUp";}>;One host-authorized delegation, with the caller Session supplied by acquisition.
AgentRecallInputtype alias
Section titled “AgentRecallInput”type AgentRecallInput = Readonly<{ agentId: string; sessionId: string; requestId: string;}>;Exact authorized destination and caller’s original send identity.
AgentDelegationInvocationtype alias
Section titled “AgentDelegationInvocation”type AgentDelegationInvocation = Readonly<{ toolCallId: string; sendIndex: number; commandId?: string; meta?: CapabilitySession["meta"]; toolCallCode?: string;}>;Host-only identity and admitted command metadata for one delegated send.
AgentControlDirectorytype alias
Section titled “AgentControlDirectory”type AgentControlDirectory = Readonly<{ list: (signal, options?) => Promise<readonly AgentControlAgent[]>; send?: ( input, sourceSessionId, signal, invocation?, ) => Promise<Accepted | Held>; recall?: (input, sourceSessionId, signal) => Promise<CancelResult>; answer?: ( input, senderSessionId, signal, ) => Promise<AgentControlAnswerOutput>; escalate?: ( input, senderSessionId, signal, ) => Promise<AgentControlEscalateOutput>; create?: (input, signal) => Promise<AgentControlAgent>; setModel?: (input, signal) => Promise<void>; archive?: (input, signal) => Promise<void>; unarchive?: (input, signal) => Promise<void>; models?: (signal) => Promise<readonly AgentControlModel[]>; checkModel?: (input, signal) => Promise<void>; open: ( agentId, signal, ) => Promise< Readonly<{ agent: ShiitakeAgent; release: () => Promise<void>; }> >;}>;Host-owned discovery and per-operation access to ordinary Agents.
answerOutputconstant
Section titled “answerOutput”const answerOutput: ZodDiscriminatedUnion< [ ZodObject< { status: ZodLiteral<"answered">; via: ZodEnum<{ in_turn: "in_turn"; follow_up: "follow_up"; }>; commandId: ZodExactOptional<ZodString>; }, $strict >, ZodObject< { status: ZodLiteral<"not_found">; }, $strict >, ZodObject< { status: ZodLiteral<"closed">; reason: ZodEnum<{ cancelled: "cancelled"; undeliverable: "undeliverable"; answered: "answered"; declined: "declined"; withdrawn: "withdrawn"; expired: "expired"; }>; }, $strict >, ZodObject< { status: ZodLiteral<"refused">; reason: ZodEnum<{ not_sender: "not_sender"; no_provenance: "no_provenance"; }>; }, $strict >, ZodObject< { status: ZodLiteral<"unavailable">; reason: ZodLiteral<"unsupported">; }, $strict >, ], "status">;Typed outcome of a sender’s answer to a child Ask.
escalateOutputconstant
Section titled “escalateOutput”const escalateOutput: ZodDiscriminatedUnion< [ ZodObject< { status: ZodLiteral<"escalated">; to: ZodLiteral<"person">; }, $strict >, ZodObject< { status: ZodLiteral<"not_found">; }, $strict >, ZodObject< { status: ZodLiteral<"closed">; reason: ZodEnum<{ cancelled: "cancelled"; undeliverable: "undeliverable"; answered: "answered"; declined: "declined"; withdrawn: "withdrawn"; expired: "expired"; }>; }, $strict >, ZodObject< { status: ZodLiteral<"refused">; reason: ZodEnum<{ not_sender: "not_sender"; no_provenance: "no_provenance"; }>; }, $strict >, ZodObject< { status: ZodLiteral<"unavailable">; reason: ZodLiteral<"unsupported">; }, $strict >, ], "status">;Typed outcome of a sender’s escalation of a child’s item.
archiveRefusalReasonsconstant
Section titled “archiveRefusalReasons”const archiveRefusalReasons: readonly [ "not_creator", "self", "running", "pending", "unreadable", "archived",];Why a host refuses an archive or restore: the caller did not create the Agent, is the Agent, the Agent has a running command or delegated work still waiting to report back, its store predates the current schema, or the Agent is archived.
waitForAgentSettlement()function
Section titled “waitForAgentSettlement()”function waitForAgentSettlement( session, commandId, timeoutMs, signal, startedAt?,): Promise< Readonly<{ acceptedSender: string | null; delegator: string | null; terminal: SessionTerminal; content: string; usage: readonly Pick<AssistantMessage, "model" | "provider" | "usage">[]; toolCalls: number; waitingOnYou: readonly Readonly<{ itemId: string; kind: string; summary: string; }>[]; }>>;Await one exact durable terminal without opening a transcript observation.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
session |
ShiitakeSession |
commandId |
string |
timeoutMs |
number |
signal |
AbortSignal |
startedAt |
number |
Returns
Section titled “Returns”Promise<Readonly<{ acceptedSender: string | null; delegator:
string | null; terminal: SessionTerminal;
content: string; usage: readonly Pick<AssistantMessage, "model" |
"provider" | "usage">[]; toolCalls: number; waitingOnYou: readonly
Readonly<{ itemId: string; kind: string; summary: string;
}>[]; }>>
createAgentControlSource()function
Section titled “createAgentControlSource()”function createAgentControlSource(directory): CapabilitySource;Compose one authorized Agent-control projection for a single run lease.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
directory |
AgentControlDirectory |
Returns
Section titled “Returns”CapabilitySource