@flow-state-dev/orchestration
Interfaces
AssigneeRoster
The declared participants a board can be assigned to, plus a human-readable rendering for error messages. Supplied by the caller so assignment is checked against the board's real participant registry — the same list the model is told about, so context and validation cannot disagree.
Properties
claimsUnassigned?
readonly claimsUnassigned?: boolean;
True when the board's default worker claims a task with no assignee, so
createTask may file one unassigned. Absent or false: nothing on the
board takes a task naming nobody, so createTask gives it to
soleAssignee, or refuses it (ownerForUnassigned).
Methods
describe()
describe(): string;
Roster rendered for an error message, e.g. researcher (…), fetch (tool).
Returns
string
has()
has(assignee): boolean;
True when assignee names a participant on this board.
Parameters
assignee
string
Returns
boolean
soleAssignee()?
soleAssignee?(): string | undefined;
The one participant a task with no assignee goes to, when there is
exactly one; undefined otherwise. Optional: a roster without it names
no default.
Returns
string | undefined
DefineSkillsCollectionOptions
Public options for the helper.
Properties
flowIsolation?
flowIsolation?: boolean;
Give every registered copy of the declaring flow its OWN catalog. Default
false — one bucket shared by every copy, which is what a single-instance
app wants.
Set true where the copies are separate parties rather than replicas: the
storage layer keys an isolated resource on the flow instance id, so two
copies read and write two different sets of skills without a second
collection key, prefix or scope. Forwarded verbatim to
defineResourceCollection, which rejects it at scope: "session" —
sessions are already flow-bound.
Isolation moves the read to a new key, so a collection seeded before this was switched on re-seeds from the new bucket and the old rows are orphaned, not lost.
maxInstances?
maxInstances?: number;
Maximum number of resources (SKILL.md + supporting files combined).
partitionBy?
partitionBy?: SkillsPartitionFn;
Keep one catalog per partition, named per run by a function of the running
context: one per party that runs through one registered copy of the
declaring flow. See partition.ts for the key layout. The value must come
from data only the server writes; undefined reads no partition's skills
and writes none.
prefix?
prefix?: string;
Pattern prefix. Default "skills". The collection pattern is ${prefix}/**.
scope?
scope?: ResourceScope;
Intrinsic scope the collection lives in. Default "org" — seeded skills
are shared across users. Use "user" for personal libraries; "session"
is mainly for tests.
ImportSkillsDirectoryOptions
Properties
overwrite?
overwrite?: boolean;
Overwrite existing entries. Default false (skip name collisions).
Overwriting is not refreshing, and the difference is what gets left
behind. This writes the source's files over whatever is there and
enumerates nothing, so a supporting file the source has since DROPPED
survives and stays reachable by its path. To pull a source edit
through cleanly — withdrawn files included — use refreshSeededSkills,
which replaces a skill's folder whole. Reach for overwrite when you mean
"write these on top", not "make this match the source".
ImportSkillsDirectoryResult
Properties
errors
errors: object[];
error
error: Error;
name
name: string;
imported
imported: string[];
skipped
skipped: object[];
name
name: string;
reason
reason: string;
InitialSkill
A code-authored skill, seeded into the org-scoped collection on startup.
Properties
files?
files?: SkillFile[];
Optional supporting files written alongside SKILL.md.
name
name: string;
Skill name — the folder name. Same rules as Skill.name.
skillMd
skillMd: string;
Full SKILL.md text including YAML frontmatter.
MatchedSkill
One skill matched by a skill-activation pass. Multiple may be active per turn — the up-front skill activator activates all of them in inline mode by default.
Properties
confidence?
confidence?: number;
Classifier confidence (0..1). Only present when source === "classifier".
input
input: string;
Argument substituted for $ARGUMENTS in the skill body. Empty if none.
name
name: string;
Skill name. Must exist in the skills collection at activation time.
source
source: SkillActivationSource;
Which tier of skillActivator produced this match.
ParsedSkillMd
Result of parsing a SKILL.md text.
Properties
body
body: string;
Raw Markdown body (no frontmatter).
state
state: SkillState;
Parsed state — the camelCase frontmatter representation.
warnings
warnings: string[];
Warnings the parser surfaced (ignored fields, soft validations).
ParseSkillMdOptions
Options for parseSkillMd.
Properties
expectedName?
expectedName?: string;
The folder the manifest lives in. When set and the frontmatter declares
name, the two must match (Agent Skills spec) — a mismatch throws.
ReadSkillsDirectoryOptions
Properties
exclude?
exclude?: string[];
Optional filter: exclude these skill names.
ignore?
ignore?: string[];
Skip files matching these globs (e.g. ["*.swp", ".DS_Store"]).
include?
include?: string[];
Optional filter: include only these skill names.
RefreshSeededSkillsResult
What refreshSeededSkills did, per source skill.
Properties
failed
failed: object[];
Skills whose refresh threw, with the error.
A refresh that touched storage must never report as a refresh that did
nothing. One bad folder does not cost the rest of the run — the loop
continues, as seeding's does — but a caller reading refreshed: [] and an
empty removed would otherwise conclude the catalog is untouched when it
may not be. A non-empty failed is the signal to look. Keys removed before
a failure are still in removed, so what did happen is nameable.
error
error: Error;
name
name: string;
refreshed
refreshed: string[];
Names whose folder was replaced from the source.
removed
removed: string[];
Keys deleted because the new source no longer carries them, as bare
collection keys ("<name>/reference/old.md"). Empty on a refresh that only
updated bodies.
skipped
skipped: string[];
Names the collection does not hold — deleted deliberately, or never seeded. Left alone either way.
RunSkillToolOptions
Properties
collectionKey
collectionKey: string;
Resource registry key for the skills collection.
initialSkills?
initialSkills?: InitialSkill[];
Default-on initial skills, lazily seeded on first invocation.
SkillActivatorOptions
Properties
activeState?
activeState?: object;
Where the matcher writes its resolved activations. Default
{ scope: "session", field: "activeSkills" }. To feed a Skills v2
per-generator binding, point this at that binding's explicit
activeState field (a matcher runs before the generator, so it cannot
reach a downstream generator's block-state default — it needs an explicit
shared field).
field
field: string;
scope
scope: "session" | "user" | "org" | "request";
allowed?
allowed?: readonly string[];
Restrict matches to the target binding's allowed set. Without it, a
/skill or keyword hit for any skill in the collection would land in the
shared field and render on a generator that was never given that skill.
classifierModel?
classifierModel?: string;
Model the tier-3 classifier uses. Default "intent/utility".
collectionKey?
collectionKey?: string;
Resource registry key for the skills collection. Default "skills".
confidenceThreshold?
confidenceThreshold?: number;
Confidence threshold for accepting a classifier match. Default 0.65.
enableKeywordMatch?
enableKeywordMatch?: boolean;
When false, skillActivator skips tier 2 (keyword scan) entirely. The
apply handler runs against whatever the slash tier — and, if enabled,
the classifier — produced. Default true, preserving today's pipeline
for orchestration's own callers. The built-in agent kind
(@flow-state-dev/workforce) is the one caller that sets this false:
keyword matching is not part of that kind's contract.
enableLlmClassifier?
enableLlmClassifier?: boolean;
When false, skillActivator skips tier 3 entirely (no LLM call). The
apply handler runs against whatever tiers 1–2 produced. Default true.
Set false in tests that should not rely on a mocked classifier and in
deployments that want only deterministic tiers.
evaluator?
evaluator?: AnyEvaluatorBlock;
Run tier 3 on this evaluator block instead of the generator classifier.
Usually skillEvaluator(model); a hand-built evaluator must ask
skillQuestions. The activator hands it { message, skills } (the same
allowed, model-invocable, capped catalog the classifier would describe)
and activates its pick: one skill, or none. The pick is final: no
confidence threshold applies, and an evaluator error fails the activator
rather than falling back to the classifier.
Refused alongside classifierModel, confidenceThreshold or
enableLlmClassifier: false, which configure the classifier this
replaces.
initialSkills?
initialSkills?: InitialSkillsSource;
Bundled defaults to seed before the matcher tiers scan the collection.
The matcher runs upstream of the generator, so it can't rely on the binding
reader's lazy seeding — on a fresh collection the slash/keyword/classifier
tiers would otherwise see an empty catalog on turn 1 and match nothing.
Pass the same initialSkills given to createSkillsLibrary — including a
per-execution resolver, which is resolved at the seed step against that
turn's own context.
maxSkillsInClassifier?
maxSkillsInClassifier?: number;
Cap on skills described in the classifier prompt. Default 20.
name?
name?: string;
Block name. Default "skill-activator".
SkillEvaluatorInput
What the activator hands its evaluator: the user's message and the skills this binding may activate (allowed, model-invocable, capped).
recentMessages is filled only for a block built by
skillEvaluator(model, { recentMessages }) with a count above 0: the
messages of the earlier turns it asked for, oldest first, read from the
session. Any other block is handed { message, skills }.
Properties
message
message: string;
recentMessages?
recentMessages?: RecentMessage[];
skills
skills: OfferedSkill[];
SkillEvaluatorOptions
Options for skillEvaluator.
Properties
recentMessages?
recentMessages?: number;
How many earlier turns the model sees before the message. A turn is one
earlier request: what the user said and every message the assistant said
back. Only user and assistant text is read. Omit it or pass 0 to
evaluate the message alone.
SkillFile
A single supporting file within a skill folder.
Properties
content
content: string;
File contents.
path
path: string;
Path relative to the skill folder root (e.g. "reference/foo.md").
SkillsBindingConfig
The per-generator binding configuration (skills.with({ ... })).
Properties
active?
active?: string[];
Statically-preloaded skill names. Their bodies + declared allowed-tools
are injected from the start. Inline-mode only; unknown names fail loud.
activeState?
activeState?: object;
Where dynamic activations live. Omit to use the generator's own block
state (request-scoped, private, non-persistent). Set an explicit
{ scope, field } to share across generators or persist across turns, and
whenever an upstream matcher (which runs before the generator) writes it.
field
field: string;
scope
scope: "session" | "user" | "org" | "request";
allowed?
allowed?: string[];
Skill names the load tool (dynamicActivation) may pull from. Omit for the
whole catalog.
It does NOT contribute these skills' declared allowed-tools — nothing
does; allowed-tools renders as an intent note and grants nothing. What it
does contribute is the catalog registration on the activeState path:
activeState + allowed sets contributesRuntimeTools below, and an
activeState binding with neither allowed nor dynamicActivation
registers no catalog tools at all.
SkillsCapabilityOptions
@flow-state-dev/skills — runtime implementation of the Skills
System. Skills are user-modifiable folders (SKILL.md + supporting files)
stored as resources, invoked by the agent through a runSkill tool.
The package is structured so each layer is independently usable:
defineSkillsCollection,parseSkillMd,serializeSkillMd— primitives for working with the on-disk format.createRunSkillTool— the router tool, exported for embedding in custom generator configurations that don't go through the capability.inlineActivate— the inline activation branch, exported so custom tool wiring can reuse it.createSkillsCapability— the recommended path: bundles all of the above into oneuses: [skillsCap]slot.readSkillsDirectory,importSkillsDirectory— Node-only directory walkers for build-time and runtime ingestion.
Type contracts live in @flow-state-dev/core (re-exported here for
convenience) so other packages can refer to them without depending on
the runtime.
Properties
catalog?
catalog?: ToolCatalog;
Tool catalog. Skills reference these by string key via allowed-tools.
collection?
collection?: string;
Resource registry key for the skills collection. Default "skills".
collectionConfig?
collectionConfig?: Pick<DefineSkillsCollectionOptions, "maxInstances" | "prefix">;
Optional collection sizing overrides. The prefix here doubles as the
skills workspace mount path: ${SKILL_DIR} resolves to
/workspace/<prefix>/<skill-name>/ when the skills collection is
mounted via the bash capability (the default mount setup).
initialSkills?
initialSkills?: InitialSkill[];
Bundled defaults — seeded into the collection on first runSkill call.
itemVisibility?
itemVisibility?: ItemVisibility | readonly ItemVisibility[];
Restrict this capability to blocks with a matching itemVisibility.
Omitted (default): every generator that declares skills via uses:
gets the full body + runSkill tool.
Set to { client: true, history: true } in multi-agent patterns so
only the main agent (planner, supervisor, blackboard synthesizer)
coordinates with skills; workers
(itemVisibility: { client: true, history: false }) don't duplicate
the skill body into their context on every step.
See CapabilityConfig.itemVisibility.
scope?
scope?: ResourceScope;
Scope to register the skills collection at. Default "org" so
seeded skills are shared across users. Use "user" for personal
skill libraries; "session" is mainly for tests.
SkillsLibraryOptions
Properties
catalog?
catalog?: ToolCatalog;
Tool catalog. Skills reference these by string key via allowed-tools.
collection?
collection?: string;
Resource registry key for the skills collection. Default "skills".
collectionConfig?
collectionConfig?: Pick<DefineSkillsCollectionOptions, "maxInstances" | "prefix" | "flowIsolation">;
Optional collection sizing / mount-prefix overrides, plus flowIsolation
— set it when every registered copy of the declaring flow should hold its
own catalog rather than share one bucket.
initialSkills?
initialSkills?: InitialSkillsSource;
Bundled defaults — seeded on a binding's first render.
A function makes the catalog per-execution instead of per-library (see
InitialSkillsSource). Everything that seeds resolves it against its
own context; what changes for the caller is that binding a skill BY NAME
(with({ active }) / with({ allowed })) then throws, because there is no
build-time catalog to validate the name against.
itemVisibility?
itemVisibility?: ItemVisibility | readonly ItemVisibility[];
Restrict this library's bindings to blocks with a matching
itemVisibility. See createSkillsCapability for the multi-agent rationale.
partitionBy?
partitionBy?: SkillsPartitionFn;
Keep one catalog per partition, named per run: a function of the running
context the composing layer supplies, returning a value derived from data
only the server writes. A run it returns undefined for reads no
partition's skills and writes none. Use it when several
parties run through one registered copy of the declaring flow and each
must hold its own catalog; flowIsolation separates copies, not parties.
registerCatalogTools?
registerCatalogTools?: boolean;
Whether a bound skill's whole catalog registers on the generator
(fullCatalog(), the safe-superset path below validateDeclaredTools).
Default true, preserving today's behaviour: a bound skill's declared
allowed-tools are still validated against catalog either way — this
only gates the second, separable job, registration. Set false when a
caller already owns tool registration through its own means (e.g. a
worker's own tools: fence) and wants catalog validated but not
granted.
scope?
scope?: ResourceScope;
Scope the skills collection lives at. Default "org" so seeded skills are
shared across users. "user" for personal libraries; "session" for tests.
SkillsManifestSourceOptions
Properties
allowed?
allowed?: readonly string[];
The names the binding's load tool will accept, when it declares a set.
Pass the SAME array the binding was given (skills.with({ allowed })).
Omitted, every enabled inline skill is listed, which is what an
allowed-less binding accepts.
collectionKey?
collectionKey?: string;
Resource registry key for the skills collection. Default "skills".
initialSkills?
initialSkills?: InitialSkillsSource;
The library's bundled defaults, so a first read seeds what a first render would.
SkillState
Parsed state for a skills/{name}/SKILL.md resource. Derived from the
file's YAML frontmatter (kebab-case) and stored on the resource as
camelCase. Unknown frontmatter keys are preserved on _preservedFields
for forward-compatibility and round-trip fidelity.
Properties
_preservedFields?
_preservedFields?: Record<string, unknown>;
Unknown kebab-case frontmatter keys preserved as camelCase for round-trip.
_seededAt?
_seededAt?: string;
ISO timestamp set by the seeder when an initialSkills entry was first written.
allowedTools?
allowedTools?: string[];
From allowed-tools. The tools the skill is written around. It never
widens access, and it decides nothing. It registers nothing:
createSkillsLibrary validates these names against the catalog and then
contributes the whole catalog, or, under registerCatalogTools: false,
contributes none of it. Either way this subset is not the unit. What the
generator may call is its own tools: when it declares one (declaring it
at all raises the fence) and otherwise whatever its capabilities
contribute.
argumentHint?
argumentHint?: string;
Optional Claude argument-hint. Surfaced in tool description; not validated at runtime.
compatibility?
compatibility?: string;
Optional spec compatibility: environment requirements, ≤500 chars.
contextMode?
contextMode?: "inline";
From context: frontmatter. Defaults to inline when omitted.
description
description: string;
Required. Used in the runSkill tool description and (truncated) in <ActiveSkills> UI.
disableModelInvocation?
disableModelInvocation?: boolean;
From disable-model-invocation. When true, skill is excluded from runSkill tool enum.
keywords?
keywords?: string[];
Optional keywords array. Lowercase tokens that the up-front
intent classifier's tier-2 keyword scan matches against the user message.
Skills without any keywords skip tier-2 and become eligible only via
tier-3 LLM classification.
license?
license?: string;
Optional spec license: a license name or the name of a bundled license file.
metadata?
metadata?: Record<string, string>;
Optional spec metadata: a string → string map for client-defined properties.
name?
name?: string;
Optional name frontmatter (required by the Agent Skills spec). The
framework derives a skill's identity from its folder; when the manifest
also declares name, it must be valid and match the folder it lives in.
whenToUse?
whenToUse?: string;
Optional Claude when_to_use. Appended to description for runSkill tool surface.
TaskSettledEntryOptions
What taskSettledEntry is built from.
Properties
block
readonly block: BlockDefinition<any, any>;
The flow's own handling of one ending, given the notice. Runs once per ending.
concurrency?
readonly concurrency?: ConcurrencyConfig;
The entry's concurrency. Default queue on the session, so two copies of
one notice run one after the other and the second finds it acknowledged.
defer?
readonly defer?: (ctx, notice) => Promise<boolean>;
Whether this notice must wait: true runs nothing and acknowledges
nothing, so the notice stays owed and the filer's pass sends it again
(with its backoff, at most every 5 minutes). For a session that is busy
with something the notice must not run beside. Being turned away is no
failed delivery: the notice's age, which ends it as undeliverable past
the host's maximum debt age, counts from the last time it was turned
away. Default: never.
Parameters
ctx
BlockContext
notice
attempt
number
boardId
string
cancelled?
string[]
ending
"completed" | "errored" | "retried" | "cancelled"
error?
string
output?
unknown
question?
string
taskId
string
waitedOn?
true
Returns
Promise<boolean>
TaskToolsOptions
How a board's task tools are offered. With resumesWaits, two lists of the
same task tools are built, one with the wait and one without; that is
deliberate, so a turn's tools are picked, never rebuilt.
Properties
dispatches?
readonly dispatches?: boolean;
The board starts a ready row at once: its ref's writes wake
whatever runs it, so a createTask starts the work now, and files each
row once per call. Default false: a board a drain runs decides for
itself when each row runs.
resumesWaits?
readonly resumesWaits?: boolean;
The board has a waker: the filing session's pass (its onTaskSettled
request, sent when a waited-on task ends) resumes a request parked on a
wait. Only then may getTask offer wait. Default false: a
board that nothing wakes would leave every wait to its deadline.
TaskTurnToolOptions
Where a task turn's own tools (holdTaskForUser, reportProgress) read the row the turn holds.
Properties
resolve
resolve: (ctx) => Promise<
| TaskCollectionRef<unknown, unknown>
| undefined>;
The ledger the running task turn's row is on, or undefined when this
flow can't reach it. Resolve from server-set state only (a task session's
birth fields, say), never from input.
Parameters
ctx
BlockContext
Returns
Promise<
| TaskCollectionRef<unknown, unknown>
| undefined>
Type Aliases
AssigneeRosterSource
type AssigneeRosterSource =
| AssigneeRoster
| ((ctx) =>
| AssigneeRoster
| Promise<AssigneeRoster>);
Where the task tools read their roster from: a fixed AssigneeRoster, or a function of the running context that returns one, read on every call that checks an assignee.
The function form is for a board whose team changes while it is in use: an assignee added between two calls is accepted on the second, and one removed is refused. It reads the running context the way a resolver reads its board, so each call is checked against the team its own session has now.
ExplicitActivationScope
type ExplicitActivationScope = z.infer<typeof explicitActivationScopeSchema>;
InitialSkillsSource
type InitialSkillsSource =
| InitialSkill[]
| ((ctx) => InitialSkill[] | undefined);
Bundled defaults, as a fixed array or as a per-execution resolver.
A resolver returning undefined (or an empty array) means "this execution
seeds nothing" — the seeding call sites return before any storage read.
RecentMessage
type RecentMessage = object;
One message of an earlier turn, as the evaluator reads it.
Properties
role
role: "user" | "assistant";
text
text: string;
ReportProgressOptions
type ReportProgressOptions = TaskTurnToolOptions;
createReportProgress's options: where it reads the row the turn holds.
SkillActivationSource
type SkillActivationSource = "slash" | "keyword" | "classifier" | "manual-override";
Origin of a skill-activation match. Carried on MatchedSkill so downstream
consumers (trace UI, telemetry) can branch on how the decision was reached.
SkillContextMode
type SkillContextMode = "inline";
Activation mode for a skill, controlled by context: frontmatter.
inline(default, and now the only value): the skill body is injected into the in-flight generator on the next tool-loop step via the existingprepareStepmachinery.
Both non-inline modes were removed: fork (an isolated subagent)
and pattern (a session-global multi-agent dispatcher). The type is kept as
a one-value union so its readers keep compiling and a future mode has a seam.
SkillEvaluatorBlock
type SkillEvaluatorBlock = EvaluatorDefinition<typeof skillEvaluatorInputSchema, SkillEvaluatorInput, SkillQuestions>;
The evaluator block skillEvaluator returns.
SkillQuestions
type SkillQuestions = object;
The question set the activator reads: one skill choice.
Properties
skill
skill: ChoiceQuestion<string>;
SkillsPartitionFn
type SkillsPartitionFn = (ctx) => string | undefined;
Names the partition a run reads and writes its skills catalog in. Returns a
non-empty string derived from data only the server writes, or undefined
for a run with no partition, which reads no partition's skills and writes
none. Synchronous: it runs on every read of the catalog.
Parameters
ctx
BlockContext
Returns
string | undefined
TaskCollectionResolver
type TaskCollectionResolver = (ctx) => Promise<TaskCollectionRef | undefined>;
Resolves the live TaskCollection a taskTools handler mutates.
Parameters
ctx
BlockContext
Returns
Promise<TaskCollectionRef | undefined>
TaskSettledInput
type TaskSettledInput = z.infer<typeof taskSettledInputSchema>;
A notice, as a flow's block takes it.
ToolCatalog
type ToolCatalog = Record<string, GeneratorTool>;
A bag of executable tools that skills may reference by string key.
Tools are executable code and cannot round-trip through a resource
collection — apps register them once and skills reference them by name
via allowed-tools in frontmatter. Unknown refs are warned and skipped.
Variables
activeSkillsArraySchema
const activeSkillsArraySchema: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
activatedAt: z.ZodNumber;
input: z.ZodOptional<z.ZodString>;
mode: z.ZodEffects<z.ZodCatch<z.ZodEnum<["inline", "fork", "pattern"]>>, "inline", unknown>;
name: z.ZodString;
source: z.ZodOptional<z.ZodEnum<["slash", "keyword", "classifier", "manual-override"]>>;
}, "strip", z.ZodTypeAny, {
activatedAt: number;
input?: string;
mode: "inline";
name: string;
source?: "classifier" | "keyword" | "manual-override" | "slash";
}, {
activatedAt: number;
input?: string;
mode?: unknown;
name: string;
source?: "classifier" | "keyword" | "manual-override" | "slash";
}>, "many">>>;
Zod schema for a single active-skill array field. Reused by the v2
per-generator binding (skills.config({ activeState }) contributes this
as the field schema at the chosen scope, and a block-state default binds it
onto the generator's own stateSchema) and by the legacy session-state
fragment below.
Parsing normalizes retired "fork" and "pattern" modes to "inline".
The raw storage reader below preserves the original modes.
inlineActivate
const inlineActivate: BlockDefinition;
matchedSkillSchema
const matchedSkillSchema: z.ZodObject<{
confidence: z.ZodOptional<z.ZodNumber>;
input: z.ZodDefault<z.ZodString>;
name: z.ZodString;
source: z.ZodEnum<["slash", "keyword", "classifier", "manual-override"]>;
}, "strip", z.ZodTypeAny, {
confidence?: number;
input: string;
name: string;
source: "classifier" | "keyword" | "manual-override" | "slash";
}, {
confidence?: number;
input?: string;
name: string;
source: "classifier" | "keyword" | "manual-override" | "slash";
}>;
Runtime shape of MatchedSkill (core type).
skillActivationSourceSchema
const skillActivationSourceSchema: z.ZodEnum<["slash", "keyword", "classifier", "manual-override"]>;
Origin of a skill-activation match — mirrors SkillActivationSource in core.
skillEvaluatorInputSchema
const skillEvaluatorInputSchema: z.ZodObject<{
message: z.ZodString;
recentMessages: z.ZodOptional<z.ZodArray<z.ZodObject<{
role: z.ZodEnum<["user", "assistant"]>;
text: z.ZodString;
}, "strip", z.ZodTypeAny, {
role: "assistant" | "user";
text: string;
}, {
role: "assistant" | "user";
text: string;
}>, "many">>;
skills: z.ZodArray<z.ZodObject<{
description: z.ZodString;
name: z.ZodString;
}, "strip", z.ZodTypeAny, {
description: string;
name: string;
}, {
description: string;
name: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
message: string;
recentMessages?: object[];
skills: object[];
}, {
message: string;
recentMessages?: object[];
skills: object[];
}>;
Runtime schema for SkillEvaluatorInput.
taskSettledInputSchema
const taskSettledInputSchema: z.ZodObject<{
attempt: z.ZodNumber;
boardId: z.ZodString;
cancelled: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
ending: z.ZodEnum<["completed", "errored", "retried", "cancelled"]>;
error: z.ZodOptional<z.ZodString>;
output: z.ZodOptional<z.ZodUnknown>;
question: z.ZodOptional<z.ZodString>;
taskId: z.ZodString;
waitedOn: z.ZodOptional<z.ZodLiteral<true>>;
}, "strict", z.ZodTypeAny, {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "cancelled" | "completed" | "errored" | "retried";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
}, {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "cancelled" | "completed" | "errored" | "retried";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
}>;
A notice, as onTaskSettled and a flow's block take it.
Functions
createHoldTaskForUser()
function createHoldTaskForUser(options): object;
The worker's question (on a task's hold): holdTaskForUser({ question }),
for a task turn, and the rule for when a turn is offered it.
- Which row. The one the turn holds (claimedRowOf), never a task id from input.
- The question. The board's one write that opens it (
askMidway): it is kept on the row as a hold, the row's lease is dropped, and the turn ends unsettled. What the turn did stands; the answer (a steer naming the question, from the Inbox, a line in the task's session, or the filer'supdateTask) owes the task one more turn on the same attempt, which starts from the brief, the last checkpoint and the answer. Its deadline is the hold's, which the host sets. - One wait per turn. A turn whose
suspendForUsertook the turn's wait on a person first is refused, naming it; and this tool, first, refuses that one. Both tools take the wait at the same point of their call, before anything they write, so a durable turn's replay decides as its first run did. - When it is offered (
offered). On a task turn holding a running row.
Parameters
options
Returns
offered
offered: (ctx) => Promise<boolean>;
Whether the running turn is offered the tool: a task turn holding a running row.
Parameters
ctx
BlockContext
Returns
Promise<boolean>
tool
tool: BlockDefinition<ZodObject<{
question: ZodString;
}, "strip", ZodTypeAny, {
question: string;
}, {
question: string;
}>, ZodUnion<[ZodObject<{
ok: ZodLiteral<true>;
questionId: ZodString;
taskId: ZodString;
}, "strip", ZodTypeAny, {
ok: true;
questionId: string;
taskId: string;
}, {
ok: true;
questionId: string;
taskId: string;
}>, ZodObject<{
error: ZodString;
ok: ZodLiteral<false>;
}, "strip", ZodTypeAny, {
error: string;
ok: false;
}, {
error: string;
ok: false;
}>]>, {
question: string;
},
| {
error: string;
ok: false;
questionId?: undefined;
taskId?: undefined;
}
| {
error?: undefined;
ok: true;
questionId: string;
taskId: string;
}>;
The tool, for a task turn's tool list.
createReportProgress()
function createReportProgress(options): object;
The worker's one task tool: reportProgress({ statusNote?, output? }), for a task turn, and the rule for when a turn is offered it.
- Which row. The one the turn holds (claimedRowOf), never an id from input, so it takes none: an inline plan step's own row, or a dispatched row, never the parent.
- What it writes.
statusNote, a one-line note for task views, andoutput, a checkpoint of the result so far. Neither changes the task's status: done still follows the worker's return, and nothing here settles the row. The latest checkpoint is the task's output; the final result becomes the output only when no checkpoint was made. - The fence. The collection's claim-fenced
reportProgress, so a finished task, a reclaimed attempt or a recreated row declines, and nothing is written. - When it is offered (
offered). On a task turn holding a running row.
Not a public action: a screen doesn't report a worker's progress.
Parameters
options
Returns
offered
offered: (ctx) => Promise<boolean>;
Whether the running turn is offered the tool: a task turn holding a running row.
Parameters
ctx
BlockContext
Returns
Promise<boolean>
tool
tool: BlockDefinition<ZodObject<{
output: ZodOptional<ZodUnknown>;
statusNote: ZodOptional<ZodString>;
}, "strip", ZodTypeAny, {
output?: unknown;
statusNote?: string;
}, {
output?: unknown;
statusNote?: string;
}>, ZodUnion<[ZodObject<{
ok: ZodLiteral<true>;
taskId: ZodString;
}, "strip", ZodTypeAny, {
ok: true;
taskId: string;
}, {
ok: true;
taskId: string;
}>, ZodObject<{
error: ZodString;
ok: ZodLiteral<false>;
}, "strip", ZodTypeAny, {
error: string;
ok: false;
}, {
error: string;
ok: false;
}>]>, {
output?: unknown;
statusNote?: string;
},
| {
error: string;
ok: false;
taskId?: undefined;
}
| {
error?: undefined;
ok: true;
taskId: string;
}>;
The tool, for a task turn's tool list.
createRunSkillTool()
function createRunSkillTool(opts): BlockDefinition<ZodObject<{
input: ZodOptional<ZodString>;
name: ZodString;
}, "strip", ZodTypeAny, {
input?: string;
name: string;
}, {
input?: string;
name: string;
}>, ZodObject<{
message: ZodOptional<ZodString>;
mode: ZodLiteral<"inline">;
skill: ZodString;
}, "strip", ZodTypeAny, {
message?: string;
mode: "inline";
skill: string;
}, {
message?: string;
mode: "inline";
skill: string;
}>, {
input?: string;
name: string;
}, {
message?: string;
mode: "inline";
skill: string;
}>;
Create the runSkill router tool configured against a specific collection
scope. Returns a BlockDefinition usable as a GeneratorTool.
Parameters
opts
Returns
BlockDefinition<ZodObject<{
input: ZodOptional<ZodString>;
name: ZodString;
}, "strip", ZodTypeAny, {
input?: string;
name: string;
}, {
input?: string;
name: string;
}>, ZodObject<{
message: ZodOptional<ZodString>;
mode: ZodLiteral<"inline">;
skill: ZodString;
}, "strip", ZodTypeAny, {
message?: string;
mode: "inline";
skill: string;
}, {
message?: string;
mode: "inline";
skill: string;
}>, {
input?: string;
name: string;
}, {
message?: string;
mode: "inline";
skill: string;
}>
createSkillActivator()
function createSkillActivator(options?): BlockDefinition<ZodObject<{
message: ZodString;
}, "passthrough", ZodTypeAny, objectOutputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">, objectInputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">>, ZodObject<{
message: ZodString;
}, "passthrough", ZodTypeAny, objectOutputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">, objectInputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">>>;
Build the up-front skill activator sequencer.
Returns a .tap-able block — it returns its input unchanged so it can
be chained ahead of downstream consumers without input-shape coupling.
Parameters
options?
Returns
BlockDefinition<ZodObject<{
message: ZodString;
}, "passthrough", ZodTypeAny, objectOutputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">, objectInputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">>, ZodObject<{
message: ZodString;
}, "passthrough", ZodTypeAny, objectOutputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">, objectInputType<{
message: ZodString;
}, ZodTypeAny, "passthrough">>>
createSkillsCapability()
function createSkillsCapability(options?): DefinedCapability;
Create a skills capability. The result plugs into any generator via
uses: [skillsCap]. Two presets are on by default:
tools—runSkillplus the full tool catalogcontext— dynamic catalog listing + active-skill bodies
Parameters
options?
Returns
DefinedCapability
createSkillsLibrary()
function createSkillsLibrary(options?): DefinedCapability;
Create a shared skills library. Install it once (uses: [skills]), then bind
per generator via skills.with({ ... }).
Parameters
options?
Returns
DefinedCapability
createSuspendForUserTool()
function createSuspendForUserTool(options): object;
The model's stop for the user (on ctx.suspendForUser):
suspendForUser({ kind, prompt }), an approval, a review or an input, and the
rule for when a turn is offered it.
- Which kinds where. On a task turn, approvals and reviews: the request
suspends, the row mirrors the stop as its suspension hold, and the Inbox
lists it. A question on a task turn holds the task instead, so
inputis refused there by name, pointing atholdTaskForUser. On a turn with no task row there is nothing to hold, so a question isinput, and its answer is the tool's result. - Its deadline is the host's setting for a person's stop, where the host
sets one, and none otherwise; the tool takes none. A model can't catch, so
at the deadline the tool returns a no-answer result (
answered: false,deadline: true), and an approval reads as a no. - One wait per turn. On a task turn, a turn that asked a question first
is refused, naming
holdTaskForUser. Read off the turn-asked fact, never off the row's open holds. - When it is offered (
offered). On any turn of a host that can stop a request for the user (durable execution,ctx.suspend).
Parameters
options
Returns
offered
offered: (ctx) => Promise<boolean>;
Whether the running turn is offered the tool: a host that can stop a request for the user.
Parameters
ctx
BlockContext
Returns
Promise<boolean>
tool
tool: BlockDefinition<ZodObject<{
kind: ZodEnum<["approval", "review", "input"]>;
prompt: ZodString;
title: ZodOptional<ZodString>;
}, "strip", ZodTypeAny, {
kind: "input" | "approval" | "review";
prompt: string;
title?: string;
}, {
kind: "input" | "approval" | "review";
prompt: string;
title?: string;
}>, ZodUnion<[ZodObject<{
answer: ZodOptional<ZodUnknown>;
approved: ZodBoolean;
deadline: ZodOptional<ZodLiteral<true>>;
kind: ZodLiteral<"approval">;
ok: ZodLiteral<true>;
}, "strip", ZodTypeAny, {
answer?: unknown;
approved: boolean;
deadline?: true;
kind: "approval";
ok: true;
}, {
answer?: unknown;
approved: boolean;
deadline?: true;
kind: "approval";
ok: true;
}>, ZodObject<{
answer: ZodUnknown;
answered: ZodLiteral<true>;
kind: ZodEnum<["review", "input"]>;
ok: ZodLiteral<true>;
}, "strip", ZodTypeAny, {
answer?: unknown;
answered: true;
kind: "input" | "review";
ok: true;
}, {
answer?: unknown;
answered: true;
kind: "input" | "review";
ok: true;
}>, ZodObject<{
answered: ZodLiteral<false>;
deadline: ZodLiteral<true>;
kind: ZodEnum<["review", "input"]>;
ok: ZodLiteral<true>;
}, "strip", ZodTypeAny, {
answered: false;
deadline: true;
kind: "input" | "review";
ok: true;
}, {
answered: false;
deadline: true;
kind: "input" | "review";
ok: true;
}>, ZodObject<{
cancelled: ZodLiteral<true>;
ok: ZodLiteral<true>;
}, "strip", ZodTypeAny, {
cancelled: true;
ok: true;
}, {
cancelled: true;
ok: true;
}>, ZodObject<{
error: ZodString;
ok: ZodLiteral<false>;
}, "strip", ZodTypeAny, {
error: string;
ok: false;
}, {
error: string;
ok: false;
}>]>, {
kind: "input" | "approval" | "review";
prompt: string;
title?: string;
},
| {
answer?: undefined;
answered?: undefined;
cancelled?: undefined;
deadline?: undefined;
error: string;
kind?: undefined;
ok: false;
}
| {
answer?: undefined;
answered?: undefined;
cancelled: true;
deadline?: undefined;
error?: undefined;
kind?: undefined;
ok: true;
}
| {
answer?: | {
}
| null;
answered?: undefined;
approved: boolean;
cancelled?: undefined;
deadline?: true;
error?: undefined;
kind: "approval";
ok: true;
}
| {
answer: unknown;
answered: true;
cancelled?: undefined;
deadline?: undefined;
error?: undefined;
kind: "input" | "review";
ok: true;
}
| {
answer?: undefined;
answered: false;
cancelled?: undefined;
deadline: true;
error?: undefined;
kind: "input" | "review";
ok: true;
}>;
The tool, for a turn's tool list.
createTaskToolsCapability()
function createTaskToolsCapability(
resolveCollection,
roster?,
options?
): DefinedCapability;
Build the taskTools capability: the task tools registered under one capability
so consumers wire it via uses: [createTaskToolsCapability(resolver)].
Parameters
resolveCollection
The board resolver: a shared board, or a drain board for a fan-out worker.
roster?
Optional roster for assignee validation, fixed or read per call from the running context (AssigneeRosterSource). Supply it so a fan-out worker enqueuing follow-up tasks mid-drain is held to the same roster the executive is.
options?
dispatches: true on a board that starts a ready row at
once, and resumesWaits: true when it has a waker, so getTask may offer
wait (TaskToolsOptions).
Returns
DefinedCapability
defineSkillsCollection()
function defineSkillsCollection(options?): object & ResourceCollectionConfig<JsonObject> & object;
Helper that returns a defineResourceCollection instance configured for
the skills layout. The returned value is a normal collection — install it
under any block's resources map; the framework routes reads/writes to
the storage layer matching its intrinsic scope.
Parameters
options?
Returns
object & ResourceCollectionConfig<JsonObject> & object
Example
resources: { skills: defineSkillsCollection({ scope: "org" }) }
importSkillsDirectory()
function importSkillsDirectory(
root,
collection,
options?
): Promise<ImportSkillsDirectoryResult>;
Read every skill from root and write it into collection. Returns
the imported names plus per-skill skip/error reasons.
Parameters
root
string
collection
ResourceCollectionRef
options?
Returns
Promise<ImportSkillsDirectoryResult>
isTaskTurn()
function isTaskTurn(ctx): boolean;
Whether the running turn is a task turn: a turn the gate serves, on the row it claimed.
Parameters
ctx
WorkerClaimReader & object
Returns
boolean
parseSkillMd()
function parseSkillMd(text, options?): ParsedSkillMd;
Parse a SKILL.md text into structured state + raw body.
Required field: description. Throws if missing or invalid. The spec's
name is optional here (the folder is the identity) but validated when
present, and checked against options.expectedName when one is given.
Unknown frontmatter keys are preserved (camelCased) under _preservedFields.
Claude-Code-only keys we don't honor at runtime produce warnings.
Parameters
text
string
options?
Returns
readSkillsDirectory()
function readSkillsDirectory(root, options?): Promise<{
errors: object[];
skills: InitialSkill[];
}>;
Read every <root>/<skill>/SKILL.md under root and return the bundled
folder representation. Throws on I/O errors at the root; per-skill errors
are collected into the returned errors field instead of throwing so a
single malformed skill doesn't poison the whole import.
Parameters
root
string
options?
Returns
Promise<{
errors: object[];
skills: InitialSkill[];
}>
refreshSeededSkills()
function refreshSeededSkills(collection, sources): Promise<RefreshSeededSkillsResult>;
Rewrite each source skill's folder in collection, for the names it already
holds.
Parameters
collection
ResourceCollectionRef
The skills collection to refresh (any scope).
sources
The current source skills. A name absent from the
collection is skipped; a name absent from sources is untouched, so a
caller can refresh one skill by passing one.
Returns
Promise<RefreshSeededSkillsResult>
Which names were refreshed, which were skipped, which keys the replacement removed, and which skills failed.
Example
// Pull the company's current copy of one skill onto a catalog holding it.
const { refreshed, failed } = await refreshSeededSkills(collection, [houseStyle]);
if (failed.length > 0) throw new Error(`refresh incomplete: ${failed[0]!.name}`);
resolveCatalogTools()
function resolveCatalogTools(
agentKey,
toolKeys,
catalog,
logPrefix
): GeneratorTool[];
Resolve toolKeys against a catalog. Unknown keys warn and drop
(additive-not-restrictive). logPrefix is the bracket tag in the
warning ([skills], [workforce]).
Parameters
agentKey
string
toolKeys
readonly string[] | undefined
catalog
Record<string, GeneratorTool>
logPrefix
string
Returns
GeneratorTool[]
serializeSkillMd()
function serializeSkillMd(state, body): string;
Serialize a parsed state + body back to SKILL.md text. Inverse of
parseSkillMd for the fields we model; preserved fields round-trip via
_preservedFields (camelCase → kebab-case).
Parameters
state
body
string
Returns
string
skillEvaluator()
function skillEvaluator(model, options?): SkillEvaluatorBlock;
Build the evaluator createSkillActivator uses for tier 3: it evaluates
the user's message against skillQuestions.
Parameters
model
string | EvaluationModel
A model string, resolved by core through the app's model
resolver when the block runs, or an evaluation model instance such as
openai.evaluationModel("gpt-6-luna"), used as given. A model that
can only generate is refused here, by core.
options?
recentMessages: how many earlier turns the model sees
before the message, so a follow-up like "yes, do that" can match the
skill an earlier offer was about. With it above 0 the evaluated state is
{ recentMessages, message }; omitted or 0, it is the message alone.
A negative, fractional or non-numeric value throws here.
Returns
Example
createSkillActivator({ initialSkills, evaluator: skillEvaluator("typesafe-ai/jev") });
createSkillActivator({
initialSkills,
evaluator: skillEvaluator("typesafe-ai/jev", { recentMessages: 3 }),
});
skillQuestions()
function skillQuestions(input): SkillQuestions;
Build the activator's question for one turn: a skill choice whose
options are the offered skills (each described by its description and
whenToUse) plus a "no skill" option, so the model never has to force a
match.
Pass it as an evaluator's questions when building the block yourself.
Parameters
input
Returns
skillsManifestSource()
function skillsManifestSource(options?): BlockManifestSource;
The skills domain, projected on demand from listEnabledSkills.
Parameters
options?
The collection key, and the binding's allowed set and
bundled defaults when it has them.
Returns
BlockManifestSource
A source the scope's manifest registry can carry.
taskSettledEntry()
function taskSettledEntry(options): object;
Build the onTaskSettled internal entry: spread it as
internal: { actions: { onTaskSettled: taskSettledEntry({ block }) } }.
Parameters
options
Returns
object
block
block: SequencerDefinition<
| {
}
| {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "completed" | "errored" | "retried" | "cancelled";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
}, {
notice?: {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "completed" | "errored" | "retried" | "cancelled";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
};
owed: boolean;
}, undefined, undefined>;
concurrency
concurrency: ConcurrencyConfig;
inputSchema
inputSchema: ZodUnion<[ZodObject<{
attempt: ZodNumber;
boardId: ZodString;
cancelled: ZodOptional<ZodArray<ZodString, "many">>;
ending: ZodEnum<["completed", "errored", "retried", "cancelled"]>;
error: ZodOptional<ZodString>;
output: ZodOptional<ZodUnknown>;
question: ZodOptional<ZodString>;
taskId: ZodString;
waitedOn: ZodOptional<ZodLiteral<true>>;
}, "strict", ZodTypeAny, {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "completed" | "errored" | "retried" | "cancelled";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
}, {
attempt: number;
boardId: string;
cancelled?: string[];
ending: "completed" | "errored" | "retried" | "cancelled";
error?: string;
output?: unknown;
question?: string;
taskId: string;
waitedOn?: true;
}>, ZodObject<{
}, "strict", ZodTypeAny, {
}, {
}>]>;