Skip to content
API reference

question/contract

Import
import * as api from "@fungi.computer/shiitake-extensions/question";
Kind Export Description
type alias Question One decoded decision question.
type alias OpenAsk One live or parked ask visible to Session clients.
type alias Answers Decoded answers indexed by question identity.
type alias AnswerInput Decoded human answer submission.
type alias DeclineInput Decoded human decline submission.
type alias HumanResult Decoded outcome of a human answer or decline.
type alias AgentAnswerResult Decoded result of an authenticated Agent answer.
type alias EscalateResult Decoded result of passing an Ask on.
constant Question A decision question: first option is recommended, free text belongs to the host.
constant Questions Bounded question set with distinct question identities.
constant OpenAsk The complete question data shared by ordinary Session clients.
constant AskProjection Bounded set of open asks projected into the Session.
constant RequestId Stable identity for a human command and its retry.
constant Answers Answers keyed by question id, with selected choices and optional free text.
constant AnswerInput Idempotent human submission of a complete answer set.
constant DeclineInput Idempotent human refusal to answer an ask.
constant ClosedStatus Terminal question outcomes, shared by human replies and model withdrawal.
constant HumanResult Admission, already-closed state, or absence returned to a human reply.
constant SenderRefusal Only the Agent an Ask waits on may answer or escalate it.
constant AgentAnswerResult Outcome of the Agent an Ask waits on answering it.
constant AnsweredBy The Agent that answered, as the host authenticated it.
constant EscalateResult Outcome of the Agent an Ask waits on passing it on.
constant EscalateInput The Agent’s request to pass an Ask on; the caller is host context.
constant AnswerFlowInput The answer conversation carries its draft between decision steps.
constant questionContract Human reads and the ordinary projection slot; model operations belong to the host.
Signature
type Question = Schema.Schema.Type<typeof Question>;

One decoded decision question.


Signature
type OpenAsk = Schema.Schema.Type<typeof OpenAsk>;

One live or parked ask visible to Session clients.


Signature
type Answers = Schema.Schema.Type<typeof Answers>;

Decoded answers indexed by question identity.


AnswerInputtype alias

Section titled “AnswerInput”
Signature
type AnswerInput = Schema.Schema.Type<typeof AnswerInput>;

Decoded human answer submission.


DeclineInputtype alias

Section titled “DeclineInput”
Signature
type DeclineInput = Schema.Schema.Type<typeof DeclineInput>;

Decoded human decline submission.


HumanResulttype alias

Section titled “HumanResult”
Signature
type HumanResult = Schema.Schema.Type<typeof HumanResult>;

Decoded outcome of a human answer or decline.


AgentAnswerResulttype alias

Section titled “AgentAnswerResult”
Signature
type AgentAnswerResult = Schema.Schema.Type<typeof AgentAnswerResult>;

Decoded result of an authenticated Agent answer.


EscalateResulttype alias

Section titled “EscalateResult”
Signature
type EscalateResult = Schema.Schema.Type<typeof EscalateResult>;

Decoded result of passing an Ask on.

Questionconstant

Section titled “Question”
Signature
const Question: Struct<{
id: String;
header: String;
question: String;
options: $Array<
Struct<{
label: String;
description: String;
}>
>;
multiple: optionalKey<Boolean>;
}>;

A decision question: first option is recommended, free text belongs to the host.


Questionsconstant

Section titled “Questions”
Signature
const Questions: $Array<
Struct<{
id: String;
header: String;
question: String;
options: $Array<
Struct<{
label: String;
description: String;
}>
>;
multiple: optionalKey<Boolean>;
}>
>;

Bounded question set with distinct question identities.


OpenAskconstant

Section titled “OpenAsk”
Signature
const OpenAsk: Struct<{
askId: String;
waitingOn: optionalKey<
Struct<{
agentId: NonEmptyString;
sessionId: NonEmptyString;
name: NonEmptyString;
}>
>;
questions: $Array<
Struct<{
id: String;
header: String;
question: String;
options: $Array<
Struct<{
label: String;
description: String;
}>
>;
multiple: optionalKey<Boolean>;
}>
>;
status: Literals<readonly ["live", "parked"]>;
createdAt: Number;
expiresAt: NullOr<Number>;
}>;

The complete question data shared by ordinary Session clients.


AskProjectionconstant

Section titled “AskProjection”
Signature
const AskProjection: Struct<{
asks: $Array<Struct<{
askId: String;
waitingOn: optionalKey<Struct<{
agentId: NonEmptyString;
sessionId: NonEmptyString;
name: NonEmptyString;
}>>;
questions: $Array<Struct<{
id: String;
header: String;
question: String;
options: $Array<Struct<{
label: ...;
description: ...;
}>>;
multiple: optionalKey<Boolean>;
}>>;
status: Literals<readonly ["live", "parked"]>;
createdAt: Number;
expiresAt: NullOr<Number>;
}>>;
}>;

Bounded set of open asks projected into the Session.


RequestIdconstant

Section titled “RequestId”
Signature
const RequestId: String;

Stable identity for a human command and its retry.


Answersconstant

Section titled “Answers”
Signature
const Answers: $Record<
String,
Struct<{
selected: $Array<String>;
text: optionalKey<String>;
}>
>;

Answers keyed by question id, with selected choices and optional free text.


AnswerInputconstant

Section titled “AnswerInput”
Signature
const AnswerInput: Struct<{
askId: String;
requestId: String;
answers: $Record<
String,
Struct<{
selected: $Array<String>;
text: optionalKey<String>;
}>
>;
}>;

Idempotent human submission of a complete answer set.


DeclineInputconstant

Section titled “DeclineInput”
Signature
const DeclineInput: Struct<{
askId: String;
requestId: String;
note: optionalKey<String>;
}>;

Idempotent human refusal to answer an ask.


ClosedStatusconstant

Section titled “ClosedStatus”
Signature
const ClosedStatus: Literals<
readonly [
"answered",
"declined",
"withdrawn",
"expired",
"cancelled",
"undeliverable",
]
>;

Terminal question outcomes, shared by human replies and model withdrawal.


HumanResultconstant

Section titled “HumanResult”
Signature
const HumanResult: Union<
readonly [
Struct<{
result: Literal<"accepted">;
via: Literals<readonly ["in_turn", "follow_up"]>;
commandId: optionalKey<String>;
}>,
Struct<{
result: Literal<"closed">;
status: Literals<
readonly [
"answered",
"declined",
"withdrawn",
"expired",
"cancelled",
"undeliverable",
]
>;
}>,
Struct<{
result: Literal<"not_found">;
}>,
]
>;

Admission, already-closed state, or absence returned to a human reply.


SenderRefusalconstant

Section titled “SenderRefusal”
Signature
const SenderRefusal: Struct<{
result: Literal<"refused">;
reason: Literal<"not_sender">;
}>;

Only the Agent an Ask waits on may answer or escalate it.


AgentAnswerResultconstant

Section titled “AgentAnswerResult”
Signature
const AgentAnswerResult: Union<
readonly [
Union<
readonly [
Struct<{
result: Literal<"accepted">;
via: Literals<readonly ["in_turn", "follow_up"]>;
commandId: optionalKey<String>;
}>,
Struct<{
result: Literal<"closed">;
status: Literals<
readonly [
"answered",
"declined",
"withdrawn",
"expired",
"cancelled",
"undeliverable",
]
>;
}>,
Struct<{
result: Literal<"not_found">;
}>,
]
>,
Struct<{
result: Literal<"refused">;
reason: Literal<"not_sender">;
}>,
]
>;

Outcome of the Agent an Ask waits on answering it.


AnsweredByconstant

Section titled “AnsweredBy”
Signature
const AnsweredBy: Struct<{
kind: Literal<"agent">;
agentId: String;
}>;

The Agent that answered, as the host authenticated it.


EscalateResultconstant

Section titled “EscalateResult”
Signature
const EscalateResult: Union<
readonly [
Struct<{
result: Literal<"escalated">;
to: Literal<"person">;
}>,
Struct<{
result: Literal<"closed">;
status: Literals<
readonly [
"answered",
"declined",
"withdrawn",
"expired",
"cancelled",
"undeliverable",
]
>;
}>,
Struct<{
result: Literal<"not_found">;
}>,
Struct<{
result: Literal<"refused">;
reason: Literal<"not_sender">;
}>,
]
>;

Outcome of the Agent an Ask waits on passing it on.


EscalateInputconstant

Section titled “EscalateInput”
Signature
const EscalateInput: Struct<{
askId: String;
}>;

The Agent’s request to pass an Ask on; the caller is host context.


AnswerFlowInputconstant

Section titled “AnswerFlowInput”
Signature
const AnswerFlowInput: Union<
readonly [
Struct<{
askId: String;
requestId: String;
index: Number;
answers: $Record<
String,
Struct<{
selected: $Array<String>;
text: optionalKey<String>;
}>
>;
stage: Literal<"decision">;
answer: Struct<{
selected: $Array<String>;
text: optionalKey<String>;
}>;
}>,
Struct<{
askId: String;
}>,
Struct<{}>,
]
>;

The answer conversation carries its draft between decision steps.


questionContractconstant

Section titled “questionContract”
Signature
const questionContract: object;

Human reads and the ordinary projection slot; model operations belong to the host.

Name Type Default value Description
id string & Brand<"ExtensionId"> - Stable extension identity.
commands object - Human question controls admitted by the Session owner.
commands.answerFlow object - Advance the server-owned answer conversation.
commands.answerFlow.scope "session" "session" The Session owns its asks and replies.
commands.answerFlow.input Union<readonly [Struct<{ askId: String; requestId: String; index: Number; answers: $Record<String, Struct<{ selected: $Array<…>; text: optionalKey<…>; }>>; stage: Literal<"decision">; answer: Struct<{ selected: $Array<String>; text: optionalKey<String>; }>; }>, Struct<{ askId: String; }>, Struct<{ }>]> AnswerFlowInput Decode the current answer-draft step.
commands.answerFlow.output declare<WhistleCatalogStepV1, WhistleCatalogStepV1> CatalogStep Return the next human conversation step.
commands.answer object - Submit a person’s completed answers.
commands.answer.scope "session" "session" The Session owns this ask.
commands.answer.input Struct<{ askId: String; requestId: String; answers: $Record<String, Struct<{ selected: $Array<String>; text: optionalKey<String>; }>>; }> AnswerInput Decode the answer submission.
commands.answer.output Union<readonly [Struct<{ result: Literal<"accepted">; via: Literals<readonly ["in_turn", "follow_up"]>; commandId: optionalKey<String>; }>, Struct<{ result: Literal<"closed">; status: Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>; }>, Struct<{ result: Literal<"not_found">; }>]> HumanResult Return admission or the ask’s terminal state.
commands.answerAgent object - Submit the answer of the Agent this Ask waits on; never a human answer.
commands.answerAgent.scope "session" "session" The child Session owns the Ask; caller authority is host context.
commands.answerAgent.input Struct<{ askId: String; requestId: String; answers: $Record<String, Struct<{ selected: $Array<String>; text: optionalKey<String>; }>>; }> AnswerInput Decode the answer submission without any caller-supplied actor.
commands.answerAgent.output Struct<{ result: Union<readonly [Union<readonly [Struct<{ result: …; via: …; commandId: …; }>, Struct<{ result: …; status: …; }>, Struct<{ result: …; }>]>, Struct<{ result: Literal<"refused">; reason: Literal<"not_sender">; }>]>; answeredBy: Struct<{ kind: Literal<"agent">; agentId: String; }>; }> - Attribute the accepted answer to its authenticated Agent.
commands.escalateAgent object - Pass the Ask on from the Agent it waits on; never a human action.
commands.escalateAgent.scope "session" "session" The child Session owns the Ask; caller authority is host context.
commands.escalateAgent.input Struct<{ askId: String; }> EscalateInput Decode the escalation without any caller-supplied recipient.
commands.escalateAgent.output Union<readonly [Struct<{ result: Literal<"escalated">; to: Literal<"person">; }>, Struct<{ result: Literal<"closed">; status: Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>; }>, Struct<{ result: Literal<"not_found">; }>, Struct<{ result: Literal<"refused">; reason: Literal<"not_sender">; }>]> EscalateResult Where the Ask waits now, or why it did not move.
commands.decline object - Decline an ask with an optional note.
commands.decline.scope "session" "session" The Session owns this ask.
commands.decline.input Struct<{ askId: String; requestId: String; note: optionalKey<String>; }> DeclineInput Decode the decline submission.
commands.decline.output Union<readonly [Struct<{ result: Literal<"accepted">; via: Literals<readonly ["in_turn", "follow_up"]>; commandId: optionalKey<String>; }>, Struct<{ result: Literal<"closed">; status: Literals<readonly ["answered", "declined", "withdrawn", "expired", "cancelled", "undeliverable"]>; }>, Struct<{ result: Literal<"not_found">; }>]> HumanResult Return admission or the ask’s terminal state.
commands.list object - Read the Session’s open asks.
commands.list.scope "session" "session" The Session owns the ask collection.
commands.list.input Struct<{ }> - No additional arguments are required.
commands.list.output Struct<{ asks: $Array<Struct<{ askId: String; waitingOn: optionalKey<Struct<{ agentId: …; sessionId: …; name: …; }>>; questions: $Array<Struct<{ id: …; header: …; question: …; options: …; multiple: …; }>>; status: Literals<readonly ["live", "parked"]>; createdAt: Number; expiresAt: NullOr<Number>; }>>; }> AskProjection Decode the currently visible asks.
projection object - Open asks visible to Session clients.
projection.schema Struct<{ asks: $Array<Struct<{ askId: String; waitingOn: optionalKey<Struct<{ agentId: NonEmptyString; sessionId: NonEmptyString; name: NonEmptyString; }>>; questions: $Array<Struct<{ id: String; header: String; question: String; options: $Array<…>; multiple: optionalKey<…>; }>>; status: Literals<readonly ["live", "parked"]>; createdAt: Number; expiresAt: NullOr<Number>; }>>; }> AskProjection Decoder for projected asks.