Entry
Typed entry kinds. An entry kind names the kind of transcript entries and types their data. The built-in kinds
are written by submissions, generation, tools, resets and compaction.
import { Entry, type Ids, type Records } from "@effective-harness/core"import * as Effect from "effect/Effect"import * as Schema from "effect/Schema"
declare const conversationId: Ids.ConversationIddeclare const record: Records.EntryRecord
const Note = Entry.make("app.note", Schema.Struct({ from: Schema.String }))const program = Effect.gen(function* () { const note = yield* Entry.append(Note, conversationId, { data: { from: "me" } }) if (Note.is(record)) record.data.from})Since v0.0.0
Assistant
Section titled “Assistant”A model answer with any stop reason: model is [AssistantMessage]. Written by generation.
Signature
declare const Assistant: Kind<never>Since v0.0.0
Compaction
Section titled “Compaction”A compaction summary: model is [UserMessage] with the wrapped summary, head the first kept entry. Written by
compaction tasks, directly or through a write submission.
Signature
declare const Compaction: Kind<unknown>Since v0.0.0
Draft (type alias)
Section titled “Draft (type alias)”What append writes for a typed kind.
Signature
type Draft<D> = { readonly model?: ReadonlyArray<Message.Message> readonly head?: EntryId | "self" readonly edits?: ReadonlyArray<ContextEdit>} & ([D] extends [never] ? { readonly data?: never } : { readonly data: D })Since v0.0.0
Kind (interface)
Section titled “Kind (interface)”Signature
export interface Kind<D = never> { readonly kind: string /** The codec of `data`; absent for a kind without data. */ readonly data: Schema.Codec<D, Json> | undefined /** Whether the entry has this kind. Narrows the type of `data`. */ readonly is: (entry: EntryRecord | undefined) => entry is EntryRecord & Typed<D>}Since v0.0.0
Start of a new context: head: "self", with an optional handoff [UserMessage].
Signature
declare const Reset: Kind<never>Since v0.0.0
System
Section titled “System”A positional prompt and tool change: model is [SystemMessage] with empty content.
Signature
declare const System: Kind<never>Since v0.0.0
ToolResult
Section titled “ToolResult”A tool call’s result: model is [ToolResultMessage]. Written by tool tasks.
Signature
declare const ToolResult: Kind<never>Since v0.0.0
Typed (type alias)
Section titled “Typed (type alias)”An entry whose data has type D.
Signature
type Typed<D> = Omit<EntryRecord, "data"> & ([D] extends [never] ? { readonly data?: never } : { readonly data: D })Since v0.0.0
User input: model is [UserMessage]. Written by submissions.
Signature
declare const User: Kind<never>Since v0.0.0
append
Section titled “append”Append an entry of a typed kind.
Signature
declare const append: <D>(kind: Kind<D>, conversationId: ConversationId, draft: Draft<D>) => anySince v0.0.0
Read an entry of a typed kind in a transaction; None when absent or of another kind.
Signature
declare const get: <D>(kind: Kind<D>, id: EntryId) => anySince v0.0.0
Define an entry kind; with a schema, its data is typed and stored as the schema’s JSON encoding.
Signature
declare const make: { (kind: string): Kind<never> <D>(kind: string, data: Schema.Codec<D, any, never, never>): Kind<D>}Since v0.0.0
messages
Section titled “messages”The model messages of an entry, typed.
Signature
declare const messages: (entry: EntryRecord | undefined) => ReadonlyArray<Message.Message>Since v0.0.0