Skip to content
API reference

loop/contract

Import
import * as api from "@fungi.computer/shiitake-extensions/loop";
Kind Export Description
type alias Loop One Session’s loop.
constant LoopCron A named cron cadence evaluated in one IANA time zone.
constant Loop One Session’s loop as every client sees it.
constant LoopCommandInput Arguments of the human /loop command. start carries the typed text: <prompt> paces itself, <N>m <prompt> or <N>h <prompt> runs on an interval. A bare call opens the controls.
constant LoopProjection Loop’s contract: Session-scope controls and one projection slot.
constant loopContract Session-owned loop controls and their visible state.
Signature
type Loop = Schema.Schema.Type<typeof Loop>;

One Session’s loop.

LoopCronconstant

Section titled “LoopCron”
Signature
const LoopCron: Struct<{
expression: String;
timeZone: String;
}>;

A named cron cadence evaluated in one IANA time zone.


Loopconstant

Section titled “Loop”
Signature
const Loop: Struct<{
loopId: String;
origin: Literals<readonly ["human", "model"]>;
expiresAt: NullOr<Int>;
prompt: String;
mode: Literals<readonly ["self_paced", "fixed_interval"]>;
cron: NullOr<
Struct<{
expression: String;
timeZone: String;
}>
>;
state: Literals<
readonly ["active", "paused", "finished", "failed", "cancelled"]
>;
commandId: String;
reason: NullOr<String>;
nextDueAt: NullOr<Int>;
lastError: NullOr<String>;
consecutiveFailures: Int;
}>;

One Session’s loop as every client sees it.


LoopCommandInputconstant

Section titled “LoopCommandInput”
Signature
const LoopCommandInput: Union<
readonly [
Struct<{
action: Literal<"start">;
text: String;
requestId: String;
}>,
Struct<{
action: Literals<
readonly ["status", "pause", "resume", "stop", "stop-ask", "new"]
>;
confirmed: optional<Boolean>;
}>,
Struct<{}>,
]
>;

Arguments of the human /loop command. start carries the typed text: <prompt> paces itself, <N>m <prompt> or <N>h <prompt> runs on an interval. A bare call opens the controls.


LoopProjectionconstant

Section titled “LoopProjection”
Signature
const LoopProjection: Struct<{
loop: Struct<{
loopId: String;
origin: Literals<readonly ["human", "model"]>;
expiresAt: NullOr<Int>;
prompt: String;
mode: Literals<readonly ["self_paced", "fixed_interval"]>;
cron: NullOr<
Struct<{
expression: String;
timeZone: String;
}>
>;
state: Literals<
readonly ["active", "paused", "finished", "failed", "cancelled"]
>;
commandId: String;
reason: NullOr<String>;
nextDueAt: NullOr<Int>;
lastError: NullOr<String>;
consecutiveFailures: Int;
}>;
}>;

Loop’s contract: Session-scope controls and one projection slot.


loopContractconstant

Section titled “loopContract”
Signature
const loopContract: object;

Session-owned loop controls and their visible state.

Name Type Default value Description
id string & Brand<"ExtensionId"> - Stable extension identity.
commands object - Loop operations admitted by the Session owner.
commands.loop object - Open or answer the human loop controls.
commands.loop.scope "session" "session" The Session owns this loop.
commands.loop.input Union<readonly [Struct<{ action: Literal<"start">; text: String; requestId: String; }>, Struct<{ action: Literals<readonly ["status", "pause", "resume", "stop", "stop-ask", "new"]>; confirmed: optional<Boolean>; }>, Struct<{ }>]> LoopCommandInput Decode the selected human action.
commands.loop.output declare<WhistleCatalogStepV1, WhistleCatalogStepV1> CatalogStep Return the server-owned conversation step.
commands.startSelfPaced object - Start a loop whose next occurrence is chosen by the model.
commands.startSelfPaced.scope "session" "session" The Session owns this loop.
commands.startSelfPaced.input Struct<{ prompt: String; requestId: String; }> - Decode the repeated prompt and command identity.
commands.startSelfPaced.output Struct<{ loop: Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }>; accepted: Struct<{ status: Literal<"accepted">; commandId: String; }>; }> StartResult Return the loop and admission receipt.
commands.startFixedInterval object - Start a loop with a fixed cron cadence.
commands.startFixedInterval.scope "session" "session" The Session owns this loop.
commands.startFixedInterval.input Struct<{ expression: String; timeZone: String; prompt: String; requestId: String; }> - Decode the prompt, cadence and command identity.
commands.startFixedInterval.output Struct<{ loop: Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }>; accepted: Struct<{ status: Literal<"accepted">; commandId: String; }>; }> StartResult Return the loop and admission receipt.
commands.pause object - Suspend the current loop.
commands.pause.scope "session" "session" The Session owns this loop.
commands.pause.input Struct<{ }> - No additional arguments are required.
commands.pause.output Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }> Loop Return the paused loop.
commands.resume object - Resume the current paused loop.
commands.resume.scope "session" "session" The Session owns this loop.
commands.resume.input Struct<{ }> - No additional arguments are required.
commands.resume.output Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }> Loop Return the resumed loop.
commands.stop object - Stop future occurrences of the current loop.
commands.stop.scope "session" "session" The Session owns this loop.
commands.stop.input Struct<{ }> - No additional arguments are required.
commands.stop.output Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }> Loop Return the stopped loop.
projection object - Current loop visible to Session clients.
projection.schema Struct<{ loop: Struct<{ loopId: String; origin: Literals<readonly ["human", "model"]>; expiresAt: NullOr<Int>; prompt: String; mode: Literals<readonly ["self_paced", "fixed_interval"]>; cron: NullOr<Struct<{ expression: String; timeZone: String; }>>; state: Literals<readonly ["active", "paused", "finished", "failed", "cancelled"]>; commandId: String; reason: NullOr<String>; nextDueAt: NullOr<Int>; lastError: NullOr<String>; consecutiveFailures: Int; }>; }> LoopProjection Decoder for projected loop state.