Skip to content
API reference

agent-control

Import
import * as api from "@fungi.computer/shiitake/agent-control";
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.

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.

  • Error
Signature
new AgentArchiveRefused(reason, message): AgentArchiveRefused;
Parameter Type
reason | "running" | "pending" | "archived" | "not_creator" | "self" | "unreadable"
message string

AgentArchiveRefused

Signature
Error.constructor;
Signature
readonly name: "AgentArchiveRefused" = "AgentArchiveRefused";
Signature
Error.name;
Signature
readonly reason:
| "running"
| "pending"
| "archived"
| "not_creator"
| "self"
| "unreadable";

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.

  • Error
Signature
new AgentCreateRefused(reason, message): AgentCreateRefused;
Parameter Type
reason "exceeds_creator" | "no_creator" | "request_conflict"
message string

AgentCreateRefused

Signature
Error.constructor;
Signature
readonly name: "AgentCreateRefused" = "AgentCreateRefused";
Signature
Error.name;
Signature
readonly reason: "exceeds_creator" | "no_creator" | "request_conflict";

AgentControlAnswerInputtype alias

Section titled “AgentControlAnswerInput”
Signature
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”
Signature
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”
Signature
type AgentControlAnswerOutput = z.infer<typeof answerOutput>;

Typed outcome of a sender’s answer to a child Ask.


AgentControlEscalateOutputtype alias

Section titled “AgentControlEscalateOutput”
Signature
type AgentControlEscalateOutput = z.infer<typeof escalateOutput>;

Typed outcome of a sender’s escalation of a child’s item.


ArchiveRefusalReasontype alias

Section titled “ArchiveRefusalReason”
Signature
type ArchiveRefusalReason = (typeof archiveRefusalReasons)[number];

One reason in archiveRefusalReasons.


AgentControlAgenttype alias

Section titled “AgentControlAgent”
Signature
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”
Signature
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”
Signature
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”
Signature
type AgentRecallInput = Readonly<{
agentId: string;
sessionId: string;
requestId: string;
}>;

Exact authorized destination and caller’s original send identity.


AgentDelegationInvocationtype alias

Section titled “AgentDelegationInvocation”
Signature
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”
Signature
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”
Signature
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”
Signature
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”
Signature
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()”
Signature
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.

Parameter Type
session ShiitakeSession
commandId string
timeoutMs number
signal AbortSignal
startedAt number

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()”
Signature
function createAgentControlSource(directory): CapabilitySource;

Compose one authorized Agent-control projection for a single run lease.

Parameter Type
directory AgentControlDirectory

CapabilitySource