@agentshouse/app-bridge 0.1.0-ccf413b4e709d → 0.1.0-ccf6bf7d473e2

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 (110) hide show
  1. package/README.md +11 -9
  2. package/dist/index.d.ts +588 -7
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/crockford.d.ts +3 -0
  6. package/dist/mdmodel/definition.d.ts +90 -0
  7. package/dist/mdmodel/divide.d.ts +2 -0
  8. package/dist/mdmodel/document.d.ts +22 -0
  9. package/dist/mdmodel/event.d.ts +76 -0
  10. package/dist/mdmodel/facts.d.ts +14 -0
  11. package/dist/mdmodel/fields.d.ts +5 -0
  12. package/dist/mdmodel/house-model.d.ts +826 -0
  13. package/dist/mdmodel/house-references.d.ts +3 -0
  14. package/dist/mdmodel/index.d.ts +42 -0
  15. package/dist/mdmodel/kinds.d.ts +17 -0
  16. package/dist/mdmodel/markdown.d.ts +74 -0
  17. package/dist/mdmodel/media-type.d.ts +71 -0
  18. package/dist/mdmodel/paths.d.ts +34 -0
  19. package/dist/mdmodel/pattern.d.ts +9 -0
  20. package/dist/mdmodel/project.d.ts +21 -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 +3 -0
  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 +181 -0
  29. package/dist/mdmodel/validate.d.ts +35 -0
  30. package/dist/mdmodel/version.d.ts +1 -0
  31. package/dist/mdmodel/yaml.d.ts +55 -0
  32. package/dist/mdruntime/actions.d.ts +25 -0
  33. package/dist/mdruntime/adapter.d.ts +540 -0
  34. package/dist/mdruntime/attached-model.d.ts +6 -0
  35. package/dist/mdruntime/binary.d.ts +17 -0
  36. package/dist/mdruntime/bootstrap.d.ts +43 -0
  37. package/dist/mdruntime/cell.d.ts +5 -0
  38. package/dist/mdruntime/chain.d.ts +11 -0
  39. package/dist/mdruntime/change-set.d.ts +31 -0
  40. package/dist/mdruntime/change.d.ts +119 -0
  41. package/dist/mdruntime/client.d.ts +97 -0
  42. package/dist/mdruntime/collection.d.ts +46 -0
  43. package/dist/mdruntime/compile.d.ts +17 -0
  44. package/dist/mdruntime/conversation-live.d.ts +146 -0
  45. package/dist/mdruntime/conversation-row.d.ts +32 -0
  46. package/dist/mdruntime/conversation.d.ts +135 -0
  47. package/dist/mdruntime/declaration.d.ts +9 -0
  48. package/dist/mdruntime/durability.d.ts +30 -0
  49. package/dist/mdruntime/failure.d.ts +15 -0
  50. package/dist/mdruntime/figures.d.ts +48 -0
  51. package/dist/mdruntime/holdings.d.ts +28 -0
  52. package/dist/mdruntime/identity.d.ts +5 -0
  53. package/dist/mdruntime/listing.d.ts +47 -0
  54. package/dist/mdruntime/live.d.ts +22 -0
  55. package/dist/mdruntime/media.d.ts +7 -0
  56. package/dist/mdruntime/messages.d.ts +55 -0
  57. package/dist/mdruntime/model.d.ts +54 -0
  58. package/dist/mdruntime/observation.d.ts +45 -0
  59. package/dist/mdruntime/open.d.ts +1 -0
  60. package/dist/mdruntime/opened.d.ts +21 -0
  61. package/dist/mdruntime/outcome.d.ts +94 -0
  62. package/dist/mdruntime/overlay.d.ts +29 -0
  63. package/dist/mdruntime/preparation.d.ts +19 -0
  64. package/dist/mdruntime/presence.d.ts +51 -0
  65. package/dist/mdruntime/query.d.ts +87 -0
  66. package/dist/mdruntime/reach.d.ts +55 -0
  67. package/dist/mdruntime/readiness.d.ts +48 -0
  68. package/dist/mdruntime/reads.d.ts +38 -0
  69. package/dist/mdruntime/recovery.d.ts +27 -0
  70. package/dist/mdruntime/refresh.d.ts +26 -0
  71. package/dist/mdruntime/replica.d.ts +62 -0
  72. package/dist/mdruntime/retried.d.ts +29 -0
  73. package/dist/mdruntime/room-draft.d.ts +172 -0
  74. package/dist/mdruntime/room-drafts.d.ts +23 -0
  75. package/dist/mdruntime/runtime.d.ts +33 -0
  76. package/dist/mdruntime/save.d.ts +58 -0
  77. package/dist/mdruntime/saves.d.ts +31 -0
  78. package/dist/mdruntime/search.d.ts +21 -0
  79. package/dist/mdruntime/seed.d.ts +24 -0
  80. package/dist/mdruntime/socket/admission.d.ts +6 -0
  81. package/dist/mdruntime/socket/answers.d.ts +5 -0
  82. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  83. package/dist/mdruntime/socket/session.d.ts +37 -0
  84. package/dist/mdruntime/socket.d.ts +66 -0
  85. package/dist/mdruntime/source.d.ts +53 -0
  86. package/dist/mdruntime/status.d.ts +25 -0
  87. package/dist/mdruntime/store/installs.d.ts +29 -0
  88. package/dist/mdruntime/store/readiness.d.ts +9 -0
  89. package/dist/mdruntime/store/records.d.ts +214 -0
  90. package/dist/mdruntime/store/room-held.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 +121 -0
  95. package/dist/mdruntime/stored.d.ts +156 -0
  96. package/dist/mdruntime/surface.d.ts +88 -0
  97. package/dist/mdruntime/tables.d.ts +414 -0
  98. package/dist/mdruntime/tallies.d.ts +17 -0
  99. package/dist/mdruntime/transfer.d.ts +4 -0
  100. package/dist/mdruntime/wire.d.ts +295 -0
  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 -2
  108. package/dist/test-host.js +48 -12
  109. package/docs/families.md +70 -20
  110. package/package.json +8 -6
@@ -0,0 +1,156 @@
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
+ import { type Composed, type Composition } from './collection.js';
3
+ import type { HeldBinary } from './overlay.js';
4
+ import type { Connection } from './tables.js';
5
+ export declare const REPLICA_TABLES: readonly string[];
6
+ export type View = 'confirmed' | 'visible' | 'refreshed';
7
+ export type StoredEntry = {
8
+ readonly path: string;
9
+ readonly content: string | null;
10
+ readonly binary: HeldBinary | null;
11
+ readonly revision: string | null;
12
+ readonly fileId: string | null;
13
+ readonly created: string | null;
14
+ readonly change: HeadChange | null;
15
+ readonly written: string | null;
16
+ readonly facts: SavedFacts | null;
17
+ };
18
+ export type OverlayEntry = StoredEntry & {
19
+ readonly present: boolean;
20
+ };
21
+ export type HeldEntry = StoredEntry & {
22
+ readonly type: string | null;
23
+ };
24
+ export type TypedEntry = {
25
+ readonly path: string;
26
+ readonly type: string | null;
27
+ readonly binary: boolean;
28
+ };
29
+ export type Referrer = {
30
+ readonly path: string;
31
+ readonly target: string;
32
+ };
33
+ export type HeldRoomRow = {
34
+ readonly locator: string;
35
+ readonly key: number;
36
+ readonly record: string;
37
+ readonly indexed: boolean;
38
+ readonly documents: number;
39
+ };
40
+ export type HeldRoomWork = {
41
+ readonly room: (HeldRoomRow & {
42
+ readonly overlaid: readonly string[];
43
+ }) | null;
44
+ readonly queue: readonly {
45
+ readonly id: string;
46
+ readonly batch: string;
47
+ readonly state: string;
48
+ }[];
49
+ };
50
+ export type Covering = {
51
+ readonly rooms: readonly {
52
+ readonly locator: string;
53
+ readonly key: number;
54
+ readonly transfer: string;
55
+ readonly roomVersion: string;
56
+ readonly indexed: boolean;
57
+ readonly documents: number;
58
+ readonly bytes: number;
59
+ readonly offline: string;
60
+ }[];
61
+ readonly queues: readonly {
62
+ readonly locator: string;
63
+ readonly ids: readonly string[];
64
+ }[];
65
+ };
66
+ export type HeldLocators = {
67
+ readonly held: readonly string[];
68
+ readonly staged: readonly string[];
69
+ };
70
+ export type ReplicaOpened = {
71
+ readonly erasing: boolean;
72
+ readonly orphans: readonly number[];
73
+ };
74
+ export type RoomCommit = {
75
+ readonly locator: string;
76
+ readonly key: number;
77
+ readonly record?: string;
78
+ readonly roots?: readonly string[];
79
+ readonly published?: {
80
+ readonly from: number | null;
81
+ };
82
+ readonly refreshed?: true;
83
+ readonly composed: Composed;
84
+ readonly confirmed?: {
85
+ readonly set: readonly StoredEntry[];
86
+ readonly removed: readonly string[];
87
+ };
88
+ readonly overlay?: {
89
+ readonly set: readonly OverlayEntry[];
90
+ readonly cleared: readonly string[];
91
+ };
92
+ };
93
+ export type Committed = {
94
+ readonly changed: Readonly<Record<string, readonly string[] | null>>;
95
+ readonly indexed: Readonly<Record<string, boolean>>;
96
+ };
97
+ export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
98
+ export declare function stage(connection: Connection, request: {
99
+ readonly locator: string;
100
+ readonly transfer: string;
101
+ readonly key: number | null;
102
+ readonly fingerprint: string;
103
+ readonly entries: readonly StoredEntry[];
104
+ readonly folders: readonly string[];
105
+ readonly part: string | null;
106
+ }): number;
107
+ export type Resumed = {
108
+ readonly key: number | null;
109
+ readonly transfer: string;
110
+ readonly staged: readonly string[];
111
+ };
112
+ export declare function resume(connection: Connection, request: {
113
+ readonly locator: string;
114
+ readonly transfer: string;
115
+ readonly fingerprint: string;
116
+ readonly parts: readonly string[];
117
+ readonly published: number | null;
118
+ }): Resumed;
119
+ export declare function refreshing(connection: Connection, request: {
120
+ readonly key: number;
121
+ readonly composed: Composed;
122
+ readonly entries: readonly StoredEntry[];
123
+ readonly removals: readonly string[];
124
+ readonly folders: readonly string[];
125
+ readonly folderRemovals: readonly string[];
126
+ }): null;
127
+ export declare function unrefresh(connection: Connection, key: number): null;
128
+ export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
129
+ export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
130
+ export declare function abandon(connection: Connection, locator: string): null;
131
+ export declare function release(connection: Connection, key: number): null;
132
+ export declare function erase(connection: Connection, locator: string | null, limit: number): {
133
+ readonly remaining: boolean;
134
+ };
135
+ export declare function rederive(connection: Connection, key: number, composed: Composed, bytes: number, ms: number, floor: number): {
136
+ readonly done: boolean;
137
+ readonly text: number;
138
+ };
139
+ export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
140
+ export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
141
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
142
+ export declare function folders(connection: Connection, key: number, list: readonly string[]): string[];
143
+ export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
144
+ export declare function opened(connection: Connection): ReplicaOpened;
145
+ export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
146
+ export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
147
+ export declare function overlaid(connection: Connection, key: number): readonly string[];
148
+ export declare function covering(connection: Connection): Covering['rooms'];
149
+ export declare function offlineMode(connection: Connection, locator: string): string | null;
150
+ export declare function stagedLocators(connection: Connection): readonly string[];
151
+ export declare function heldLocators(connection: Connection): readonly string[];
152
+ export declare function demoted(connection: Connection): null;
153
+ export declare function facts(connection: Connection): Readonly<Record<string, string>>;
154
+ export declare function presentation(connection: Connection, app: string): string | null;
155
+ export declare function tablesOf(statements: readonly string[]): readonly string[];
156
+ export declare function ended(connection: Connection): void;
@@ -0,0 +1,88 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import { type HistoryQuery } from './actions.js';
3
+ import type { ListedAgent, Member, 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: 'figures'): Promise<Observation<FiguresResult>>;
76
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
77
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
78
+ };
79
+ reauthorize(): Promise<void>;
80
+ };
81
+ 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' | 'figures' | 'holdings' | 'read';
82
+ export type ComposedRuntime = RuntimeView & {
83
+ seed(entry: EntrySeed): void;
84
+ stop(): Promise<void>;
85
+ persisted(answer: Persistence): void;
86
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
87
+ };
88
+ export declare function composedRuntime(runtime: Runtime): ComposedRuntime;
@@ -0,0 +1,414 @@
1
+ import { type QueryAnswer, type QueryRoom } from './compile.js';
2
+ import type { Composed } from './collection.js';
3
+ import type { UnsentWork } from './durability.js';
4
+ import { type ConversationWrite, type HeldConversation, type HeldFact, type HeldRow, type MessageWindow } from './messages.js';
5
+ import type { GroupTotal, Plan } from './query.js';
6
+ import { type ReadAt } from './reads.js';
7
+ import { type ConversationTally, type RoomTally } from './tallies.js';
8
+ import { type Committed, type Covering, type HeldEntry, type HeldLocators, type HeldRoomRow, type HeldRoomWork, type ReplicaOpened, type Referrer, type Resumed, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
9
+ export type { Committed, Covering, HeldEntry, HeldLocators, HeldRoomRow, HeldRoomWork, OverlayEntry, ReplicaOpened, Referrer, Resumed, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
10
+ export type { QueryAnswer, QueryRoom } from './compile.js';
11
+ export type { ConversationFact, ConversationWrite, HeldConversation, HeldFact, HeldRow, MessageWindow, } from './messages.js';
12
+ export type { ConversationTally, RoomTally } from './tallies.js';
13
+ export type Value = string | number | bigint | Uint8Array | null;
14
+ export type Row = Readonly<Record<string, Value>>;
15
+ export interface Connection {
16
+ run(sql: string, bind?: readonly Value[]): void;
17
+ rows(sql: string, bind?: readonly Value[]): readonly Row[];
18
+ collate(name: string, compare: (left: string, right: string) => number): void;
19
+ }
20
+ export interface SqliteEngine {
21
+ readonly capi: {
22
+ readonly SQLITE_UTF8: number;
23
+ sqlite3_create_collation_v2(database: number, name: string, encoding: number, argument: number, compare: (argument: number, leftLength: number, left: number, rightLength: number, right: number) => number, destroy: number): number;
24
+ };
25
+ readonly wasm: {
26
+ heap8u(): Uint8Array;
27
+ };
28
+ }
29
+ export interface SqliteStatement {
30
+ readonly parameterCount: number;
31
+ bind(values: readonly Value[]): unknown;
32
+ step(): boolean;
33
+ get(values: Value[]): Value[];
34
+ getColumnNames(names: string[]): string[];
35
+ resetNoThrow(clearBindings: boolean): number;
36
+ finalize(): unknown;
37
+ }
38
+ export interface SqliteDatabase {
39
+ readonly pointer: number;
40
+ createFunction(name: string, run: (context: number, ...values: Value[]) => Value, options: {
41
+ readonly arity: number;
42
+ readonly deterministic: true;
43
+ }): unknown;
44
+ exec(options: {
45
+ readonly sql: string;
46
+ readonly bind: readonly Value[];
47
+ readonly rowMode?: 'object';
48
+ readonly returnValue?: 'resultRows';
49
+ }): Row[];
50
+ prepare(sql: string): SqliteStatement;
51
+ }
52
+ export declare function sqliteConnection(engine: SqliteEngine, database: SqliteDatabase): Connection;
53
+ export declare const FILE_PART_BYTES = 1048576;
54
+ export declare const RUNTIME_TABLES: readonly string[];
55
+ export type AuthoredFact = 'holder' | 'generation';
56
+ export type StoredFile = {
57
+ readonly key: string;
58
+ readonly blob: Blob;
59
+ };
60
+ export interface FileSpool {
61
+ held(): Iterable<string>;
62
+ spool(key: string, type: string, parts: Iterable<Uint8Array>): Promise<Blob>;
63
+ drop(key: string): Promise<void>;
64
+ probe(bytes: number): Promise<void>;
65
+ }
66
+ export type KeptPending = {
67
+ readonly id: string;
68
+ readonly batch: string;
69
+ readonly state: string;
70
+ readonly files: readonly string[];
71
+ readonly paths: readonly string[];
72
+ readonly moving: boolean;
73
+ };
74
+ export type KeptRecord = {
75
+ readonly record: string;
76
+ readonly files: readonly string[];
77
+ };
78
+ export type AuthoredRows = {
79
+ readonly locator: string;
80
+ readonly order?: readonly string[];
81
+ readonly added?: readonly KeptPending[];
82
+ readonly founded?: readonly Omit<KeptPending, 'state'>[];
83
+ readonly roomDrafts?: readonly (KeptRecord & {
84
+ readonly path: string;
85
+ })[];
86
+ readonly consumedRoomDrafts?: readonly string[];
87
+ };
88
+ export type HeldQueues = {
89
+ readonly queues: readonly {
90
+ readonly locator: string;
91
+ readonly ids: readonly string[];
92
+ }[];
93
+ readonly pending: readonly {
94
+ readonly locator: string;
95
+ readonly id: string;
96
+ readonly batch: string;
97
+ readonly state: string;
98
+ }[];
99
+ };
100
+ export type HeldStatus = {
101
+ readonly queued: readonly string[];
102
+ readonly lastCompleted: string | null;
103
+ readonly changes: readonly {
104
+ readonly locator: string;
105
+ readonly path: string;
106
+ }[];
107
+ readonly resets: readonly {
108
+ readonly locator: string;
109
+ readonly reset: string;
110
+ }[];
111
+ readonly returned: readonly string[];
112
+ };
113
+ export type OpenedFile = {
114
+ readonly key: string;
115
+ readonly byteLength: number;
116
+ readonly mediaType: string;
117
+ };
118
+ export type OpenedRoom = GroupTotal & {
119
+ readonly room: string;
120
+ };
121
+ export type OpenedHeld = {
122
+ readonly rooms: readonly OpenedRoom[];
123
+ readonly cleanable: number;
124
+ };
125
+ type Asked<A, R> = {
126
+ readonly asked: A;
127
+ readonly answer: R;
128
+ };
129
+ type Nothing = Readonly<Record<never, never>>;
130
+ export type CommittedWrite = Committed & {
131
+ readonly fenced: string | null;
132
+ };
133
+ export type AuthoredWrite = {
134
+ readonly writes: readonly AuthoredRows[];
135
+ readonly files: readonly StoredFile[];
136
+ readonly whole: boolean;
137
+ };
138
+ export interface RuntimeRequests {
139
+ readonly 'authored.status': Asked<Nothing, HeldStatus>;
140
+ readonly 'authored.moving': Asked<Nothing, HeldQueues>;
141
+ readonly 'authored.pending': Asked<{
142
+ readonly locator: string;
143
+ readonly id: string;
144
+ }, {
145
+ readonly state: string | null;
146
+ readonly room: boolean;
147
+ }>;
148
+ readonly 'authored.batch': Asked<{
149
+ readonly locator: string;
150
+ readonly id: string;
151
+ }, string | null>;
152
+ readonly 'authored.order': Asked<{
153
+ readonly locator: string;
154
+ }, readonly string[]>;
155
+ readonly 'authored.queued': Asked<Nothing, readonly string[]>;
156
+ readonly 'authored.roomDrafts': Asked<{
157
+ readonly locator: string | null;
158
+ readonly paths: readonly string[] | null;
159
+ }, readonly string[]>;
160
+ readonly 'authored.chatDraft.read': Asked<{
161
+ readonly conversation: string;
162
+ }, string | null>;
163
+ readonly 'authored.chatDrafts': Asked<Nothing, readonly string[]>;
164
+ readonly 'authored.calls': Asked<Nothing, readonly string[]>;
165
+ readonly 'authored.fences': Asked<Nothing, readonly string[]>;
166
+ readonly 'authored.unsent': Asked<Nothing, readonly UnsentWork[]>;
167
+ readonly 'authored.fact': Asked<{
168
+ readonly name: AuthoredFact;
169
+ }, string | null>;
170
+ readonly 'authored.file': Asked<{
171
+ readonly key: string;
172
+ readonly type: string;
173
+ }, Blob>;
174
+ readonly 'authored.amend': Asked<{
175
+ readonly locator: string;
176
+ readonly id: string;
177
+ readonly amendment: string;
178
+ }, null>;
179
+ readonly 'authored.roomDraft': Asked<{
180
+ readonly locator: string;
181
+ readonly path: string;
182
+ readonly kept: KeptRecord | null;
183
+ readonly files: readonly StoredFile[];
184
+ }, string | null>;
185
+ readonly 'authored.chatDraft': Asked<{
186
+ readonly kept: readonly {
187
+ readonly conversation: string;
188
+ readonly record: string;
189
+ }[];
190
+ readonly dropped: readonly string[];
191
+ }, null>;
192
+ readonly 'authored.call': Asked<{
193
+ readonly operation: string;
194
+ readonly kept: KeptRecord | null;
195
+ readonly files: readonly StoredFile[];
196
+ }, null>;
197
+ readonly 'authored.remember': Asked<{
198
+ readonly name: AuthoredFact;
199
+ readonly value: string;
200
+ }, null>;
201
+ readonly 'authored.claim': Asked<{
202
+ readonly holder: string;
203
+ }, boolean>;
204
+ readonly 'authored.end': Asked<{
205
+ readonly holder: string | null;
206
+ }, boolean>;
207
+ readonly 'replica.open': Asked<Nothing, ReplicaOpened>;
208
+ readonly 'replica.rooms': Asked<{
209
+ readonly locators: readonly string[] | null;
210
+ }, readonly HeldRoomRow[]>;
211
+ readonly 'replica.room': Asked<{
212
+ readonly locator: string;
213
+ }, HeldRoomWork>;
214
+ readonly 'replica.covering': Asked<Nothing, Covering>;
215
+ readonly 'replica.offline': Asked<{
216
+ readonly locator: string;
217
+ }, string | null>;
218
+ readonly 'replica.held': Asked<Nothing, HeldLocators>;
219
+ readonly 'replica.demote': Asked<Nothing, null>;
220
+ readonly 'replica.facts': Asked<Nothing, Readonly<Record<string, string>>>;
221
+ readonly 'replica.presentation': Asked<{
222
+ readonly app: string;
223
+ }, string | null>;
224
+ readonly 'replica.query': Asked<{
225
+ readonly plan: Plan;
226
+ readonly rooms: readonly QueryRoom[];
227
+ readonly budget: number | null;
228
+ }, QueryAnswer>;
229
+ readonly 'replica.tallies': Asked<{
230
+ readonly totals: Plan;
231
+ readonly rooms: readonly QueryRoom[];
232
+ readonly since: string;
233
+ }, readonly RoomTally[]>;
234
+ readonly 'replica.entries': Asked<{
235
+ readonly key: number;
236
+ readonly view: View;
237
+ readonly paths: readonly string[];
238
+ }, readonly HeldEntry[]>;
239
+ readonly 'replica.typed': Asked<{
240
+ readonly key: number;
241
+ readonly view: View;
242
+ readonly paths: readonly string[];
243
+ }, readonly TypedEntry[]>;
244
+ readonly 'replica.referrers': Asked<{
245
+ readonly key: number;
246
+ readonly view: View;
247
+ readonly targets: readonly string[];
248
+ }, readonly Referrer[]>;
249
+ readonly 'replica.folders': Asked<{
250
+ readonly key: number;
251
+ readonly paths: readonly string[];
252
+ }, readonly string[]>;
253
+ readonly 'replica.typedWithin': Asked<{
254
+ readonly key: number;
255
+ readonly view: View;
256
+ readonly roots: readonly string[];
257
+ readonly within: boolean;
258
+ }, boolean>;
259
+ readonly 'replica.stage': Asked<{
260
+ readonly locator: string;
261
+ readonly transfer: string;
262
+ readonly key: number | null;
263
+ readonly fingerprint: string;
264
+ readonly entries: readonly StoredEntry[];
265
+ readonly folders: readonly string[];
266
+ readonly part: string | null;
267
+ }, number | null>;
268
+ readonly 'replica.resume': Asked<{
269
+ readonly locator: string;
270
+ readonly transfer: string;
271
+ readonly fingerprint: string;
272
+ readonly parts: readonly string[];
273
+ readonly published: number | null;
274
+ }, Resumed | null>;
275
+ readonly 'replica.refresh': Asked<{
276
+ readonly key: number;
277
+ readonly composed: Composed;
278
+ readonly entries: readonly StoredEntry[];
279
+ readonly removals: readonly string[];
280
+ readonly folders: readonly string[];
281
+ readonly folderRemovals: readonly string[];
282
+ }, null>;
283
+ readonly 'replica.unrefresh': Asked<{
284
+ readonly key: number;
285
+ }, null>;
286
+ readonly 'replica.commit': Asked<{
287
+ readonly authored?: AuthoredWrite;
288
+ readonly rooms: readonly RoomCommit[];
289
+ }, CommittedWrite>;
290
+ readonly 'replica.fence': Asked<{
291
+ readonly locators: readonly string[];
292
+ }, null>;
293
+ readonly 'replica.erase': Asked<{
294
+ readonly locator: string | null;
295
+ readonly limit: number;
296
+ }, {
297
+ readonly remaining: boolean;
298
+ }>;
299
+ readonly 'replica.abandon': Asked<{
300
+ readonly locator: string;
301
+ }, null>;
302
+ readonly 'replica.unfence': Asked<{
303
+ readonly locators: readonly string[];
304
+ }, readonly string[]>;
305
+ readonly 'replica.release': Asked<{
306
+ readonly key: number;
307
+ }, null>;
308
+ readonly 'replica.rederive': Asked<{
309
+ readonly key: number;
310
+ readonly composed: Composed;
311
+ readonly bytes: number;
312
+ readonly ms: number;
313
+ readonly floor: number;
314
+ }, {
315
+ readonly done: boolean;
316
+ readonly text: number;
317
+ }>;
318
+ readonly 'replica.fact': Asked<{
319
+ readonly name: string;
320
+ readonly value: string;
321
+ }, null>;
322
+ readonly 'replica.present': Asked<{
323
+ readonly app: string;
324
+ readonly value: string;
325
+ }, null>;
326
+ readonly 'opened.find': Asked<{
327
+ readonly locator: string;
328
+ readonly path: string;
329
+ readonly revision: string;
330
+ }, OpenedFile | null>;
331
+ readonly 'opened.begin': Asked<{
332
+ readonly key: string;
333
+ readonly locator: string;
334
+ readonly path: string;
335
+ readonly revision: string;
336
+ readonly mediaType: string;
337
+ }, boolean>;
338
+ readonly 'opened.part': Asked<{
339
+ readonly key: string;
340
+ readonly part: number;
341
+ readonly bytes: Uint8Array;
342
+ }, boolean>;
343
+ readonly 'opened.keep': Asked<{
344
+ readonly key: string;
345
+ readonly sha256: string;
346
+ readonly byteLength: number;
347
+ readonly parts: number;
348
+ }, boolean>;
349
+ readonly 'opened.drop': Asked<{
350
+ readonly key: string;
351
+ }, null>;
352
+ readonly 'opened.clean': Asked<Nothing, number>;
353
+ readonly 'opened.held': Asked<Nothing, OpenedHeld>;
354
+ readonly 'file.part': Asked<{
355
+ readonly key: string;
356
+ readonly part: number;
357
+ }, Uint8Array | null>;
358
+ readonly 'conversation.held': Asked<{
359
+ readonly conversations: readonly string[] | null;
360
+ }, readonly HeldConversation[]>;
361
+ readonly 'conversation.keep': Asked<ConversationWrite, null>;
362
+ readonly 'conversation.window': Asked<{
363
+ readonly conversation: string;
364
+ readonly limit: number;
365
+ readonly before: readonly [string, string] | null;
366
+ readonly phrase: string | null;
367
+ }, MessageWindow>;
368
+ readonly 'conversation.count': Asked<{
369
+ readonly conversation: string;
370
+ readonly phrase: string | null;
371
+ }, number>;
372
+ readonly 'conversation.turn': Asked<{
373
+ readonly conversation: string;
374
+ readonly turn: string;
375
+ }, boolean>;
376
+ readonly 'conversation.rows': Asked<{
377
+ readonly conversations: readonly string[];
378
+ }, readonly HeldRow[]>;
379
+ readonly 'conversation.tallies': Asked<{
380
+ readonly conversations: readonly string[] | null;
381
+ readonly since: string;
382
+ }, readonly ConversationTally[]>;
383
+ readonly 'conversation.facts': Asked<Nothing, readonly HeldFact[]>;
384
+ readonly 'conversation.fact': Asked<HeldFact, null>;
385
+ readonly 'conversation.stored': Asked<Nothing, readonly string[]>;
386
+ readonly 'conversation.drop': Asked<{
387
+ readonly conversations: readonly string[];
388
+ }, readonly string[]>;
389
+ readonly 'space.probe': Asked<Nothing, null>;
390
+ readonly 'read.stored': Asked<ReadAt, string | null>;
391
+ readonly 'read.keep': Asked<ReadAt & {
392
+ readonly answer: string;
393
+ }, null>;
394
+ readonly 'read.builds': Asked<{
395
+ readonly build: string;
396
+ }, null>;
397
+ }
398
+ export type RuntimeKind = keyof RuntimeRequests;
399
+ export type RuntimeRequest<K extends RuntimeKind = RuntimeKind> = {
400
+ readonly [Kind in K]: {
401
+ readonly kind: Kind;
402
+ } & RuntimeRequests[Kind]['asked'];
403
+ }[K];
404
+ export type RuntimeAnswer<K extends RuntimeKind> = RuntimeRequests[K]['answer'];
405
+ export interface RuntimeDatabase {
406
+ ask<K extends RuntimeKind>(request: RuntimeRequest<K>): Promise<RuntimeAnswer<K>>;
407
+ }
408
+ export declare function isRuntime(request: {
409
+ readonly kind: string;
410
+ }): request is RuntimeRequest;
411
+ export declare function readsRuntime(request: {
412
+ readonly kind: string;
413
+ }): boolean;
414
+ 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;