summaryrefslogtreecommitdiffhomepage
path: root/packages/kernel/src/contracts/conversation.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-06 18:55:53 +0900
committerAdam Malczewski <[email protected]>2026-06-06 18:55:53 +0900
commit22936857685c318b71752d625808100b1a96e63e (patch)
tree5e10a73d616c206e3820a8d8568e5f3d4c8a302e /packages/kernel/src/contracts/conversation.ts
parent969afc45f895230fe3da1c737f18e64452efc8f2 (diff)
downloaddispatch-22936857685c318b71752d625808100b1a96e63e.tar.gz
dispatch-22936857685c318b71752d625808100b1a96e63e.zip
feat(frontend,wire): surface system (FE slice 1) + @dispatch/wire types-only split (B2)
FE slice 1 — backend-declared, frontend-agnostic surface system (verified live): new types-only @dispatch/ui-contract (SurfaceSpec / field kinds / region / ActionRef / catalog), surface-registry (typed service handle), transport-ws (Bun WS :24205, path-agnostic upgrade), surface-loaded-extensions (first real surface); kernel HostAPI.getExtensions; host-bin wiring; bin/up. Harness: retire AGENTS 'backend only', ORCHESTRATOR §3/§7/§8, frontend-design.md locked. B2 — wire-types split (chat-slice prerequisite): new types-only @dispatch/wire single-sources the wire ABI (AgentEvent + 11 variants; conversation model Chunk/ChatMessage/Role/TurnId/StepId + 6 chunk variants; Usage) with zero @dispatch/* deps. @dispatch/kernel re-exports via shims so its public surface is byte-identical (zero consumer blast radius). transport-contract re-exports AgentEvent from @dispatch/wire and drops its @dispatch/kernel dependency, so HTTP clients (the web frontend) consume the wire without the kernel runtime. tsc -b + biome clean; 460 vitest + 77 bun pass.
Diffstat (limited to 'packages/kernel/src/contracts/conversation.ts')
-rw-r--r--packages/kernel/src/contracts/conversation.ts101
1 files changed, 15 insertions, 86 deletions
diff --git a/packages/kernel/src/contracts/conversation.ts b/packages/kernel/src/contracts/conversation.ts
index c9ad0eb..ec9a389 100644
--- a/packages/kernel/src/contracts/conversation.ts
+++ b/packages/kernel/src/contracts/conversation.ts
@@ -1,91 +1,20 @@
/**
* Conversation model — the kernel's representation of a dialogue.
*
- * The kernel owns only the types and pure transforms. Persistence is a core
- * extension (conversation-store). A turn is one user→assistant cycle; a step
- * is one LLM round-trip within a turn. Chunks are append-only.
+ * Re-exported from @dispatch/wire so the kernel barrel surface stays
+ * byte-identical. The canonical definitions live in @dispatch/wire.
*/
-/** Who produced a message. */
-export type Role = "system" | "user" | "assistant" | "tool";
-
-/** Opaque identifier for a turn (one user→assistant cycle). */
-export type TurnId = string & { readonly __brand: "TurnId" };
-
-/** Opaque identifier for a step (one LLM round-trip within a turn). */
-export type StepId = string & { readonly __brand: "StepId" };
-
-/**
- * A chunk is one ordered piece of a message — the atomic unit of the
- * append-only conversation log. Discriminated by `type`.
- */
-export type Chunk =
- | TextChunk
- | ThinkingChunk
- | ToolCallChunk
- | ToolResultChunk
- | ErrorChunk
- | SystemChunk;
-
-/** A piece of plain text content from the assistant or user. */
-export interface TextChunk {
- readonly type: "text";
- readonly text: string;
-}
-
-/** A piece of model reasoning / thinking content (e.g. extended thinking). */
-export interface ThinkingChunk {
- readonly type: "thinking";
- readonly text: string;
-}
-
-/**
- * A model's request to run a tool. The kernel routes by `name`; the tool
- * implementation never sees this directly — it receives parsed `input` via
- * `ToolContract.execute`.
- */
-export interface ToolCallChunk {
- readonly type: "tool-call";
- readonly toolCallId: string;
- readonly toolName: string;
- readonly input: unknown;
-}
-
-/**
- * The result of a tool execution, attributed to the originating tool-call id.
- * The kernel guarantees every tool-call chunk gets exactly one result chunk
- * (synthesized if interrupted — see reconcile).
- */
-export interface ToolResultChunk {
- readonly type: "tool-result";
- readonly toolCallId: string;
- readonly toolName: string;
- readonly content: string;
- readonly isError: boolean;
-}
-
-/** An error that occurred during generation or tool dispatch. */
-export interface ErrorChunk {
- readonly type: "error";
- readonly message: string;
- readonly code?: string;
-}
-
-/**
- * A system-injected message (e.g. system prompt, context assembly output).
- * Kept distinct from text so the log records provenance.
- */
-export interface SystemChunk {
- readonly type: "system";
- readonly text: string;
-}
-
-/**
- * A chat message: a role plus an ordered sequence of chunks. Messages are the
- * unit passed to and from the provider; chunks are the unit persisted and
- * rendered.
- */
-export interface ChatMessage {
- readonly role: Role;
- readonly chunks: readonly Chunk[];
-}
+export type {
+ ChatMessage,
+ Chunk,
+ ErrorChunk,
+ Role,
+ StepId,
+ SystemChunk,
+ TextChunk,
+ ThinkingChunk,
+ ToolCallChunk,
+ ToolResultChunk,
+ TurnId,
+} from "@dispatch/wire";