@particle-academy/fancy-chat-js 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,604 @@
1
+ /** The contract major. A reader refuses any other and ignores unknown fields. */
2
+ declare const CONTRACT_VERSION: 1;
3
+ type ActorKind = "agent" | "human" | "system";
4
+ interface Actor {
5
+ kind: ActorKind;
6
+ id: string;
7
+ label?: string;
8
+ }
9
+ /**
10
+ * One event in a thread's append-only log. `seq` is per thread, monotonic and
11
+ * gapless, assigned by the server; it is the only ordering.
12
+ */
13
+ interface ChatEvent<TData = Record<string, unknown>> {
14
+ v: 1;
15
+ seq: number;
16
+ threadId: string;
17
+ runId?: string | null;
18
+ turnId?: string | null;
19
+ parentRunId?: string | null;
20
+ rootRunId?: string | null;
21
+ at: string;
22
+ type: string;
23
+ actor: Actor;
24
+ data: TData;
25
+ }
26
+ type TurnState = "pending" | "running" | "awaiting-human" | "cancelling" | "settled";
27
+ type TurnOutcome = "completed" | "failed" | "refused" | "cancelled" | "interrupted";
28
+ /** `decided`: the server took the message as a typed decision; it was never delivered to the agent. */
29
+ type DeliveryState = "sending" | "sent" | "queued" | "steered" | "delivered" | "decided" | "failed" | "dropped" | "unsent";
30
+ type ApprovalState = "pending" | "deciding" | "approved" | "rejected" | "edited" | "applied" | "apply-failed" | "withdrawn" | "expired";
31
+ type OptionKind = "allow-once" | "allow-always" | "reject-once" | "reject-always" | "edit";
32
+ type OptionTone = "positive" | "negative" | "neutral";
33
+ type Decision = "approve" | "reject" | "edit";
34
+ /** A message part. Core kinds are a closed set; apps add `x-<app>.<name>`. */
35
+ interface Part {
36
+ id: string;
37
+ kind: string;
38
+ [field: string]: unknown;
39
+ }
40
+ interface TextPart extends Part {
41
+ kind: "text";
42
+ format: "markdown" | "plain";
43
+ text: string;
44
+ interim?: boolean;
45
+ }
46
+ interface ApprovalOption {
47
+ id: string;
48
+ kind: OptionKind;
49
+ label: string;
50
+ }
51
+ interface ApprovalRecord {
52
+ approvalId: string;
53
+ runId?: string | null;
54
+ /** The turn the approval parked, when the server knows it. */
55
+ turnId?: string | null;
56
+ toolCallId?: string | null;
57
+ title: string;
58
+ summary: string;
59
+ preview: Part[];
60
+ options: ApprovalOption[];
61
+ state: ApprovalState;
62
+ decidedBy?: Actor | null;
63
+ decision?: Decision | null;
64
+ optionId?: string | null;
65
+ note?: string | null;
66
+ expiresAt?: string | null;
67
+ error?: string | null;
68
+ }
69
+ type QuestionFieldType = "single" | "multi" | "text";
70
+ interface QuestionField {
71
+ id: string;
72
+ type: QuestionFieldType;
73
+ label?: string;
74
+ options?: {
75
+ id: string;
76
+ label: string;
77
+ }[];
78
+ required: boolean;
79
+ }
80
+ interface QuestionRecord {
81
+ questionId: string;
82
+ prompt: string;
83
+ fields: QuestionField[];
84
+ allowNote: boolean;
85
+ state?: "open" | "answered" | "dismissed";
86
+ answeredBy?: Actor | null;
87
+ values?: Record<string, unknown> | null;
88
+ notes?: Record<string, string> | null;
89
+ }
90
+ interface AnswerDraft {
91
+ values: Record<string, unknown>;
92
+ notes: Record<string, string>;
93
+ }
94
+ type Result<T = Record<never, never>> = ({
95
+ ok: true;
96
+ } & T) | {
97
+ ok: false;
98
+ error: string;
99
+ };
100
+
101
+ /** The closed set of core event types. Anything else must be `x-<app>.<name>`. */
102
+ declare const CORE_EVENT_TYPES: readonly ["thread.snapshot", "thread.reset", "run.started", "run.finished", "run.failed", "run.cancelled", "turn.started", "turn.transition", "turn.settled", "message.created", "message.updated", "message.retracted", "delivery.changed", "part.started", "part.delta", "part.completed", "thinking.started", "thinking.delta", "thinking.completed", "tool.called", "tool.progress", "tool.result", "plan.updated", "approval.requested", "approval.decided", "approval.applied", "approval.withdrawn", "question.asked", "question.answered", "undo.opened", "undo.committed", "undo.reverted", "agent.status", "usage", "provider.fallback", "control.handoff"];
103
+ type CoreEventType = (typeof CORE_EVENT_TYPES)[number];
104
+ /** An ISO 8601 timestamp with a zone, as every `at` and deadline carries. */
105
+ declare function isTimestamp(value: unknown): value is string;
106
+ declare function isEventType(type: unknown): boolean;
107
+ declare function isPlainObject(value: unknown): value is Record<string, unknown>;
108
+ /**
109
+ * Checks an event envelope. Refuses an unknown major (`contract.version`) and
110
+ * ignores unknown fields; never guesses. Errors name the field, never a value.
111
+ */
112
+ declare function validateEvent(input: unknown): Result<{
113
+ event: ChatEvent;
114
+ }>;
115
+
116
+ /**
117
+ * Typed approval: a human typing "approve" while an approval is actionable.
118
+ * OPT-IN PER APP (owner, 2026-11-15): off by default and no phrases until the
119
+ * host sets them. Deterministic, never an LLM. A match takes the same decide
120
+ * path, with the same checks, as pressing the button, and is consumed as the
121
+ * decision rather than sent to the agent.
122
+ */
123
+ interface TypedApprovalConfig {
124
+ enabled: boolean;
125
+ /** Which phrase list applies. */
126
+ locale: string;
127
+ /** Per locale, the exact phrases (after normalisation) that approve or reject. */
128
+ phrases: Record<string, {
129
+ approve?: string[];
130
+ reject?: string[];
131
+ }>;
132
+ }
133
+ declare const DEFAULT_TYPED_APPROVAL: TypedApprovalConfig;
134
+ /** English phrases a host may opt into. Never applied unless passed in `phrases`. */
135
+ declare const ENGLISH_TYPED_APPROVAL_PHRASES: {
136
+ approve: string[];
137
+ reject: string[];
138
+ };
139
+ /**
140
+ * NFKC, lower case, trimmed, trailing `.`/`!`/`?` dropped, inner white space
141
+ * collapsed to one space. Scans, never a backtracking regex.
142
+ */
143
+ declare function normalizePhrase(text: string): string;
144
+ /**
145
+ * The decision a typed message makes on a pending approval, or null. Only an
146
+ * exact phrase matches; "please approve it" is a message, not a decision. Edit
147
+ * is never typed.
148
+ */
149
+ declare function matchTypedApproval(text: string, approval: Pick<ApprovalRecord, "state" | "options"> | null, config?: Partial<TypedApprovalConfig>): {
150
+ optionId: string;
151
+ decision: Decision;
152
+ } | null;
153
+
154
+ type UndoState = "open" | "committed" | "reverted";
155
+ interface UndoEntry {
156
+ actionId: string;
157
+ label: string;
158
+ /** ISO 8601. The host commits at this instant; a revert must arrive before it. */
159
+ deadline: string;
160
+ state: UndoState;
161
+ }
162
+ /**
163
+ * Time left to revert, from a clock the caller supplies (it never reads one).
164
+ * At the deadline the window is shut, and an unreadable deadline is shut
165
+ * rather than open, so a malformed record can never be reverted late.
166
+ */
167
+ declare function undoWindow(entry: Pick<UndoEntry, "deadline" | "state">, now: number): {
168
+ remainingMs: number;
169
+ canRevert: boolean;
170
+ };
171
+
172
+ declare const PLAN_STEP_STATUSES: readonly ["pending", "running", "held", "done", "failed", "skipped"];
173
+ type PlanStepStatus = (typeof PLAN_STEP_STATUSES)[number];
174
+ interface PlanStepLike {
175
+ id: string;
176
+ title: string;
177
+ status: PlanStepStatus | string;
178
+ owner: "agent" | "human" | string;
179
+ approvalId?: string;
180
+ }
181
+ /**
182
+ * A held step releases ONLY through the approval path: it may leave `held`
183
+ * once its approval (the one it was held on) is approved, edited or applied,
184
+ * and may only go to `skipped` or `failed` once that approval was refused. A
185
+ * step cannot be released by dropping it, or by swapping its approval id.
186
+ */
187
+ declare function checkPlanUpdate(prev: readonly PlanStepLike[], next: readonly PlanStepLike[], approvals: readonly {
188
+ approvalId: string;
189
+ state: ApprovalState | string;
190
+ }[]): Result;
191
+
192
+ /**
193
+ * The one transition table, shared with fancy-chat-php (which vendors the same
194
+ * file and pins its hash). Nothing here may encode a transition the JSON does
195
+ * not hold.
196
+ */
197
+ declare const machines: {
198
+ v: number;
199
+ turn: {
200
+ initial: string;
201
+ states: string[];
202
+ outcomes: string[];
203
+ transitions: ({
204
+ from: string;
205
+ action: string;
206
+ to: string;
207
+ outcome?: undefined;
208
+ reason?: undefined;
209
+ } | {
210
+ from: string;
211
+ action: string;
212
+ to: string;
213
+ outcome: string;
214
+ reason?: undefined;
215
+ } | {
216
+ from: string;
217
+ action: string;
218
+ to: string;
219
+ outcome: string;
220
+ reason: string;
221
+ })[];
222
+ };
223
+ delivery: {
224
+ initial: string;
225
+ states: string[];
226
+ final: string[];
227
+ transitions: {
228
+ from: string;
229
+ action: string;
230
+ to: string;
231
+ }[];
232
+ };
233
+ approval: {
234
+ initial: string;
235
+ states: string[];
236
+ final: string[];
237
+ actionable: string[];
238
+ transitions: {
239
+ from: string;
240
+ action: string;
241
+ to: string;
242
+ }[];
243
+ };
244
+ reservedTools: {
245
+ about: string;
246
+ exact: string[];
247
+ contains: string[];
248
+ };
249
+ optionKinds: {
250
+ "allow-once": {
251
+ tone: string;
252
+ decision: string;
253
+ };
254
+ "allow-always": {
255
+ tone: string;
256
+ decision: string;
257
+ };
258
+ "reject-once": {
259
+ tone: string;
260
+ decision: string;
261
+ };
262
+ "reject-always": {
263
+ tone: string;
264
+ decision: string;
265
+ };
266
+ edit: {
267
+ tone: string;
268
+ decision: string;
269
+ };
270
+ };
271
+ };
272
+ type TurnTransition = {
273
+ ok: true;
274
+ to: TurnState;
275
+ outcome: TurnOutcome | null;
276
+ reason: string | null;
277
+ } | {
278
+ ok: false;
279
+ error: "turn.illegal";
280
+ };
281
+ declare function transitionTurn(from: string, action: string): TurnTransition;
282
+ /** True when `action` moves a turn to `settled`. Only `turn.settled` may carry one. */
283
+ declare function isSettlingTurnAction(action: string): boolean;
284
+ type SimpleTransition<S> = {
285
+ ok: true;
286
+ to: S;
287
+ } | {
288
+ ok: false;
289
+ error: string;
290
+ };
291
+ declare function transitionDelivery(from: string, action: string): SimpleTransition<DeliveryState>;
292
+ declare function transitionApproval(from: string, action: string): SimpleTransition<ApprovalState>;
293
+ /** Button tone and decision come from the option KIND, never its label. */
294
+ declare function optionTone(kind: string): {
295
+ tone: OptionTone | null;
296
+ decision: Decision | null;
297
+ };
298
+
299
+ declare const CORE_PART_KINDS: readonly ["text", "code", "table", "chart", "file", "image", "tool-call", "tool-result", "card", "question", "approval"];
300
+ declare const CHART_TYPES: readonly ["line", "bar", "area", "pie", "scatter"];
301
+ interface PartLimits {
302
+ /** JSON byte size of one part, nested parts included. Default 65536. */
303
+ maxPartBytes: number;
304
+ /** Card nesting depth, the outermost part being 1. Default 3. */
305
+ maxDepth: number;
306
+ /** Parts in one message. Default 64. */
307
+ maxParts: number;
308
+ }
309
+ declare const DEFAULT_PART_LIMITS: PartLimits;
310
+ /** Who authored the part. Only server code may place HITL parts or raw ECharts options. */
311
+ type PartOrigin = "agent" | "server";
312
+ interface PartDefinition<P extends Part = Part> {
313
+ /** `x-<app>.<name>`. Core kinds cannot be redefined. */
314
+ kind: string;
315
+ validate?: (part: P) => boolean | string;
316
+ toText?: (part: P) => string;
317
+ }
318
+ interface PartRegistry {
319
+ register<P extends Part>(definition: PartDefinition<P>): PartRegistry;
320
+ get(kind: string): PartDefinition | undefined;
321
+ kinds(): string[];
322
+ }
323
+ declare function createPartRegistry(definitions?: PartDefinition[]): PartRegistry;
324
+ interface PartContext {
325
+ origin: PartOrigin;
326
+ limits?: Partial<PartLimits>;
327
+ registry?: PartRegistry;
328
+ }
329
+ /** JSON byte size, the same measure fancy-chat-php uses (unescaped slashes and unicode). */
330
+ declare function jsonBytes(value: unknown): number;
331
+ /** Validates one part. Unknown core kinds fail; `x-*` kinds pass unless their registered validator refuses. */
332
+ declare function validatePart(part: unknown, context: PartContext): Result;
333
+ /** Validates a message's parts: the count cap, then each part. */
334
+ declare function validateParts(parts: unknown, context: PartContext): Result;
335
+ /**
336
+ * Plain text for a part: copy, notifications, storage, and the fallback render
337
+ * of a kind the client does not know. Never empty-drops a part.
338
+ */
339
+ declare function partToText(part: Part, registry?: PartRegistry): string;
340
+
341
+ /**
342
+ * Only a human may decide an approval or answer a question. The kind must be
343
+ * exactly `human` and the id non-empty; the host's authenticated resolver is
344
+ * what produces this actor, never the request body.
345
+ */
346
+ declare function canDecide(actor: unknown): actor is Actor & {
347
+ kind: "human";
348
+ };
349
+ /** A tool name in the human's confirmation channel. Never offered to an agent. */
350
+ declare function isReservedToolName(name: string): boolean;
351
+ /**
352
+ * Whether an answer draft may be submitted. Each required field needs a value,
353
+ * or (when the question allows notes) a non-blank note. Values must be of the
354
+ * field's type and options must be offered ones.
355
+ */
356
+ declare function canSubmitAnswer(question: QuestionRecord, draft: AnswerDraft): Result;
357
+ interface HitlItem {
358
+ id: string;
359
+ kind: "approval" | "question" | string;
360
+ state: string;
361
+ seq: number;
362
+ }
363
+ /**
364
+ * Exactly one HITL item is actionable within a coordination scope: the oldest
365
+ * by seq. While any decision is in flight, none is.
366
+ */
367
+ declare function pickActionable(items: readonly HitlItem[], kinds?: readonly string[]): string | null;
368
+
369
+ /** The agent status vocabulary. One derivation, used by both servers and the client. */
370
+ declare const AGENT_STATUSES: readonly ["not-started", "starting", "working", "cooling", "idle", "sleeping", "parked", "paused-limit", "signed-out", "broken"];
371
+ type AgentStatusName = (typeof AGENT_STATUSES)[number];
372
+ interface AgentSnapshot {
373
+ /** Milliseconds since the epoch. The derivation is pure: it never reads a clock. */
374
+ now: number;
375
+ signedIn?: boolean;
376
+ broken?: string | null;
377
+ limit?: {
378
+ until: number;
379
+ } | null;
380
+ everStarted?: boolean;
381
+ turn?: {
382
+ state: TurnState;
383
+ since: number;
384
+ } | null;
385
+ lastSettledAt?: number | null;
386
+ background?: number;
387
+ plan?: {
388
+ n: number;
389
+ m: number;
390
+ doing: string | null;
391
+ } | null;
392
+ pendingHitl?: number;
393
+ }
394
+ interface StatusConfig {
395
+ /** How long after a turn settles the agent reads as cooling. Default 15000. */
396
+ coolingMs: number;
397
+ /** Idle time after which the agent reads as sleeping. Default 600000. */
398
+ sleepAfterMs: number;
399
+ /** Recovery action ids per status; the host's map replaces the default for each status it names. */
400
+ recovery?: Partial<Record<AgentStatusName, string[]>>;
401
+ }
402
+ declare const DEFAULT_STATUS_CONFIG: StatusConfig;
403
+ declare const DEFAULT_RECOVERY: Record<AgentStatusName, string[]>;
404
+ interface AgentStatus {
405
+ status: AgentStatusName;
406
+ detail: Record<string, unknown> | null;
407
+ since: number | null;
408
+ recovery: string[];
409
+ }
410
+ declare function deriveAgentStatus(snapshot: AgentSnapshot, config?: Partial<StatusConfig>): AgentStatus;
411
+
412
+ /**
413
+ * The client side of resumable replay. Events are applied strictly in seq
414
+ * order: duplicates are dropped, events past a gap are held until the gap
415
+ * fills, and the gap is reported so the transport can re-request
416
+ * `after = lastSeq`. A `thread.reset` jumps the cursor to its own seq.
417
+ */
418
+ interface SeqLog {
419
+ readonly lastSeq: number;
420
+ readonly held: ReadonlyMap<number, ChatEvent>;
421
+ }
422
+ interface Gap {
423
+ /** The last seq applied. Re-request with `after = gap.after`. */
424
+ after: number;
425
+ /** The first seq held past the gap. */
426
+ before: number;
427
+ }
428
+ interface IngestResult {
429
+ log: SeqLog;
430
+ /** Events now safe to reduce, in seq order. */
431
+ applied: ChatEvent[];
432
+ missing: Gap | null;
433
+ }
434
+ declare function createSeqLog(after?: number): SeqLog;
435
+ declare function ingestEvents(log: SeqLog, events: readonly ChatEvent[]): IngestResult;
436
+
437
+ interface MessageEntry {
438
+ id: string;
439
+ role: string;
440
+ author: Actor | null;
441
+ turnId: string | null;
442
+ parts: Part[];
443
+ /** Ids of parts still streaming. */
444
+ open: string[];
445
+ delivery: DeliveryState | null;
446
+ supersedes: string | null;
447
+ retracted: boolean;
448
+ superseded: boolean;
449
+ }
450
+ interface TurnEntry {
451
+ turnId: string;
452
+ state: TurnState;
453
+ outcome: TurnOutcome | null;
454
+ reason: string | null;
455
+ /**
456
+ * The human message that started this turn (`turn.started` `data.messageId`,
457
+ * when that message is in the log), so a host can retry a failed turn with its
458
+ * original input. Null for a turn no message started.
459
+ */
460
+ messageId: string | null;
461
+ }
462
+ interface ThinkingEntry {
463
+ /**
464
+ * One run may think several times, between tool calls. Each block has its own id:
465
+ * the event's `data.thinkingId` when it sends one, else the run id for the run's
466
+ * first block and `<runId>#2`, `#3`... for the next.
467
+ */
468
+ thinkingId: string;
469
+ runId: string;
470
+ text: string;
471
+ live: boolean;
472
+ }
473
+ interface ToolEntry {
474
+ toolCallId: string;
475
+ runId: string | null;
476
+ name: string;
477
+ args: Record<string, unknown>;
478
+ startedAt: string | null;
479
+ progress: {
480
+ fraction: number | null;
481
+ text: string | null;
482
+ } | null;
483
+ outcome: "ok" | "failure" | "refusal" | null;
484
+ durationMs: number | null;
485
+ /**
486
+ * False when the backend could only bound the duration, not measure it (e.g. a
487
+ * Prism Harness step timed across a process hop): render it as "at most".
488
+ */
489
+ durationExact: boolean;
490
+ outputRef: string | null;
491
+ truncated: boolean;
492
+ /**
493
+ * The result's text inline, as the tool or its failure wrote it (a failure's own
494
+ * words, not a generic "failed"). Plain text: render it as text or code, NEVER as
495
+ * HTML. The server bounds it and sets `truncated`; `outputRef` points at the rest.
496
+ */
497
+ output: string | null;
498
+ /** Set when the output is code (e.g. "json"), for a code view; null means plain text. */
499
+ outputLanguage: string | null;
500
+ }
501
+ interface PlanStep {
502
+ id: string;
503
+ title: string;
504
+ status: "pending" | "running" | "held" | "done" | "failed" | "skipped";
505
+ owner: "agent" | "human";
506
+ approvalId?: string;
507
+ }
508
+ interface PlanEntry {
509
+ runId: string;
510
+ steps: PlanStep[];
511
+ }
512
+ type RowKind = "message" | "thinking" | "tool" | "plan" | "approval" | "question" | "undo";
513
+ /**
514
+ * Edit-and-resend: the rows between a superseded message and the one that
515
+ * replaced it. The projection records the branch; the HOST's policy decides
516
+ * what happens to it (branch, the default: keep it, shown on demand; truncate:
517
+ * the server retracts its messages).
518
+ */
519
+ interface BranchEntry {
520
+ supersededId: string;
521
+ byId: string;
522
+ rowIds: string[];
523
+ }
524
+ /**
525
+ * The whole projected thread as plain JSON. This IS the snapshot format: a
526
+ * `thread.reset` carries one, and the PHP twin produces the same shape.
527
+ */
528
+ interface ThreadState {
529
+ lastSeq: number;
530
+ /** Events refused by the machines or the human-only rule. Diagnostics, never state. */
531
+ illegal: number;
532
+ order: {
533
+ kind: RowKind;
534
+ id: string;
535
+ }[];
536
+ messages: MessageEntry[];
537
+ turns: TurnEntry[];
538
+ thinking: ThinkingEntry[];
539
+ tools: ToolEntry[];
540
+ plans: PlanEntry[];
541
+ approvals: ApprovalRecord[];
542
+ questions: QuestionRecord[];
543
+ undos: UndoEntry[];
544
+ branches: BranchEntry[];
545
+ }
546
+ type Row = ({
547
+ kind: "message";
548
+ } & MessageEntry) | ({
549
+ kind: "thinking";
550
+ id: string;
551
+ } & ThinkingEntry) | ({
552
+ kind: "tool";
553
+ id: string;
554
+ } & ToolEntry) | ({
555
+ kind: "plan";
556
+ id: string;
557
+ } & PlanEntry) | {
558
+ kind: "approval";
559
+ id: string;
560
+ approvalId: string;
561
+ state: ApprovalRecord["state"];
562
+ } | {
563
+ kind: "question";
564
+ id: string;
565
+ questionId: string;
566
+ state: NonNullable<QuestionRecord["state"]>;
567
+ } | ({
568
+ kind: "undo";
569
+ id: string;
570
+ } & UndoEntry);
571
+ declare function emptyThreadState(): ThreadState;
572
+ /**
573
+ * Applies one event to the state, in place. Idempotent: an event at or below
574
+ * `lastSeq` changes nothing. Returns whether the event was applied (legal or
575
+ * not). An illegal event bumps `illegal` and leaves every entry untouched.
576
+ *
577
+ * Total: it never throws. A malformed event the checks below do not anticipate
578
+ * is counted illegal and the cursor moves past it, exactly as for an illegal
579
+ * transition. A throw would escape into the client's transport, which reads it
580
+ * as a failed request and retries the same batch forever.
581
+ */
582
+ declare function applyEvent(state: ThreadState, event: ChatEvent): boolean;
583
+ /**
584
+ * Under the truncate policy, the turns a removed branch must cancel: every
585
+ * UNSETTLED turn the branch references, through a message in it (the
586
+ * superseded message included) or an approval placed in it. In `state.turns`
587
+ * order. Settled turns and turns outside the branch are never touched.
588
+ */
589
+ declare function turnsToCancelForBranch(state: ThreadState, supersededId: string): string[];
590
+ /** The rows a thread renders, in order of first appearance. */
591
+ declare function rowsOf(state: ThreadState): Row[];
592
+ interface ThreadProjection {
593
+ lastSeq: number;
594
+ illegal: number;
595
+ rows: Row[];
596
+ turns: TurnEntry[];
597
+ approvals: ApprovalRecord[];
598
+ questions: QuestionRecord[];
599
+ state: ThreadState;
600
+ }
601
+ /** Pure: folds events, in the order given, into the projected thread. */
602
+ declare function projectThread(events: readonly ChatEvent[], initial?: ThreadState): ThreadProjection;
603
+
604
+ export { AGENT_STATUSES, type Actor, type ActorKind, type AgentSnapshot, type AgentStatus, type AgentStatusName, type AnswerDraft, type ApprovalOption, type ApprovalRecord, type ApprovalState, type BranchEntry, CHART_TYPES, CONTRACT_VERSION, CORE_EVENT_TYPES, CORE_PART_KINDS, type ChatEvent, type CoreEventType, DEFAULT_PART_LIMITS, DEFAULT_RECOVERY, DEFAULT_STATUS_CONFIG, DEFAULT_TYPED_APPROVAL, type Decision, type DeliveryState, ENGLISH_TYPED_APPROVAL_PHRASES, type Gap, type HitlItem, type IngestResult, type MessageEntry, type OptionKind, type OptionTone, PLAN_STEP_STATUSES, type Part, type PartContext, type PartDefinition, type PartLimits, type PartOrigin, type PartRegistry, type PlanEntry, type PlanStep, type PlanStepLike, type PlanStepStatus, type QuestionField, type QuestionFieldType, type QuestionRecord, type Result, type Row, type RowKind, type SeqLog, type SimpleTransition, type StatusConfig, type TextPart, type ThinkingEntry, type ThreadProjection, type ThreadState, type ToolEntry, type TurnEntry, type TurnOutcome, type TurnState, type TurnTransition, type TypedApprovalConfig, type UndoEntry, type UndoState, applyEvent, canDecide, canSubmitAnswer, checkPlanUpdate, createPartRegistry, createSeqLog, deriveAgentStatus, emptyThreadState, ingestEvents, isEventType, isPlainObject, isReservedToolName, isSettlingTurnAction, isTimestamp, jsonBytes, machines, matchTypedApproval, normalizePhrase, optionTone, partToText, pickActionable, projectThread, rowsOf, transitionApproval, transitionDelivery, transitionTurn, turnsToCancelForBranch, undoWindow, validateEvent, validatePart, validateParts };