@agentshouse/app-bridge 0.1.0-c895bda3a3f6a → 0.1.0-c8a196c36dc76

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 (119) hide show
  1. package/README.md +6 -6
  2. package/dist/index.d.ts +247 -407
  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 +14 -9
  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 -22
  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 +161 -81
  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 +36 -23
  43. package/dist/mdruntime/collection.d.ts +27 -4
  44. package/dist/mdruntime/compile.d.ts +9 -7
  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 +67 -46
  48. package/dist/mdruntime/declaration.d.ts +9 -0
  49. package/dist/mdruntime/durability.d.ts +20 -0
  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 +19 -2
  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 +6 -12
  62. package/dist/mdruntime/observation.d.ts +30 -13
  63. package/dist/mdruntime/opened.d.ts +1 -1
  64. package/dist/mdruntime/outcome.d.ts +17 -2
  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 +13 -211
  69. package/dist/mdruntime/reach.d.ts +25 -14
  70. package/dist/mdruntime/readiness.d.ts +20 -7
  71. package/dist/mdruntime/reads.d.ts +38 -0
  72. package/dist/mdruntime/recovery.d.ts +4 -1
  73. package/dist/mdruntime/refresh.d.ts +26 -0
  74. package/dist/mdruntime/replica.d.ts +11 -16
  75. package/dist/mdruntime/retried.d.ts +29 -0
  76. package/dist/mdruntime/room-draft.d.ts +33 -9
  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 -86
  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 +0 -2
  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 +116 -154
  99. package/dist/mdruntime/stored.d.ts +80 -69
  100. package/dist/mdruntime/surface.d.ts +93 -0
  101. package/dist/mdruntime/tables.d.ts +118 -93
  102. package/dist/mdruntime/tallies.d.ts +17 -0
  103. package/dist/mdruntime/transfer.d.ts +4 -0
  104. package/dist/mdruntime/wire.d.ts +81 -7
  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 -1
  111. package/dist/test-host.js +45 -2
  112. package/docs/families.md +78 -39
  113. package/package.json +2 -2
  114. package/dist/mdmodel/blocks.d.ts +0 -10
  115. package/dist/mdmodel/condition.d.ts +0 -180
  116. package/dist/mdmodel/links.d.ts +0 -28
  117. package/dist/mdmodel/profile.d.ts +0 -5
  118. package/dist/mdruntime/connection.d.ts +0 -153
  119. package/dist/mdruntime/fulltext.d.ts +0 -26
@@ -1,5 +1,4 @@
1
- import type { Outline } from '../mdmodel/index.js';
2
- import type { HeadChange } from './adapter.js';
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
3
2
  import { type Composed, type Composition } from './collection.js';
4
3
  import type { HeldBinary } from './overlay.js';
5
4
  import type { Connection } from './tables.js';
@@ -8,12 +7,13 @@ export type View = 'confirmed' | 'visible' | 'refreshed';
8
7
  export type StoredEntry = {
9
8
  readonly path: string;
10
9
  readonly content: string | null;
11
- readonly outline: Outline | null;
12
10
  readonly binary: HeldBinary | null;
13
11
  readonly revision: string | null;
14
12
  readonly fileId: string | null;
13
+ readonly created: string | null;
15
14
  readonly change: HeadChange | null;
16
15
  readonly written: string | null;
16
+ readonly facts: SavedFacts | null;
17
17
  };
18
18
  export type OverlayEntry = StoredEntry & {
19
19
  readonly present: boolean;
@@ -21,6 +21,11 @@ export type OverlayEntry = StoredEntry & {
21
21
  export type HeldEntry = StoredEntry & {
22
22
  readonly type: string | null;
23
23
  };
24
+ export type ValuedEntry = {
25
+ readonly path: string;
26
+ readonly type: string;
27
+ readonly fields: Readonly<Record<string, unknown>>;
28
+ };
24
29
  export type TypedEntry = {
25
30
  readonly path: string;
26
31
  readonly type: string | null;
@@ -29,35 +34,57 @@ export type TypedEntry = {
29
34
  export type Referrer = {
30
35
  readonly path: string;
31
36
  readonly target: string;
32
- readonly kind: string;
33
37
  };
34
- export type HeldKey = {
38
+ export type HeldRoomRow = {
39
+ readonly locator: string;
35
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 = {
36
60
  readonly locator: string;
61
+ readonly handle: string;
62
+ readonly key: number;
37
63
  readonly transfer: string;
38
- readonly rederiving: number | null;
39
- readonly searching: number | null;
64
+ readonly roomVersion: string;
65
+ readonly indexed: boolean;
66
+ readonly documents: number;
67
+ readonly bytes: number;
68
+ readonly offline: string;
40
69
  };
41
- export type ReplicaOpened = {
42
- readonly rooms: readonly {
43
- readonly locator: string;
44
- readonly key: number;
45
- readonly record: string;
46
- }[];
47
- readonly keys: readonly HeldKey[];
48
- readonly facts: Readonly<Record<string, string>>;
49
- readonly presentation: readonly {
50
- readonly app: string;
51
- readonly value: string;
52
- }[];
53
- readonly overlaid: readonly {
54
- readonly key: number;
55
- readonly path: string;
56
- }[];
57
- readonly erasing: readonly {
58
- 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 {
59
78
  readonly locator: string;
79
+ readonly ids: readonly string[];
60
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;
61
88
  readonly orphans: readonly number[];
62
89
  };
63
90
  export type RoomCommit = {
@@ -80,15 +107,11 @@ export type RoomCommit = {
80
107
  };
81
108
  };
82
109
  export type Committed = {
83
- readonly counts: Readonly<Record<string, number>>;
84
110
  readonly changed: Readonly<Record<string, readonly string[] | null>>;
85
111
  readonly indexed: Readonly<Record<string, boolean>>;
86
112
  };
87
- export type CountedRoom = {
88
- readonly key: number;
89
- readonly roots: readonly string[];
90
- };
91
- 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;
92
115
  export declare function stage(connection: Connection, request: {
93
116
  readonly locator: string;
94
117
  readonly transfer: string;
@@ -96,7 +119,20 @@ export declare function stage(connection: Connection, request: {
96
119
  readonly fingerprint: string;
97
120
  readonly entries: readonly StoredEntry[];
98
121
  readonly folders: readonly string[];
122
+ readonly part: string | null;
99
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;
100
136
  export declare function refreshing(connection: Connection, request: {
101
137
  readonly key: number;
102
138
  readonly composed: Composed;
@@ -106,7 +142,6 @@ export declare function refreshing(connection: Connection, request: {
106
142
  readonly folderRemovals: readonly string[];
107
143
  }): null;
108
144
  export declare function unrefresh(connection: Connection, key: number): null;
109
- export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
110
145
  export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
111
146
  export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
112
147
  export declare function abandon(connection: Connection, locator: string): null;
@@ -118,45 +153,21 @@ export declare function rederive(connection: Connection, key: number, composed:
118
153
  readonly done: boolean;
119
154
  readonly text: number;
120
155
  };
121
- export type HeldText = {
122
- readonly path: string;
123
- readonly revision: string;
124
- readonly content: string;
125
- };
126
- export declare function holdTexts(connection: Connection, request: {
127
- readonly key: number;
128
- readonly locator: string;
129
- readonly composed: Composed;
130
- readonly texts: readonly HeldText[];
131
- }): string[];
132
- export declare function unholdTexts(connection: Connection, request: {
133
- readonly key: number;
134
- readonly locator: string;
135
- readonly composed: Composed;
136
- }): {
137
- readonly paths: readonly string[];
138
- readonly bytes: number;
139
- };
140
- export declare function remembered(connection: Connection, request: {
141
- readonly key: number;
142
- readonly locator: string;
143
- readonly paths: readonly string[];
144
- }): null;
145
- export declare function wanted(connection: Connection, request: {
146
- readonly key: number;
147
- readonly locator: string;
148
- }): {
149
- readonly path: string;
150
- readonly revision: string;
151
- }[];
152
156
  export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
153
157
  export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
154
- export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
155
- export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
156
- readonly path: string;
157
- readonly revision: string;
158
- }[];
159
- export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
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[];
160
160
  export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
161
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[];
162
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;
@@ -1,14 +1,17 @@
1
1
  import { type QueryAnswer, type QueryRoom } from './compile.js';
2
2
  import type { Composed } from './collection.js';
3
- import { type SearchAsk } from './fulltext.js';
4
- import { type ConversationWrite, type HeldConversation, type MessageWindow } from './messages.js';
5
- import type { Plan } from './query.js';
6
- import type { SearchWindow } from './search.js';
7
- import { type Committed, type CountedRoom, type HeldEntry, type HeldText, type ReplicaOpened, type Referrer, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
8
- export type { Committed, CountedRoom, HeldEntry, HeldText, OverlayEntry, ReplicaOpened, Referrer, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
3
+ import { type AuthoredFact, type AuthoredWrite, type HeldQueues, type KeptRecord, type StoredFile } from './authored.js';
4
+ import type { UnsentWork } from './durability.js';
5
+ import { type ConversationWrite, type HeldConversation, type HeldFact, type HeldRow, type MessageWindow } from './messages.js';
6
+ import type { GroupTotal, Plan } from './query.js';
7
+ import { type ReadAt } from './reads.js';
8
+ import { type ConversationTally, type RoomTally } from './tallies.js';
9
+ import { type Committed, type CoverLog, type Covering, type HeldEntry, type HeldLocators, type HeldRoomRow, type HeldRoomWork, type ReplicaOpened, type Referrer, type Resumed, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
10
+ export type { Committed, CoverLog, Covering, HeldEntry, HeldLocators, HeldRoomRow, HeldRoomWork, OverlayEntry, ReplicaOpened, Referrer, Resumed, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
11
+ export { authoredEmptied, authoredTable, FILE_PART_BYTES, formatted, heldTables, type AuthoredFact, type AuthoredRows, type KeptRecord, type StoredFile, } from './authored.js';
9
12
  export type { QueryAnswer, QueryRoom } from './compile.js';
10
- export type { SearchAsk } from './fulltext.js';
11
- export type { ConversationWrite, HeldConversation, MessageWindow } from './messages.js';
13
+ export type { ConversationFact, ConversationWrite, HeldConversation, HeldFact, HeldRow, MessageWindow, } from './messages.js';
14
+ export type { ConversationTally, RoomTally } from './tallies.js';
12
15
  export type Value = string | number | bigint | Uint8Array | null;
13
16
  export type Row = Readonly<Record<string, Value>>;
14
17
  export interface Connection {
@@ -36,6 +39,10 @@ export interface SqliteStatement {
36
39
  }
37
40
  export interface SqliteDatabase {
38
41
  readonly pointer: number;
42
+ createFunction(name: string, run: (context: number, ...values: Value[]) => Value, options: {
43
+ readonly arity: number;
44
+ readonly deterministic: true;
45
+ }): unknown;
39
46
  exec(options: {
40
47
  readonly sql: string;
41
48
  readonly bind: readonly Value[];
@@ -45,56 +52,38 @@ export interface SqliteDatabase {
45
52
  prepare(sql: string): SqliteStatement;
46
53
  }
47
54
  export declare function sqliteConnection(engine: SqliteEngine, database: SqliteDatabase): Connection;
48
- export declare const FILE_PART_BYTES = 1048576;
49
55
  export declare const RUNTIME_TABLES: readonly string[];
50
- export type AuthoredFact = 'holder' | 'binding' | 'generation';
51
- export type StoredFile = {
52
- readonly key: string;
53
- readonly blob: Blob;
54
- };
55
56
  export interface FileSpool {
56
57
  held(): Iterable<string>;
57
58
  spool(key: string, type: string, parts: Iterable<Uint8Array>): Promise<Blob>;
58
59
  drop(key: string): Promise<void>;
59
60
  probe(bytes: number): Promise<void>;
60
61
  }
61
- export type KeptPending = {
62
- readonly id: string;
63
- readonly batch: string;
64
- readonly state: string;
65
- readonly files: readonly string[];
66
- };
67
- export type KeptRecord = {
68
- readonly record: string;
69
- readonly files: readonly string[];
70
- };
71
- export type AuthoredRows = {
72
- readonly locator: string;
73
- readonly order?: readonly string[];
74
- readonly added?: readonly KeptPending[];
75
- readonly founded?: readonly Omit<KeptPending, 'state'>[];
76
- readonly roomDrafts?: readonly (KeptRecord & {
77
- readonly path: string;
78
- })[];
79
- readonly consumedRoomDrafts?: readonly string[];
80
- };
81
- export type HeldQueues = {
82
- readonly queues: readonly {
62
+ export type HeldStatus = {
63
+ readonly queued: readonly string[];
64
+ readonly lastCompleted: string | null;
65
+ readonly changes: readonly {
83
66
  readonly locator: string;
84
- readonly ids: readonly string[];
67
+ readonly path: string;
85
68
  }[];
86
- readonly pending: readonly {
69
+ readonly resets: readonly {
87
70
  readonly locator: string;
88
- readonly id: string;
89
- readonly batch: string;
90
- readonly state: string;
71
+ readonly reset: string;
91
72
  }[];
73
+ readonly returned: readonly string[];
92
74
  };
93
75
  export type OpenedFile = {
94
76
  readonly key: string;
95
77
  readonly byteLength: number;
96
78
  readonly mediaType: string;
97
79
  };
80
+ export type OpenedRoom = GroupTotal & {
81
+ readonly room: string;
82
+ };
83
+ export type OpenedHeld = {
84
+ readonly rooms: readonly OpenedRoom[];
85
+ readonly cleanable: number;
86
+ };
98
87
  type Asked<A, R> = {
99
88
  readonly asked: A;
100
89
  readonly answer: R;
@@ -103,18 +92,35 @@ type Nothing = Readonly<Record<never, never>>;
103
92
  export type CommittedWrite = Committed & {
104
93
  readonly fenced: string | null;
105
94
  };
106
- export type AuthoredWrite = {
107
- readonly writes: readonly AuthoredRows[];
108
- readonly files: readonly StoredFile[];
109
- readonly whole: boolean;
110
- readonly discards?: readonly string[];
111
- };
112
95
  export interface RuntimeRequests {
113
- readonly 'authored.queues': Asked<Nothing, HeldQueues>;
114
- readonly 'authored.roomDrafts': Asked<Nothing, readonly string[]>;
96
+ readonly 'authored.status': Asked<Nothing, HeldStatus>;
97
+ readonly 'authored.moving': Asked<Nothing, HeldQueues>;
98
+ readonly 'authored.pending': Asked<{
99
+ readonly locator: string;
100
+ readonly id: string;
101
+ }, {
102
+ readonly state: string | null;
103
+ readonly room: boolean;
104
+ }>;
105
+ readonly 'authored.batch': Asked<{
106
+ readonly locator: string;
107
+ readonly id: string;
108
+ }, string | null>;
109
+ readonly 'authored.order': Asked<{
110
+ readonly locator: string;
111
+ }, readonly string[]>;
112
+ readonly 'authored.queued': Asked<Nothing, readonly string[]>;
113
+ readonly 'authored.roomDrafts': Asked<{
114
+ readonly locator: string | null;
115
+ readonly paths: readonly string[] | null;
116
+ }, readonly string[]>;
117
+ readonly 'authored.chatDraft.read': Asked<{
118
+ readonly conversation: string;
119
+ }, string | null>;
115
120
  readonly 'authored.chatDrafts': Asked<Nothing, readonly string[]>;
116
121
  readonly 'authored.calls': Asked<Nothing, readonly string[]>;
117
122
  readonly 'authored.fences': Asked<Nothing, readonly string[]>;
123
+ readonly 'authored.unsent': Asked<Nothing, readonly UnsentWork[]>;
118
124
  readonly 'authored.fact': Asked<{
119
125
  readonly name: AuthoredFact;
120
126
  }, string | null>;
@@ -156,11 +162,36 @@ export interface RuntimeRequests {
156
162
  readonly holder: string | null;
157
163
  }, boolean>;
158
164
  readonly 'replica.open': Asked<Nothing, ReplicaOpened>;
165
+ readonly 'replica.rooms': Asked<{
166
+ readonly locators: readonly string[] | null;
167
+ }, readonly HeldRoomRow[]>;
168
+ readonly 'replica.room': Asked<{
169
+ readonly locator: string;
170
+ }, HeldRoomWork>;
171
+ readonly 'replica.covering': Asked<{
172
+ readonly since: CoverLog | null;
173
+ }, Covering>;
174
+ readonly 'replica.offline': Asked<{
175
+ readonly locator: string;
176
+ }, string | null>;
177
+ readonly 'replica.held': Asked<Nothing, HeldLocators>;
178
+ readonly 'replica.demote': Asked<Nothing, null>;
179
+ readonly 'replica.facts': Asked<{
180
+ readonly names: readonly string[] | null;
181
+ }, Readonly<Record<string, string>>>;
182
+ readonly 'replica.presentation': Asked<{
183
+ readonly app: string;
184
+ }, string | null>;
159
185
  readonly 'replica.query': Asked<{
160
186
  readonly plan: Plan;
161
187
  readonly rooms: readonly QueryRoom[];
162
188
  readonly budget: number | null;
163
189
  }, QueryAnswer>;
190
+ readonly 'replica.tallies': Asked<{
191
+ readonly totals: Plan;
192
+ readonly rooms: readonly QueryRoom[];
193
+ readonly since: string;
194
+ }, readonly RoomTally[]>;
164
195
  readonly 'replica.entries': Asked<{
165
196
  readonly key: number;
166
197
  readonly view: View;
@@ -175,20 +206,9 @@ export interface RuntimeRequests {
175
206
  readonly key: number;
176
207
  readonly view: View;
177
208
  readonly targets: readonly string[];
178
- readonly kinds: readonly string[];
179
209
  }, readonly Referrer[]>;
180
- readonly 'replica.files': Asked<{
181
- readonly key: number;
182
- readonly view: View;
183
- readonly after: string | null;
184
- readonly limit: number;
185
- }, readonly {
186
- readonly path: string;
187
- readonly revision: string;
188
- }[]>;
189
210
  readonly 'replica.folders': Asked<{
190
211
  readonly key: number;
191
- readonly view: View;
192
212
  readonly paths: readonly string[];
193
213
  }, readonly string[]>;
194
214
  readonly 'replica.typedWithin': Asked<{
@@ -197,10 +217,6 @@ export interface RuntimeRequests {
197
217
  readonly roots: readonly string[];
198
218
  readonly within: boolean;
199
219
  }, boolean>;
200
- readonly 'replica.counts': Asked<{
201
- readonly rooms: readonly CountedRoom[];
202
- }, readonly number[]>;
203
- readonly 'replica.search': Asked<SearchAsk, SearchWindow>;
204
220
  readonly 'replica.stage': Asked<{
205
221
  readonly locator: string;
206
222
  readonly transfer: string;
@@ -208,7 +224,15 @@ export interface RuntimeRequests {
208
224
  readonly fingerprint: string;
209
225
  readonly entries: readonly StoredEntry[];
210
226
  readonly folders: readonly string[];
227
+ readonly part: string | null;
211
228
  }, number | null>;
229
+ readonly 'replica.resume': Asked<{
230
+ readonly locator: string;
231
+ readonly transfer: string;
232
+ readonly fingerprint: string;
233
+ readonly parts: readonly string[];
234
+ readonly published: number | null;
235
+ }, Resumed | null>;
212
236
  readonly 'replica.refresh': Asked<{
213
237
  readonly key: number;
214
238
  readonly composed: Composed;
@@ -236,6 +260,9 @@ export interface RuntimeRequests {
236
260
  readonly 'replica.abandon': Asked<{
237
261
  readonly locator: string;
238
262
  }, null>;
263
+ readonly 'replica.unfence': Asked<{
264
+ readonly locators: readonly string[];
265
+ }, readonly string[]>;
239
266
  readonly 'replica.release': Asked<{
240
267
  readonly key: number;
241
268
  }, null>;
@@ -249,32 +276,6 @@ export interface RuntimeRequests {
249
276
  readonly done: boolean;
250
277
  readonly text: number;
251
278
  }>;
252
- readonly 'replica.hold': Asked<{
253
- readonly key: number;
254
- readonly locator: string;
255
- readonly composed: Composed;
256
- readonly texts: readonly HeldText[];
257
- }, readonly string[]>;
258
- readonly 'replica.remember': Asked<{
259
- readonly key: number;
260
- readonly locator: string;
261
- readonly paths: readonly string[];
262
- }, null>;
263
- readonly 'replica.wanted': Asked<{
264
- readonly key: number;
265
- readonly locator: string;
266
- }, readonly {
267
- readonly path: string;
268
- readonly revision: string;
269
- }[]>;
270
- readonly 'replica.unhold': Asked<{
271
- readonly key: number;
272
- readonly locator: string;
273
- readonly composed: Composed;
274
- }, {
275
- readonly paths: readonly string[];
276
- readonly bytes: number;
277
- }>;
278
279
  readonly 'replica.fact': Asked<{
279
280
  readonly name: string;
280
281
  readonly value: string;
@@ -310,28 +311,50 @@ export interface RuntimeRequests {
310
311
  readonly key: string;
311
312
  }, null>;
312
313
  readonly 'opened.clean': Asked<Nothing, number>;
314
+ readonly 'opened.held': Asked<Nothing, OpenedHeld>;
313
315
  readonly 'file.part': Asked<{
314
316
  readonly key: string;
315
317
  readonly part: number;
316
318
  }, Uint8Array | null>;
317
- readonly 'conversation.held': Asked<Nothing, readonly HeldConversation[]>;
319
+ readonly 'conversation.held': Asked<{
320
+ readonly conversations: readonly string[] | null;
321
+ }, readonly HeldConversation[]>;
318
322
  readonly 'conversation.keep': Asked<ConversationWrite, null>;
319
323
  readonly 'conversation.window': Asked<{
320
324
  readonly conversation: string;
321
325
  readonly limit: number;
322
326
  readonly before: readonly [string, string] | null;
327
+ readonly phrase: string | null;
323
328
  }, MessageWindow>;
324
329
  readonly 'conversation.count': Asked<{
325
330
  readonly conversation: string;
331
+ readonly phrase: string | null;
326
332
  }, number>;
327
333
  readonly 'conversation.turn': Asked<{
328
334
  readonly conversation: string;
329
335
  readonly turn: string;
330
336
  }, boolean>;
337
+ readonly 'conversation.rows': Asked<{
338
+ readonly conversations: readonly string[];
339
+ }, readonly HeldRow[]>;
340
+ readonly 'conversation.tallies': Asked<{
341
+ readonly conversations: readonly string[] | null;
342
+ readonly since: string;
343
+ }, readonly ConversationTally[]>;
344
+ readonly 'conversation.facts': Asked<Nothing, readonly HeldFact[]>;
345
+ readonly 'conversation.fact': Asked<HeldFact, null>;
346
+ readonly 'conversation.stored': Asked<Nothing, readonly string[]>;
331
347
  readonly 'conversation.drop': Asked<{
332
348
  readonly conversations: readonly string[];
333
- }, null>;
349
+ }, readonly string[]>;
334
350
  readonly 'space.probe': Asked<Nothing, null>;
351
+ readonly 'read.stored': Asked<ReadAt, string | null>;
352
+ readonly 'read.keep': Asked<ReadAt & {
353
+ readonly answer: string;
354
+ }, null>;
355
+ readonly 'read.builds': Asked<{
356
+ readonly build: string;
357
+ }, null>;
335
358
  }
336
359
  export type RuntimeKind = keyof RuntimeRequests;
337
360
  export type RuntimeRequest<K extends RuntimeKind = RuntimeKind> = {
@@ -346,5 +369,7 @@ export interface RuntimeDatabase {
346
369
  export declare function isRuntime(request: {
347
370
  readonly kind: string;
348
371
  }): request is RuntimeRequest;
349
- export declare function readsRuntime(request: RuntimeRequest): boolean;
372
+ export declare function readsRuntime(request: {
373
+ readonly kind: string;
374
+ }): boolean;
350
375
  export declare function answerRuntime(connection: Connection, request: RuntimeRequest, spool: FileSpool): unknown;
@@ -0,0 +1,17 @@
1
+ import { type QueryRoom } from './compile.js';
2
+ import type { GroupTotal, Plan } from './query.js';
3
+ import type { Connection } from './tables.js';
4
+ export type RoomTally = {
5
+ readonly key: number;
6
+ readonly documents: GroupTotal;
7
+ readonly files: GroupTotal;
8
+ readonly documentTimes: readonly (readonly [string | null, string | null])[];
9
+ readonly chatTimes: readonly string[];
10
+ readonly messageTimes: readonly string[];
11
+ };
12
+ export type ConversationTally = {
13
+ readonly conversation: string;
14
+ readonly said: readonly string[];
15
+ };
16
+ export declare function roomTallies(connection: Connection, totals: Plan, rooms: readonly QueryRoom[], since: string): RoomTally[];
17
+ export declare function conversationTallies(connection: Connection, conversations: readonly string[] | null, since: string): ConversationTally[];
@@ -0,0 +1,4 @@
1
+ export type Unconfirmed = {
2
+ kind: 'unconfirmed';
3
+ };
4
+ export declare const unconfirmed: Unconfirmed;