Skip to content

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.ConversationId
declare 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


A model answer with any stop reason: model is [AssistantMessage]. Written by generation.

Signature

declare const Assistant: Kind<never>

Source

Since v0.0.0

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>

Source

Since v0.0.0

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 })

Source

Since v0.0.0

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>
}

Source

Since v0.0.0

Start of a new context: head: "self", with an optional handoff [UserMessage].

Signature

declare const Reset: Kind<never>

Source

Since v0.0.0

A positional prompt and tool change: model is [SystemMessage] with empty content.

Signature

declare const System: Kind<never>

Source

Since v0.0.0

A tool call’s result: model is [ToolResultMessage]. Written by tool tasks.

Signature

declare const ToolResult: Kind<never>

Source

Since v0.0.0

An entry whose data has type D.

Signature

type Typed<D> = Omit<EntryRecord, "data"> & ([D] extends [never] ? { readonly data?: never } : { readonly data: D })

Source

Since v0.0.0

User input: model is [UserMessage]. Written by submissions.

Signature

declare const User: Kind<never>

Source

Since v0.0.0

Append an entry of a typed kind.

Signature

declare const append: <D>(kind: Kind<D>, conversationId: ConversationId, draft: Draft<D>) => any

Source

Since 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) => any

Source

Since 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>
}

Source

Since v0.0.0

The model messages of an entry, typed.

Signature

declare const messages: (entry: EntryRecord | undefined) => ReadonlyArray<Message.Message>

Source

Since v0.0.0