@agentshouse/mdruntime-families 0.1.0-c8a9a2ed09538 → 0.1.0-c8d38a26efb97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/mdruntime/actions.d.ts +19 -0
  2. package/dist/mdruntime/adapter.d.ts +1 -0
  3. package/dist/mdruntime/bootstrap.d.ts +43 -0
  4. package/dist/mdruntime/cell.d.ts +5 -0
  5. package/dist/mdruntime/client.d.ts +7 -1
  6. package/dist/mdruntime/conversation.d.ts +1 -0
  7. package/dist/mdruntime/durability.d.ts +9 -0
  8. package/dist/mdruntime/holdings.d.ts +28 -0
  9. package/dist/mdruntime/install.d.ts +55 -0
  10. package/dist/mdruntime/listing.d.ts +52 -0
  11. package/dist/mdruntime/log.d.ts +5 -0
  12. package/dist/mdruntime/preparation.d.ts +19 -0
  13. package/dist/mdruntime/reach.d.ts +3 -1
  14. package/dist/mdruntime/reads.d.ts +1 -0
  15. package/dist/mdruntime/refresh.d.ts +26 -0
  16. package/dist/mdruntime/room-drafts.d.ts +7 -12
  17. package/dist/mdruntime/runtime.d.ts +41 -0
  18. package/dist/mdruntime/saves.d.ts +69 -0
  19. package/dist/mdruntime/seed.d.ts +3 -8
  20. package/dist/mdruntime/socket/admission.d.ts +6 -0
  21. package/dist/mdruntime/socket/answers.d.ts +5 -0
  22. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  23. package/dist/mdruntime/socket/rooms.d.ts +42 -0
  24. package/dist/mdruntime/socket/session.d.ts +38 -0
  25. package/dist/mdruntime/socket.d.ts +69 -0
  26. package/dist/mdruntime/store/readiness.d.ts +9 -0
  27. package/dist/mdruntime/store/room-held.d.ts +7 -0
  28. package/dist/mdruntime/store/space.d.ts +10 -0
  29. package/dist/mdruntime/store/watchers.d.ts +2 -0
  30. package/dist/mdruntime/store.d.ts +41 -0
  31. package/dist/mdruntime/{connection.d.ts → surface.d.ts} +25 -88
  32. package/dist/mdruntime/tables.d.ts +9 -1
  33. package/dist/mdruntime/transfer.d.ts +4 -0
  34. package/dist/mdruntime/turn.d.ts +8 -0
  35. package/dist/mdruntime/wire.d.ts +2 -1
  36. package/package.json +1 -1
@@ -0,0 +1,19 @@
1
+ import type { ConversationHistoryRequest } from './adapter.js';
2
+ import { type CallResult, type HistoryAnswer, type Resolution } from './outcome.js';
3
+ import type { Attempted } from './recovery.js';
4
+ import type { Runtime } from './runtime.js';
5
+ export type HistoryQuery = {
6
+ revision?: string;
7
+ pageToken?: string;
8
+ };
9
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
10
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
11
+ room: string;
12
+ path: string;
13
+ } | null>;
14
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
15
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, dispatching?: () => Promise<void>): Promise<CallResult>;
16
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
17
+ export declare function called(runtime: Runtime, name: string, input: unknown): Promise<CallResult>;
18
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
19
+ export declare function resendLater(runtime: Runtime): void;
@@ -526,6 +526,7 @@ export type Adapter = {
526
526
  readonly nameableRoomTypes?: readonly string[];
527
527
  readonly typedPaths?: readonly TypedPath[];
528
528
  readonly unkeptReads?: readonly string[];
529
+ readonly leadingReads?: readonly string[];
529
530
  authorize(): Promise<Authorization>;
530
531
  discover?(authorization: Authorization): Promise<DiscoverResult>;
531
532
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
@@ -0,0 +1,43 @@
1
+ import type { ModelState } from './model.js';
2
+ import type { Adapter, TypedPath, AdapterFailure, Authorization, BootstrapPart, DiscoveredRoom, NotReady, RetryableRefusal, RoomModels } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import type { InstallationStep } from './readiness.js';
5
+ import { type Refreshing } from './refresh.js';
6
+ import type { ReplicaRecord } from './replica.js';
7
+ import type { StagedPage, TransferRecord } from './store.js';
8
+ import { type Unconfirmed } from './transfer.js';
9
+ export type Bootstrapped = {
10
+ kind: 'staged';
11
+ record: ReplicaRecord;
12
+ refreshed: boolean;
13
+ };
14
+ export type BootstrapOutcome = Bootstrapped | Unconfirmed | NotReady | RetryableRefusal | AdapterFailure;
15
+ export type HeldModels = {
16
+ collection: ModelState;
17
+ };
18
+ export type Remodel = (models: RoomModels | undefined, held: HeldModels) => HeldModels;
19
+ export type Reads = Pick<Adapter, 'bootstrap' | 'refresh' | 'reached'>;
20
+ export type Arriving = {
21
+ at(bytes: number): void;
22
+ end(): void;
23
+ };
24
+ export type Resumed = {
25
+ readonly record: TransferRecord | null;
26
+ readonly staged: ReadonlySet<string>;
27
+ };
28
+ export type Staging = {
29
+ held(locator: string): TransferRecord | null;
30
+ turn(locator: string, step: InstallationStep): Promise<() => void>;
31
+ unqueued(): Promise<void>;
32
+ queued(text: number): () => void;
33
+ arriving(locator: string): Arriving;
34
+ readonly streamed: boolean;
35
+ stage(record: TransferRecord, page: StagedPage, composition: Composition): Promise<TransferRecord | null>;
36
+ resume(record: TransferRecord, parts: readonly BootstrapPart[], composition: Composition): Promise<Resumed | null>;
37
+ derive(locator: string, key: number, composition: Composition): Promise<boolean>;
38
+ refreshing(locator: string, key: number, composition: Composition): Promise<Refreshing>;
39
+ abandon(locator: string): Promise<void>;
40
+ setAside(locator: string): Promise<void>;
41
+ release(key: number): Promise<void>;
42
+ };
43
+ export declare function bootstrapRoom(adapter: Reads, authorization: Authorization, room: DiscoveredRoom, held: HeldModels, builtIn: ModelState, typedPaths: readonly TypedPath[], remodel: Remodel, continuing: () => boolean, staging: Staging): Promise<BootstrapOutcome>;
@@ -0,0 +1,5 @@
1
+ export type Cell<T> = {
2
+ now(): T;
3
+ set(change: Partial<T>): void;
4
+ };
5
+ export declare function createCell<T extends object>(first: T): Cell<T>;
@@ -1,11 +1,16 @@
1
1
  import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
2
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
+ import type { HistoryQuery } from './actions.js';
3
+ import type { AppRoom } from './listing.js';
4
+ import type { ConnectionRefusal } from './socket.js';
5
+ import type { RoomSchemas } from './surface.js';
6
+ import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
3
7
  import type { Member, ServiceMode } from './adapter.js';
4
8
  import type { UnsentWork } from './durability.js';
5
9
  import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
6
10
  import { type Observation } from './observation.js';
7
11
  import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
8
12
  import type { FiguresResult } from './figures.js';
13
+ import type { Holdings } from './holdings.js';
9
14
  import type { DocumentResult, GroupResult, PendingResult } from './query.js';
10
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
11
16
  import type { SearchRequest, SearchResult } from './search.js';
@@ -84,6 +89,7 @@ export type MdRuntimeClient = {
84
89
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
85
90
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
86
91
  (topic: 'figures'): Promise<Observation<FiguresResult>>;
92
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
87
93
  (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
88
94
  };
89
95
  reauthorize(): Promise<void>;
@@ -12,6 +12,7 @@ export type ConversationEntry = ConversationHeld & {
12
12
  agent: {
13
13
  identity: string;
14
14
  name: string;
15
+ retired: boolean;
15
16
  };
16
17
  name: string;
17
18
  created: string;
@@ -4,12 +4,21 @@ export type UnsentWork = {
4
4
  readonly kind: UnsentKind;
5
5
  readonly count: number;
6
6
  };
7
+ export type AppCode = {
8
+ readonly running: number;
9
+ readonly older: number;
10
+ };
11
+ export type HeldCode = {
12
+ readonly house: number | null;
13
+ readonly apps: readonly string[];
14
+ };
7
15
  export type RuntimeShell = {
8
16
  persistence: Persistence;
9
17
  generation: string | null;
10
18
  keepGeneration(value: string): void | Promise<void>;
11
19
  dropGeneration(): void | Promise<void>;
12
20
  cleanUp?(): Promise<number>;
21
+ measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
13
22
  reset(): Promise<void>;
14
23
  };
15
24
  export declare function refusedForSpace(error: unknown): boolean;
@@ -0,0 +1,28 @@
1
+ import type { AppCode } from './durability.js';
2
+ import type { GroupTotal, PendingResult } from './query.js';
3
+ import type { Deliver, Fail } from './reach.js';
4
+ import type { Runtime } from './runtime.js';
5
+ import type { OpenedRoom } from './tables.js';
6
+ export type RoomDocuments = {
7
+ readonly room: string;
8
+ readonly documents: GroupTotal;
9
+ };
10
+ export type HeldApp = ({
11
+ readonly app: string;
12
+ readonly state: 'measured';
13
+ } & AppCode) | {
14
+ readonly app: string;
15
+ readonly state: 'asking' | 'unknown';
16
+ };
17
+ export type Holdings = {
18
+ readonly rooms: readonly RoomDocuments[] | PendingResult;
19
+ readonly opened: GroupTotal & {
20
+ readonly rooms: readonly OpenedRoom[];
21
+ };
22
+ readonly apps: readonly HeldApp[];
23
+ readonly house: number | null;
24
+ readonly total: number | null;
25
+ readonly cleanUp: number | null;
26
+ };
27
+ export declare const CLEANED_TOPIC = "cleaned";
28
+ export declare function watchHoldings({ store, figures, shell }: Runtime, deliver: Deliver, fail: Fail): () => void;
@@ -0,0 +1,55 @@
1
+ import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
2
+ import { type Reads } from './bootstrap.js';
3
+ import type { Installation, RoomCoverage } from './readiness.js';
4
+ import { advancement, type Refresher } from './refresh.js';
5
+ import type { ReplicaRecord } from './replica.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import type { Live } from './socket.js';
8
+ import { type CoveredRoom, type InstallHold, type RuntimeStore, type Store } from './store.js';
9
+ import { type Unconfirmed } from './transfer.js';
10
+ type Standing = {
11
+ readonly key: number | null;
12
+ readonly confirmed: number;
13
+ };
14
+ export type Unheld = {
15
+ readonly staged: boolean;
16
+ };
17
+ export type Withheld = AdapterFailure | RetryableRefusal | NotReady | Unconfirmed;
18
+ type Landing = {
19
+ readonly kind: 'refreshed';
20
+ readonly from: Standing;
21
+ readonly remodelled: boolean;
22
+ } | {
23
+ readonly kind: 'bootstrapped';
24
+ readonly refreshed: boolean;
25
+ readonly from: Standing;
26
+ };
27
+ type Refreshed = {
28
+ kind: 'advanced';
29
+ record: ReplicaRecord;
30
+ from: Standing;
31
+ remodelled: boolean;
32
+ } | Exclude<Awaited<ReturnType<typeof advancement>>, {
33
+ kind: 'advanced';
34
+ }>;
35
+ export declare const ERASE_BATCH = 512;
36
+ export declare function installationOf(store: Store, coverage: readonly RoomCoverage[], held: ReadonlyMap<string, CoveredRoom>): Installation;
37
+ export declare function roomInFlight(store: Store, locator: string): boolean;
38
+ export declare function sweep({ store, socket, journal }: Runtime): void;
39
+ export declare function forgetInstall(store: Store, locator: string): void;
40
+ export declare function caughtUpTo(runtime: Runtime, locator: string): void;
41
+ export declare function catching(store: Store, locator: string): void;
42
+ export declare function confirmedAgain(store: Store, locator: string): void;
43
+ export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
44
+ export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
45
+ export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
46
+ export declare function replaced(store: Store, locators: readonly string[]): void;
47
+ export declare function reachedBy({ store, socket }: Runtime, locator: string, roomVersion: string): Promise<boolean>;
48
+ export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
49
+ export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
50
+ export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
51
+ export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
52
+ readonly kind: 'transport-uncertainty';
53
+ } | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
54
+ export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
55
+ export {};
@@ -0,0 +1,52 @@
1
+ import type { HeldRooms } from '@agentshouse/mdmodel';
2
+ import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import { type ModelState, type TypesResult } from './model.js';
5
+ import { type PortReach } from './reach.js';
6
+ import type { ReplicaRecord } from './replica.js';
7
+ import type { Runtime } from './runtime.js';
8
+ import type { RoomDeclaration } from './socket.js';
9
+ import type { Stored } from './store.js';
10
+ export type AppTypedSelection = {
11
+ roots: readonly string[];
12
+ model: TypesResult;
13
+ };
14
+ export type AppRoom = {
15
+ name: string;
16
+ locator: string;
17
+ handle: string;
18
+ operations: OperationScopes;
19
+ replica: ReplicaAdmission;
20
+ model: TypesResult;
21
+ typedSelection: AppTypedSelection | null;
22
+ providerOwnedPaths: readonly string[];
23
+ roomVersion: string | null;
24
+ documents: number;
25
+ synchronizationAvailable: boolean;
26
+ refusal: ProviderRefusal | null;
27
+ locked: boolean;
28
+ };
29
+ type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
30
+ type ListedEntry = ListedRoom & {
31
+ readonly documents: number;
32
+ };
33
+ export type Listing = ReadonlyMap<string, ListedEntry>;
34
+ export declare function modelIn({ socket }: Runtime, locator: string, stored: Stored | undefined): ModelState;
35
+ export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
36
+ export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
37
+ readonly room: RoomDeclaration;
38
+ readonly available: boolean;
39
+ } | undefined;
40
+ export declare function listedLocators({ store, socket }: Runtime, held: ReadonlyMap<string, unknown>): string[];
41
+ export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
42
+ export declare function listingNow(runtime: Runtime): Promise<Listing>;
43
+ export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
44
+ export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
45
+ export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
46
+ export declare function listHeld({ store, socket }: Runtime, locator: string): void;
47
+ export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
48
+ export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
49
+ export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
50
+ export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
51
+ export declare function name(runtime: Runtime, locator: string): Promise<void>;
52
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare function createLog(): {
2
+ record(event: string): void;
3
+ export(): string;
4
+ };
5
+ export type Log = ReturnType<typeof createLog>;
@@ -0,0 +1,19 @@
1
+ import type { PlanReach } from './query.js';
2
+ import { type PortReach } from './reach.js';
3
+ import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
4
+ import type { Runtime } from './runtime.js';
5
+ export type ReadinessPort = {
6
+ readonly target: string;
7
+ readonly code: CodeAvailability;
8
+ };
9
+ export type ReadinessWatch = {
10
+ readonly port: ReadinessPort;
11
+ readonly reach: PortReach | null;
12
+ readonly deliver: (readiness: Readiness) => void;
13
+ };
14
+ export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
15
+ export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
16
+ export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
17
+ export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
18
+ export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
19
+ export declare function filled(runtime: Runtime): void;
@@ -1,4 +1,6 @@
1
- import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
1
+ import type { AppRoom } from './listing.js';
2
+ import type { ReadinessPort } from './preparation.js';
3
+ import type { MdRuntime, RuntimeTopic } from './surface.js';
2
4
  import type { Plan, PlanReach, QueryResult } from './query.js';
3
5
  import type { Readiness } from './readiness.js';
4
6
  import type { SearchResult } from './search.js';
@@ -21,6 +21,7 @@ export type ReadAnswersOptions = {
21
21
  readonly database: RuntimeDatabase;
22
22
  readonly build: string;
23
23
  readonly unkept: readonly string[];
24
+ readonly leading: readonly string[];
24
25
  readonly recovery: Recovery;
25
26
  call(name: string, input: unknown): Promise<CallResult>;
26
27
  online(): boolean;
@@ -0,0 +1,26 @@
1
+ import type { AdapterFailure, Authorization, RefreshPage, RefreshRequest, RefreshResult, RetryableRefusal } from './adapter.js';
2
+ import type { Remodel } from './bootstrap.js';
3
+ import type { ReplicaRecord } from './replica.js';
4
+ import type { RefreshedPage } from './store.js';
5
+ import type { HeldEntry, StoredEntry } from './tables.js';
6
+ import { type Unconfirmed } from './transfer.js';
7
+ export type Advancement = {
8
+ kind: 'still-current';
9
+ } | {
10
+ kind: 'advanced';
11
+ record: ReplicaRecord;
12
+ changed: ReadonlySet<string>;
13
+ } | {
14
+ kind: 'beyond-horizon';
15
+ } | RetryableRefusal | Unconfirmed | AdapterFailure;
16
+ export type Refresher = (authorization: Authorization, request: RefreshRequest) => Promise<RefreshResult>;
17
+ export type Refreshing = {
18
+ turn(): void;
19
+ prior(paths: readonly string[]): Promise<ReadonlyMap<string, HeldEntry>>;
20
+ later(paths: readonly string[], roomVersion: string): Promise<ReadonlySet<string>>;
21
+ stage(page: RefreshedPage): Promise<boolean>;
22
+ };
23
+ type PageContent = Pick<RefreshPage, 'documents' | 'facts' | 'revisions' | 'fileIds' | 'created' | 'changes' | 'binaryFiles'>;
24
+ export declare function pageEntries(page: PageContent, removals: readonly string[], roomVersion: string, prior: (paths: readonly string[]) => Promise<ReadonlyMap<string, HeldEntry>>): Promise<StoredEntry[]>;
25
+ export declare function advancement(refresh: Refresher, authorization: Authorization, held: ReplicaRecord, remodel: Remodel, continuing: () => boolean, staging: Refreshing): Promise<Advancement>;
26
+ export {};
@@ -1,13 +1,8 @@
1
1
  import { type ChangeSet } from './change-set.js';
2
2
  import { type VisibleLayer } from './replica.js';
3
3
  import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
4
+ import type { Runtime } from './runtime.js';
4
5
  import type { Store } from './store.js';
5
- export type RoomDrafting = {
6
- readonly store: Store;
7
- closed(): boolean;
8
- publishChangeSet(set: ChangeSet): Promise<void>;
9
- statusShown(): Promise<void>;
10
- };
11
6
  export type RoomDraftSurface = {
12
7
  list(): Promise<readonly RoomDraft[]>;
13
8
  read(room: string, path: string): Promise<RoomDraft | null>;
@@ -20,9 +15,9 @@ export type PresentationSurface = {
20
15
  edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
21
16
  };
22
17
  export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
23
- export declare function publishRoomDrafts({ store, closed }: RoomDrafting, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
24
- export declare function emitPresentation({ store, closed }: RoomDrafting, app: string): Promise<void>;
25
- export declare function roomDraftSurface(drafting: RoomDrafting): RoomDraftSurface;
26
- export declare function presentationSurface(drafting: RoomDrafting): PresentationSurface;
27
- export declare function watchRoomDrafts({ store, closed }: RoomDrafting, deliver: (value: unknown) => void): () => void;
28
- export declare function watchPresentation({ store, closed }: RoomDrafting, app: string, deliver: (value: unknown) => void): () => void;
18
+ export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
19
+ export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
20
+ export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
21
+ export declare function presentationSurface(runtime: Runtime): PresentationSurface;
22
+ export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
23
+ export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
@@ -0,0 +1,41 @@
1
+ import type { Authorization, DiscoveredRoom, ScopedRefusal, TypedPath } from './adapter.js';
2
+ import type { ChangeSet } from './change-set.js';
3
+ import type { ChangeBatch } from './change.js';
4
+ import type { RuntimeShell } from './durability.js';
5
+ import type { ConversationStore } from './conversation.js';
6
+ import type { FiguresRead } from './figures.js';
7
+ import type { Withheld } from './install.js';
8
+ import type { LiveQueries } from './live.js';
9
+ import type { Log } from './log.js';
10
+ import type { ModelState } from './model.js';
11
+ import type { ReadAnswers } from './reads.js';
12
+ import type { Recovery } from './recovery.js';
13
+ import type { ReplicaRecord } from './replica.js';
14
+ import type { RuntimeSocket, RoomDeclaration } from './socket.js';
15
+ import type { CycleProgress } from './status.js';
16
+ import type { Settling } from './saves.js';
17
+ import type { HeldCover, RuntimeStore, Store, Work } from './store.js';
18
+ import type { schemaTypes } from './attached-model.js';
19
+ export type Runtime = {
20
+ readonly store: Store;
21
+ readonly socket: RuntimeSocket;
22
+ readonly journal: Log;
23
+ readonly recovery: Recovery;
24
+ readonly shell: RuntimeShell;
25
+ readonly localSaves: boolean;
26
+ readonly roomTypes: Parameters<typeof schemaTypes>[1];
27
+ readonly builtIn: ModelState;
28
+ readonly typedPaths: readonly TypedPath[];
29
+ readonly usableWhenHeld: readonly string[];
30
+ readonly build: string;
31
+ readonly conversations: ConversationStore;
32
+ readonly liveQueries: LiveQueries<HeldCover>;
33
+ readonly figures: FiguresRead;
34
+ readonly lastAnswers: ReadAnswers;
35
+ settle(local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
36
+ scoped(result: ScopedRefusal, room: RoomDeclaration, local: RuntimeStore): Promise<void>;
37
+ submitLater(locator: string): void;
38
+ unpair(local: RuntimeStore): Promise<void>;
39
+ advanced(room: DiscoveredRoom, local: RuntimeStore, authorized: Authorization): Promise<Withheld | null>;
40
+ withhold(withheld: Withheld, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress): Promise<void>;
41
+ };
@@ -0,0 +1,69 @@
1
+ import { type ChangeSet } from './change-set.js';
2
+ import { type ChangeBatch, type WrittenBy } from './change.js';
3
+ import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
4
+ import { type HeldReplica, type ReplicaRecord, type Slice, type VisibleLayer } from './replica.js';
5
+ import { type ReturnReason, type RoomDraftParts } from './room-draft.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import { type SaveRefusal } from './save.js';
8
+ import type { AuthoredWrite, CommittedWrite, PendingState, RoomCommit, RuntimeStore, Store, StoredEntry, View, Work } from './store.js';
9
+ export type SaveResult = {
10
+ outcome: 'saved';
11
+ identifier: string;
12
+ } | ({
13
+ outcome: 'refused';
14
+ } & SaveRefusal);
15
+ export type SavedRoomDraft = {
16
+ readonly path: string;
17
+ readonly revision: string;
18
+ };
19
+ export type SavedParts = {
20
+ readonly path: string;
21
+ readonly parts: RoomDraftParts;
22
+ };
23
+ export type BinaryFileSurface = {
24
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
25
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
26
+ show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
27
+ attach(room: string, file: File): Promise<AttachAnswer>;
28
+ part(file: string, part: number): Promise<Uint8Array | null>;
29
+ };
30
+ export type Leaving = {
31
+ batch: ChangeBatch;
32
+ returned: ReturnReason | null;
33
+ };
34
+ export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
35
+ export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
36
+ export declare function landedWhole(store: Store, locator: string, batch: ChangeBatch, confirmedLayer: Slice, current?: Readonly<Record<string, string>>): Promise<boolean>;
37
+ export type Settling = {
38
+ leaving?: readonly Leaving[];
39
+ room?: boolean;
40
+ view?: View;
41
+ commit?: Pick<RoomCommit, 'published' | 'refreshed'>;
42
+ changes?: {
43
+ readonly set: readonly StoredEntry[];
44
+ readonly removed: readonly string[];
45
+ };
46
+ };
47
+ export declare function preparedAfter(runtime: Runtime, locator: string, answer: CommittedWrite): void;
48
+ export declare function replayed(store: Store, record: ReplicaRecord, confirmedLayer: Slice, queue: readonly ChangeBatch[]): import("./turn.js").Later<import("./replica.js").Replayed>;
49
+ export declare function overlayDiff(record: ReplicaRecord, before: HeldReplica | undefined, visible: VisibleLayer, touched: ReadonlySet<string>): Promise<{
50
+ overlay: NonNullable<RoomCommit['overlay']>;
51
+ touched: ReadonlySet<string>;
52
+ }>;
53
+ export type Settlement = {
54
+ readonly locator: string;
55
+ readonly left: readonly ChangeBatch[];
56
+ readonly commit: {
57
+ readonly rooms: readonly RoomCommit[];
58
+ readonly writes: readonly AuthoredWrite[];
59
+ };
60
+ apply(answer: CommittedWrite): ChangeSet;
61
+ };
62
+ export declare function settle(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
63
+ export declare function together(runtime: Runtime, local: RuntimeStore, settlements: readonly Settlement[]): Promise<ChangeSet>;
64
+ export declare function settlement(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<Settlement>;
65
+ export declare function unpairing(runtime: Runtime, local: RuntimeStore, locator: string, batches: readonly ChangeBatch[]): Promise<Settlement>;
66
+ export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
67
+ export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
68
+ export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
69
+ export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
@@ -2,6 +2,7 @@ import type { Cover } from './live.js';
2
2
  import { type KeyedResult } from './observation.js';
3
3
  import type { Plan, QueryRows } from './query.js';
4
4
  import type { Deliver } from './reach.js';
5
+ import type { Runtime } from './runtime.js';
5
6
  import type { HeldCover, Store } from './store.js';
6
7
  export type EntrySeed = {
7
8
  readonly at: Readonly<Record<string, string>>;
@@ -14,16 +15,10 @@ export type Seeded = {
14
15
  readonly rows: QueryRows;
15
16
  readonly at: Readonly<Record<string, string>>;
16
17
  };
17
- export type Seeding = {
18
- readonly store: Store;
19
- reached(room: string, version: string, target: string): boolean;
20
- listed(): boolean;
21
- declares(room: string): boolean;
22
- };
23
18
  type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
24
19
  export declare function entrySeedOf(value: unknown): EntrySeed | null;
25
20
  export declare function seededResult(seed: Seeded): KeyedResult;
26
- export declare function seedApplies(seeding: Seeding, plan: Plan, held: HeldCover): Seeded | null;
21
+ export declare function seedApplies(runtime: Runtime, plan: Plan, held: HeldCover): Seeded | null;
27
22
  export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
28
- export declare function watchSeeded(seeding: Seeding, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
23
+ export declare function watchSeeded(runtime: Runtime, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
29
24
  export {};
@@ -0,0 +1,6 @@
1
+ export type Admission = {
2
+ heldStream(): Promise<() => void>;
3
+ unqueued(): Promise<void>;
4
+ queued(text: number): () => void;
5
+ };
6
+ export declare function createAdmission(): Admission;
@@ -0,0 +1,5 @@
1
+ export type Answers = {
2
+ awaitingAnswer(locator: string): () => void;
3
+ answered(locator: string): Promise<void> | undefined;
4
+ };
5
+ export declare function createAnswers(): Answers;
@@ -0,0 +1,19 @@
1
+ export type Live = () => boolean;
2
+ type LaneRules = {
3
+ generation(): number;
4
+ continuing(): boolean;
5
+ stopping(): boolean;
6
+ };
7
+ export type Lanes = {
8
+ task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
9
+ inRoom<T>(locator: string, work: (live: Live) => Promise<T>): Promise<T>;
10
+ roomTask(locator: string, work: (live: Live) => Promise<void>): Promise<void>;
11
+ roomWork(): number;
12
+ current(): Promise<unknown>;
13
+ finished(): Promise<unknown>;
14
+ calling(operation: string): boolean;
15
+ call(operation: string): void;
16
+ called(operation: string): void;
17
+ };
18
+ export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
19
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { DiscoveredRoom, ProviderRefusal, TypedSelection } from '../adapter.js';
2
+ import type { ModelState } from '../model.js';
3
+ export type RoomDeclaration = Omit<DiscoveredRoom, 'roomVersion' | 'typedSelection'> & {
4
+ typedSelection?: TypedSelection | null;
5
+ };
6
+ export type Declared = {
7
+ readonly room: RoomDeclaration | null;
8
+ readonly available: boolean;
9
+ };
10
+ export type RoomStanding = {
11
+ readonly unreadable: boolean;
12
+ readonly refusal: ProviderRefusal | null;
13
+ readonly unheldModel: ModelState | null;
14
+ readonly stale: boolean;
15
+ readonly repairable: {
16
+ readonly reset: string | undefined;
17
+ } | null;
18
+ readonly repairing: boolean;
19
+ readonly reloadDue: boolean;
20
+ readonly confirmed: boolean;
21
+ readonly unpreparable: boolean;
22
+ };
23
+ export type Rooms = {
24
+ declare(locator: string, declared: Declared): void;
25
+ declared(locator: string): Declared | undefined;
26
+ declarations(): ReadonlyMap<string, Declared>;
27
+ discover(room: DiscoveredRoom): void;
28
+ discovered(locator: string): DiscoveredRoom | undefined;
29
+ discoveredRooms(): readonly DiscoveredRoom[];
30
+ undiscoverAll(): void;
31
+ standing(locator: string): RoomStanding;
32
+ stand(locator: string, change: Partial<RoomStanding>): void;
33
+ standingWhere(held: (room: RoomStanding) => boolean): readonly string[];
34
+ standAll(change: Partial<RoomStanding>): void;
35
+ forget(locator: string): void;
36
+ askAgain(locator: string, ask: () => void): void;
37
+ readied(locator: string): void;
38
+ unreadied(): void;
39
+ connectionLost(lapsed: () => void): void;
40
+ connectionLive(): void;
41
+ };
42
+ export declare function createRooms(): Rooms;
@@ -0,0 +1,38 @@
1
+ import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
2
+ import { type Cell } from '../cell.js';
3
+ import type { Open } from '../open.js';
4
+ import type { CycleProgress, SyncStatus } from '../status.js';
5
+ export type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
6
+ export type ConnectionRefusalCode = Open<RefusalReason>;
7
+ export type ConnectionRefusal = {
8
+ code: ConnectionRefusalCode;
9
+ retryable: boolean;
10
+ reauthorizationOffered: boolean;
11
+ refusal: ProviderRefusal | null;
12
+ };
13
+ export type Moving = {
14
+ readonly state: SyncStatus['state'];
15
+ readonly providerUnreachable: boolean;
16
+ readonly resting: boolean;
17
+ };
18
+ export type Session = {
19
+ readonly closed: boolean;
20
+ readonly stopping: boolean;
21
+ readonly paused: boolean;
22
+ readonly authorization: Authorization | undefined;
23
+ readonly refusal: ConnectionRefusal | null;
24
+ readonly discoveries: number;
25
+ readonly roomsNamed: boolean;
26
+ readonly roomsListed: boolean;
27
+ readonly serviceMode: ServiceMode;
28
+ readonly haltedRefusal: boolean;
29
+ readonly openSignals: number;
30
+ readonly authorityChanges: number;
31
+ readonly currencyQueued: number | null;
32
+ readonly moving: Moving;
33
+ readonly complete: boolean;
34
+ readonly recorded: boolean;
35
+ readonly underway: CycleProgress | null;
36
+ readonly streamed: CycleProgress | null;
37
+ };
38
+ export declare function createSession(authorization: Authorization | undefined): Cell<Session>;
@@ -0,0 +1,69 @@
1
+ import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, ServiceMode } from './adapter.js';
2
+ import type { Reads } from './bootstrap.js';
3
+ import type { Cell } from './cell.js';
4
+ import type { Log } from './log.js';
5
+ import { type Admission } from './socket/admission.js';
6
+ import { type Answers } from './socket/answers.js';
7
+ import { type Lanes } from './socket/lanes.js';
8
+ import { type Rooms } from './socket/rooms.js';
9
+ import { type Session } from './socket/session.js';
10
+ export type { Live } from './socket/lanes.js';
11
+ export type { Declared, RoomDeclaration } from './socket/rooms.js';
12
+ export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
13
+ type SocketEvent = {
14
+ readonly kind: 'opened';
15
+ } | {
16
+ readonly kind: 'discovered';
17
+ readonly discovery: Discovery;
18
+ readonly missed: boolean;
19
+ } | {
20
+ readonly kind: 'closed';
21
+ readonly revoked: boolean;
22
+ readonly lost: boolean;
23
+ readonly opened: boolean;
24
+ } | Exclude<RoomStreamEvent, {
25
+ kind: 'opened' | 'discovered' | 'closed';
26
+ }>;
27
+ export type RuntimeSocket = Admission & Answers & {
28
+ readonly reads: Reads;
29
+ readonly streamed: boolean;
30
+ readonly session: Cell<Session>;
31
+ readonly rooms: Rooms;
32
+ readonly lanes: Lanes;
33
+ readonly ready: Promise<void>;
34
+ readonly firstDiscovery: Promise<void>;
35
+ conversations(): Adapter['conversations'];
36
+ search(): Adapter['search'];
37
+ discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
38
+ follows: Adapter['follows'];
39
+ mutate: Adapter['mutate'];
40
+ binary: Adapter['binary'];
41
+ link: Adapter['link'];
42
+ attach: Adapter['attach'];
43
+ history: Adapter['history'];
44
+ action: Adapter['action'];
45
+ authorize(): Promise<void>;
46
+ observe(listen: (event: SocketEvent) => void): void;
47
+ observeConversations(listen: (event: ConversationEvent) => void): void;
48
+ observeServiceMode(listen: (mode: ServiceMode) => void): void;
49
+ close(): void;
50
+ readyFromStore(): void;
51
+ notifyReady(): void;
52
+ closed(): boolean;
53
+ stopping(): boolean;
54
+ continuing(): boolean;
55
+ reached(): boolean;
56
+ writesHeld(): boolean;
57
+ haltedSince(opens: number): boolean;
58
+ isOpen(): boolean;
59
+ isAnnounced(): boolean;
60
+ isHanded(): boolean;
61
+ generation(): number;
62
+ naming(): boolean;
63
+ hand(rooms: readonly HeldRoom[]): void;
64
+ name(room: HeldRoom): void;
65
+ named(): void;
66
+ abortReads(): void;
67
+ stopReads(): void;
68
+ };
69
+ export declare function createSocket(adapter: Adapter, journal: Log, authorization: Authorization | undefined): RuntimeSocket;
@@ -0,0 +1,9 @@
1
+ export type ReadinessQueue<W> = {
2
+ add(watch: W): () => void;
3
+ held(watch: W): boolean;
4
+ changed(watch: W, reading: string): boolean;
5
+ owe(watches: readonly W[]): void;
6
+ queue(): void;
7
+ close(): void;
8
+ };
9
+ export declare function createReadinessQueue<W>(deliver: (owed: readonly W[]) => Promise<void>, unpublished: (error: unknown) => void): ReadinessQueue<W>;
@@ -0,0 +1,7 @@
1
+ export type RoomHeld<T> = {
2
+ of(locator: string, key: string): T | undefined;
3
+ hold(locator: string, key: string, value: T): void;
4
+ drop(locator: string, key: string): void;
5
+ forget(locator: string): void;
6
+ };
7
+ export declare function createRoomHeld<T>(): RoomHeld<T>;
@@ -0,0 +1,10 @@
1
+ import type { RuntimeDatabase } from '../tables.js';
2
+ export type Space = {
3
+ full(): boolean;
4
+ fill(): boolean;
5
+ probing(): boolean;
6
+ probeEachMinute(): void;
7
+ probe(): Promise<boolean>;
8
+ stop(): void;
9
+ };
10
+ export declare function createSpace(database: RuntimeDatabase, freed: () => void): Space;
@@ -6,8 +6,10 @@ export type Watcher = {
6
6
  export type Watching = 'all' | 'waiting' | 'ready';
7
7
  type Watchers = {
8
8
  publication(work: () => Promise<void>): Promise<void>;
9
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
9
10
  watch(topic: string, notify: (value: unknown) => void): Watcher;
10
11
  watching(topic: string, which?: Watching): readonly Watcher[];
12
+ tell(topic: string, value: unknown): void;
11
13
  close(): void;
12
14
  };
13
15
  export declare function createWatchers(unpublished: (error: unknown) => void): Watchers;
@@ -1,15 +1,25 @@
1
1
  import type { TypedPath } from './adapter.js';
2
2
  import { schemaTypes } from './attached-model.js';
3
+ import { type Cell } from './cell.js';
3
4
  import type { ChangeBatch } from './change.js';
5
+ import type { ChangeSet } from './change-set.js';
4
6
  import type { Composition } from './collection.js';
7
+ import type { ReadinessWatch } from './preparation.js';
8
+ import type { Persistence } from './readiness.js';
9
+ import type { Listing } from './listing.js';
5
10
  import type { Seeded } from './seed.js';
6
11
  import type { ModelState } from './model.js';
12
+ import { type OpenedFiles } from './opened.js';
7
13
  import { type HeldReplica, type ReplicaRecord } from './replica.js';
8
14
  import type { RoomDraftRecord } from './room-draft.js';
15
+ import { type SyncStatus } from './status.js';
9
16
  import type { RuntimeDatabase } from './tables.js';
10
17
  import { type Fences } from './store/fences.js';
11
18
  import { type Installs } from './store/installs.js';
12
19
  import { type HeldCover, type PendingState, type RuntimeStore } from './store/records.js';
20
+ import { type ReadinessQueue } from './store/readiness.js';
21
+ import { type RoomHeld } from './store/room-held.js';
22
+ import { type Space } from './store/space.js';
13
23
  import { type Watcher, type Watching } from './store/watchers.js';
14
24
  import { createWrites, type InstallHold } from './store/writes.js';
15
25
  export { NO_INSTALL, type RoomInstall } from './store/installs.js';
@@ -29,20 +39,45 @@ export type Work = {
29
39
  readonly queue: readonly ChangeBatch[];
30
40
  readonly states: ReadonlyMap<string, PendingState>;
31
41
  };
42
+ type LandedAhead = Readonly<Record<string, string | undefined>>;
43
+ type AttachedFile = {
44
+ readonly revision: string;
45
+ readonly mediaType: string;
46
+ };
32
47
  type Seeds = {
33
48
  of(key: string): Seeded | undefined;
34
49
  keep(key: string, seed: Seeded): void;
35
50
  drop(key: string): void;
36
51
  };
52
+ export type Device = {
53
+ readonly persistence: Persistence;
54
+ readonly storageLoss: string | null;
55
+ readonly heldWhenOpened: boolean;
56
+ readonly preparing: boolean;
57
+ readonly sweeping: boolean;
58
+ readonly unpreparedDemand: ReadonlySet<string>;
59
+ readonly establishing: ReadonlySet<string>;
60
+ readonly status: SyncStatus;
61
+ readonly roomsShown: Listing | null;
62
+ };
37
63
  type StoreOptions = {
38
64
  readonly database: RuntimeDatabase;
39
65
  readonly roomTypes: Parameters<typeof schemaTypes>[1];
40
66
  readonly builtIn: ModelState;
41
67
  readonly typedPaths: readonly TypedPath[];
68
+ readonly persistence: Persistence;
42
69
  opening(records: RuntimeStore): Promise<RuntimeStore>;
43
70
  unpublished(error: unknown): void;
71
+ changed(set: ChangeSet): Promise<void>;
72
+ deliverReadiness(owed: readonly ReadinessWatch[]): Promise<void>;
73
+ spaceFreed(): void;
44
74
  };
45
75
  export type Store = {
76
+ readonly device: Cell<Device>;
77
+ readonly space: Space;
78
+ readonly readiness: ReadinessQueue<ReadinessWatch>;
79
+ ask: RuntimeDatabase['ask'];
80
+ changed(set: ChangeSet): Promise<void>;
46
81
  open(): Promise<RuntimeStore>;
47
82
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
48
83
  exclusive<T>(work: () => Promise<T>): Promise<T>;
@@ -64,11 +99,17 @@ export type Store = {
64
99
  draft(locator: string, path: string): Promise<RoomDraftRecord | undefined>;
65
100
  composed(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>): Composition;
66
101
  publication(work: () => Promise<void>): Promise<void>;
102
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
67
103
  watch(topic: string, notify: (value: unknown) => void): Watcher;
68
104
  watching(topic: string, which?: Watching): readonly Watcher[];
105
+ tell(topic: string, value: unknown): void;
69
106
  readonly fences: Fences;
70
107
  readonly installs: Installs;
71
108
  readonly seeds: Seeds;
109
+ readonly landed: RoomHeld<LandedAhead>;
110
+ readonly attached: RoomHeld<AttachedFile>;
111
+ readonly opened: OpenedFiles;
112
+ part(file: string, part: number): Promise<Uint8Array | null>;
72
113
  forget(locator: string): void;
73
114
  close(): void;
74
115
  };
@@ -1,91 +1,32 @@
1
- import { type DocumentQuery, type GroupQuery } from '@agentshouse/mdmodel';
1
+ import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
2
+ import { type HistoryQuery } from './actions.js';
3
+ import type { Member, ServiceMode } from './adapter.js';
4
+ import type { WrittenBy } from './change.js';
5
+ import type { ChatDraftSurface, ConversationEntry, ConversationAgent, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
6
+ import type { UnsentWork } from './durability.js';
7
+ import type { FiguresResult } from './figures.js';
8
+ import { type Holdings } from './holdings.js';
9
+ import { type AppRoom } from './listing.js';
2
10
  import { type TypesResult } from './model.js';
3
11
  import { type Observation } from './observation.js';
4
- import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
5
- import { type FiguresResult } from './figures.js';
6
- import { type EntrySeed } from './seed.js';
7
- import { type SearchRequest, type SearchResult } from './search.js';
8
- import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
9
- import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
10
- import { type WrittenBy } from './change.js';
11
- import type { Open } from './open.js';
12
- import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
13
- import { type ObservedRead } from './reads.js';
14
- import { type Recovery } from './recovery.js';
15
- import { type SaveRefusal } from './save.js';
16
- import { type RoomDraft, type RoomDraftParts } from './room-draft.js';
17
- import { type SyncStatus } from './status.js';
18
- import { type RuntimeShell, type UnsentWork } from './durability.js';
19
- import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
20
- import { type RuntimeDatabase } from './store.js';
21
- import { type PresentationSurface, type RoomDraftSurface } from './room-drafts.js';
12
+ import type { HistoryAnswer, QueueEntry, Resolution, CallResult } from './outcome.js';
13
+ import { type ReadinessPort } from './preparation.js';
14
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
22
15
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
23
- export type AppTypedSelection = {
24
- roots: readonly string[];
25
- model: TypesResult;
26
- };
27
- export type AppRoom = {
28
- name: string;
29
- locator: string;
30
- handle: string;
31
- operations: import('./adapter.js').OperationScopes;
32
- replica: import('./adapter.js').ReplicaAdmission;
33
- model: TypesResult;
34
- typedSelection: AppTypedSelection | null;
35
- providerOwnedPaths: readonly string[];
36
- roomVersion: string | null;
37
- documents: number;
38
- synchronizationAvailable: boolean;
39
- refusal: ProviderRefusal | null;
40
- locked: boolean;
41
- };
16
+ import type { Persistence, Readiness } from './readiness.js';
17
+ import type { ObservedRead } from './reads.js';
18
+ import type { RoomDraft } from './room-draft.js';
19
+ import { type PresentationSurface, type RoomDraftSurface } from './room-drafts.js';
20
+ import type { Runtime } from './runtime.js';
21
+ import { type BinaryFileSurface, type SavedParts, type SavedRoomDraft, type SaveResult } from './saves.js';
22
+ import type { SearchRequest, SearchResult } from './search.js';
23
+ import { type EntrySeed } from './seed.js';
24
+ import type { ConnectionRefusal } from './socket.js';
25
+ import type { SyncStatus } from './status.js';
42
26
  export type RoomSchemas = {
43
27
  collection: TypesResult;
44
28
  typedSelection: TypesResult | null;
45
29
  };
46
- type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
47
- export type ConnectionRefusalCode = Open<RefusalReason>;
48
- export type ConnectionRefusal = {
49
- code: ConnectionRefusalCode;
50
- retryable: boolean;
51
- reauthorizationOffered: boolean;
52
- refusal: ProviderRefusal | null;
53
- };
54
- export type MdRuntimeOptions = {
55
- adapter: Adapter;
56
- shell: RuntimeShell;
57
- database: RuntimeDatabase;
58
- authorization?: Authorization;
59
- signal?: AbortSignal;
60
- recovery?: Recovery;
61
- usableWhenHeld?: readonly string[];
62
- build?: string;
63
- };
64
- export type SaveResult = {
65
- outcome: 'saved';
66
- identifier: string;
67
- } | ({
68
- outcome: 'refused';
69
- } & SaveRefusal);
70
- export type SavedRoomDraft = {
71
- readonly path: string;
72
- readonly revision: string;
73
- };
74
- export type SavedParts = {
75
- readonly path: string;
76
- readonly parts: RoomDraftParts;
77
- };
78
- export type BinaryFileSurface = {
79
- read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
80
- link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
81
- show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
82
- attach(room: string, file: File): Promise<AttachAnswer>;
83
- part(file: string, part: number): Promise<Uint8Array | null>;
84
- };
85
- export type HistoryQuery = {
86
- revision?: string;
87
- pageToken?: string;
88
- };
89
30
  export type MdRuntime = {
90
31
  loaded(): Promise<void>;
91
32
  rooms(): Promise<readonly AppRoom[]>;
@@ -131,20 +72,16 @@ export type MdRuntime = {
131
72
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
132
73
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
133
74
  (topic: 'figures'): Promise<Observation<FiguresResult>>;
75
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
134
76
  (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
135
77
  };
136
78
  reauthorize(): Promise<void>;
137
79
  };
138
- export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'read';
139
- export type ReadinessPort = {
140
- readonly target: string;
141
- readonly code: CodeAvailability;
142
- };
80
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'holdings' | 'read';
143
81
  export type ComposedRuntime = RuntimeView & {
144
82
  seed(entry: EntrySeed): void;
145
83
  stop(): Promise<void>;
146
84
  persisted(answer: Persistence): void;
147
85
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
148
86
  };
149
- export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
150
- export {};
87
+ export declare function composedRuntime(runtime: Runtime): ComposedRuntime;
@@ -3,7 +3,7 @@ import type { Composed } from './collection.js';
3
3
  import type { UnsentWork } from './durability.js';
4
4
  import type { JobMarker } from './job.js';
5
5
  import { type ConversationWrite, type HeldConversation, type HeldRow, type MessageWindow } from './messages.js';
6
- import type { Plan } from './query.js';
6
+ import type { GroupTotal, Plan } from './query.js';
7
7
  import { type ReadAt } from './reads.js';
8
8
  import { type ConversationTally, type RoomTally } from './tallies.js';
9
9
  import { type Committed, type Covering, type HeldEntry, type HeldLocators, type HeldRoomRow, type HeldRoomWork, type ReplicaOpened, type Referrer, type Resumed, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
@@ -116,6 +116,13 @@ export type OpenedFile = {
116
116
  readonly byteLength: number;
117
117
  readonly mediaType: string;
118
118
  };
119
+ export type OpenedRoom = GroupTotal & {
120
+ readonly room: string;
121
+ };
122
+ export type OpenedHeld = {
123
+ readonly rooms: readonly OpenedRoom[];
124
+ readonly cleanable: number;
125
+ };
119
126
  type Asked<A, R> = {
120
127
  readonly asked: A;
121
128
  readonly answer: R;
@@ -345,6 +352,7 @@ export interface RuntimeRequests {
345
352
  readonly key: string;
346
353
  }, null>;
347
354
  readonly 'opened.clean': Asked<Nothing, number>;
355
+ readonly 'opened.held': Asked<Nothing, OpenedHeld>;
348
356
  readonly 'file.part': Asked<{
349
357
  readonly key: string;
350
358
  readonly part: number;
@@ -0,0 +1,4 @@
1
+ export type Unconfirmed = {
2
+ kind: 'unconfirmed';
3
+ };
4
+ export declare const unconfirmed: Unconfirmed;
@@ -0,0 +1,8 @@
1
+ export declare function yielded(): Promise<void>;
2
+ export declare const ROW_WEIGHT = 256;
3
+ export type Later<T> = T | Promise<T>;
4
+ export declare function after<T, R>(value: Later<T>, next: (value: T) => Later<R>): Later<R>;
5
+ export declare function paced(): (weight: number) => Later<void>;
6
+ export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number, ended?: () => void, paused?: () => Promise<void>): Later<void>;
7
+ export declare function finished<R>(steps: Generator<number, R, void>): R;
8
+ export declare function stepped<R>(steps: Generator<number, R, void>): Later<R>;
@@ -1,4 +1,4 @@
1
- import type { ConnectionRefusal } from './connection.js';
1
+ import type { ConnectionRefusal } from './socket.js';
2
2
  import type { Described } from './failure.js';
3
3
  export type RuntimePort = {
4
4
  postMessage(message: unknown): void;
@@ -197,6 +197,7 @@ declare const TOPICS: {
197
197
  readonly conversations: 'within';
198
198
  readonly agents: 'within';
199
199
  readonly figures: 'whole';
200
+ readonly holdings: 'whole';
200
201
  readonly read: 'whole';
201
202
  };
202
203
  export declare const WIRE: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime-families",
3
- "version": "0.1.0-c8a9a2ed09538",
3
+ "version": "0.1.0-c8d38a26efb97",
4
4
  "description": "react-admin and Refine data providers over the MD Runtime client",
5
5
  "license": "MIT",
6
6
  "type": "module",