@agentshouse/app-bridge 0.1.0-c646d0da70608 → 0.1.0-c64bbf5cda7ef

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 (100) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +943 -19
  3. package/dist/mdmodel/definition.d.ts +17 -1
  4. package/dist/mdmodel/document.d.ts +6 -5
  5. package/dist/mdmodel/event.d.ts +77 -0
  6. package/dist/mdmodel/facts.d.ts +14 -0
  7. package/dist/mdmodel/index.d.ts +24 -9
  8. package/dist/mdmodel/kinds.d.ts +18 -0
  9. package/dist/mdmodel/links.d.ts +28 -0
  10. package/dist/mdmodel/paths.d.ts +9 -1
  11. package/dist/mdmodel/pattern.d.ts +9 -0
  12. package/dist/mdmodel/project.d.ts +1 -0
  13. package/dist/mdmodel/query/language.d.ts +253 -0
  14. package/dist/mdmodel/query/match.d.ts +13 -0
  15. package/dist/mdmodel/query/rows.d.ts +31 -0
  16. package/dist/mdmodel/query/sql.d.ts +38 -0
  17. package/dist/mdmodel/reserved.d.ts +4 -0
  18. package/dist/mdmodel/types.d.ts +39 -4
  19. package/dist/mdmodel/validate.d.ts +30 -4
  20. package/dist/mdruntime/actions.d.ts +19 -0
  21. package/dist/mdruntime/adapter.d.ts +151 -79
  22. package/dist/mdruntime/attached-model.d.ts +7 -0
  23. package/dist/mdruntime/binary.d.ts +0 -5
  24. package/dist/mdruntime/bootstrap.d.ts +43 -0
  25. package/dist/mdruntime/cell.d.ts +5 -0
  26. package/dist/mdruntime/chain.d.ts +11 -0
  27. package/dist/mdruntime/change-set.d.ts +9 -16
  28. package/dist/mdruntime/change.d.ts +32 -1
  29. package/dist/mdruntime/client.d.ts +33 -10
  30. package/dist/mdruntime/collection.d.ts +11 -21
  31. package/dist/mdruntime/compile.d.ts +15 -0
  32. package/dist/mdruntime/conversation-row.d.ts +32 -0
  33. package/dist/mdruntime/conversation.d.ts +43 -18
  34. package/dist/mdruntime/durability.d.ts +16 -4
  35. package/dist/mdruntime/figures.d.ts +47 -0
  36. package/dist/mdruntime/holdings.d.ts +28 -0
  37. package/dist/mdruntime/identity.d.ts +5 -0
  38. package/dist/mdruntime/install.d.ts +55 -0
  39. package/dist/mdruntime/job.d.ts +32 -0
  40. package/dist/mdruntime/listing.d.ts +52 -0
  41. package/dist/mdruntime/live.d.ts +22 -0
  42. package/dist/mdruntime/log.d.ts +5 -0
  43. package/dist/mdruntime/media.d.ts +7 -0
  44. package/dist/mdruntime/messages.d.ts +51 -0
  45. package/dist/mdruntime/model.d.ts +8 -10
  46. package/dist/mdruntime/observation.d.ts +17 -2
  47. package/dist/mdruntime/opened.d.ts +21 -0
  48. package/dist/mdruntime/outcome.d.ts +49 -8
  49. package/dist/mdruntime/overlay.d.ts +4 -5
  50. package/dist/mdruntime/preparation.d.ts +19 -0
  51. package/dist/mdruntime/query.d.ts +26 -185
  52. package/dist/mdruntime/reach.d.ts +19 -9
  53. package/dist/mdruntime/readiness.d.ts +14 -17
  54. package/dist/mdruntime/reads.d.ts +35 -0
  55. package/dist/mdruntime/recovery.d.ts +3 -2
  56. package/dist/mdruntime/refresh.d.ts +26 -0
  57. package/dist/mdruntime/replica.d.ts +55 -33
  58. package/dist/mdruntime/room-draft.d.ts +37 -6
  59. package/dist/mdruntime/room-drafts.d.ts +23 -0
  60. package/dist/mdruntime/runtime.d.ts +41 -0
  61. package/dist/mdruntime/save.d.ts +53 -14
  62. package/dist/mdruntime/saves.d.ts +69 -0
  63. package/dist/mdruntime/search.d.ts +15 -78
  64. package/dist/mdruntime/seed.d.ts +24 -0
  65. package/dist/mdruntime/socket/admission.d.ts +6 -0
  66. package/dist/mdruntime/socket/answers.d.ts +5 -0
  67. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  68. package/dist/mdruntime/socket/rooms.d.ts +42 -0
  69. package/dist/mdruntime/socket/session.d.ts +38 -0
  70. package/dist/mdruntime/socket.d.ts +69 -0
  71. package/dist/mdruntime/source.d.ts +60 -0
  72. package/dist/mdruntime/status.d.ts +4 -5
  73. package/dist/mdruntime/store/fences.d.ts +15 -0
  74. package/dist/mdruntime/store/installs.d.ts +29 -0
  75. package/dist/mdruntime/store/readiness.d.ts +9 -0
  76. package/dist/mdruntime/store/records.d.ts +211 -0
  77. package/dist/mdruntime/store/room-held.d.ts +7 -0
  78. package/dist/mdruntime/store/space.d.ts +10 -0
  79. package/dist/mdruntime/store/watchers.d.ts +16 -0
  80. package/dist/mdruntime/store/writes.d.ts +23 -0
  81. package/dist/mdruntime/store.d.ts +106 -150
  82. package/dist/mdruntime/stored.d.ts +155 -0
  83. package/dist/mdruntime/surface.d.ts +87 -0
  84. package/dist/mdruntime/tables.d.ts +414 -0
  85. package/dist/mdruntime/tallies.d.ts +17 -0
  86. package/dist/mdruntime/transfer.d.ts +0 -5
  87. package/dist/mdruntime/turn.d.ts +5 -3
  88. package/dist/mdruntime/wire.d.ts +50 -6
  89. package/dist/test-host.d.ts +7 -4
  90. package/dist/test-host.js +19 -29
  91. package/docs/families.md +69 -53
  92. package/package.json +8 -3
  93. package/dist/calls.d.ts +0 -117
  94. package/dist/calls.js +0 -1
  95. package/dist/mdmodel/condition.d.ts +0 -149
  96. package/dist/mdruntime/acquisition.d.ts +0 -13
  97. package/dist/mdruntime/connection.d.ts +0 -138
  98. package/dist/mdruntime/file.d.ts +0 -19
  99. package/dist/mdruntime/rows.d.ts +0 -36
  100. package/dist/mdruntime/shared.d.ts +0 -10
@@ -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;
@@ -0,0 +1,16 @@
1
+ export type Watcher = {
2
+ held(): boolean;
3
+ stop(): void;
4
+ answer(value: unknown): void;
5
+ };
6
+ export type Watching = 'all' | 'waiting' | 'ready';
7
+ type Watchers = {
8
+ publication(work: () => Promise<void>): Promise<void>;
9
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
10
+ watch(topic: string, notify: (value: unknown) => void): Watcher;
11
+ watching(topic: string, which?: Watching): readonly Watcher[];
12
+ tell(topic: string, value: unknown): void;
13
+ close(): void;
14
+ };
15
+ export declare function createWatchers(unpublished: (error: unknown) => void): Watchers;
16
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { Composition } from '../collection.js';
2
+ import type { RefreshedPage, RuntimeStore } from './records.js';
3
+ export type InstallHold = {
4
+ take(): void;
5
+ release(): void;
6
+ };
7
+ type Writes = {
8
+ exclusive<T>(work: () => Promise<T>): Promise<T>;
9
+ gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
10
+ written(): Promise<unknown>;
11
+ startingWrite<T>(work: () => Promise<T>): Promise<T>;
12
+ finishingWrite<T>(work: () => Promise<T>): Promise<T>;
13
+ ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
14
+ rederive(local: RuntimeStore, key: number, composition: Composition): Promise<{
15
+ readonly done: boolean;
16
+ readonly text: number;
17
+ }>;
18
+ refreshPage(local: RuntimeStore, key: number, composition: Composition, page: RefreshedPage): Promise<void>;
19
+ stageBytes(): number;
20
+ deriveBytes(): number;
21
+ };
22
+ export declare function createWrites(): Writes;
23
+ export {};
@@ -1,160 +1,116 @@
1
- import type { ModelState } from './model.js';
2
- import type { Capability, HeadChange, Member, OperationScopes, ProviderLimit, ReplicaAdmission, TypedSelection } from './adapter.js';
3
- import type { AcceptedMessage, KeptReceipt } from './adapter.js';
1
+ import type { TypedPath } from './adapter.js';
2
+ import { schemaTypes } from './attached-model.js';
3
+ import { type Cell } from './cell.js';
4
4
  import type { ChangeBatch } from './change.js';
5
- import { type HeldBinary } from './overlay.js';
6
- import type { ChatDraftFile } from './file.js';
7
- import type { Submission } from './outcome.js';
8
- import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
9
- export declare const STORE_SCHEMA = 25;
10
- export declare const AUTHORED_SCHEMA = 2;
11
- export type ReplicaRecord = {
12
- locator: string;
13
- name: string;
14
- handle: string;
15
- operations: OperationScopes;
16
- replica: ReplicaAdmission;
17
- model: ModelState;
18
- typedSelection: TypedSelection | null;
19
- selectionModel: ModelState;
20
- providerOwnedPaths: readonly string[];
21
- roomVersion: string;
22
- transfer: string;
23
- documents: Readonly<Record<string, string>>;
24
- binaries: Readonly<Record<string, HeldBinary>>;
25
- revisions: Readonly<Record<string, string>>;
26
- changes: Readonly<Record<string, HeadChange>>;
27
- written: Readonly<Record<string, string>>;
28
- };
29
- export type StagedLayer = Pick<ReplicaRecord, 'documents' | 'binaries' | 'revisions' | 'changes' | 'written'>;
30
- export type TransferRecord = {
31
- locator: string;
32
- transfer: string;
33
- selection: string;
34
- from: string;
35
- last: string;
36
- pageToken: string | null;
37
- models: {
38
- collection: ModelState;
39
- selection: ModelState;
40
- };
41
- };
42
- export type PendingState = {
43
- readonly drafts: readonly SavedDraft[];
44
- readonly submission: Submission;
45
- readonly lost: boolean;
46
- readonly upload?: unknown;
47
- readonly accepted?: string;
48
- };
49
- export type TargetRecord = {
50
- established: boolean;
51
- search: boolean;
52
- };
53
- export type QueueRecord = {
54
- locator: string;
55
- pending: readonly {
56
- batch: ChangeBatch;
57
- state: PendingState;
58
- }[];
59
- };
60
- export type PresentationRecord = {
61
- app: string;
62
- value: unknown;
5
+ import type { ChangeSet } from './change-set.js';
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';
10
+ import type { Seeded } from './seed.js';
11
+ import type { ModelState } from './model.js';
12
+ import { type OpenedFiles } from './opened.js';
13
+ import { type HeldReplica, type ReplicaRecord } from './replica.js';
14
+ import type { RoomDraftRecord } from './room-draft.js';
15
+ import { type SyncStatus } from './status.js';
16
+ import type { RuntimeDatabase } from './tables.js';
17
+ import { type Fences } from './store/fences.js';
18
+ import { type Installs } from './store/installs.js';
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';
23
+ import { type Watcher, type Watching } from './store/watchers.js';
24
+ import { createWrites, type InstallHold } from './store/writes.js';
25
+ export { NO_INSTALL, type RoomInstall } from './store/installs.js';
26
+ export type { AuthoredWrite, ChatDraftRecord, ChatSubmission, CoveredRoom, Facts, HeldConversation, HeldCover, PendingState, RefreshedPage, RuntimeStore, StagedPage, TransferRecord, } from './store/records.js';
27
+ export type { InstallHold } from './store/writes.js';
28
+ export type { CommittedWrite, QueryRoom, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, View, } from './tables.js';
29
+ export type Stored = {
30
+ readonly record: ReplicaRecord;
31
+ readonly indexed: boolean;
32
+ readonly documents: number;
63
33
  };
64
- export type HeldConversation = {
65
- conversation: string;
66
- read: string | null | undefined;
67
- partial: boolean;
34
+ export type Held = HeldReplica & {
35
+ readonly states: ReadonlyMap<string, PendingState>;
68
36
  };
69
- export type ConversationWrite = {
70
- conversation: string;
71
- messages: readonly AcceptedMessage[];
72
- read?: {
73
- at: string | null;
74
- partial: boolean;
75
- };
37
+ export type Work = {
38
+ readonly replica: Held | undefined;
39
+ readonly queue: readonly ChangeBatch[];
40
+ readonly states: ReadonlyMap<string, PendingState>;
76
41
  };
77
- export type ChatSubmission = {
78
- readonly operation: string;
79
- readonly text: string;
80
- readonly files: readonly ChatDraftFile[];
81
- readonly turn: string | null;
42
+ type LandedAhead = Readonly<Record<string, string | undefined>>;
43
+ type AttachedFile = {
44
+ readonly revision: string;
45
+ readonly mediaType: string;
82
46
  };
83
- export type ChatDraftRecord = {
84
- conversation: string;
85
- text: string;
86
- files: readonly ChatDraftFile[];
87
- revision: string;
88
- submitted?: readonly ChatSubmission[];
89
- moves?: readonly string[];
47
+ type Seeds = {
48
+ of(key: string): Seeded | undefined;
49
+ keep(key: string, seed: Seeded): void;
50
+ drop(key: string): void;
90
51
  };
91
- export type RecordWrite = {
92
- next: ReplicaRecord;
93
- previous: ReplicaRecord | null;
94
- stored?: StagedLayer;
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;
95
62
  };
96
- export type AuthoredWrite = {
97
- locator: string;
98
- queue: readonly ChangeBatch[];
99
- saved?: ReadonlyMap<string, readonly SavedDraft[]>;
100
- roomDrafts?: readonly RoomDraftRecord[];
101
- consumedRoomDrafts?: readonly string[];
63
+ type StoreOptions = {
64
+ readonly database: RuntimeDatabase;
65
+ readonly roomTypes: Parameters<typeof schemaTypes>[1];
66
+ readonly builtIn: ModelState;
67
+ readonly typedPaths: readonly TypedPath[];
68
+ readonly persistence: Persistence;
69
+ opening(records: RuntimeStore): Promise<RuntimeStore>;
70
+ unpublished(error: unknown): void;
71
+ changed(set: ChangeSet): Promise<void>;
72
+ deliverReadiness(owed: readonly ReadinessWatch[]): Promise<void>;
73
+ spaceFreed(): void;
102
74
  };
103
- export type RuntimeStore = {
104
- all(): Promise<readonly ReplicaRecord[]>;
105
- keepAuthored(input: AuthoredWrite): Promise<void>;
106
- write(input: RecordWrite): Promise<void>;
107
- revokeModels(records: readonly ReplicaRecord[]): Promise<void>;
108
- lastCompleted(): Promise<string | null>;
109
- complete(at: string): Promise<void>;
110
- providerLimits(): Promise<readonly ProviderLimit[]>;
111
- capabilities(): Promise<readonly Capability[]>;
112
- declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
113
- member(): Promise<Member | null>;
114
- keepMember(member: Member | null): Promise<void>;
115
- targets(): Promise<Readonly<Record<string, TargetRecord>>>;
116
- keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
117
- queues(): Promise<readonly QueueRecord[]>;
118
- submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
119
- accept(locator: string, id: string, roomVersion: string): Promise<void>;
120
- keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
121
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
122
- presentation(): Promise<readonly PresentationRecord[]>;
123
- present(record: PresentationRecord): Promise<void>;
124
- conversations(): Promise<readonly HeldConversation[]>;
125
- keepMessages(write: ConversationWrite): Promise<void>;
126
- messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
127
- messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
128
- messageIdentities(conversation: string): Promise<readonly string[]>;
129
- turnArrived(conversation: string, turn: string): Promise<boolean>;
130
- dropConversations(conversations: readonly string[]): Promise<void>;
131
- chatDrafts(): Promise<readonly ChatDraftRecord[]>;
132
- keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
133
- dropChatDraft(conversation: string): Promise<void>;
134
- keepRoomDraft(record: RoomDraftRecord): Promise<void>;
135
- discardRoomDraft(locator: string, path: string): Promise<void>;
136
- fences(): Promise<readonly string[]>;
137
- erase(locators: readonly string[]): Promise<void>;
138
- discard(locator: string): Promise<void>;
139
- transfers(): Promise<readonly TransferRecord[]>;
140
- staged(record: TransferRecord): Promise<StagedLayer>;
141
- stage(record: TransferRecord, page: StagedLayer): Promise<void>;
142
- abandon(locator: string): Promise<void>;
143
- receivedHeads(): Promise<readonly KeptReceipt[]>;
144
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
145
- keepReceived(key: string, head: unknown, part?: {
146
- index: number;
147
- value: unknown;
148
- }): Promise<void>;
149
- dropReceived(keys: readonly string[]): Promise<void>;
150
- generation(): Promise<string | null>;
151
- rememberGeneration(value: string): Promise<void>;
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>;
81
+ open(): Promise<RuntimeStore>;
82
+ durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
83
+ exclusive<T>(work: () => Promise<T>): Promise<T>;
84
+ gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
85
+ written(): Promise<unknown>;
86
+ startingWrite<T>(work: () => Promise<T>): Promise<T>;
87
+ finishingWrite<T>(work: () => Promise<T>): Promise<T>;
88
+ ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
89
+ rederive: ReturnType<typeof createWrites>['rederive'];
90
+ refreshPage: ReturnType<typeof createWrites>['refreshPage'];
91
+ stageBytes(): number;
92
+ deriveBytes(): number;
93
+ rooms(locators?: readonly string[]): Promise<ReadonlyMap<string, Stored>>;
94
+ record(locator: string): Promise<ReplicaRecord | undefined>;
95
+ work(locator: string): Promise<Work>;
96
+ replica(locator: string): Promise<Held | undefined>;
97
+ covering(): Promise<HeldCover>;
98
+ drafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
99
+ draft(locator: string, path: string): Promise<RoomDraftRecord | undefined>;
100
+ composed(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>): Composition;
101
+ publication(work: () => Promise<void>): Promise<void>;
102
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
103
+ watch(topic: string, notify: (value: unknown) => void): Watcher;
104
+ watching(topic: string, which?: Watching): readonly Watcher[];
105
+ tell(topic: string, value: unknown): void;
106
+ readonly fences: Fences;
107
+ readonly installs: Installs;
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>;
113
+ forget(locator: string): void;
152
114
  close(): void;
153
115
  };
154
- export declare function authoredHolder(): Promise<string | null>;
155
- export declare function authoredBy(holder: string): Promise<boolean>;
156
- export declare function authoredBinding(): Promise<string | null>;
157
- export declare function bindAuthored(binding: string): Promise<void>;
158
- export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
159
- export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
160
- export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
116
+ export declare function createStore(options: StoreOptions): Store;
@@ -0,0 +1,155 @@
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
+ import type { HeldBinary } from './overlay.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const REPLICA_TABLES: readonly string[];
6
+ export type View = 'confirmed' | 'visible' | 'refreshed';
7
+ export type StoredEntry = {
8
+ readonly path: string;
9
+ readonly content: string | null;
10
+ readonly binary: HeldBinary | null;
11
+ readonly revision: string | null;
12
+ readonly fileId: string | null;
13
+ readonly created: string | null;
14
+ readonly change: HeadChange | null;
15
+ readonly written: string | null;
16
+ readonly facts: SavedFacts | null;
17
+ };
18
+ export type OverlayEntry = StoredEntry & {
19
+ readonly present: boolean;
20
+ };
21
+ export type HeldEntry = StoredEntry & {
22
+ readonly type: string | null;
23
+ };
24
+ export type TypedEntry = {
25
+ readonly path: string;
26
+ readonly type: string | null;
27
+ readonly binary: boolean;
28
+ };
29
+ export type Referrer = {
30
+ readonly path: string;
31
+ readonly target: string;
32
+ };
33
+ export type HeldRoomRow = {
34
+ readonly locator: string;
35
+ readonly key: number;
36
+ readonly record: string;
37
+ readonly indexed: boolean;
38
+ readonly documents: number;
39
+ };
40
+ export type HeldRoomWork = {
41
+ readonly room: (HeldRoomRow & {
42
+ readonly overlaid: readonly string[];
43
+ }) | null;
44
+ readonly queue: readonly {
45
+ readonly id: string;
46
+ readonly batch: string;
47
+ readonly state: string;
48
+ }[];
49
+ };
50
+ export type Covering = {
51
+ readonly rooms: readonly {
52
+ readonly locator: string;
53
+ readonly key: number;
54
+ readonly transfer: string;
55
+ readonly roomVersion: string;
56
+ readonly indexed: boolean;
57
+ readonly documents: number;
58
+ readonly bytes: number;
59
+ readonly offline: string;
60
+ }[];
61
+ readonly queues: readonly {
62
+ readonly locator: string;
63
+ readonly ids: readonly string[];
64
+ }[];
65
+ };
66
+ export type HeldLocators = {
67
+ readonly held: readonly string[];
68
+ readonly staged: readonly string[];
69
+ };
70
+ export type ReplicaOpened = {
71
+ readonly erasing: boolean;
72
+ readonly orphans: readonly number[];
73
+ };
74
+ export type RoomCommit = {
75
+ readonly locator: string;
76
+ readonly key: number;
77
+ readonly record?: string;
78
+ readonly roots?: readonly string[];
79
+ readonly published?: {
80
+ readonly from: number | null;
81
+ };
82
+ readonly refreshed?: true;
83
+ readonly composed: Composed;
84
+ readonly confirmed?: {
85
+ readonly set: readonly StoredEntry[];
86
+ readonly removed: readonly string[];
87
+ };
88
+ readonly overlay?: {
89
+ readonly set: readonly OverlayEntry[];
90
+ readonly cleared: readonly string[];
91
+ };
92
+ };
93
+ export type Committed = {
94
+ readonly changed: Readonly<Record<string, readonly string[] | null>>;
95
+ readonly indexed: Readonly<Record<string, boolean>>;
96
+ };
97
+ export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
98
+ export declare function stage(connection: Connection, request: {
99
+ readonly locator: string;
100
+ readonly transfer: string;
101
+ readonly key: number | null;
102
+ readonly fingerprint: string;
103
+ readonly entries: readonly StoredEntry[];
104
+ readonly folders: readonly string[];
105
+ readonly part: string | null;
106
+ }): number;
107
+ export type Resumed = {
108
+ readonly key: number | null;
109
+ readonly transfer: string;
110
+ readonly staged: readonly string[];
111
+ };
112
+ export declare function resume(connection: Connection, request: {
113
+ readonly locator: string;
114
+ readonly transfer: string;
115
+ readonly fingerprint: string;
116
+ readonly parts: readonly string[];
117
+ readonly published: number | null;
118
+ }): Resumed;
119
+ export declare function refreshing(connection: Connection, request: {
120
+ readonly key: number;
121
+ readonly composed: Composed;
122
+ readonly entries: readonly StoredEntry[];
123
+ readonly removals: readonly string[];
124
+ readonly folders: readonly string[];
125
+ readonly folderRemovals: readonly string[];
126
+ }): null;
127
+ export declare function unrefresh(connection: Connection, key: number): null;
128
+ export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
129
+ export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
130
+ export declare function abandon(connection: Connection, locator: string): null;
131
+ export declare function release(connection: Connection, key: number): null;
132
+ export declare function erase(connection: Connection, locator: string | null, limit: number): {
133
+ readonly remaining: boolean;
134
+ };
135
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
136
+ readonly done: boolean;
137
+ readonly text: number;
138
+ };
139
+ export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
140
+ export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
141
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
142
+ export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
143
+ export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
144
+ export declare function opened(connection: Connection): ReplicaOpened;
145
+ export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
146
+ export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
147
+ export declare function overlaid(connection: Connection, key: number): readonly string[];
148
+ export declare function covering(connection: Connection): Covering['rooms'];
149
+ export declare function offlineMode(connection: Connection, locator: string): string | null;
150
+ export declare function stagedLocators(connection: Connection): readonly string[];
151
+ export declare function heldLocators(connection: Connection): readonly string[];
152
+ export declare function demoted(connection: Connection): null;
153
+ export declare function facts(connection: Connection): Readonly<Record<string, string>>;
154
+ export declare function presentation(connection: Connection, app: string): string | null;
155
+ export declare function ended(connection: Connection): void;
@@ -0,0 +1,87 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
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';
10
+ import { type TypesResult } from './model.js';
11
+ import { type Observation } from './observation.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';
15
+ import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
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';
26
+ export type RoomSchemas = {
27
+ collection: TypesResult;
28
+ typedSelection: TypesResult | null;
29
+ };
30
+ export type MdRuntime = {
31
+ loaded(): Promise<void>;
32
+ rooms(): Promise<readonly AppRoom[]>;
33
+ query: {
34
+ (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
35
+ (query: GroupQuery): Promise<GroupResult | PendingResult>;
36
+ };
37
+ search(request: SearchRequest): Promise<SearchResult>;
38
+ types(locator: string): Promise<RoomSchemas>;
39
+ roomDraft: RoomDraftSurface;
40
+ conversation: ConversationSurface;
41
+ chatDraft: ChatDraftSurface;
42
+ presentation: PresentationSurface;
43
+ save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
44
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
45
+ history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
46
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
47
+ binaryFile: BinaryFileSurface;
48
+ call(name: string, input: unknown): Promise<CallResult>;
49
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
50
+ log(): string;
51
+ persistence(): boolean;
52
+ retry(): Promise<void>;
53
+ cleanUp(): Promise<number>;
54
+ unsent(): Promise<readonly UnsentWork[]>;
55
+ reset(): Promise<void>;
56
+ readAgain(): Promise<void>;
57
+ observe: {
58
+ (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
59
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
60
+ (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
61
+ (topic: 'storage-loss'): Promise<Observation<string | null>>;
62
+ (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
63
+ (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
64
+ (topic: 'member'): Promise<Observation<Member | null>>;
65
+ (topic: 'authority-changes'): Promise<Observation<number>>;
66
+ (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
+ (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
68
+ (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
69
+ (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
70
+ (topic: 'presentation', app: string): Promise<Observation<unknown>>;
71
+ (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
72
+ (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
73
+ (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
74
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
75
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
76
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
77
+ };
78
+ reauthorize(): Promise<void>;
79
+ };
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';
81
+ export type ComposedRuntime = RuntimeView & {
82
+ seed(entry: EntrySeed): void;
83
+ stop(): Promise<void>;
84
+ persisted(answer: Persistence): void;
85
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
86
+ };
87
+ export declare function composedRuntime(runtime: Runtime): ComposedRuntime;