@flow-state-dev/workforce/browser
Interfaces
TaskBrief
A task's brief, as its item names it.
Properties
taskId
readonly taskId: string;
The task the brief is, by id.
WorkforceClient
A user's roster, and their sessions with each worker.
Methods
addDelegate()
addDelegate(
sessionId,
worker,
note?
): Promise<void>;
Add worker to the delegates of the user's conversation sessionId,
with an optional note on what it's good at, through the conversation's
addDelegate action. Rejects with the coordinator's reason, changing
nothing, for a worker that isn't on the roster, takes no task, or is
already there.
Parameters
sessionId
string
worker
string
note?
string
Returns
Promise<void>
edit()
edit(input): Promise<{
flow: string;
id: string;
}>;
Change one of the user's own workers, through the roster flow's edit.
The worker's next turn reads the change; a turn already running keeps
what it started with. On a standard worker, the first edit copies it to
the user's own roster under the same id, and the change lands on that
copy: its conversations, tasks and messages stay where they are. It
keeps its file's flow, since board tasks reach it there.
Parameters
input
Returns
Promise<{
flow: string;
id: string;
}>
ensureWorkerSession()
ensureWorkerSession(criteria): Promise<SessionSummary>;
What findWorkerSession returns, or a new session with the worker
when there is none, created on the worker's flow at an id derived from
the user, the organization, the flow and the criteria. Two calls at once
get the same session. With workstreamId it never creates one: a
workstream's open starts its lead's session, and until the entry names
it this throws. With taskId it never creates one either: a task's
session is opened when its conversation's board hands it over, and until
then this throws. Nor with filingSessionId: a conversation's delegate
session is opened when the conversation hands it a post or a task, and
until then this throws. Throws, too, when the worker isn't on the
user's roster.
Parameters
criteria
Returns
Promise<SessionSummary>
findWorkerSession()
findWorkerSession(criteria): Promise<SessionSummary | undefined>;
The user's session with the worker the criteria name, on the worker's
current flow, or undefined when there is none. With worker alone, or
with projectId, that is the session at the derived address
ensureWorkerSession creates, where another worker's message
lands: a session the user opened at any other id is not returned.
Otherwise the most recent match on the criteria's keys: a session that
carries a criteria key the call doesn't name is not returned. With workstreamId, the one session the user's
entry for that workstream names, or undefined while it names none.
Throws when the worker isn't on the user's roster.
Parameters
criteria
Returns
Promise<SessionSummary | undefined>
fire()
fire(id): Promise<{
id: string;
}>;
Fire one of the user's own workers, through the roster flow's fire. It
leaves the roster; its conversations stay readable, and a new turn there
is refused. Rejects for a standard worker.
Parameters
id
string
Returns
Promise<{
id: string;
}>
fork()
fork(from, id): Promise<{
flow: string;
id: string;
}>;
Copy a standard worker, or one of the user's own, to a new worker of the
user's own under id, through the roster flow's fork.
Parameters
from
string
id
string
Returns
Promise<{
flow: string;
id: string;
}>
hire()
hire(input): Promise<{
flow: string;
id: string;
}>;
Hire a worker of the user's own, through the roster flow's hire. It is
on roster at once, and its first turn runs on its row: nothing is
registered and nothing restarts. Rejects, writing nothing, for a standard
worker's id or one already on the roster, a flow that isn't a worker
flow, or settings that flow refuses.
Parameters
input
Returns
Promise<{
flow: string;
id: string;
}>
instructions()
instructions(id): Promise<WorkerInstructions>;
A worker's instructions, for a form that edits them: its core
instructions, the user's additional instructions, and whether the core
ones are a standard worker's (fixed), which an edit can't replace.
Read through the roster flow's workerInstructions view, with no
session. Rejects for a worker that isn't on the user's roster.
Parameters
id
string
Returns
Promise<WorkerInstructions>
organization()
organization(): Promise<string>;
The organization the server acts in for this user under the roster
flow's sign-in: the verified principal's, never one the caller names, and
the one a worker's conversation is derived under. Read once per client,
with no session; a failed read is not kept, so the next call asks again.
Rejects with the server's ClientHttpError: a 401 or 403 is a refusal.
Returns
Promise<string>
removeDelegate()
removeDelegate(sessionId, worker): Promise<void>;
Take worker off the conversation's delegates, through its removeDelegate action.
Parameters
sessionId
string
worker
string
Returns
Promise<void>
reset()
reset(id): Promise<{
id: string;
}>;
Delete the user's copy of a standard worker, through the roster flow's
reset, so its next turn reads the file again. Rejects for a worker that
isn't standard, or one the user hasn't edited.
Parameters
id
string
Returns
Promise<{
id: string;
}>
retryTurn()
retryTurn(sessionId, requestId): Promise<void>;
Run the turn requestId of session sessionId again, through its retry route.
Parameters
sessionId
string
requestId
string
Returns
Promise<void>
roster()
roster(): Promise<RosterEntry[]>;
The user's roster: their own workers and every standard worker, by id, each naming its flow. Read again after any turn: a turn that hires, forks or fires changes it.
Returns
Promise<RosterEntry[]>
send()
Call Signature
send(
sessionId,
message,
options?
): Promise<{
requestId: string;
}>;
Send message to the user's session sessionId through the worker
flow's door (respond), with any uploaded attachments. The client sets
the send's request id before anything is awaited, so it is known before
the server answers and stopTurns can tell a line sent after a stop
began. Resolves once the server took the send, to { requestId }: what a
screen matches the line and its turn by, or stops it by (stopRun). With
{ stream: true } it resolves to the send's streamed Response instead,
for a screen showing the answer as it is written (a session feed's
followResponse), and rejects, naming the status, when the server
refused it.
taskId: the task the line is sent from. It goes only to a door that
takes one (the worker inventory's doorTakesTask for the session's flow),
which stamps it on the line and its reply; a strict door that takes none
would refuse the key, so it is left out there, and where the inventory
can't be read.
Parameters
sessionId
string
message
string
options?
attachments?
readonly FileContent[]
taskId?
string
Returns
Promise<{
requestId: string;
}>
Call Signature
send(
sessionId,
message,
options
): Promise<Response>;
Parameters
sessionId
string
message
string
options
attachments?
readonly FileContent[]
stream
true
taskId?
string
Returns
Promise<Response>
setWorkProject()
setWorkProject(
worker,
project,
options?
): Promise<{
project: {
id: string;
visibility: "shared" | "private";
};
}>;
Set the project one of the user's own conversations with worker works
in: its runs, and the tasks it files from now on. With no sessionId,
the user's default conversation with the worker (created when there is
none); with one, that session of the user's, such as a new session just
created. A later call replaces the project; tasks already filed keep the
one they were filed in. Rejects, storing nothing, for a project the user
isn't a member of (a private one: isn't theirs), and for a session that
isn't the user's own conversation: the project coordinator's, a task's,
a delegate's or a workstream lead's, or one running another worker.
Parameters
worker
string
project
id
string
visibility
"shared" | "private"
options?
sessionId?
string
Returns
Promise<{
project: {
id: string;
visibility: "shared" | "private";
};
}>
standingRules()
standingRules(worker, input): Promise<{
line?: string;
rules: object[];
version: number;
}>;
Read or edit the user's standing rules with worker, in that user's
session with the worker. The worker's flow must declare the rules action
(its inventory row says rules: true). A refused write rejects with the
reason and stores nothing.
Parameters
worker
string
input
| {
op: "read";
}
| {
op: "add";
text: string;
version: number;
}
| {
current: string;
number: number;
op: "change";
text: string;
version: number;
}
| {
current: string;
number: number;
op: "remove";
version: number;
}
Returns
Promise<{
line?: string;
rules: object[];
version: number;
}>
startSession()
startSession(worker, options?): Promise<SessionSummary>;
Open a new session with worker on its flow, at a fresh id: another
conversation beside the user's others, where ensureWorkerSession
finds or makes the one at the derived address. With fields, the server
writes the app's session fields (the installation's sessionFields) once,
through the worker flow's setSessionFields, before this resolves; a
refused field rejects, naming it, and the session stays without it.
Throws when the worker isn't on the user's roster.
Parameters
worker
string
options?
fields?
Record<string, unknown>
Returns
Promise<SessionSummary>
stopRun()
stopRun(sessionId, requestId): Promise<void>;
Stop the one run requestId of session sessionId, through the flow the
session runs on: the abort stopTurns makes for each turn, by id.
A run that already ended is no failure. Resolves once the server took the
abort; the run's own status says when it stopped. Rejects when an answer
resumed the run before the stop reached it, so it still runs: stop it again.
Parameters
sessionId
string
requestId
string
Returns
Promise<void>
stopTurns()
stopTurns(sessionId): Promise<string[]>;
Stop every turn of session sessionId running when it reads them (its
in-progress requests of TURN_ACTIONS, oldest first), each turn this
client sent before the call among them. It leaves each turn this client
sent after the call began: a follow-up sent straight after Stop runs on.
It reads the running turns once, so another client's turn which starts
after the read may run. A turn that ended meanwhile is no failure; one
that went on past the stop (an answer resumed it first) rejects, asking
for another stop. Resolves to the ids of the turns it stopped, for a
screen that shows the stop until each has ended.
Parameters
sessionId
string
Returns
Promise<string[]>
upload()
upload(worker, request): Promise<FileContent>;
Upload one file for a line to worker, through the worker's flow, whose
sign-in a send to it runs: the reference a send's attachments take. A
first line, with no session yet, uploads this way too. Throws when the
worker isn't on the user's roster.
Parameters
worker
string
request
UploadRequest
Returns
Promise<FileContent>
watchRoster()
watchRoster(onRoster, options?): () => void;
Follow the user's roster: onRoster gets it once read, and again each
time a hire, fork, edit or fire, from any tab or any worker's turn,
changes it. Only a change is reported. It watches the roster view: each
answer names the topics its run read, and a notice on one reads again,
as do a connect, a reconnect and a resync; where push can miss a change
the client's timer reads every three seconds. Every watcher of the roster
in one client shares one read. A failed read goes to onError
and is tried again on its own (1 s, doubling to 30 s); the next read that
lands is reported even if the roster didn't change. Returns the stop
function; nothing is reported after it.
Parameters
onRoster
(entries) => void
options?
onError?
(error) => void
Returns
() => void
Type Aliases
BoardTask
type BoardTask = z.infer<typeof boardTaskSchema>;
One board task, as boardTaskOf reads it.
DelegatesView
type DelegatesView = WorkerDelegates["view"];
The delegates view, as defineWorkerDelegates builds it. Import as a type in client code.
EditWorkerInput
type EditWorkerInput = object;
A change to one of the user's own workers, as WorkforceClient.edit takes it: each field given replaces the stored one.
Properties
additionalInstructions?
additionalInstructions?: string | null;
What the user adds after the core instructions, read under their own heading; null or blank clears it.
description?
description?: string | null;
flow?
flow?: string;
id
id: string;
instructions?
instructions?: string | null;
Replaces the core instructions of one of the user's own workers. Refused on a standard worker, whose core instructions are its file's.
name?
name?: string | null;
A new display name; null clears it. The id never changes.
settings?
settings?: Record<string, unknown>;
Replaces the stored settings whole.
settingsPatch?
settingsPatch?: Record<string, unknown>;
Sets the settings it names over the stored ones and keeps the rest: what an
app that sees only its showSettings sends to change one. Not with settings.
skills?
skills?: string[];
FiledTaskValue
type FiledTaskValue = object;
A task this conversation filed (workforce:task).
Properties
assignee?
assignee?: string;
The worker it is for, when the filing named one.
taskId
taskId: string;
title
title: string;
The task's title, else its goal.
HireWorkerInput
type HireWorkerInput = object;
A new worker of the user's own, as WorkforceClient.hire takes it:
the roster flow's hire action's input.
Properties
description?
description?: string;
flow?
flow?: string;
The worker flow it runs on. Omitted, agent.
id
id: string;
The new worker's id: one path segment, not a standard worker's.
instructions?
instructions?: string;
name?
name?: string;
The name a user reads it by. Omitted, none: a view shows its id.
settings?
settings?: Record<string, unknown>;
The keys a WORKER.md frontmatter accepts other than flow and description.
skills?
skills?: string[];
Skills by name.
InboxBoardTask
type InboxBoardTask = z.infer<typeof inboxBoardTaskSchema>;
One board task of the inbox view.
InboxSuspensionDetail
type InboxSuspensionDetail = Omit<PendingUserSuspension, "sessionId"> & object;
A suspension's detail: the projection the pending-suspensions read answers, and the worker whose run it is.
Type Declaration
sessionId
readonly sessionId: string | null;
The session the suspension waits in; null for a run with no conversation.
workerId
readonly workerId: string | null;
The worker that asked, when its session names one; null otherwise, and for a run with no conversation.
InboxView
type InboxView = ViewDefinition<BlockDefinition<typeof inboxViewInputSchema, typeof inboxViewSchema>, "user">;
The inbox view, as defineInboxView builds it. Import as a type in client code.
InboxViewValue
type InboxViewValue = z.infer<typeof inboxViewSchema>;
What the inbox view answers.
ListedTurn
type ListedTurn = z.infer<typeof sessionTurnSchema>;
One entry of the session turns view.
ListedWorkerSession
type ListedWorkerSession = z.infer<typeof listedWorkerSessionSchema>;
One entry of the worker sessions view.
ProjectAddressRef
type ProjectAddressRef = object;
A project's address: where it lives, and its id.
Properties
id
id: string;
visibility
visibility: "shared" | "private";
ReceivedMessageValue
type ReceivedMessageValue = object;
A message another worker sent this one (workforce:received).
Properties
budget
budget: number;
How many more messages the exchange may send.
from
from: string;
The worker that sent it.
id
id: string;
The message's id: what an answer names as inReplyTo.
inReplyTo?
inReplyTo?: string;
The message this one answers, when it is an answer.
noAnswer?
noAnswer?: true;
The framework's "no answer": the worker asked gave none.
replyRequested?
replyRequested?: true;
The sender asked for a reply.
text
text: string;
RosterEntry
type RosterEntry = object;
One worker on a user's roster.
Properties
description
description: string | null;
What it is for, or null.
edited
edited: boolean;
A standard worker the user has edited: the row read is their own copy of
it, under its id, until WorkforceClient.reset. false otherwise.
flow
flow: string;
The flow it runs on, and the flow its sessions are created on.
forkedFrom
forkedFrom: string | null;
For one of the user's own workers forked from a standard one: that worker's id. null otherwise.
id
id: string;
The worker's id: what ensureWorkerSession({ worker }) takes.
name
name: string | null;
Its display name, or null when it has none (a view shows its id): the
user's own row's name, else a standard worker's file's name:. Display
only; the id stays its address.
settings
settings: Readonly<Record<string, unknown>>;
The settings its flow shows (showSettings where the app registers the
flow), with the worker's values: a coding worker's harness, say. Only
the keys the worker sets; {} when its flow shows none.
standard
standard: boolean;
Whether it is a standard worker (from the installation's files) rather than the user's own.
teamName
teamName: string | null;
Its team's display name, or null when the team has none or the worker has no team.
SentMessageTarget
type SentMessageTarget =
| string
| {
task: string;
}
| {
session: string;
};
Who a sent message went to: a worker's id, the session that works a task, or one of the user's conversations.
SentMessageValue
type SentMessageValue = object;
A message this worker sent (workforce:sent). One per call: a refused send is a line too, saying why.
Properties
inReplyTo?
inReplyTo?: string;
The message it answers.
messageId?
messageId?: string;
The message's id, once it was sent.
refused?
refused?: string;
Why nothing was sent: the send's own error.
replyRequested?
replyRequested?: true;
It asked for a reply, which comes later as a message.
text
text: string;
to
to: SentMessageTarget;
wait?
wait?: SentMessageWait;
It waits for the answer in this turn. The line is written again when it ends, under the same key.
SentMessageWait
type SentMessageWait = object;
How a waited send stands (wait: true): waiting until the answer or the deadline, then the call's result; error says why a failed one got no answer.
Properties
error?
error?: string;
noAnswer?
noAnswer?: true;
recipient?
recipient?: "waiting_on_person";
reply?
reply?: string;
status
status: "waiting" | "answered" | "running" | "failed";
SessionTurnsView
type SessionTurnsView = ViewDefinition<BlockDefinition<typeof sessionTurnsInputSchema, typeof sessionTurnsSchema>, "user">;
The session turns view, as defineSessionTurnsView builds it. Import as a type in client code.
TaskResultValue
type TaskResultValue = object;
A task this conversation filed ended (workforce:result), under the worker that ran it.
Properties
ending
ending: "completed" | "errored" | "cancelled";
from?
from?: string;
The worker that ran it.
taskId
taskId: string;
text
text: string;
What the board said of the ending, as its message beside this line says it.
title
title: string;
WorkerMessagesView
type WorkerMessagesView = ViewDefinition<BlockDefinition<typeof inputSchema, typeof outputSchema>, "user">;
The worker messages view, as defineWorkerMessagesView builds it. Import as a type in client code.
WorkerSessionsView
type WorkerSessionsView = ViewDefinition<BlockDefinition<typeof workerSessionsInputSchema, typeof workerSessionsSchema>, "user">;
The worker sessions view, as defineWorkerSessionsView builds it. Import as a type in client code.
WorkforceClientSource
type WorkforceClientSource = Pick<Client, "userId" | "flow" | "sessions" | "resource" | "view" | "subscribe">;
The slice of the one client a workforce client reads and writes through. Its user is the one whose roster and sessions are read: with authentication, the signed-in user.
Variables
checkRepositoryView
const checkRepositoryView: ViewRef;
The repository check, for client.view(checkRepositoryView, { repository }).
delegatesViewRef
const delegatesViewRef: (flow) => ViewRef;
The delegates of a conversation on worker flow flow, as listDelegates
answers them, kept live: useView(delegatesViewRef(flow), {}, { sessionId }).
Parameters
flow
string
Returns
ViewRef
FILED_TASK_DATA_TYPE
const FILED_TASK_DATA_TYPE: "workforce:task" = "workforce:task";
The client-only data record a task a conversation filed is drawn from. Pinned: an app's renderer is keyed by it.
historySummaryResource
const historySummaryResource: object & ResourceConfig & object;
The history summary's session resource at its default name: the definition
every historySummary(...) without a name installs, so a screen reads the
same one (useResource(historySummaryResource, { sessionId })). Its public
face is the mark (throughRequestId), whether the summary is whole
(complete) and how many folds it took; never the summary's words.
Type Declaration
client
readonly client: object;
client.expose
readonly expose: readonly ["throughRequestId", "complete", "folds"];
default
readonly default: object;
default.attempts
attempts: number;
default.complete
complete: boolean;
default.folds
folds: number;
default.gap
gap: boolean;
default.nextRequestId
nextRequestId: string | null;
default.nextSettledRequestId
nextSettledRequestId: string | null;
default.pending
pending: string[];
default.summary
summary: string | null;
default.throughRequestId
throughRequestId: string | null;
default.throughStartedAtMs
throughStartedAtMs: number | null;
ref
readonly ref: string;
scope
readonly scope: "session";
stateSchema
readonly stateSchema: z.ZodObject<{
attempts: z.ZodDefault<z.ZodNumber>;
complete: z.ZodDefault<z.ZodBoolean>;
folds: z.ZodDefault<z.ZodNumber>;
gap: z.ZodDefault<z.ZodBoolean>;
nextRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
nextSettledRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
pending: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
summary: z.ZodDefault<z.ZodNullable<z.ZodString>>;
throughRequestId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
throughStartedAtMs: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
}, "strip", z.ZodTypeAny, {
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}, {
attempts?: number;
complete?: boolean;
folds?: number;
gap?: boolean;
nextRequestId?: string | null;
nextSettledRequestId?: string | null;
pending?: string[];
summary?: string | null;
throughRequestId?: string | null;
throughStartedAtMs?: number | null;
}>;
writable
readonly writable: true;
ClientType
ClientType: Pick<{
attempts: number;
complete: boolean;
folds: number;
gap: boolean;
nextRequestId: string | null;
nextSettledRequestId: string | null;
pending: string[];
summary: string | null;
throughRequestId: string | null;
throughStartedAtMs: number | null;
}, "complete" | "folds" | "throughRequestId">;
ContextType
ContextType: ResourceContext;
StateType
StateType: object;
StateType.attempts
attempts: number;
StateType.complete
complete: boolean;
StateType.folds
folds: number;
StateType.gap
gap: boolean;
StateType.nextRequestId
nextRequestId: string | null;
StateType.nextSettledRequestId
nextSettledRequestId: string | null;
StateType.pending
pending: string[];
StateType.summary
summary: string | null;
StateType.throughRequestId
throughRequestId: string | null;
StateType.throughStartedAtMs
throughStartedAtMs: number | null;
inboxViewRef
const inboxViewRef: ViewRef;
What waits on the user across their sessions, and every board row: useView(inboxViewRef).
privateProjectsResource
const privateProjectsResource: object & ResourceCollectionConfig & object;
The private projects' definition, for a browser read of the caller's own projects/*.
Type Declaration
client
readonly client: object;
client.expose
readonly expose: readonly ["id", "title", "brief", "status", "ownerUserId", "members", "repository", "mcpServers", "checks"];
client.state
readonly state: object;
client.state.read
readonly read: true;
flowIsolation
readonly flowIsolation: false;
pattern
readonly pattern: "projects/*";
runBy
readonly runBy: object;
runBy.flow
flow: "projects";
scope
readonly scope: "user";
stateSchema
readonly stateSchema: z.ZodObject<{
brief: z.ZodDefault<z.ZodNullable<z.ZodString>>;
checks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
id: z.ZodString;
mcpServers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
ownerUserId: z.ZodString;
repository: z.ZodDefault<z.ZodNullable<z.ZodString>>;
status: z.ZodDefault<z.ZodString>;
title: z.ZodString;
}, "strip", z.ZodTypeAny, {
brief: string | null;
checks: string[];
id: string;
mcpServers: string[];
members: string[];
ownerUserId: string;
repository: string | null;
status: string;
title: string;
}, {
brief?: string | null;
checks?: string[];
id: string;
mcpServers?: string[];
members?: string[];
ownerUserId: string;
repository?: string | null;
status?: string;
title: string;
}>;
__brand
readonly __brand: "ResourceCollection";
ClientType
ClientType: Pick<{
brief: string | null;
checks: string[];
id: string;
mcpServers: string[];
members: string[];
ownerUserId: string;
repository: string | null;
status: string;
title: string;
},
| "brief"
| "checks"
| "id"
| "mcpServers"
| "members"
| "ownerUserId"
| "repository"
| "status"
| "title">;
StateType
StateType: object;
StateType.brief
brief: string | null;
StateType.checks
checks: string[];
StateType.id
id: string;
StateType.mcpServers
mcpServers: string[];
StateType.members
members: string[];
StateType.ownerUserId
ownerUserId: string;
StateType.repository
repository: string | null;
StateType.status
status: string;
StateType.title
title: string;
projectSetupView
const projectSetupView: ViewRef;
The project setup, for client.view(projectSetupView, {}) or useView(projectSetupView, {}).
projectsResource
const projectsResource: object & ResourceCollectionConfig & object;
The shared projects' definition, for a browser read of the organization's projects/*.
Type Declaration
client
readonly client: object;
client.expose
readonly expose: readonly ["id", "title", "brief", "status", "ownerUserId", "members", "repository", "mcpServers", "checks"];
client.state
readonly state: object;
client.state.read
readonly read: true;
flowIsolation
readonly flowIsolation: false;
pattern
readonly pattern: "projects/*";
runBy
readonly runBy: object;
runBy.flow
flow: "projects";
scope
readonly scope: "org";
stateSchema
readonly stateSchema: z.ZodObject<{
brief: z.ZodDefault<z.ZodNullable<z.ZodString>>;
checks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
id: z.ZodString;
mcpServers: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
members: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
ownerUserId: z.ZodString;
repository: z.ZodDefault<z.ZodNullable<z.ZodString>>;
status: z.ZodDefault<z.ZodString>;
title: z.ZodString;
}, "strip", z.ZodTypeAny, {
brief: string | null;
checks: string[];
id: string;
mcpServers: string[];
members: string[];
ownerUserId: string;
repository: string | null;
status: string;
title: string;
}, {
brief?: string | null;
checks?: string[];
id: string;
mcpServers?: string[];
members?: string[];
ownerUserId: string;
repository?: string | null;
status?: string;
title: string;
}>;
__brand
readonly __brand: "ResourceCollection";
ClientType
ClientType: Pick<{
brief: string | null;
checks: string[];
id: string;
mcpServers: string[];
members: string[];
ownerUserId: string;
repository: string | null;
status: string;
title: string;
},
| "brief"
| "checks"
| "id"
| "mcpServers"
| "members"
| "ownerUserId"
| "repository"
| "status"
| "title">;
StateType
StateType: object;
StateType.brief
brief: string | null;
StateType.checks
checks: string[];
StateType.id
id: string;
StateType.mcpServers
mcpServers: string[];
StateType.members
members: string[];
StateType.ownerUserId
ownerUserId: string;
StateType.repository
repository: string | null;
StateType.status
status: string;
StateType.title
title: string;
routinesView
const routinesView: ViewRef;
The user's routines, for client.view(routinesView, {}) or useView(routinesView). Its answer is { routines }.
SENT_MESSAGE_DATA_TYPE
const SENT_MESSAGE_DATA_TYPE: "workforce:sent" = "workforce:sent";
The client-only data record a message a worker sent (sendMessage) is drawn from, refused ones too. Pinned: an app's renderer is keyed by it.
TASK_RESULT_DATA_TYPE
const TASK_RESULT_DATA_TYPE: "workforce:result" = "workforce:result";
The client-only data record a task's ending is drawn from, under the worker that ran it. Pinned: an app's renderer is keyed by it.
workerInventoryResource
const workerInventoryResource: object & ResourceCollectionConfig & object;
The worker inventory's definition, for a browser read: useResource(workerInventoryResource, { all: true })
or client.resource(workerInventoryResource), typed by the fields the read publishes.
Type Declaration
client
readonly client: object;
client.expose
readonly expose: readonly ["id", "kind", "door", "rules", "doorTakesTask", "name", "teamName", "hired", "incarnation"];
client.state
readonly state: object;
client.state.read
readonly read: true;
flowIsolation
readonly flowIsolation: false;
pattern
readonly pattern: "inventory/workers/*";
scope
readonly scope: "org";
stateSchema
readonly stateSchema: z.ZodObject<{
door: z.ZodDefault<z.ZodNullable<z.ZodString>>;
doorTakesTask: z.ZodDefault<z.ZodBoolean>;
hired: z.ZodDefault<z.ZodNullable<z.ZodBoolean>>;
id: z.ZodString;
incarnation: z.ZodDefault<z.ZodNullable<z.ZodString>>;
kind: z.ZodString;
name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
rules: z.ZodDefault<z.ZodBoolean>;
teamName: z.ZodDefault<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
door: string | null;
doorTakesTask: boolean;
hired: boolean | null;
id: string;
incarnation: string | null;
kind: string;
name: string | null;
rules: boolean;
teamName: string | null;
}, {
door?: string | null;
doorTakesTask?: boolean;
hired?: boolean | null;
id: string;
incarnation?: string | null;
kind: string;
name?: string | null;
rules?: boolean;
teamName?: string | null;
}>;
__brand
readonly __brand: "ResourceCollection";
ClientType
ClientType: Pick<{
door: string | null;
doorTakesTask: boolean;
hired: boolean | null;
id: string;
incarnation: string | null;
kind: string;
name: string | null;
rules: boolean;
teamName: string | null;
},
| "door"
| "doorTakesTask"
| "hired"
| "id"
| "incarnation"
| "kind"
| "name"
| "rules"
| "teamName">;
StateType
StateType: object;
StateType.door
door: string | null;
StateType.doorTakesTask
doorTakesTask: boolean;
StateType.hired
hired: boolean | null;
StateType.id
id: string;
StateType.incarnation
incarnation: string | null;
StateType.kind
kind: string;
StateType.name
name: string | null;
StateType.rules
rules: boolean;
StateType.teamName
teamName: string | null;
workerMessagesResource
const workerMessagesResource: object & ResourceCollectionConfig & object;
The log's definition, for a browser read of the caller's own messages: useResource(workerMessagesResource, { all: true }).
Type Declaration
client
readonly client: object;
client.state
readonly state: object;
client.state.read
readonly read: true;
flowIsolation
readonly flowIsolation: false;
indexes
readonly indexes: object;
indexes.inReplyTo
readonly inReplyTo: (_key, message) => any;
Parameters
_key
string
message
any
Returns
any
indexes.open
readonly open: (_key, message) => any[] | null;
Parameters
_key
string
message
any
Returns
any[] | null
pattern
readonly pattern: "workforce/messages/*";
prefetchMode
readonly prefetchMode: "lazy";
scope
readonly scope: "user";
stateSchema
readonly stateSchema: z.ZodObject<{
addressedBy: z.ZodOptional<z.ZodEnum<["task", "session"]>>;
answeredBy: z.ZodOptional<z.ZodString>;
at: z.ZodNumber;
chain: z.ZodOptional<z.ZodString>;
deadlineAt: z.ZodOptional<z.ZodNumber>;
deliveredAs: z.ZodOptional<z.ZodString>;
deliveredAt: z.ZodOptional<z.ZodNumber>;
exchange: z.ZodString;
forward: z.ZodOptional<z.ZodObject<{
as: z.ZodEnum<["addressed", "inferred"]>;
url: z.ZodString;
}, "strict", z.ZodTypeAny, {
as: "addressed" | "inferred";
url: string;
}, {
as: "addressed" | "inferred";
url: string;
}>>;
from: z.ZodString;
fromFlow: z.ZodString;
fromSession: z.ZodString;
hop: z.ZodNumber;
id: z.ZodString;
inReplyTo: z.ZodOptional<z.ZodString>;
noAnswer: z.ZodOptional<z.ZodLiteral<true>>;
queuedBehind: z.ZodOptional<z.ZodLiteral<"user">>;
reason: z.ZodOptional<z.ZodString>;
replyRequested: z.ZodOptional<z.ZodLiteral<true>>;
resent: z.ZodOptional<z.ZodObject<{
at: z.ZodNumber;
n: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
at: number;
n: number;
}, {
at: number;
n: number;
}>>;
status: z.ZodEnum<["unconfirmed", "delivered", "refused", "undeliverable"]>;
takenBy: z.ZodOptional<z.ZodString>;
text: z.ZodString;
to: z.ZodString;
toFlow: z.ZodString;
toldAt: z.ZodOptional<z.ZodNumber>;
toSession: z.ZodString;
toState: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
toTask: z.ZodOptional<z.ZodString>;
waitEndedAt: z.ZodOptional<z.ZodNumber>;
waitGate: z.ZodOptional<z.ZodObject<{
gateId: z.ZodString;
requestId: z.ZodString;
}, "strip", z.ZodTypeAny, {
gateId: string;
requestId: string;
}, {
gateId: string;
requestId: string;
}>>;
}, "strip", z.ZodTypeAny, {
addressedBy?: "session" | "task";
answeredBy?: string;
at: number;
chain?: string;
deadlineAt?: number;
deliveredAs?: string;
deliveredAt?: number;
exchange: string;
forward?: {
as: "addressed" | "inferred";
url: string;
};
from: string;
fromFlow: string;
fromSession: string;
hop: number;
id: string;
inReplyTo?: string;
noAnswer?: true;
queuedBehind?: "user";
reason?: string;
replyRequested?: true;
resent?: {
at: number;
n: number;
};
status: "delivered" | "refused" | "unconfirmed" | "undeliverable";
takenBy?: string;
text: string;
to: string;
toFlow: string;
toldAt?: number;
toSession: string;
toState?: Record<string, string>;
toTask?: string;
waitEndedAt?: number;
waitGate?: {
gateId: string;
requestId: string;
};
}, {
addressedBy?: "session" | "task";
answeredBy?: string;
at: number;
chain?: string;
deadlineAt?: number;
deliveredAs?: string;
deliveredAt?: number;
exchange: string;
forward?: {
as: "addressed" | "inferred";
url: string;
};
from: string;
fromFlow: string;
fromSession: string;
hop: number;
id: string;
inReplyTo?: string;
noAnswer?: true;
queuedBehind?: "user";
reason?: string;
replyRequested?: true;
resent?: {
at: number;
n: number;
};
status: "delivered" | "refused" | "unconfirmed" | "undeliverable";
takenBy?: string;
text: string;
to: string;
toFlow: string;
toldAt?: number;
toSession: string;
toState?: Record<string, string>;
toTask?: string;
waitEndedAt?: number;
waitGate?: {
gateId: string;
requestId: string;
};
}>;
__brand
readonly __brand: "ResourceCollection";
ClientType
ClientType: object;
ClientType.addressedBy?
addressedBy?: "session" | "task";
ClientType.answeredBy?
answeredBy?: string;
ClientType.at
at: number;
ClientType.chain?
chain?: string;
ClientType.deadlineAt?
deadlineAt?: number;
ClientType.deliveredAs?
deliveredAs?: string;
ClientType.deliveredAt?
deliveredAt?: number;
ClientType.exchange
exchange: string;
ClientType.forward?
forward?: object;
ClientType.forward.as
as: "addressed" | "inferred";
ClientType.forward.url
url: string;
ClientType.from
from: string;
ClientType.fromFlow
fromFlow: string;
ClientType.fromSession
fromSession: string;
ClientType.hop
hop: number;
ClientType.id
id: string;
ClientType.inReplyTo?
inReplyTo?: string;
ClientType.noAnswer?
noAnswer?: true;
ClientType.queuedBehind?
queuedBehind?: "user";
ClientType.reason?
reason?: string;
ClientType.replyRequested?
replyRequested?: true;
ClientType.resent?
resent?: object;
ClientType.resent.at
at: number;
ClientType.resent.n
n: number;
ClientType.status
status: "delivered" | "refused" | "unconfirmed" | "undeliverable";
ClientType.takenBy?
takenBy?: string;
ClientType.text
text: string;
ClientType.to
to: string;
ClientType.toFlow
toFlow: string;
ClientType.toldAt?
toldAt?: number;
ClientType.toSession
toSession: string;
ClientType.toState?
toState?: Record<string, string>;
ClientType.toTask?
toTask?: string;
ClientType.waitEndedAt?
waitEndedAt?: number;
ClientType.waitGate?
waitGate?: object;
ClientType.waitGate.gateId
gateId: string;
ClientType.waitGate.requestId
requestId: string;
StateType
StateType: object;
StateType.addressedBy?
addressedBy?: "session" | "task";
StateType.answeredBy?
answeredBy?: string;
StateType.at
at: number;
StateType.chain?
chain?: string;
StateType.deadlineAt?
deadlineAt?: number;
StateType.deliveredAs?
deliveredAs?: string;
StateType.deliveredAt?
deliveredAt?: number;
StateType.exchange
exchange: string;
StateType.forward?
forward?: object;
StateType.forward.as
as: "addressed" | "inferred";
StateType.forward.url
url: string;
StateType.from
from: string;
StateType.fromFlow
fromFlow: string;
StateType.fromSession
fromSession: string;
StateType.hop
hop: number;
StateType.id
id: string;
StateType.inReplyTo?
inReplyTo?: string;
StateType.noAnswer?
noAnswer?: true;
StateType.queuedBehind?
queuedBehind?: "user";
StateType.reason?
reason?: string;
StateType.replyRequested?
replyRequested?: true;
StateType.resent?
resent?: object;
StateType.resent.at
at: number;
StateType.resent.n
n: number;
StateType.status
status: "delivered" | "refused" | "unconfirmed" | "undeliverable";
StateType.takenBy?
takenBy?: string;
StateType.text
text: string;
StateType.to
to: string;
StateType.toFlow
toFlow: string;
StateType.toldAt?
toldAt?: number;
StateType.toSession
toSession: string;
StateType.toState?
toState?: Record<string, string>;
StateType.toTask?
toTask?: string;
StateType.waitEndedAt?
waitEndedAt?: number;
StateType.waitGate?
waitGate?: object;
StateType.waitGate.gateId
gateId: string;
StateType.waitGate.requestId
requestId: string;
WORKSTREAM_STATE_KEY
const WORKSTREAM_STATE_KEY: "workstreamId" = "workstreamId";
The session-state field that names the workstream a worker session leads:
the workstream's project address plus its id, as workstreamRef writes it
(<visibility>/<projectId>/<workstreamId>). Set when a workstream's open
creates its lead's session; readonly, and checked at create against the
creating user's own entry. Pinned: the criteria key findWorkerSession
and ensureWorkerSession take.
workstreamReportView
const workstreamReportView: ViewRef;
One entry's report, for client.view(workstreamReportView, { project, owner, id }). Its answer is { report }.
Functions
boardTaskOf()
function boardTaskOf(
boardRef,
ownerSessionId,
fallbackId,
stored
): object;
A stored task on board boardRef, held by conversation ownerSessionId.
fallbackId names it when the stored entry has no id (its key in the ledger).
Parameters
boardRef
string
ownerSessionId
string
fallbackId
string
stored
unknown
Returns
object
assignee
assignee: string | null;
attachments
attachments: FileContent[];
boardRef
boardRef: string;
completedAt
completedAt: number | null;
context
context: string | null;
createdAt
createdAt: number | null;
deps
deps: string[];
error
error: string | null;
goal
goal: string | null;
holds
holds: (
| {
actor: "user" | "system";
ask: {
kind: "input" | "approval" | "review";
prompt: string;
title?: string;
};
due?: number;
id: string;
openedAt: number;
source: {
kind: "suspension";
requestId: string;
suspensionId: string;
};
}
| {
actor: "user" | "system";
ask: {
kind: "confirm" | "external" | "question";
onNo?: "cancel" | "continue";
prompt: string;
title?: string;
};
due?: number;
id: string;
midway?: true;
openedAt: number;
source: {
closedBy: (
| {
by: "answer";
}
| {
by: "event";
event: string;
key: string;
})[];
kind: "task";
};
})[];
id
id: string;
labels
labels: string[];
ownerSessionId
ownerSessionId: string;
priority
priority: string | null;
run
run:
| {
attempt: number;
requestId: string;
sessionId: string;
}
| null;
spend
spend:
| {
costUsd?: number | null;
harness: string | null;
inputTokens: number | null;
live: boolean;
model: string | null;
outputTokens: number | null;
unreported: boolean;
}
| null;
startedAt
startedAt: number | null;
status
status: string;
steers
steers: object[];
title
title: string;
updatedAt
updatedAt: number | null;
createWorkforceClient()
function createWorkforceClient(fsd): WorkforceClient;
Build a workforce client over the one client, as that client's user.
Parameters
fsd
The app's client (createClient): its user, transport and credential.
Returns
isOpenMessage()
function isOpenMessage(message): boolean;
A message still open: on its way (unconfirmed), or asked for a reply that
hasn't come (no answeredBy) and neither refused nor undeliverable. What the
message log's open index holds, and so what the worker messages view answers.
Parameters
message
addressedBy?
"session" | "task"
answeredBy?
string
at
number
chain?
string
deadlineAt?
number
deliveredAs?
string
deliveredAt?
number
exchange
string
forward?
{
as: "addressed" | "inferred";
url: string;
}
forward.as
"addressed" | "inferred"
forward.url
string
from
string
fromFlow
string
fromSession
string
hop
number
id
string
inReplyTo?
string
noAnswer?
true
queuedBehind?
"user"
reason?
string
replyRequested?
true
resent?
{
at: number;
n: number;
}
resent.at
number
resent.n
number
status
"unconfirmed" | "delivered" | "refused" | "undeliverable"
takenBy?
string
text
string
to
string
toFlow
string
toldAt?
number
toSession
string
toState?
Record<string, string>
toTask?
string
waitEndedAt?
number
waitGate?
{
gateId: string;
requestId: string;
}
waitGate.gateId
string
waitGate.requestId
string
Returns
boolean
sentTargetLabel()
function sentTargetLabel(to): string;
A worker's id as it is; a task as "task <id>"; a conversation as "conversation <id>"; "another worker" when the line doesn't say.
Parameters
to
SentMessageTarget | undefined
Returns
string
taskBriefMetadata()
function taskBriefMetadata(brief): object;
The metadata a task's brief is written with.
Parameters
brief
Returns
object
taskBrief
taskBrief: TaskBrief;
taskBriefOf()
function taskBriefOf(item): TaskBrief | undefined;
The task brief a message item is, or undefined for any other item. A
brief stored before its item carried the marker reads as undefined.
Parameters
item
A stored or streamed item: a message's metadata.
metadata?
Readonly<Record<string, unknown>>
type?
string
Returns
TaskBrief | undefined
workstreamsAccessor()
function workstreamsAccessor(visibility): string;
The accessor a project's entries are declared under at visibility.
Parameters
visibility
"shared" | "private"
Returns
string
workstreamStorageKey()
function workstreamStorageKey(address, ownerSegment): string;
The storage key of ownerSegment's entry for address:
workstreams/<projectId>/<ownerSegment>/<workstreamId>.
Parameters
address
ownerSegment
string
The owner's key segment, ownerSegment(userId) from core.
Returns
string
References
answerTextOf
Re-exports answerTextOf
CONNECTOR_KEYS_PATH
Re-exports CONNECTOR_KEYS_PATH
ConnectorKeyStatus
Re-exports ConnectorKeyStatus
COORDINATOR_FLOW
Re-exports COORDINATOR_FLOW
COORDINATOR_JUDGMENT
Re-exports COORDINATOR_JUDGMENT
COORDINATOR_ROUTE
Re-exports COORDINATOR_ROUTE
DelegateAnswer
Re-exports DelegateAnswer
delegateAnswerMetadata
Re-exports delegateAnswerMetadata
delegateAnswerOf
Re-exports delegateAnswerOf
deriveWorkerSessionId
Re-exports deriveWorkerSessionId
DONE_STATUS
Re-exports DONE_STATUS
ERROR_REPORTER_FLOW
Re-exports ERROR_REPORTER_FLOW
FILING_SESSION_STATE_KEY
Re-exports FILING_SESSION_STATE_KEY
isDerivedWorkerSessionId
Re-exports isDerivedWorkerSessionId
LIST_ROUTINES_ACTION
Re-exports LIST_ROUTINES_ACTION
ListedRoutine
Re-exports ListedRoutine
listedRoutineSchema
Re-exports listedRoutineSchema
MAX_RULE_CHARS
Re-exports MAX_RULE_CHARS
MAX_RULES
Re-exports MAX_RULES
ParsedWorkstreamEntry
Re-exports ParsedWorkstreamEntry
parseProjectRef
Re-exports parseProjectRef
parseWorkstreamEntry
Re-exports parseWorkstreamEntry
parseWorkstreamRef
Re-exports parseWorkstreamRef
PRIVATE_WORKSTREAMS_RESOURCE
Re-exports PRIVATE_WORKSTREAMS_RESOURCE
ProgressEntry
Re-exports ProgressEntry
PROJECT_STATE_KEY
Re-exports PROJECT_STATE_KEY
projectProgress
Re-exports projectProgress
ProjectProgress
Re-exports ProjectProgress
projectRef
Re-exports projectRef
PROJECTS_FLOW
Re-exports PROJECTS_FLOW
PROJECTS_PATTERN
Re-exports PROJECTS_PATTERN
ProjectSetup
Re-exports ProjectSetup
ProjectSetupView
Re-exports ProjectSetupView
RECEIVED_MESSAGE_DATA_TYPE
Re-exports RECEIVED_MESSAGE_DATA_TYPE
ROSTER_FLOW
Re-exports ROSTER_FLOW
rosterView
Re-exports rosterView
RosterView
Re-exports RosterView
ROUTINE_VERBS
Re-exports ROUTINE_VERBS
RoutineMaker
Re-exports RoutineMaker
routineMakerSchema
Re-exports routineMakerSchema
RULE_TOOLS
Re-exports RULE_TOOLS
SCHEDULES_PATTERN
Re-exports SCHEDULES_PATTERN
SEND_MESSAGE_TOOL
Re-exports SEND_MESSAGE_TOOL
sessionIdOfFiling
Re-exports sessionIdOfFiling
sessionTurnsViewRef
Re-exports sessionTurnsViewRef
SET_SESSION_FIELDS_ACTION
Re-exports SET_SESSION_FIELDS_ACTION
SET_WORK_PROJECT_ACTION
Re-exports SET_WORK_PROJECT_ACTION
SetWorkProjectOutput
Re-exports SetWorkProjectOutput
STALE_AFTER_MS
Re-exports STALE_AFTER_MS
STANDING_RULES_ACTION
Re-exports STANDING_RULES_ACTION
STANDING_RULES_LINE
Re-exports STANDING_RULES_LINE
StandingRule
Re-exports StandingRule
StandingRulesActionInput
Re-exports StandingRulesActionInput
StandingRulesActionOutput
Re-exports StandingRulesActionOutput
TASK_ID_STATE_KEY
Re-exports TASK_ID_STATE_KEY
TURN_ACTIONS
Re-exports TURN_ACTIONS
WORK_PROJECT_STATE_KEY
Re-exports WORK_PROJECT_STATE_KEY
WORKER_ID_STATE_KEY
Re-exports WORKER_ID_STATE_KEY
WORKER_MESSAGES_PATTERN
Re-exports WORKER_MESSAGES_PATTERN
WORKER_MESSAGES_RESOURCE
Re-exports WORKER_MESSAGES_RESOURCE
WorkerInstructions
Re-exports WorkerInstructions
workerInstructionsView
Re-exports workerInstructionsView
WorkerInstructionsView
Re-exports WorkerInstructionsView
WorkerMessageResourceState
Re-exports WorkerMessageResourceState
workerMessageResourceStateSchema
Re-exports workerMessageResourceStateSchema
workerMessagesViewRef
Re-exports workerMessagesViewRef
WorkerSessionCriteria
Re-exports WorkerSessionCriteria
workerSessionsViewRef
Re-exports workerSessionsViewRef
workerUsageView
Re-exports workerUsageView
WorkstreamAddress
Re-exports WorkstreamAddress
WorkstreamEntry
Re-exports WorkstreamEntry
workstreamRef
Re-exports workstreamRef
WORKSTREAMS_PATTERN
Re-exports WORKSTREAMS_PATTERN
WORKSTREAMS_RESOURCE
Re-exports WORKSTREAMS_RESOURCE