@threadbase-sh/agent-types 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ronen Mars
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @threadbase/agent-types
2
+
3
+ Shared wire types for the Threadbase multi-agent pipeline.
4
+
5
+ These types live on the boundary between two processes:
6
+
7
+ - **tb-multi-agent** — the Temporal worker that runs the orchestrator + turn workflows and the AI-agent activities.
8
+ - **tb-streamer** — the Temporal client that owns the WebSocket connection to the mobile frontend and writes JSONL.
9
+
10
+ Both processes consume this package so the wire shapes (progress events, signal payloads, session addendum, final-answer flags) stay in sync. There is no runtime code beyond a single frozen `STAGES` array; everything else is type-only.
11
+
12
+ ## How consumers depend on this
13
+
14
+ Both consumers add this repo as a **git submodule** at a pinned commit, then point their `package.json` at the submodule path via a `file:` dep:
15
+
16
+ ```jsonc
17
+ // tb-multi-agent/packages/agent-types/ ← submodule path
18
+ // tb-streamer/vendor/agent-types/ ← submodule path
19
+
20
+ "@threadbase/agent-types": "file:packages/agent-types" // tb-multi-agent
21
+ "@threadbase/agent-types": "file:vendor/agent-types" // tb-streamer
22
+ ```
23
+
24
+ Bumping the wire contract is a deliberate three-step act:
25
+
26
+ 1. Edit + commit + push here.
27
+ 2. In the consuming repo, `git submodule update --remote vendor/agent-types` (or `packages/agent-types`).
28
+ 3. Commit the submodule SHA bump in the consuming repo.
29
+
30
+ This pattern mirrors how `tb-streamer` consumes `@threadbase/scanner` today.
31
+
32
+ ## Why `private: true` in package.json
33
+
34
+ The package is **source-public** (this repo is public on GitHub) but **not published to npm**. The `private: true` flag prevents accidental `npm publish` runs. The roadmap for going registry-public lives alongside the tb-streamer distribution refactor — both packages move to npm together (Stage 3 in `tb-multi-agent/docs/ROADMAP.md`).
35
+
36
+ ## Stages of distribution maturity
37
+
38
+ - ~~**Stage 1:** local `file:` dep, sibling-checkout requirement.~~ Retired 2026-06-04.
39
+ - **Stage 2 (current):** standalone GitHub repo, consumed via git submodule. Both consumers pin a SHA.
40
+ - **Stage 3 (planned):** published npm package. See `tb-multi-agent/docs/ROADMAP.md` and the tb-streamer distribution-refactor spec for the broader unification.
41
+
42
+ ## Local development
43
+
44
+ ```bash
45
+ npm install
46
+ npm test # vitest, 23 tests
47
+ npm run build # tsc → dist/
48
+ npm run typecheck
49
+ ```
50
+
51
+ The package is self-contained: no runtime deps, only `typescript` + `vitest` as devDeps.
@@ -0,0 +1,6 @@
1
+ export { STAGES } from './stage';
2
+ export type { Stage } from './stage';
3
+ export type { ProgressEvent, ProgressEventType, AgentOutputPayload, } from './progress';
4
+ export type { ConversationTurn, UserInputSignal, } from './signal';
5
+ export type { SessionStageAddendum } from './session';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,YAAY,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,gBAAgB,EAChB,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ // packages/agent-types/src/index.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.STAGES = void 0;
5
+ var stage_1 = require("./stage");
6
+ Object.defineProperty(exports, "STAGES", { enumerable: true, get: function () { return stage_1.STAGES; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;AAEpC,iCAAiC;AAAxB,+FAAA,MAAM,OAAA"}
@@ -0,0 +1,56 @@
1
+ import type { Stage } from './stage';
2
+ /**
3
+ * The three event kinds the worker may emit to tb-streamer over the webhook.
4
+ *
5
+ * - stage_transition: the workflow has moved to a new stage. Carries `stage`,
6
+ * and `reworkAttempt` when `stage === 'rework'`.
7
+ * - agent_output: an agent (worker / reviewer / sign-off) has produced an
8
+ * output block to surface to the UI as a chat message. Carries an
9
+ * `AgentOutputPayload` in `payload`.
10
+ * - terminal_failure: the turn has failed and will not produce more output.
11
+ * Carries a free-form reason in `payload`.
12
+ */
13
+ export type ProgressEventType = 'stage_transition' | 'agent_output' | 'terminal_failure';
14
+ /**
15
+ * The envelope worker activities POST to tb-streamer's webhook receiver.
16
+ *
17
+ * Identity:
18
+ * - `sessionId` routes the event to the right WebSocket connection.
19
+ * - `turnId` groups events that belong to the same user turn.
20
+ * - `eventId` is the dedupe key. MUST be generated in workflow code via
21
+ * `workflow.uuid4()` so it survives Temporal replay — see spec §7.6.
22
+ * - `seq` is monotonic within a turn for stable ordering.
23
+ *
24
+ * Wire compatibility:
25
+ * - `stage` is typed as `Stage` here (the package owns the enum), but the
26
+ * webhook receiver accepts it as `string` for additive compatibility, so
27
+ * the server can ship a new stage value without the client needing a
28
+ * coordinated release.
29
+ */
30
+ export interface ProgressEvent {
31
+ sessionId: string;
32
+ turnId: string;
33
+ eventId: string;
34
+ seq: number;
35
+ type: ProgressEventType;
36
+ stage?: Stage;
37
+ reworkAttempt?: number;
38
+ timestamp: number;
39
+ payload?: Record<string, unknown>;
40
+ }
41
+ /**
42
+ * Payload of an `agent_output` event. Stored in `ProgressEvent.payload`.
43
+ *
44
+ * - `content` is the body of the chat block the UI will render.
45
+ * - `partial` is reserved for a future streaming-token mode; in milestone B
46
+ * blocks are always complete on emission, so this is always undefined.
47
+ * - `reviewerOverruled` is set on the FINAL agent_output when the rework
48
+ * cap was hit and the answer is being delivered without reviewer approval.
49
+ * See spec §7.4.
50
+ */
51
+ export interface AgentOutputPayload {
52
+ content: string;
53
+ partial?: boolean;
54
+ reviewerOverruled?: boolean;
55
+ }
56
+ //# sourceMappingURL=progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GACzB,kBAAkB,GAClB,cAAc,GACd,kBAAkB,CAAC;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,iBAAiB,CAAC;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=progress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress.js","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import type { Stage } from './stage';
2
+ /**
3
+ * Fields added to tb-streamer's existing session shape (and the
4
+ * `session_update` WebSocket event) for multi-agent mode.
5
+ *
6
+ * Every field is optional so this remains additive — existing mobile clients
7
+ * that don't know about `stage` keep working; new clients can render
8
+ * per-stage UI affordances.
9
+ *
10
+ * - `stage` widens to `string` on the wire so the worker can ship a new
11
+ * stage value before clients are updated. Internally we type it as
12
+ * `Stage | string` to keep autocomplete + literal-checking on the
13
+ * producer side.
14
+ * - `stalledSinceMs` is the number of milliseconds the session has been on
15
+ * the current stage without progress. The frontend uses it to surface
16
+ * "still working…" or to flag a hang.
17
+ * - `reworkAttempt` is only meaningful when `stage === 'rework'`.
18
+ */
19
+ export interface SessionStageAddendum {
20
+ stage?: Stage | string;
21
+ stalledSinceMs?: number;
22
+ reworkAttempt?: number;
23
+ }
24
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * One entry in the conversationHistory snapshot.
3
+ *
4
+ * Owned by tb-streamer in milestone B — tb-streamer composes the snapshot from
5
+ * its existing ConversationCache (SQLite-backed). The shape is mirrored here so
6
+ * the signal payload has a stable wire type.
7
+ *
8
+ * Additional fields (timestamp, metadata, tool calls) may be added without
9
+ * breaking compatibility: the orchestrator only forwards the snapshot through
10
+ * to activities, it does not inspect entry shape.
11
+ */
12
+ export interface ConversationTurn {
13
+ role: 'user' | 'assistant';
14
+ content: string;
15
+ }
16
+ /**
17
+ * Payload sent by tb-streamer with every `userInput` signal to a session's
18
+ * long-lived orchestrator workflow.
19
+ *
20
+ * - `turnId` is allocated by tb-streamer per user message; it is the same
21
+ * turn id worn by every progress event the resulting turn emits.
22
+ * - `prompt` is the user's message text.
23
+ * - `conversationHistory` is a snapshot tb-streamer composes from its cache.
24
+ * It rides in the payload instead of living in workflow state — see
25
+ * spec §6.1 for the rationale (option B.1).
26
+ */
27
+ export interface UserInputSignal {
28
+ turnId: string;
29
+ prompt: string;
30
+ conversationHistory: ConversationTurn[];
31
+ }
32
+ //# sourceMappingURL=signal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;CACzC"}
package/dist/signal.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // packages/agent-types/src/signal.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=signal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.js","sourceRoot":"","sources":["../src/signal.ts"],"names":[],"mappings":";AAAA,qCAAqC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The seven stages a turn passes through. Declared as a readonly tuple so the
3
+ * `Stage` type is the exact union of these literals — `string` on the wire for
4
+ * additive compatibility, but type-checked internally.
5
+ */
6
+ export declare const STAGES: readonly ["thinking", "queued", "processing", "review", "rework", "sign-off", "done"];
7
+ export type Stage = (typeof STAGES)[number];
8
+ //# sourceMappingURL=stage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage.d.ts","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,MAAM,uFAQR,CAAC;AAEZ,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC"}
package/dist/stage.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ // packages/agent-types/src/stage.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.STAGES = void 0;
5
+ /**
6
+ * The seven stages a turn passes through. Declared as a readonly tuple so the
7
+ * `Stage` type is the exact union of these literals — `string` on the wire for
8
+ * additive compatibility, but type-checked internally.
9
+ */
10
+ exports.STAGES = Object.freeze([
11
+ 'thinking',
12
+ 'queued',
13
+ 'processing',
14
+ 'review',
15
+ 'rework',
16
+ 'sign-off',
17
+ 'done',
18
+ ]);
19
+ //# sourceMappingURL=stage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stage.js","sourceRoot":"","sources":["../src/stage.ts"],"names":[],"mappings":";AAAA,oCAAoC;;;AAEpC;;;;GAIG;AACU,QAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAClC,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,MAAM;CACE,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@threadbase-sh/agent-types",
3
+ "version": "0.1.0",
4
+ "description": "Shared wire types for the Threadbase multi-agent pipeline (tb-multi-agent ↔ tb-streamer).",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/RonenMars/threadbase-agent-types.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/RonenMars/threadbase-agent-types/issues"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "main": "dist/index.js",
17
+ "types": "dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ },
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": ["dist", "src", "README.md"],
26
+ "scripts": {
27
+ "build": "tsc -p tsconfig.json",
28
+ "typecheck": "tsc -p tsconfig.json --noEmit",
29
+ "test": "vitest run"
30
+ },
31
+ "devDependencies": {
32
+ "@semantic-release/changelog": "^6.0.3",
33
+ "@semantic-release/git": "^10.0.1",
34
+ "conventional-changelog-conventionalcommits": "^9.3.1",
35
+ "semantic-release": "^25.0.5",
36
+ "typescript": "^5.6.0",
37
+ "vitest": "^2.1.0"
38
+ }
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ // packages/agent-types/src/index.ts
2
+
3
+ export { STAGES } from './stage';
4
+ export type { Stage } from './stage';
5
+
6
+ export type {
7
+ ProgressEvent,
8
+ ProgressEventType,
9
+ AgentOutputPayload,
10
+ } from './progress';
11
+
12
+ export type {
13
+ ConversationTurn,
14
+ UserInputSignal,
15
+ } from './signal';
16
+
17
+ export type { SessionStageAddendum } from './session';
@@ -0,0 +1,62 @@
1
+ // packages/agent-types/src/progress.ts
2
+ import type { Stage } from './stage';
3
+
4
+ /**
5
+ * The three event kinds the worker may emit to tb-streamer over the webhook.
6
+ *
7
+ * - stage_transition: the workflow has moved to a new stage. Carries `stage`,
8
+ * and `reworkAttempt` when `stage === 'rework'`.
9
+ * - agent_output: an agent (worker / reviewer / sign-off) has produced an
10
+ * output block to surface to the UI as a chat message. Carries an
11
+ * `AgentOutputPayload` in `payload`.
12
+ * - terminal_failure: the turn has failed and will not produce more output.
13
+ * Carries a free-form reason in `payload`.
14
+ */
15
+ export type ProgressEventType =
16
+ | 'stage_transition'
17
+ | 'agent_output'
18
+ | 'terminal_failure';
19
+
20
+ /**
21
+ * The envelope worker activities POST to tb-streamer's webhook receiver.
22
+ *
23
+ * Identity:
24
+ * - `sessionId` routes the event to the right WebSocket connection.
25
+ * - `turnId` groups events that belong to the same user turn.
26
+ * - `eventId` is the dedupe key. MUST be generated in workflow code via
27
+ * `workflow.uuid4()` so it survives Temporal replay — see spec §7.6.
28
+ * - `seq` is monotonic within a turn for stable ordering.
29
+ *
30
+ * Wire compatibility:
31
+ * - `stage` is typed as `Stage` here (the package owns the enum), but the
32
+ * webhook receiver accepts it as `string` for additive compatibility, so
33
+ * the server can ship a new stage value without the client needing a
34
+ * coordinated release.
35
+ */
36
+ export interface ProgressEvent {
37
+ sessionId: string;
38
+ turnId: string;
39
+ eventId: string;
40
+ seq: number;
41
+ type: ProgressEventType;
42
+ stage?: Stage;
43
+ reworkAttempt?: number;
44
+ timestamp: number;
45
+ payload?: Record<string, unknown>;
46
+ }
47
+
48
+ /**
49
+ * Payload of an `agent_output` event. Stored in `ProgressEvent.payload`.
50
+ *
51
+ * - `content` is the body of the chat block the UI will render.
52
+ * - `partial` is reserved for a future streaming-token mode; in milestone B
53
+ * blocks are always complete on emission, so this is always undefined.
54
+ * - `reviewerOverruled` is set on the FINAL agent_output when the rework
55
+ * cap was hit and the answer is being delivered without reviewer approval.
56
+ * See spec §7.4.
57
+ */
58
+ export interface AgentOutputPayload {
59
+ content: string;
60
+ partial?: boolean;
61
+ reviewerOverruled?: boolean;
62
+ }
package/src/session.ts ADDED
@@ -0,0 +1,25 @@
1
+ // packages/agent-types/src/session.ts
2
+ import type { Stage } from './stage';
3
+
4
+ /**
5
+ * Fields added to tb-streamer's existing session shape (and the
6
+ * `session_update` WebSocket event) for multi-agent mode.
7
+ *
8
+ * Every field is optional so this remains additive — existing mobile clients
9
+ * that don't know about `stage` keep working; new clients can render
10
+ * per-stage UI affordances.
11
+ *
12
+ * - `stage` widens to `string` on the wire so the worker can ship a new
13
+ * stage value before clients are updated. Internally we type it as
14
+ * `Stage | string` to keep autocomplete + literal-checking on the
15
+ * producer side.
16
+ * - `stalledSinceMs` is the number of milliseconds the session has been on
17
+ * the current stage without progress. The frontend uses it to surface
18
+ * "still working…" or to flag a hang.
19
+ * - `reworkAttempt` is only meaningful when `stage === 'rework'`.
20
+ */
21
+ export interface SessionStageAddendum {
22
+ stage?: Stage | string;
23
+ stalledSinceMs?: number;
24
+ reworkAttempt?: number;
25
+ }
package/src/signal.ts ADDED
@@ -0,0 +1,34 @@
1
+ // packages/agent-types/src/signal.ts
2
+
3
+ /**
4
+ * One entry in the conversationHistory snapshot.
5
+ *
6
+ * Owned by tb-streamer in milestone B — tb-streamer composes the snapshot from
7
+ * its existing ConversationCache (SQLite-backed). The shape is mirrored here so
8
+ * the signal payload has a stable wire type.
9
+ *
10
+ * Additional fields (timestamp, metadata, tool calls) may be added without
11
+ * breaking compatibility: the orchestrator only forwards the snapshot through
12
+ * to activities, it does not inspect entry shape.
13
+ */
14
+ export interface ConversationTurn {
15
+ role: 'user' | 'assistant';
16
+ content: string;
17
+ }
18
+
19
+ /**
20
+ * Payload sent by tb-streamer with every `userInput` signal to a session's
21
+ * long-lived orchestrator workflow.
22
+ *
23
+ * - `turnId` is allocated by tb-streamer per user message; it is the same
24
+ * turn id worn by every progress event the resulting turn emits.
25
+ * - `prompt` is the user's message text.
26
+ * - `conversationHistory` is a snapshot tb-streamer composes from its cache.
27
+ * It rides in the payload instead of living in workflow state — see
28
+ * spec §6.1 for the rationale (option B.1).
29
+ */
30
+ export interface UserInputSignal {
31
+ turnId: string;
32
+ prompt: string;
33
+ conversationHistory: ConversationTurn[];
34
+ }
package/src/stage.ts ADDED
@@ -0,0 +1,18 @@
1
+ // packages/agent-types/src/stage.ts
2
+
3
+ /**
4
+ * The seven stages a turn passes through. Declared as a readonly tuple so the
5
+ * `Stage` type is the exact union of these literals — `string` on the wire for
6
+ * additive compatibility, but type-checked internally.
7
+ */
8
+ export const STAGES = Object.freeze([
9
+ 'thinking',
10
+ 'queued',
11
+ 'processing',
12
+ 'review',
13
+ 'rework',
14
+ 'sign-off',
15
+ 'done',
16
+ ] as const);
17
+
18
+ export type Stage = (typeof STAGES)[number];