feat(chord): Chord v2 is the package's root

src/next is src (the main export), src/next-node is src/node with short subpaths (/http, /workers, /plugins,
/plugins/runtime, /app, /surfaces, /web, /react, /tui, /tui/launcher); the foundations get /json and /watch;
Chord v1 moves to src/old (/old, /old/node) until p2 runs on v2; tests and docs move likewise (test/, docs/,
test/old, docs/old). Durable and env import the foundations from their subpaths.
This commit is contained in:
Mario Zechner 2026-11-02 22:36:54 +00:00
parent 0a4fad5489
commit e9c0ff4d84
966 changed files with 2968 additions and 2804 deletions

View file

@ -518,7 +518,7 @@ const resumed = await root.watch(context, transcript.resume);
Entries never change once committed, so a merge only adds; one that adds nothing returns the same `items` array. See `test/examples/31-transcript.ts`.
Watches are Chord's `WatchHandle` (exported by `@earendil-works/chord`; Durable re-exports it). The listener gets one `WatchCall` per call, tagged by `kind`, and the newest commit's context: `{ kind: "value", value, ops, retired }`. Chord's watches also have `{ kind: "failed", error }` calls for failures a source recovers from; Durable's failures are final, so a Durable watch never sends one and ends instead. A watch ends once, and `closed` (or `stop()`) gives a `WatchEnd` tagged by `kind`: `stopped`, `aborted` (its acquisition context was aborted), `ended` (the Harness closed, or a task document's task ended), `listener_error`, or `failed` (the Harness failed). An ended watch keeps its last value and no longer references the Harness.
Watches are Chord's `WatchHandle` (exported by `@earendil-works/chord/watch`; Durable re-exports it). The listener gets one `WatchCall` per call, tagged by `kind`, and the newest commit's context: `{ kind: "value", value, ops, retired }`. Chord's watches also have `{ kind: "failed", error }` calls for failures a source recovers from; Durable's failures are final, so a Durable watch never sends one and ends instead. A watch ends once, and `closed` (or `stop()`) gives a `WatchEnd` tagged by `kind`: `stopped`, `aborted` (its acquisition context was aborted), `ended` (the Harness closed, or a task document's task ended), `listener_error`, or `failed` (the Harness failed). An ended watch keeps its last value and no longer references the Harness.
Adapters that must change in the same step as Durable's memory, such as a Chord source over a view, attach a synchronous observer instead of a watch: `harness.observeConversation(id, observer, context)`, `harness.observeTaskGraph(observer, context)`, and `harness.observeDoc(token, ...scope, observer, context)` return the current `value` and `detach()`, and call `observer.advance(call, context)` with every later change as a `WatchCall` (always a `value` call), unfolded, as memory adopts it: inside the storage's commit for a stored commit, at once for a deferred one (before it is stored). A document observer gets one call per change at its address, so a commit that retires and recreates the document gives two; the task graph also advances without a commit when a registry change alters a task's `blocked` reason. A change can arrive before the `observeXXX()` promise resolves; its ops apply from the observation's `value`. `observer.end(end)` comes once with a `WatchEnd`: `ended` when the Harness closes or, for a task document, right after the retirement of the commit that ends its task, `failed` when the Harness fails. `advance` only records the change: no awaits, no Harness calls, no throws, and quick, since every commit waits for it. One that throws (or returns a rejected promise) is reported, detached, and ended `listener_error`. Watches are built on these observers.

View file

@ -4,16 +4,10 @@
It uses existing package types as follows:
```ts
import type {
Context,
Draft,
JsonRepresentation,
JsonValue,
WatchCall,
WatchEnd,
WatchHandle,
} from "@earendil-works/chord";
import type { Op } from "@earendil-works/chord/delta";
import type { Context } from "@earendil-works/chord/context";
import type { Draft, Op } from "@earendil-works/chord/delta";
import type { JsonRepresentation, JsonValue } from "@earendil-works/chord/json";
import type { WatchCall, WatchEnd, WatchHandle } from "@earendil-works/chord/watch";
import type {
AssistantMessage,
CacheRetention,
@ -5381,7 +5375,7 @@ aborted directly (section 8.3).
### 9.1 Watches
Durable exposes committed state only through watches: Chord's `WatchHandle`
and its end type `WatchEnd`, exported by `@earendil-works/chord` (Durable
and its end type `WatchEnd`, exported by `@earendil-works/chord/watch` (Durable
re-exports both):
```ts

View file

@ -34,8 +34,9 @@
* or when the script diverges: it makes another call, or calls in another order, than the journal says. Each ends the
* call with an error result.
*/
import { type Context, copyJson, type JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { ownedSlice } from "@earendil-works/chord/delta";
import { copyJson, type JsonValue } from "@earendil-works/chord/json";
import type { TextContent } from "@earendil-works/pi-ai";
import { toCodemodeIdentifier } from "@earendil-works/pi-codemode/declarations";
import type {

View file

@ -7,7 +7,8 @@
* tool listings): a nested durable call with its own task, live row, abort, usage accounting, and replay policy. The
* code mode tool turns a script's call of the global into a call of that tool.
*/
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type {
AnyModel,
ClassifierContext,

View file

@ -1,5 +1,5 @@
import { copyJson, type JsonValue } from "@earendil-works/chord";
import type { Op } from "@earendil-works/chord/delta";
import { copyJson, type JsonValue } from "@earendil-works/chord/json";
import { idFromNumber } from "./ids.ts";
import type {
CheckpointInfo,

View file

@ -1,4 +1,4 @@
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import type { CompactionReason, ToolDiagnostic } from "./harness/types.ts";
import type { Entry, EntryRecord, TypedEntry } from "./types.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
/** Result of a fallible operation. Expected failures are returned instead of thrown. */
export type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };

View file

@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
import { type FSWatcher, watch as fsWatch, type Stats } from "node:fs";
import { lstat, readdir, readFile, stat, statfs } from "node:fs/promises";
import { dirname, relative, sep } from "node:path";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { type FileChange, FileError, type FileWatcher, type WatchTarget } from "./index.ts";
/** How `NodeExecutionEnv` watches. */

View file

@ -20,7 +20,7 @@ import {
import { homedir, constants as osConstants, tmpdir } from "node:os";
import { basename, isAbsolute, join, resolve, win32 } from "node:path";
import { fileURLToPath } from "node:url";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { StreamDecoder } from "./decode.ts";
import {
type BinaryReader,

View file

@ -1,4 +1,5 @@
import { copyJson, type Draft } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import { copyJson } from "@earendil-works/chord/json";
import { defineDoc } from "../documents.ts";
import { documentRetention, persistWithin } from "../session/session.ts";
import type { ConversationId, ConversationRecord, Tx } from "../types.ts";

View file

@ -1,4 +1,5 @@
import type { Context, Draft } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { Draft } from "@earendil-works/chord/delta";
import type { AssistantMessage, Message, ModelThinkingLevel, SimpleStreamOptions } from "@earendil-works/pi-ai";
import { calculateContextTokens, estimateMessageTokens } from "@earendil-works/pi-ai/utils/estimate";
import { isRetryableAssistantError, retryDelayMs } from "@earendil-works/pi-ai/utils/retry";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { AssistantMessage, Message, ToolCall, ToolResultMessage } from "@earendil-works/pi-ai";
import { SystemEntry } from "../entries.ts";
import { idFromNumber } from "../ids.ts";

View file

@ -1,4 +1,4 @@
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import type { Task } from "../types.ts";
import type {
AnyTask,

View file

@ -1,4 +1,6 @@
import { type Context, copyJson, type Draft, type JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { Draft } from "@earendil-works/chord/delta";
import { copyJson, type JsonValue } from "@earendil-works/chord/json";
import type {
Api,
AssistantMessage,

View file

@ -1,5 +1,6 @@
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { withAbortSignal, withoutAbortSignal } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type { Models } from "@earendil-works/pi-ai";
import {
type ClientIdentity,

View file

@ -1,4 +1,5 @@
import { copyJson, type Draft, type JsonRepresentation } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import { copyJson, type JsonRepresentation } from "@earendil-works/chord/json";
import { defineDoc } from "../documents.ts";
import { UserEntry } from "../entries.ts";
import type { ConversationId, EntryDraft, EntryId, EntryRecord, JsonObject, SubmissionId, Tx } from "../types.ts";

View file

@ -1,5 +1,5 @@
import type { JsonValue } from "@earendil-works/chord";
import { appendText, type Draft } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
/** How `assignJson()` writes one value instead of assigning it leaf by leaf. */
export type AssignPlan =

View file

@ -1,4 +1,5 @@
import type { Draft, JsonRepresentation, JsonValue } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import type { JsonRepresentation, JsonValue } from "@earendil-works/chord/json";
import type { AssistantMessage, Usage } from "@earendil-works/pi-ai";
import { defineDoc } from "../documents.ts";
import type { Transaction } from "../session/transaction.ts";

View file

@ -1,6 +1,7 @@
// What a streamed answer changed in its partial message between two partial commits, so a commit costs the new text.
import type { JsonRepresentation, JsonValue } from "@earendil-works/chord";
import { appendText, type Draft } from "@earendil-works/chord/delta";
import type { JsonRepresentation, JsonValue } from "@earendil-works/chord/json";
import type { AssistantMessage, AssistantMessageEvent, ToolCall } from "@earendil-works/pi-ai";
import { type JsonChange, StreamingJsonParser } from "@earendil-works/pi-ai/utils/streaming-json";
import { type AssignPlan, assignJson } from "./json.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { Message, SystemMessage, Tool, ToolReference } from "@earendil-works/pi-ai";
import { declarationsEqual, getCurrentTools, toToolDeclaration } from "@earendil-works/pi-ai/utils/transcript";
import { SystemEntry } from "../entries.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { uuidv7 } from "@earendil-works/pi-ai/utils/uuid";
import { defineDoc } from "../documents.ts";
import type { TaskRuntime } from "../types.ts";

View file

@ -1,8 +1,8 @@
// A Harness's registry over a Chord registry (Chord v2 slice 8 §5): the composed value of p3's extensions registry,
// read as Durable's `RegistryReader`.
import type { RegistryValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { RegistryValue } from "@earendil-works/chord/next";
import type { RegistryReader, RegistrySnapshot, ToolRegistration } from "./types.ts";
/**

View file

@ -1,6 +1,12 @@
import { type Context, copyJson, type JsonValue } from "@earendil-works/chord";
import { awaitWithContext, withAbortSignal, withoutAbortSignal, withTelemetry } from "@earendil-works/chord/context";
import {
awaitWithContext,
type Context,
withAbortSignal,
withoutAbortSignal,
withTelemetry,
} from "@earendil-works/chord/context";
import { ownedSlice } from "@earendil-works/chord/delta";
import { copyJson, type JsonValue } from "@earendil-works/chord/json";
import type { Models } from "@earendil-works/pi-ai";
import {
createTypedMetrics,

View file

@ -1,5 +1,5 @@
import { type Context, copyJson, type JsonRepresentation } from "@earendil-works/chord";
import { withTelemetry } from "@earendil-works/chord/context";
import { type Context, withTelemetry } from "@earendil-works/chord/context";
import { copyJson, type JsonRepresentation } from "@earendil-works/chord/json";
import {
createTypedSpanStarter,
NOOP_TELEMETRY_CONTEXT,

View file

@ -1,6 +1,7 @@
import { type Context, type JsonValue, Watch, type WatchCall, type WatchHandle } from "@earendil-works/chord";
import { BACKGROUND_CONTEXT, withoutAbortSignal } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT, type Context, withoutAbortSignal } from "@earendil-works/chord/context";
import { applyImmutable, type Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { Watch, type WatchCall, type WatchHandle } from "@earendil-works/chord/watch";
import {
closeEndOf,
closeEnds,

View file

@ -1,6 +1,6 @@
import { type Context, copyJson, type Draft, type JsonRepresentation, type JsonValue } from "@earendil-works/chord";
import { awaitWithContext } from "@earendil-works/chord/context";
import { overlap, ownedSlice } from "@earendil-works/chord/delta";
import { awaitWithContext, type Context } from "@earendil-works/chord/context";
import { type Draft, overlap, ownedSlice } from "@earendil-works/chord/delta";
import { copyJson, type JsonRepresentation, type JsonValue } from "@earendil-works/chord/json";
import {
boundOutput,
OutputBuffer,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { idFromNumber } from "../ids.ts";
import type { Cursor, EntryId, EntryQuery, EntryRecord, Page } from "../types.ts";
import type { ConversationView, ConversationWindow } from "./view.ts";

View file

@ -1,4 +1,6 @@
import type { Context, JsonValue, WatchHandle } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type { WatchHandle } from "@earendil-works/chord/watch";
import type {
Api,
AssistantMessage,

View file

@ -1,4 +1,5 @@
import { copyJson, type Draft, type JsonRepresentation } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import { copyJson, type JsonRepresentation } from "@earendil-works/chord/json";
import type { Usage } from "@earendil-works/pi-ai";
import { defineDoc } from "../documents.ts";
import type { ConversationId, Tx } from "../types.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { SessionFailed } from "../errors.ts";
import type { ConversationId, Cursor, EntryQuery, Page } from "../types.ts";

View file

@ -1,13 +1,7 @@
import {
type Context,
type JsonValue,
Watch,
type WatchCall,
type WatchEnd,
type WatchHandle,
} from "@earendil-works/chord";
import { withoutAbortSignal } from "@earendil-works/chord/context";
import { type Context, withoutAbortSignal } from "@earendil-works/chord/context";
import { applyImmutable, type NonEmptyPath, type Op, type Path } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { Watch, type WatchCall, type WatchEnd, type WatchHandle } from "@earendil-works/chord/watch";
import { idFromNumber } from "../ids.ts";
import {
closeEndOf,

View file

@ -1,4 +1,4 @@
export type { NativeWatchCall, WatchCall, WatchEnd, WatchHandle } from "@earendil-works/chord";
export type { NativeWatchCall, WatchCall, WatchEnd, WatchHandle } from "@earendil-works/chord/watch";
export { defineDoc, defineDocFamily } from "./documents.ts";
export {
AssistantEntry,

View file

@ -1,5 +1,6 @@
// Write-through cache of hot Storage record reads for the Session that owns the Storage.
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type {
CommitResult,
ConversationId,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { addressId } from "../documents.ts";
import type {
ConversationId,

View file

@ -1,5 +1,6 @@
// The keys of the Session line: what a commit writes and a job reads, so a read of an unpublished write waits for it.
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { addressId } from "../documents.ts";
import type {
CommitResult,

View file

@ -1,6 +1,7 @@
import { type Context, type JsonValue, Watch, type WatchEnd } from "@earendil-works/chord";
import { awaitWithContext, BACKGROUND_CONTEXT, withoutAbortSignal } from "@earendil-works/chord/context";
import { awaitWithContext, BACKGROUND_CONTEXT, type Context, withoutAbortSignal } from "@earendil-works/chord/context";
import { type Op, PendingOps, track } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { Watch, type WatchEnd } from "@earendil-works/chord/watch";
import type { SpanAttributes } from "@earendil-works/pi-telemetry";
import {
type AnyDocToken,

View file

@ -1,6 +1,14 @@
import { type Context, copyJson, type Draft, type JsonValue } from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { type Change, type Op, type PendingOps, type Prepared, type Tracker, track } from "@earendil-works/chord/delta";
import { BACKGROUND_CONTEXT, type Context } from "@earendil-works/chord/context";
import {
type Change,
type Draft,
type Op,
type PendingOps,
type Prepared,
type Tracker,
track,
} from "@earendil-works/chord/delta";
import { copyJson, type JsonValue } from "@earendil-works/chord/json";
import type { TelemetryCarrier } from "@earendil-works/pi-telemetry";
import {
type AnyDocDefinition,

View file

@ -1,5 +1,5 @@
// The Session's writer: commits the mutation line admitted, stored in batches off the line and published in line order.
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { withoutAbortSignal } from "@earendil-works/chord/context";
import { SessionFailed } from "../errors.ts";
import type { CommitResult, Seq, StorageWrite } from "../types.ts";

View file

@ -1,7 +1,8 @@
/// <reference lib="dom" />
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { apply, type Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { StorageRequestError } from "../errors.ts";
import { idFromNumber, seqFromNumber } from "../ids.ts";
import type {

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { NodeExecutionEnv } from "../../env/node.ts";
import { JsonlStorage, type JsonlStorageOptions } from "./storage.ts";

View file

@ -1,4 +1,5 @@
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type { FileError, FileSystem } from "../../env/index.ts";
import { StorageRequestError } from "../../errors.ts";
import { idFromNumber, seqFromNumber } from "../../ids.ts";

View file

@ -1,5 +1,6 @@
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { applyImmutableBatches, type Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { StorageRequestError } from "../errors.ts";
import { idFromNumber, seqFromNumber } from "../ids.ts";
import type {

View file

@ -1,5 +1,6 @@
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { apply, type Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import type { SqliteDatabase, SqliteExecutor, SqliteValue } from "@earendil-works/chord/sqlite";
import { StorageRequestError } from "../../errors.ts";
import { idFromNumber, seqFromNumber } from "../../ids.ts";

View file

@ -5,7 +5,6 @@
// documents in two passes, existing ones first (their content, then their retirement, which frees the addresses this
// commit's creations take), then the creations and copies.
import type { Context, JsonValue } from "@earendil-works/chord";
import {
type EncodedRow,
type DocumentContent as EngineContent,
@ -20,7 +19,9 @@ import {
type Step,
type StoreWrite,
writeContent,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { StorageRequestError } from "../../errors.ts";
import type {
DocumentContent,

View file

@ -11,7 +11,7 @@ import {
type DocumentRecord as EngineRecord,
loadContent,
readDocumentEntry,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import type { SqliteExecutor } from "@earendil-works/chord/sqlite";
import { seqFromNumber } from "../../ids.ts";
import type {

View file

@ -2,8 +2,8 @@
// into SQL over the declared tables: no SQL is rendered per call, and a read selects only the record cell (by id, an
// entry's commit seq too; each column returned costs) and parses one JSON text per record, as `SqliteStorage`'s do.
import type { Context } from "@earendil-works/chord";
import type { Order, OwnerTable, WhereNode } from "@earendil-works/chord/next";
import type { Order, OwnerTable, WhereNode } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { SqliteExecutor, SqliteValue } from "@earendil-works/chord/sqlite";
import type { CommitTables } from "./commit.ts";

View file

@ -2,7 +2,6 @@
// allocator), commits as one composite write of the store's commit step, and the reads, each one guarded read of the
// store (several queries at one state in a read transaction), its request errors in a tagged result told after it.
import type { Context, JsonValue } from "@earendil-works/chord";
import {
type ChordStore,
type Claimant,
@ -11,7 +10,9 @@ import {
type SeriesCommit,
type Store,
StoreOwnerTables,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type { SqliteExecutor } from "@earendil-works/chord/sqlite";
import { StorageRequestError } from "../../errors.ts";
import { idFromNumber, seqFromNumber } from "../../ids.ts";

View file

@ -3,8 +3,8 @@
// Durable's JSON encoding; index columns are never `opt`, so absent values take sentinels no encoded value can be
// (`0` for an absent owner, which is never an id; `""` for an absent request id: an encoded string starts with `"`).
import type { JsonValue } from "@earendil-works/chord";
import { defineTable, int, json, str, unknown } from "@earendil-works/chord/next";
import { defineTable, int, json, str, unknown } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import type { ConversationRecord, EntryRecord, SubmissionRecord, TaskRecord } from "../../types.ts";
/** A record as one `json(...)` cell. */

View file

@ -1,6 +1,6 @@
// One batch through `Storage.commit()`, for tests and suites that seed or write a storage directly.
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { Seq, Storage, StorageWrite } from "../types.ts";
/** Commits `writes` as one batch and resolves with its seq; rejects with the refusal if the storage refused it. */

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT, withAbortSignal } from "@earendil-works/chord/context";
import {
type ExecutionEnv,

View file

@ -1,5 +1,5 @@
import type { JsonValue } from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type {
ConversationId,
DocumentCreate,

View file

@ -1,6 +1,6 @@
import type { JsonValue } from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { idFromNumber } from "../ids.ts";
import {
type ConversationId,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { bool, num, obj, opt, type Static, str } from "@earendil-works/pi-schema";
import { defineTool } from "../harness/define.ts";
import type { ToolExecutionApi, ToolExecutionResult, ToolRegistration } from "../harness/types.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { type ExecutionEnv, getOrThrow } from "../env/index.ts";
/** Tail of the mutation chain of each file, keyed by file system id and canonical path. */

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { type ExecutionEnv, getOrThrow } from "../env/index.ts";
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { characterEnd } from "@earendil-works/chord/output";
import { lit, num, obj, opt, type Static, str, union } from "@earendil-works/pi-schema";
import {

View file

@ -1,5 +1,7 @@
import type { Context, Draft, JsonValue, WatchCall, WatchEnd, WatchHandle } from "@earendil-works/chord";
import type { Op } from "@earendil-works/chord/delta";
import type { Context } from "@earendil-works/chord/context";
import type { Draft, Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import type { WatchCall, WatchEnd, WatchHandle } from "@earendil-works/chord/watch";
import type { Message, Models } from "@earendil-works/pi-ai";
import type { TelemetryCarrier } from "@earendil-works/pi-telemetry";
import type { ExecutionEnv } from "./env/index.ts";

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
createModels,
type FauxProviderHandle,

View file

@ -1,7 +1,7 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
type AssistantImages,
type ClassifierResult,

View file

@ -1,7 +1,7 @@
import { mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { type AssistantMessage, fauxAssistantMessage, fauxText, fauxToolCall } from "@earendil-works/pi-ai";
import { type CodemodeRun, CodemodeSandbox } from "@earendil-works/pi-codemode";
import {

View file

@ -18,7 +18,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT as context } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai/models";
import { type Conversation, createRegistry, type EntryId, Harness, LiveDoc, type Storage } from "../src/index.ts";

View file

@ -5,7 +5,7 @@
// Run from packages/durable:
// node --conditions=source --experimental-strip-types test/examples/21-subagent-foreground.ts
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { AssistantMessage, FauxResponseStep } from "@earendil-works/pi-ai";
import { createModels } from "@earendil-works/pi-ai/models";

View file

@ -7,7 +7,6 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import {
createHost,
defineFacet,
@ -17,7 +16,8 @@ import {
openStore,
sqliteBackend,
str,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
import { createModels } from "@earendil-works/pi-ai";
import { createRegistry, Harness, ROOT_CONVERSATION_ID } from "../../src/index.ts";

View file

@ -5,7 +5,6 @@
// Run from packages/durable:
// node --conditions=source --experimental-strip-types test/examples/36-durable-views.ts
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import {
arr,
createHost,
@ -17,7 +16,8 @@ import {
openStore,
sqliteBackend,
str,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
import { createModels } from "@earendil-works/pi-ai";
import { createRegistry, Harness, ROOT_CONVERSATION_ID } from "../../src/index.ts";

View file

@ -6,7 +6,6 @@
// Run from packages/durable:
// node --conditions=source --experimental-strip-types test/examples/37-harness-registry.ts
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import {
arr,
createHost,
@ -19,7 +18,8 @@ import {
type RegistryTable,
sqliteBackend,
str,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
import { createModels } from "@earendil-works/pi-ai";
import {

View file

@ -1,7 +1,8 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Draft, JsonValue } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import { fauxAssistantMessage, fauxToolCall } from "@earendil-works/pi-ai";
import {
CompactionTask,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
type CommitResult,
createSession,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { createModels, type Message } from "@earendil-works/pi-ai";
import {
type ContextView,

View file

@ -1,6 +1,6 @@
// Group commit and the scheduler (docs/group-commit.md §6): decisions read the scheduler's memory in regions that
// wait for the unpublished commits whose keys they read, memberships written at admission, outcomes, and close.
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type ConversationId,
createRegistry,

View file

@ -1,8 +1,9 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { withAbortSignal } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { createModels, fauxAssistantMessage, fauxText, fauxToolCall } from "@earendil-works/pi-ai";
import {
type Conversation,

View file

@ -1,7 +1,7 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
type AssistantMessage,
fauxAssistantMessage,

View file

@ -1,9 +1,9 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import { withAbortSignal } from "@earendil-works/chord/context";
import { applyImmutable } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type AssistantMessage,
fauxAssistantMessage,

View file

@ -2,8 +2,8 @@
// document) and for task document watches, which end with their task.
import { setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import type { WatchCall } from "@earendil-works/chord";
import { withAbortSignal } from "@earendil-works/chord/context";
import type { WatchCall } from "@earendil-works/chord/watch";
import {
type ConversationView,
defineDoc,

View file

@ -1,5 +1,5 @@
import { copyJson } from "@earendil-works/chord";
import { type Op, track } from "@earendil-works/chord/delta";
import { copyJson } from "@earendil-works/chord/json";
import {
type AssistantMessage,
type AssistantMessageEvent,

View file

@ -1,4 +1,3 @@
import { BACKGROUND_CONTEXT as context } from "@earendil-works/chord/context";
import {
arr,
createHost,
@ -10,7 +9,8 @@ import {
type Native,
type RegistryTable,
str,
} from "@earendil-works/chord/next";
} from "@earendil-works/chord";
import { BACKGROUND_CONTEXT as context } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai/models";
import { describe, expect, it } from "vitest";
import {

View file

@ -1,5 +1,5 @@
import { runInNewContext } from "node:vm";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai";
import {
createRegistry,

View file

@ -1,7 +1,7 @@
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type AssistantMessage,
fauxAssistantMessage,

View file

@ -1,7 +1,8 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import {
fauxAssistantMessage,
fauxText,

View file

@ -1,8 +1,8 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import { applyImmutable, type Op } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type ConversationId,
type ConversationView,

View file

@ -1,7 +1,8 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { createModels } from "@earendil-works/pi-ai";
import {
createRegistry,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { withAbortSignal, withCancel } from "@earendil-works/chord/context";
import { createModels } from "@earendil-works/pi-ai";
import {

View file

@ -4,7 +4,7 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type AssistantMessage,
fauxAssistantMessage,

View file

@ -1,7 +1,7 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type AssistantMessage,
fauxAssistantMessage,

View file

@ -1,7 +1,7 @@
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type AssistantMessage,
type FauxResponseStep,

View file

@ -3,7 +3,7 @@
import { GCProfiler, getHeapStatistics, setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import type { Draft } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import { applyImmutable, type Op } from "@earendil-works/chord/delta";
import {
type AssistantMessage,

View file

@ -1,7 +1,8 @@
/// <reference lib="dom" />
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { registerStorageConformance } from "@earendil-works/pi-durable/testing";
import { IDBKeyRange as FakeIDBKeyRange, IDBObjectStore as FakeIDBObjectStore, IDBFactory } from "fake-indexeddb";
import { describe, expect, it, vi } from "vitest";

View file

@ -1,8 +1,9 @@
import { mkdtemp, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { basename, join } from "node:path";
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import { registerStorageConformance } from "@earendil-works/pi-durable/testing";
import { afterEach, describe, expect, it } from "vitest";
import { err, FileError, type FileSystem, type Result } from "../src/env/index.ts";

View file

@ -1,7 +1,7 @@
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { basename, join } from "node:path";
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
type CommitPublication,
type CommitResult,

View file

@ -1,4 +1,4 @@
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import { describe, expect, it } from "vitest";
import { idFromNumber } from "../src/ids.ts";
import { CachedStorage } from "../src/session/cached-storage.ts";

View file

@ -2,8 +2,8 @@
// each kind of listener then sees.
import { setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import type { JsonValue } from "@earendil-works/chord";
import { applyImmutable } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type CommitChange,
type CommitOptions,

View file

@ -1,4 +1,4 @@
import type { Draft } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import {
type ConversationId,
createSession,

View file

@ -1,4 +1,5 @@
import type { Draft, JsonValue } from "@earendil-works/chord";
import type { Draft } from "@earendil-works/chord/delta";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type ConversationId,
defineDoc,

View file

@ -1,6 +1,6 @@
// Group commit on the Session line (docs/group-commit.md): batching, gates, outcome fences, publication, failures per
// part, upkeep through the writer, backpressure, bounds, and a randomized interleaving against an oracle.
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
type CommitOptions,
type CommitResult,

View file

@ -1,8 +1,8 @@
// Tests for `Session.observeDoc()`, the synchronous observer of one document address that watches are built on.
import { setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import type { WatchCall, WatchEnd } from "@earendil-works/chord";
import { withAbortSignal } from "@earendil-works/chord/context";
import type { WatchCall, WatchEnd } from "@earendil-works/chord/watch";
import {
type CommitObserver,
type ConversationId,

View file

@ -1,4 +1,4 @@
import type { Context } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import {
type CommitChange,

View file

@ -1,4 +1,4 @@
import type { JsonValue } from "@earendil-works/chord";
import type { JsonValue } from "@earendil-works/chord/json";
import {
type ConversationId,
defineDoc,

View file

@ -1,6 +1,6 @@
import { setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import type { Context, WatchCall, WatchEnd } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import {
BACKGROUND_CONTEXT,
createContextKey,
@ -9,6 +9,7 @@ import {
withContextValue,
} from "@earendil-works/chord/context";
import { applyImmutable } from "@earendil-works/chord/delta";
import type { WatchCall, WatchEnd } from "@earendil-works/chord/watch";
import { type DocumentWatch, defineDoc, defineDocFamily, MemoryStorage } from "@earendil-works/pi-durable";
import { describe, expect, it } from "vitest";
import { SessionImpl } from "../src/session/session.ts";

View file

@ -4,7 +4,8 @@
* patterns end to end.
*/
import type { Context, Draft } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import type { Draft } from "@earendil-works/chord/delta";
import type { AssistantMessage, Models, ToolCall } from "@earendil-works/pi-ai";
import {
type Conversation,

View file

@ -2,8 +2,9 @@ import { mkdtemp, rm, stat } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { DatabaseSync } from "node:sqlite";
import type { Context, JsonValue } from "@earendil-works/chord";
import type { Context } from "@earendil-works/chord/context";
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
import type { JsonValue } from "@earendil-works/chord/json";
import type { SqliteDatabase } from "@earendil-works/chord/sqlite";
import { registerStorageConformance } from "@earendil-works/pi-durable/testing";
import { afterEach, describe, expect, it } from "vitest";

View file

@ -8,8 +8,8 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { setFlagsFromString } from "node:v8";
import { runInNewContext } from "node:vm";
import { type ChordStore, createHost, openStore, sqliteBackend } from "@earendil-works/chord";
import { BACKGROUND_CONTEXT, withTelemetry } from "@earendil-works/chord/context";
import { type ChordStore, createHost, openStore, sqliteBackend } from "@earendil-works/chord/next";
import type { SqliteDatabase, SqliteExecutor } from "@earendil-works/chord/sqlite";
import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
import { InMemoryTelemetryContext } from "@earendil-works/pi-telemetry";

Some files were not shown because too many files have changed in this diff Show more