UNPKG

trellis

Version:

Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications

151 lines 6 kB
import { type AttestationTarget } from './project.js'; export interface JournalMeta { format: 'jsonl'; tailHash: string; byteLength: number; lineCount: number; } /** One ledger hosted by a remote sprite (discovery / clone target). */ export interface RemoteRepoInfo { repoId: string; /** Owner entity id (`identity:<did>`) — ADR 0032 identity-addressed discovery. */ owner?: string; /** Repo slug scoped under the owner (`{peer}/{repo}`). */ name?: string; slug?: string; tailHash?: string; byteLength?: number; lineCount?: number; updatedAt?: string; } export interface RemotePeerConfig { url: string; repoId: string; name?: string; lastAckHash?: string; lastAckAt?: string; /** Owner entity id + repo slug (ADR 0032) — pushed so the sprite indexes identity. */ owner?: string; repo?: string; } export interface RemoteConfigFile { default?: RemotePeerConfig; [name: string]: RemotePeerConfig | undefined; } export interface RemoteSecrets { apiKey?: string; } export interface HttpResponse { status: number; body: string; } export interface HttpTransport { get(url: string, headers?: Record<string, string>): Promise<HttpResponse>; post(url: string, body: unknown, headers?: Record<string, string>): Promise<HttpResponse>; } export interface RemoteStatus { local: JournalMeta | null; remote: JournalMeta | null; synced: boolean; diverged: boolean; } export interface PushResult { pushed: boolean; tailHash: string; previousTail?: string; } export interface PullResult { path: string; tailHash: string; lineCount: number; } export declare function defaultFetchTransport(): HttpTransport; export declare function trellisDir(rootPath: string): string; export declare function opsPathForRoot(rootPath: string): string; export declare function configPathForRoot(rootPath: string): string; export declare function secretsPathForRoot(rootPath: string): string; export declare function readRemoteSecrets(rootPath: string): RemoteSecrets; export declare function writeRemoteSecrets(rootPath: string, secrets: RemoteSecrets): void; export declare function readRemoteConfig(rootPath: string): RemoteConfigFile; /** Stable ledger identity persisted in `.trellis/config.json` (ADR 0031). */ export declare function readPersistedRepoId(rootPath: string): string | null; export declare function writeRemoteConfig(rootPath: string, remote: RemoteConfigFile): void; export declare function getDefaultRemote(rootPath: string): RemotePeerConfig | null; export declare function authHeaders(rootPath: string): Record<string, string>; export declare function readJournalMeta(opsPath: string): JournalMeta | null; export declare function fetchRemoteTail(peer: RemotePeerConfig, transport: HttpTransport, headers: Record<string, string>): Promise<JournalMeta | null>; export declare function listRemoteRepos(peer: RemotePeerConfig, transport?: HttpTransport, headers?: Record<string, string>): Promise<RemoteRepoInfo[]>; export declare function remoteStatus(rootPath: string, transport?: HttpTransport): Promise<RemoteStatus>; export declare function pushRemoteLedger(rootPath: string, transport?: HttpTransport, opts?: { dryRun?: boolean; }): Promise<PushResult>; export declare function pullRemoteLedger(rootPath: string, transport?: HttpTransport, opts?: { to?: string; }): Promise<PullResult>; export declare function validateJsonl(raw: string): void; export declare function tailIsNewer(a: string, b: string): boolean; export declare function installPulledOps(rootPath: string, opts?: { from?: string; force?: boolean; }): { installed: boolean; from: string; backup?: string; }; /** Read the persisted `project` metadata block (owner/name/kind) from config. */ export declare function readPersistedProject(rootPath: string): { owner?: string; name?: string; kind?: string; }; export declare function addRemote(rootPath: string, url: string, opts?: { name?: string; repoId?: string; apiKey?: string; owner?: string; repo?: string; }): RemotePeerConfig; export interface CloneOptions { /** Override repo discovery — must match a ledger hosted by the remote. */ repoId?: string; apiKey?: string; /** Git URL for the byte tier; cloned into `destDir` before materialize. */ gitUrl?: string; /** Skip worktree materialization — chain + config only. */ opsOnly?: boolean; /** * Identity-addressed clone (ADR 0032): when set, the ledger's repo * attestation is verified against the person's public key before the * checkpoint is accepted, and the owner/name are persisted to config. */ expected?: AttestationTarget; } export interface CloneResult { repoId: string; tailHash: string; lineCount: number; opsPath: string; materialized: boolean; /** Owner entity id + repo slug, when attested/known. */ owner?: string; name?: string; } /** Fresh local `.trellis/` initialized from a remote sprite's latest checkpoint (ADR 0031). */ export declare function cloneRemoteLedger(url: string, destDir: string, opts?: CloneOptions, transport?: HttpTransport): Promise<CloneResult>; export declare function remoteAckWindowMs(): number; export declare function hasRecentRemoteAck(rootPath: string): boolean; export declare function assertRecentRemoteAckForRepair(rootPath: string, opts?: { iKnow?: boolean; confirmDestructive?: boolean; }): void; /** In-memory sprite for tests. */ export declare class MemoryRemoteSprite implements HttpTransport { private tips; private checkpoints; private projectMeta; get(url: string): Promise<HttpResponse>; post(url: string, body: unknown): Promise<HttpResponse>; /** Test helper: set remote ahead of local without push from client. */ seedRemote(repoId: string, meta: JournalMeta, checkpoint: string): void; } //# sourceMappingURL=oplog-remote.d.ts.map