@agentshouse/app-bridge 0.1.0-c8d8dc6285bbd → 0.1.0-c8dc2a697434d

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 (120) hide show
  1. package/README.md +7 -7
  2. package/dist/index.d.ts +595 -24
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/definition.d.ts +20 -11
  6. package/dist/mdmodel/document.d.ts +14 -8
  7. package/dist/mdmodel/event.d.ts +76 -0
  8. package/dist/mdmodel/facts.d.ts +14 -0
  9. package/dist/mdmodel/fields.d.ts +1 -1
  10. package/dist/mdmodel/house-model.d.ts +869 -0
  11. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  12. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  13. package/dist/mdmodel/index.d.ts +40 -15
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/media-type.d.ts +71 -0
  17. package/dist/mdmodel/moment.d.ts +6 -0
  18. package/dist/mdmodel/not-ready.d.ts +1 -0
  19. package/dist/mdmodel/paths.d.ts +15 -1
  20. package/dist/mdmodel/pattern.d.ts +9 -0
  21. package/dist/mdmodel/query/language.d.ts +253 -0
  22. package/dist/mdmodel/query/match.d.ts +13 -0
  23. package/dist/mdmodel/query/rows.d.ts +31 -0
  24. package/dist/mdmodel/query/sql.d.ts +38 -0
  25. package/dist/mdmodel/references.d.ts +2 -2
  26. package/dist/mdmodel/reserved.d.ts +5 -0
  27. package/dist/mdmodel/room-types.d.ts +6 -0
  28. package/dist/mdmodel/types.d.ts +22 -17
  29. package/dist/mdmodel/validate.d.ts +12 -6
  30. package/dist/mdmodel/yaml.d.ts +4 -4
  31. package/dist/mdruntime/actions.d.ts +25 -0
  32. package/dist/mdruntime/adapter.d.ts +181 -113
  33. package/dist/mdruntime/attached-model.d.ts +6 -0
  34. package/dist/mdruntime/authored.d.ts +87 -0
  35. package/dist/mdruntime/bootstrap.d.ts +43 -0
  36. package/dist/mdruntime/cell.d.ts +5 -0
  37. package/dist/mdruntime/chain.d.ts +2 -1
  38. package/dist/mdruntime/change-set.d.ts +4 -0
  39. package/dist/mdruntime/change.d.ts +5 -0
  40. package/dist/mdruntime/client.d.ts +33 -25
  41. package/dist/mdruntime/collection.d.ts +31 -7
  42. package/dist/mdruntime/compile.d.ts +8 -6
  43. package/dist/mdruntime/conversation-live.d.ts +149 -0
  44. package/dist/mdruntime/conversation-row.d.ts +39 -0
  45. package/dist/mdruntime/conversation.d.ts +72 -51
  46. package/dist/mdruntime/declaration.d.ts +9 -0
  47. package/dist/mdruntime/durability.d.ts +19 -1
  48. package/dist/mdruntime/failure.d.ts +3 -0
  49. package/dist/mdruntime/figures.d.ts +48 -0
  50. package/dist/mdruntime/holdings.d.ts +28 -0
  51. package/dist/mdruntime/identity.d.ts +0 -1
  52. package/dist/mdruntime/install.d.ts +59 -0
  53. package/dist/mdruntime/listing.d.ts +51 -0
  54. package/dist/mdruntime/live.d.ts +24 -0
  55. package/dist/mdruntime/media.d.ts +24 -0
  56. package/dist/mdruntime/messages.d.ts +35 -5
  57. package/dist/mdruntime/model.d.ts +8 -11
  58. package/dist/mdruntime/observation.d.ts +29 -13
  59. package/dist/mdruntime/opened.d.ts +1 -1
  60. package/dist/mdruntime/outcome.d.ts +30 -7
  61. package/dist/mdruntime/overlay.d.ts +7 -2
  62. package/dist/mdruntime/preparation.d.ts +40 -0
  63. package/dist/mdruntime/presence.d.ts +57 -0
  64. package/dist/mdruntime/query.d.ts +18 -208
  65. package/dist/mdruntime/reach.d.ts +21 -13
  66. package/dist/mdruntime/readiness.d.ts +12 -21
  67. package/dist/mdruntime/reads.d.ts +38 -0
  68. package/dist/mdruntime/recovery.d.ts +3 -0
  69. package/dist/mdruntime/refresh.d.ts +26 -0
  70. package/dist/mdruntime/replica.d.ts +13 -20
  71. package/dist/mdruntime/retried.d.ts +29 -0
  72. package/dist/mdruntime/room-draft.d.ts +51 -12
  73. package/dist/mdruntime/room-drafts.d.ts +23 -0
  74. package/dist/mdruntime/runtime.d.ts +33 -0
  75. package/dist/mdruntime/save.d.ts +42 -84
  76. package/dist/mdruntime/saves.d.ts +33 -0
  77. package/dist/mdruntime/search.d.ts +12 -63
  78. package/dist/mdruntime/seed.d.ts +11 -2
  79. package/dist/mdruntime/socket/admission.d.ts +6 -0
  80. package/dist/mdruntime/socket/answers.d.ts +5 -0
  81. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  82. package/dist/mdruntime/socket/session.d.ts +37 -0
  83. package/dist/mdruntime/socket.d.ts +66 -0
  84. package/dist/mdruntime/source.d.ts +58 -0
  85. package/dist/mdruntime/status.d.ts +4 -5
  86. package/dist/mdruntime/store/installs.d.ts +29 -0
  87. package/dist/mdruntime/store/readiness.d.ts +10 -0
  88. package/dist/mdruntime/store/records.d.ts +222 -0
  89. package/dist/mdruntime/store/room-held.d.ts +7 -0
  90. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  91. package/dist/mdruntime/store/space.d.ts +10 -0
  92. package/dist/mdruntime/store/watchers.d.ts +16 -0
  93. package/dist/mdruntime/store/writes.d.ts +23 -0
  94. package/dist/mdruntime/store.d.ts +113 -157
  95. package/dist/mdruntime/stored.d.ts +79 -57
  96. package/dist/mdruntime/surface.d.ts +89 -0
  97. package/dist/mdruntime/tables.d.ts +129 -107
  98. package/dist/mdruntime/tallies.d.ts +17 -0
  99. package/dist/mdruntime/transfer.d.ts +0 -5
  100. package/dist/mdruntime/wire.d.ts +75 -13
  101. package/dist/session-content/bounds.d.ts +7 -0
  102. package/dist/session-content/check.d.ts +18 -0
  103. package/dist/session-content/index.d.ts +7 -0
  104. package/dist/session-content/parts.d.ts +103 -0
  105. package/dist/session-content/state.d.ts +61 -0
  106. package/dist/session-content/turn.d.ts +328 -0
  107. package/dist/test-host.d.ts +8 -4
  108. package/dist/test-host.js +28 -28
  109. package/docs/families.md +79 -67
  110. package/package.json +2 -2
  111. package/dist/calls.d.ts +0 -1007
  112. package/dist/calls.js +0 -1
  113. package/dist/mdmodel/blocks.d.ts +0 -10
  114. package/dist/mdmodel/condition.d.ts +0 -160
  115. package/dist/mdmodel/links.d.ts +0 -28
  116. package/dist/mdmodel/profile.d.ts +0 -5
  117. package/dist/mdruntime/connection.d.ts +0 -151
  118. package/dist/mdruntime/file.d.ts +0 -11
  119. package/dist/mdruntime/fulltext.d.ts +0 -26
  120. package/dist/mdruntime/shared.d.ts +0 -15
@@ -1,169 +1,125 @@
1
- import type { BootstrapInventory, Capability, KeptReceipt, Member, ProviderLimit } from './adapter.js';
1
+ import type { TypedPath } from './adapter.js';
2
+ import { schemaTypes } from './attached-model.js';
3
+ import { type Cell } from './cell.js';
2
4
  import type { ChangeBatch } from './change.js';
5
+ import type { ChangeSet } from './change-set.js';
3
6
  import type { Composition } from './collection.js';
4
- import type { Plan } from './query.js';
5
- import type { ReplicaRecord } from './replica.js';
6
- import type { Submission } from './outcome.js';
7
- import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
7
+ import type { ReadinessShowing, ReadinessWatch } from './preparation.js';
8
+ import type { Persistence } from './readiness.js';
9
+ import type { Retries } from './retried.js';
10
+ import type { Seeded } from './seed.js';
8
11
  import type { ModelState } from './model.js';
9
- import type { SearchWindow } from './search.js';
10
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View, Walked } from './tables.js';
11
- export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
12
- export type TransferWriting = {
13
- readonly token: string | null;
14
- readonly written: number;
12
+ import { type OpenedFiles } from './opened.js';
13
+ import { type HeldReplica, type ReplicaRecord } from './replica.js';
14
+ import type { ReturnReason, RoomDraftRecord } from './room-draft.js';
15
+ import { type SyncStatus } from './status.js';
16
+ import type { RuntimeDatabase } from './tables.js';
17
+ import { type Installs } from './store/installs.js';
18
+ import { type HeldCover, type HeldStatus, type PendingState, type RuntimeStore } from './store/records.js';
19
+ import { type ReadinessQueue } from './store/readiness.js';
20
+ import { type RoomHeld } from './store/room-held.js';
21
+ import { type RoomsShown } from './store/rooms-shown.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 type { RoomInstall } from './store/installs.js';
26
+ export type { AuthoredWrite, ChatDraftRecord, ChatSubmission, ConversationFact, 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;
15
33
  };
16
- export type TransferRecord = {
17
- readonly locator: string;
18
- readonly transfer: string;
19
- readonly selection: string;
20
- readonly from: string;
21
- readonly last: string;
22
- readonly pageToken: string | null;
23
- readonly writing: TransferWriting | null;
24
- readonly inventory: BootstrapInventory | null;
25
- readonly done: BootstrapInventory;
26
- readonly models: {
27
- readonly collection: ModelState;
28
- readonly selection: ModelState;
29
- };
30
- readonly key: number | null;
34
+ export type Held = HeldReplica & {
35
+ readonly states: ReadonlyMap<string, PendingState>;
31
36
  };
32
- export type PendingState = {
33
- readonly drafts: readonly SavedDraft[];
34
- readonly submission: Submission;
35
- readonly lost: boolean;
36
- readonly upload?: unknown;
37
- readonly accepted?: string;
37
+ export type Work = {
38
+ readonly replica: Held | undefined;
39
+ readonly queue: readonly ChangeBatch[];
40
+ readonly states: ReadonlyMap<string, PendingState>;
38
41
  };
39
- export type TargetRecord = {
40
- established: boolean;
42
+ type HeldConflict = {
43
+ readonly revisions: Readonly<Record<string, string | undefined>>;
44
+ readonly returned: ReturnReason | null;
41
45
  };
42
- export type QueueRecord = {
43
- locator: string;
44
- pending: readonly {
45
- batch: ChangeBatch;
46
- state: PendingState;
47
- }[];
46
+ type AttachedFile = {
47
+ readonly revision: string;
48
+ readonly mediaType: string;
48
49
  };
49
- export type PresentationRecord = {
50
- app: string;
51
- value: unknown;
50
+ type Seeds = {
51
+ of(key: string): Seeded | undefined;
52
+ keep(key: string, seed: Seeded): void;
53
+ drop(key: string): void;
52
54
  };
53
- export type ChatSubmission = {
54
- readonly operation: string;
55
- readonly text: string;
56
- readonly turn: string | null;
55
+ type Device = {
56
+ readonly persistence: Persistence;
57
+ readonly storageLoss: string | null;
58
+ readonly heldWhenOpened: boolean;
59
+ readonly preparing: boolean;
60
+ readonly sweeping: boolean;
61
+ readonly unpreparedDemand: ReadonlySet<string>;
62
+ readonly unpreparable: ReadonlySet<string>;
63
+ readonly establishing: ReadonlySet<string>;
64
+ readonly status: SyncStatus;
57
65
  };
58
- export type ChatDraftRecord = {
59
- conversation: string;
60
- text: string;
61
- revision: string;
62
- submitted?: readonly ChatSubmission[];
63
- moves?: readonly string[];
66
+ type StoreOptions = {
67
+ readonly database: RuntimeDatabase;
68
+ readonly roomTypes: Parameters<typeof schemaTypes>[1];
69
+ readonly builtIn: ModelState;
70
+ readonly typedPaths: readonly TypedPath[];
71
+ readonly persistence: Persistence;
72
+ readonly retries: Retries;
73
+ lost(locator: string): boolean;
74
+ losing(): boolean;
75
+ opening(records: RuntimeStore): Promise<RuntimeStore>;
76
+ unpublished(error: unknown): void;
77
+ changed(set: ChangeSet): Promise<void>;
78
+ deliverReadiness(owed: readonly ReadinessWatch[], rooms: ReadonlySet<string> | null): Promise<void>;
79
+ spaceFreed(): void;
64
80
  };
65
- export type CallRecord = {
66
- readonly operation: string;
67
- readonly name: string;
68
- readonly input: unknown;
81
+ export type Store = {
82
+ readonly device: Cell<Device>;
83
+ readonly roomsShown: RoomsShown;
84
+ readonly space: Space;
85
+ readonly readiness: ReadinessQueue<ReadinessWatch, ReadinessShowing>;
86
+ ask: RuntimeDatabase['ask'];
87
+ changed(set: ChangeSet): Promise<void>;
88
+ open(): Promise<RuntimeStore>;
89
+ durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
90
+ exclusive<T>(work: () => Promise<T>): Promise<T>;
91
+ gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
92
+ written(): Promise<unknown>;
93
+ startingWrite<T>(work: () => Promise<T>): Promise<T>;
94
+ finishingWrite<T>(work: () => Promise<T>): Promise<T>;
95
+ ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
96
+ rederive: ReturnType<typeof createWrites>['rederive'];
97
+ refreshPage: ReturnType<typeof createWrites>['refreshPage'];
98
+ stageBytes(): number;
99
+ deriveBytes(): number;
100
+ rooms(locators?: readonly string[]): Promise<ReadonlyMap<string, Stored>>;
101
+ record(locator: string): Promise<ReplicaRecord | undefined>;
102
+ work(locator: string): Promise<Work>;
103
+ replica(locator: string): Promise<Held | undefined>;
104
+ covering(): Promise<HeldCover>;
105
+ status(): Promise<HeldStatus>;
106
+ queued(): Promise<readonly string[]>;
107
+ drafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
108
+ draft(locator: string, path: string): Promise<RoomDraftRecord | undefined>;
109
+ composed(record: Pick<ReplicaRecord, 'model' | 'declaration'>): Composition;
110
+ publication(work: () => Promise<void>): Promise<void>;
111
+ owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
112
+ watch(topic: string, notify: (value: unknown) => void): Watcher;
113
+ watching(topic: string, which?: Watching): readonly Watcher[];
114
+ tell(topic: string, value: unknown): void;
115
+ readonly installs: Installs;
116
+ readonly seeds: Seeds;
117
+ readonly conflicted: RoomHeld<HeldConflict>;
118
+ readonly attached: RoomHeld<AttachedFile>;
119
+ readonly opened: OpenedFiles;
120
+ part(file: string, part: number): Promise<Uint8Array | null>;
121
+ prepareAgain(locator?: string): void;
122
+ forget(locator: string): void;
123
+ close(): void;
69
124
  };
70
- export type AuthoredWrite = {
71
- locator: string;
72
- queue?: readonly ChangeBatch[];
73
- founded?: readonly ChangeBatch[];
74
- saved?: ReadonlyMap<string, readonly SavedDraft[]>;
75
- roomDrafts?: readonly RoomDraftRecord[];
76
- consumedRoomDrafts?: readonly string[];
77
- accepted?: readonly {
78
- readonly id: string;
79
- readonly roomVersion: string;
80
- }[];
81
- };
82
- export type StagedPage = {
83
- readonly entries: readonly StoredEntry[];
84
- readonly folders: readonly string[];
85
- };
86
- export type RefreshedPage = StagedPage & {
87
- readonly removals: readonly string[];
88
- readonly folderRemovals: readonly string[];
89
- };
90
- export type Opened = {
91
- readonly rooms: ReadonlyMap<string, ReplicaRecord>;
92
- readonly transfers: ReadonlyMap<string, TransferRecord>;
93
- readonly unindexed: ReadonlySet<number>;
94
- readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
95
- readonly erasing: boolean;
96
- readonly orphans: readonly number[];
97
- readonly lastCompleted: string | null;
98
- readonly providerLimits: readonly ProviderLimit[];
99
- readonly capabilities: readonly Capability[];
100
- readonly member: Member | null;
101
- readonly targets: Readonly<Record<string, TargetRecord>>;
102
- readonly presentation: readonly PresentationRecord[];
103
- };
104
- export type Commit = {
105
- readonly rooms: readonly RoomCommit[];
106
- readonly writes?: readonly AuthoredWrite[];
107
- readonly files?: readonly StoredFile[];
108
- readonly whole?: boolean;
109
- readonly discards?: readonly string[];
110
- };
111
- export type RuntimeStore = {
112
- opened(): Promise<Opened>;
113
- counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
114
- query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
115
- changes(keys: readonly number[]): number;
116
- entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
117
- typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
118
- referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
119
- walk(key: number, view: View, after: string | null, bytes: number): Promise<Walked>;
120
- files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
121
- readonly path: string;
122
- readonly revision: string;
123
- }[]>;
124
- typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
125
- search(ask: SearchAsk): Promise<SearchWindow>;
126
- stage(record: TransferRecord, composition: Composition, page: StagedPage, written?: string): Promise<number | null>;
127
- transferPart(locator: string, token: string): Promise<Uint8Array | null>;
128
- keepPart(locator: string, token: string, part: Uint8Array): Promise<void>;
129
- refresh(key: number, page: RefreshedPage): Promise<void>;
130
- unrefresh(key: number): Promise<void>;
131
- commit(commit: Commit): Promise<CommittedWrite>;
132
- fence(locators: readonly string[]): Promise<void>;
133
- erase(locator: string | null, limit: number): Promise<boolean>;
134
- abandon(locator: string, kept?: boolean): Promise<number | null>;
135
- release(key: number): Promise<void>;
136
- rederive(key: number, limit: number): Promise<boolean>;
137
- fact(name: string, value: unknown): Promise<void>;
138
- queues(): Promise<readonly QueueRecord[]>;
139
- submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
140
- keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
141
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
142
- present(record: PresentationRecord): Promise<void>;
143
- conversations(): Promise<readonly HeldConversation[]>;
144
- keepMessages(write: ConversationWrite): Promise<void>;
145
- messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
146
- messageCount(conversation: string): Promise<number>;
147
- turnArrived(conversation: string, turn: string): Promise<boolean>;
148
- dropConversations(conversations: readonly string[]): Promise<void>;
149
- chatDrafts(): Promise<readonly ChatDraftRecord[]>;
150
- keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
151
- dropChatDraft(conversation: string): Promise<void>;
152
- calls(): Promise<readonly CallRecord[]>;
153
- keepCall(record: CallRecord): Promise<void>;
154
- dropCall(operation: string): Promise<void>;
155
- keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
156
- discardRoomDraft(locator: string, path: string): Promise<void>;
157
- fences(): Promise<readonly string[]>;
158
- receivedHeads(): Promise<readonly KeptReceipt[]>;
159
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
160
- keepReceived(key: string, head: unknown, part?: {
161
- index: number;
162
- value: unknown;
163
- }): Promise<void>;
164
- dropReceived(keys: readonly string[]): Promise<void>;
165
- generation(): Promise<string | null>;
166
- rememberGeneration(value: string): Promise<void>;
167
- file(key: string, type: string): Promise<Blob>;
168
- };
169
- export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
125
+ export declare function createStore(options: StoreOptions): Store;
@@ -1,5 +1,5 @@
1
- import type { HeadChange } from './adapter.js';
2
- import type { Composition } from './collection.js';
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
3
  import type { HeldBinary } from './overlay.js';
4
4
  import type { Connection } from './tables.js';
5
5
  export declare const REPLICA_TABLES: readonly string[];
@@ -10,8 +10,10 @@ export type StoredEntry = {
10
10
  readonly binary: HeldBinary | null;
11
11
  readonly revision: string | null;
12
12
  readonly fileId: string | null;
13
+ readonly created: string | null;
13
14
  readonly change: HeadChange | null;
14
15
  readonly written: string | null;
16
+ readonly facts: SavedFacts | null;
15
17
  };
16
18
  export type OverlayEntry = StoredEntry & {
17
19
  readonly present: boolean;
@@ -27,39 +29,56 @@ export type TypedEntry = {
27
29
  export type Referrer = {
28
30
  readonly path: string;
29
31
  readonly target: string;
30
- readonly kind: string;
31
32
  };
32
- export type HeldKey = {
33
+ export type HeldRoomRow = {
34
+ readonly locator: string;
33
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 CoverLog = {
51
+ readonly token: string;
52
+ readonly at: number;
53
+ };
54
+ export type CoveredRow = {
34
55
  readonly locator: string;
56
+ readonly key: number;
35
57
  readonly transfer: string;
36
- readonly rederiving: number | null;
58
+ readonly roomVersion: string;
59
+ readonly indexed: boolean;
60
+ readonly documents: number;
61
+ readonly bytes: number;
62
+ readonly offline: string;
37
63
  };
38
- export type ReplicaOpened = {
39
- readonly rooms: readonly {
40
- readonly locator: string;
41
- readonly key: number;
42
- readonly record: string;
43
- }[];
44
- readonly transfers: readonly {
45
- readonly locator: string;
46
- readonly key: number;
47
- readonly record: string;
48
- }[];
49
- readonly keys: readonly HeldKey[];
50
- readonly facts: Readonly<Record<string, string>>;
51
- readonly presentation: readonly {
52
- readonly app: string;
53
- readonly value: string;
54
- }[];
55
- readonly overlaid: readonly {
56
- readonly key: number;
57
- readonly path: string;
58
- }[];
59
- readonly erasing: readonly {
60
- readonly key: number;
64
+ export type CoveredRooms = {
65
+ readonly log: CoverLog;
66
+ readonly whole: boolean;
67
+ readonly rooms: readonly CoveredRow[];
68
+ readonly removed: readonly string[];
69
+ };
70
+ export type Covering = CoveredRooms & {
71
+ readonly queues: readonly {
61
72
  readonly locator: string;
73
+ readonly ids: readonly string[];
62
74
  }[];
75
+ };
76
+ export type HeldLocators = {
77
+ readonly held: readonly string[];
78
+ readonly staged: readonly string[];
79
+ };
80
+ export type ReplicaOpened = {
81
+ readonly erasing: boolean;
63
82
  readonly orphans: readonly number[];
64
83
  };
65
84
  export type RoomCommit = {
@@ -71,7 +90,7 @@ export type RoomCommit = {
71
90
  readonly from: number | null;
72
91
  };
73
92
  readonly refreshed?: true;
74
- readonly composition?: Composition;
93
+ readonly composed: Composed;
75
94
  readonly confirmed?: {
76
95
  readonly set: readonly StoredEntry[];
77
96
  readonly removed: readonly string[];
@@ -82,63 +101,66 @@ export type RoomCommit = {
82
101
  };
83
102
  };
84
103
  export type Committed = {
85
- readonly counts: Readonly<Record<string, number>>;
86
104
  readonly changed: Readonly<Record<string, readonly string[] | null>>;
87
105
  readonly indexed: Readonly<Record<string, boolean>>;
88
106
  };
89
- export type CountedRoom = {
90
- readonly key: number;
91
- readonly roots: readonly string[];
92
- };
93
- export type Walked = {
94
- readonly entries: readonly HeldEntry[];
95
- readonly next: string | null;
96
- };
97
- export declare function fingerprint(composition: Composition): string;
98
107
  export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
99
108
  export declare function stage(connection: Connection, request: {
100
109
  readonly locator: string;
101
110
  readonly transfer: string;
102
- readonly record: string;
103
111
  readonly key: number | null;
104
- readonly composition: Composition;
112
+ readonly fingerprint: string;
105
113
  readonly entries: readonly StoredEntry[];
106
114
  readonly folders: readonly string[];
107
- readonly written?: string;
115
+ readonly part: string | null;
108
116
  }): number;
117
+ export type Resumed = {
118
+ readonly key: number | null;
119
+ readonly transfer: string;
120
+ readonly staged: readonly string[];
121
+ };
122
+ export declare function resume(connection: Connection, request: {
123
+ readonly locator: string;
124
+ readonly transfer: string;
125
+ readonly fingerprint: string;
126
+ readonly parts: readonly string[];
127
+ readonly published: number | null;
128
+ }): Resumed;
109
129
  export declare function refreshing(connection: Connection, request: {
110
130
  readonly key: number;
131
+ readonly composed: Composed;
111
132
  readonly entries: readonly StoredEntry[];
112
133
  readonly removals: readonly string[];
113
134
  readonly folders: readonly string[];
114
135
  readonly folderRemovals: readonly string[];
115
136
  }): null;
116
137
  export declare function unrefresh(connection: Connection, key: number): null;
117
- export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
118
138
  export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
119
139
  export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
120
- export declare function abandon(connection: Connection, locator: string, kept: boolean): number | null;
140
+ export declare function abandon(connection: Connection, locator: string): null;
121
141
  export declare function release(connection: Connection, key: number): null;
122
142
  export declare function erase(connection: Connection, locator: string | null, limit: number): {
123
143
  readonly remaining: boolean;
124
144
  };
125
- export declare function rederive(connection: Connection, key: number, limit: number): {
145
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
126
146
  readonly done: boolean;
147
+ readonly text: number;
127
148
  };
128
149
  export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
129
150
  export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
130
- export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
131
- export declare function walk(connection: Connection, key: number, view: View, after: string | null, bytes: number): Walked;
132
- export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
133
- readonly path: string;
134
- readonly revision: string;
135
- }[];
151
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
152
+ export declare function folders(connection: Connection, key: number, list: readonly string[]): string[];
136
153
  export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
137
- export declare function transferPart(connection: Connection, locator: string, token: string): Uint8Array | null;
138
- export declare function keepPart(connection: Connection, request: {
139
- readonly locator: string;
140
- readonly token: string;
141
- readonly part: Uint8Array;
142
- }): null;
143
154
  export declare function opened(connection: Connection): ReplicaOpened;
155
+ export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
156
+ export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
157
+ export declare function overlaid(connection: Connection, key: number): readonly string[];
158
+ export declare function covering(connection: Connection, since: CoverLog | null): CoveredRooms;
159
+ export declare function offlineMode(connection: Connection, locator: string): string | null;
160
+ export declare function stagedLocators(connection: Connection): readonly string[];
161
+ export declare function heldLocators(connection: Connection): readonly string[];
162
+ export declare function demoted(connection: Connection): null;
163
+ export declare function facts(connection: Connection, names: readonly string[] | null): Readonly<Record<string, string>>;
164
+ export declare function presentation(connection: Connection, app: string): string | null;
165
+ export declare function tablesOf(statements: readonly string[]): readonly string[];
144
166
  export declare function ended(connection: Connection): void;
@@ -0,0 +1,89 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import { type HistoryQuery } from './actions.js';
3
+ import type { ListedAgent, Member, RoomList, ServiceMode } from './adapter.js';
4
+ import type { WrittenBy } from './change.js';
5
+ import { type ChatDraftSurface, type ConversationEntry, type ConversationAgent, type ConversationOptions, type ConversationSurface, type 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
+ answered(operation: string): Promise<boolean>;
50
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
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: 'listed-agents'): Promise<Observation<readonly ListedAgent[]>>;
75
+ (topic: 'room-list'): Promise<Observation<RoomList | null>>;
76
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
77
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
78
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
79
+ };
80
+ reauthorize(): Promise<void>;
81
+ };
82
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'listed-agents' | 'room-list' | 'figures' | 'holdings' | 'read';
83
+ export type ComposedRuntime = RuntimeView & {
84
+ seed(entry: EntrySeed): void;
85
+ stop(): Promise<void>;
86
+ persisted(answer: Persistence): void;
87
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
88
+ };
89
+ export declare function composedRuntime(runtime: Runtime): ComposedRuntime;