@agentshouse/app-bridge 0.1.0-c3ebb08f5de71 → 0.1.0-c3ee7fcd01608

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