Skip to content

Harness

The Harness: a Session with the built-in conversation creation hook, the scheduler, the settings, and the application’s registry wired together.

import { type Extension, Harness, MemoryStorage, Registry } from "@effective-harness/core"
import * as Layer from "effect/Layer"
declare const Files: Extension.Extension
const HarnessLive = Harness.layer({ settings: { toolExecution: "sequential" } }).pipe(
Layer.provideMerge(Registry.layer([Files])),
Layer.provideMerge(MemoryStorage.layer)
)

Every commit that creates or forks a conversation, through Conversation or a raw Tx, runs the built-in creation hook: the conversation’s pi.agent (a fork keeps its asOf copy, a task-owned conversation copies its owner’s, an ownerless one starts empty), then options.conversationCreated.

Since v0.0.0


Signature

declare class Harness

Source

Since v0.0.0

Signature

export interface HarnessShape {
readonly report: (cause: Cause.Cause<unknown>) => Effect.Effect<void>
/** Admit a submission in one commit; see `Conversation.submit`. */
readonly submit: (
conversationId: ConversationId,
draft: SubmissionDraft
) => Effect.Effect<SubmissionId, CommitError | ConversationBusy>
/** Start a manual compaction in one commit; see `Conversation.compact`. */
readonly compact: (conversationId: ConversationId, instructions?: string) => Effect.Effect<TaskId, CommitError>
}

Source

Since v0.0.0

Signature

export interface Options {
readonly settings?: Settings.HarnessSettings
/** The models agents may select. Default: none. */
readonly models?: Iterable<ModelCatalog.CatalogModel>
/** How conversations get an execution environment. Default: none (`noEnv`). */
readonly env?: Layer.Layer<ExecEnv.ExecEnvBuilder>
/** Runs in every commit that creates or forks a conversation, after the built-in creation hook. */
readonly conversationCreated?: (record: ConversationRecord) => Effect.Effect<void, WriteError, Tx>
/** Start scheduling when the layer is built. Default `true`. */
readonly resume?: boolean
/** How many task invocations run at once. Default: unlimited. */
readonly concurrency?: number
/** Failures the Harness cannot surface otherwise. Default: log a warning. */
readonly report?: (cause: Cause.Cause<unknown>) => Effect.Effect<void>
}

Source

Since v0.0.0

The Harness over the Storage and Registry in context. Also provides Session, Scheduler, Settings, TaskDispatcher, ModelCatalog, ExecEnvBuilder and Submissions. Closing the layer’s scope closes it: every invocation is interrupted, nothing is written, and the work resumes when the storage is reopened.

Signature

declare const layer: (
options?: Options
) => Layer.Layer<
| Harness
| Session.Session
| Scheduler.Scheduler
| Settings.Settings
| TaskDispatcher.TaskDispatcher
| ModelCatalog.ModelCatalog
| ExecEnv.ExecEnvBuilder
| Submission.Submissions,
CommitError,
Storage | Registry
>

Source

Since v0.0.0

No execution environment: the default when the host provides no ExecEnvBuilder.

Signature

declare const noEnv: Layer.Layer<ExecEnv.ExecEnvBuilder>

Source

Since v0.0.0