@agentshouse/app-bridge 0.1.0-cfb240c3fb89d → 0.1.0-cfb893a1d2cd3

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 (124) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +686 -13
  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 +40 -11
  6. package/dist/mdmodel/document.d.ts +15 -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 +43 -14
  14. package/dist/mdmodel/indexed.d.ts +8 -0
  15. package/dist/mdmodel/kinds.d.ts +19 -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 +24 -2
  21. package/dist/mdmodel/pattern.d.ts +9 -0
  22. package/dist/mdmodel/project.d.ts +1 -0
  23. package/dist/mdmodel/query/language.d.ts +253 -0
  24. package/dist/mdmodel/query/match.d.ts +13 -0
  25. package/dist/mdmodel/query/rows.d.ts +31 -0
  26. package/dist/mdmodel/query/sql.d.ts +38 -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 +44 -15
  31. package/dist/mdmodel/validate.d.ts +34 -4
  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 +247 -117
  35. package/dist/mdruntime/attached-model.d.ts +6 -0
  36. package/dist/mdruntime/authored.d.ts +87 -0
  37. package/dist/mdruntime/binary.d.ts +0 -5
  38. package/dist/mdruntime/bootstrap.d.ts +43 -0
  39. package/dist/mdruntime/cell.d.ts +5 -0
  40. package/dist/mdruntime/chain.d.ts +11 -0
  41. package/dist/mdruntime/change-set.d.ts +13 -16
  42. package/dist/mdruntime/change.d.ts +36 -1
  43. package/dist/mdruntime/client.d.ts +50 -25
  44. package/dist/mdruntime/collection.d.ts +33 -21
  45. package/dist/mdruntime/compile.d.ts +17 -0
  46. package/dist/mdruntime/conversation-live.d.ts +149 -0
  47. package/dist/mdruntime/conversation-row.d.ts +39 -0
  48. package/dist/mdruntime/conversation.d.ts +85 -48
  49. package/dist/mdruntime/declaration.d.ts +9 -0
  50. package/dist/mdruntime/durability.d.ts +24 -1
  51. package/dist/mdruntime/failure.d.ts +3 -0
  52. package/dist/mdruntime/figures.d.ts +48 -0
  53. package/dist/mdruntime/holdings.d.ts +28 -0
  54. package/dist/mdruntime/house-query.d.ts +20 -0
  55. package/dist/mdruntime/identity.d.ts +5 -0
  56. package/dist/mdruntime/install.d.ts +59 -0
  57. package/dist/mdruntime/listing.d.ts +59 -0
  58. package/dist/mdruntime/live.d.ts +24 -0
  59. package/dist/mdruntime/media.d.ts +24 -0
  60. package/dist/mdruntime/messages.d.ts +57 -0
  61. package/dist/mdruntime/modal.d.ts +1 -0
  62. package/dist/mdruntime/model.d.ts +14 -14
  63. package/dist/mdruntime/observation.d.ts +42 -10
  64. package/dist/mdruntime/opened.d.ts +21 -0
  65. package/dist/mdruntime/outcome.d.ts +62 -9
  66. package/dist/mdruntime/overlay.d.ts +9 -6
  67. package/dist/mdruntime/preparation.d.ts +40 -0
  68. package/dist/mdruntime/presence.d.ts +57 -0
  69. package/dist/mdruntime/query.d.ts +27 -186
  70. package/dist/mdruntime/reach.d.ts +29 -7
  71. package/dist/mdruntime/readiness.d.ts +54 -0
  72. package/dist/mdruntime/reads.d.ts +38 -0
  73. package/dist/mdruntime/recovery.d.ts +6 -2
  74. package/dist/mdruntime/refresh.d.ts +26 -0
  75. package/dist/mdruntime/replica.d.ts +50 -33
  76. package/dist/mdruntime/retried.d.ts +29 -0
  77. package/dist/mdruntime/room-draft.d.ts +66 -12
  78. package/dist/mdruntime/room-drafts.d.ts +23 -0
  79. package/dist/mdruntime/runtime.d.ts +34 -0
  80. package/dist/mdruntime/save.d.ts +43 -48
  81. package/dist/mdruntime/saves.d.ts +33 -0
  82. package/dist/mdruntime/search.d.ts +15 -77
  83. package/dist/mdruntime/seed.d.ts +24 -0
  84. package/dist/mdruntime/socket/admission.d.ts +6 -0
  85. package/dist/mdruntime/socket/answers.d.ts +5 -0
  86. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  87. package/dist/mdruntime/socket/session.d.ts +38 -0
  88. package/dist/mdruntime/socket.d.ts +67 -0
  89. package/dist/mdruntime/source.d.ts +58 -0
  90. package/dist/mdruntime/status.d.ts +5 -2
  91. package/dist/mdruntime/store/installs.d.ts +29 -0
  92. package/dist/mdruntime/store/readiness.d.ts +10 -0
  93. package/dist/mdruntime/store/records.d.ts +225 -0
  94. package/dist/mdruntime/store/room-held.d.ts +7 -0
  95. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  96. package/dist/mdruntime/store/space.d.ts +10 -0
  97. package/dist/mdruntime/store/watchers.d.ts +16 -0
  98. package/dist/mdruntime/store/writes.d.ts +23 -0
  99. package/dist/mdruntime/store.d.ts +115 -141
  100. package/dist/mdruntime/stored.d.ts +166 -0
  101. package/dist/mdruntime/surface.d.ts +93 -0
  102. package/dist/mdruntime/tables.d.ts +375 -0
  103. package/dist/mdruntime/tallies.d.ts +17 -0
  104. package/dist/mdruntime/transfer.d.ts +0 -5
  105. package/dist/mdruntime/wire.d.ts +243 -36
  106. package/dist/session-content/check.d.ts +17 -0
  107. package/dist/session-content/index.d.ts +6 -0
  108. package/dist/session-content/parts.d.ts +30 -0
  109. package/dist/session-content/state.d.ts +59 -0
  110. package/dist/session-content/turn.d.ts +137 -0
  111. package/dist/test-host.d.ts +14 -1
  112. package/dist/test-host.js +50 -3
  113. package/docs/families.md +113 -36
  114. package/package.json +8 -3
  115. package/dist/calls.d.ts +0 -117
  116. package/dist/calls.js +0 -1
  117. package/dist/mdmodel/blocks.d.ts +0 -10
  118. package/dist/mdmodel/condition.d.ts +0 -149
  119. package/dist/mdmodel/profile.d.ts +0 -5
  120. package/dist/mdruntime/connection.d.ts +0 -127
  121. package/dist/mdruntime/file.d.ts +0 -19
  122. package/dist/mdruntime/rows.d.ts +0 -36
  123. package/dist/mdruntime/shared.d.ts +0 -10
  124. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,6 +1,10 @@
1
+ import type { SavedFacts, TypedPath, VerifiedModel } from '../mdmodel/index.js';
2
+ import type { Operation, SessionState } from '../session-content/index.js';
1
3
  import type { ModelResult } from './model.js';
4
+ export type { SavedFacts, TypedPath };
2
5
  import type { Open } from './open.js';
3
6
  import type { ChangeBatch } from './change.js';
7
+ import type { QueryDocument } from './query.js';
4
8
  export type Authorization = object;
5
9
  export type MdModelIdentity = {
6
10
  identity: string;
@@ -10,37 +14,31 @@ export type TypedSelection = {
10
14
  roots: readonly string[];
11
15
  };
12
16
  export type OperationScopes = {
13
- read: readonly string[];
14
- sync: readonly string[];
15
17
  write: readonly string[];
16
- delete: readonly string[];
18
+ erase: readonly string[];
17
19
  };
18
20
  export type ReplicaAdmission = {
19
21
  selection: string;
20
22
  admission: Open<'admitted' | 'unavailable'>;
23
+ offline: Open<'locked' | 'open'>;
21
24
  };
22
- export type DiscoveredRoom = {
23
- name: string;
24
- locator: string;
25
- handle: string;
26
- roomVersion: string;
27
- operations: OperationScopes;
28
- replica: ReplicaAdmission;
29
- typedSelection?: TypedSelection;
30
- providerOwnedPaths: readonly string[];
25
+ export type RoomDeclaration = {
26
+ readonly name: string;
27
+ readonly handle: string;
28
+ readonly operations: OperationScopes;
29
+ readonly replica: ReplicaAdmission;
30
+ readonly typedSelection: TypedSelection | null;
31
+ readonly providerOwnedPaths: readonly string[];
32
+ readonly authoredPaths: readonly string[];
33
+ };
34
+ export type DiscoveredRoom = RoomDeclaration & {
35
+ readonly locator: string;
36
+ readonly roomVersion: string;
31
37
  };
32
38
  export type Capability = {
33
39
  name: string;
34
40
  limits?: readonly ProviderLimit[];
35
41
  actions?: readonly ActionDeclaration[];
36
- conversationAgents?: ConversationAgents;
37
- };
38
- export type ConversationAgents = {
39
- locator: string;
40
- type: string;
41
- identity: string;
42
- name: string;
43
- retired?: string;
44
42
  };
45
43
  export type ListedConversation = {
46
44
  conversation: string;
@@ -49,8 +47,12 @@ export type ListedConversation = {
49
47
  created: string;
50
48
  finished: string | null;
51
49
  outcome: string | null;
50
+ waiting: boolean;
51
+ newest: string | null;
52
+ processEnded: string | null;
53
+ subject: string | null;
52
54
  };
53
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
55
+ export type ConversationAction = 'conversations/create' | 'conversations/send' | 'conversations/interaction/answer' | 'conversations/interrupt' | 'conversations/kill' | 'conversations/delete' | 'conversations/take-out' | 'conversations/rename' | 'conversations/option/set' | 'conversations/retry' | 'agent-functions/decide';
54
56
  export type ConversationMessage = {
55
57
  identity: string;
56
58
  turn: string;
@@ -59,6 +61,7 @@ export type ConversationMessage = {
59
61
  };
60
62
  export type AcceptedMessage = ConversationMessage & {
61
63
  position: string;
64
+ change: string;
62
65
  };
63
66
  export type ConversationHistoryRequest = {
64
67
  conversations: readonly {
@@ -74,37 +77,10 @@ export type ConversationHistoryPage = {
74
77
  export type ConversationHistories = {
75
78
  histories: readonly ConversationHistoryPage[];
76
79
  };
77
- export type TurnContext = {
78
- used: number;
79
- window: number;
80
- };
81
80
  export type TurnOperation = {
82
81
  op: 'begin';
83
82
  at: string;
84
- } | {
85
- op: 'start';
86
- index: number;
87
- part: unknown;
88
- } | {
89
- op: 'append';
90
- index: number;
91
- text: string;
92
- } | {
93
- op: 'status';
94
- index: number;
95
- status: string;
96
- result: unknown;
97
- } | {
98
- op: 'count';
99
- index: number;
100
- count: number;
101
- } | {
102
- op: 'plan';
103
- index: number;
104
- entries: readonly unknown[];
105
- } | ({
106
- op: 'context';
107
- } & TurnContext);
83
+ } | Operation;
108
84
  export type ProcessCommand = {
109
85
  [field: string]: unknown;
110
86
  name: string;
@@ -162,6 +138,23 @@ export type ConversationEvent = {
162
138
  kind: 'options';
163
139
  conversation: string;
164
140
  options: readonly SessionOption[];
141
+ } | {
142
+ kind: 'starting';
143
+ conversation: string;
144
+ step: string | null;
145
+ } | {
146
+ kind: 'state';
147
+ conversation: string;
148
+ state: SessionState | null;
149
+ } | {
150
+ kind: 'link';
151
+ conversation: string;
152
+ connected: boolean;
153
+ } | {
154
+ kind: 'deliveries';
155
+ conversation: string;
156
+ waiting: readonly string[];
157
+ unknown: readonly string[];
165
158
  } | {
166
159
  kind: 'accepted-message';
167
160
  conversation: string;
@@ -171,22 +164,83 @@ export type ConversationEvent = {
171
164
  conversation: string;
172
165
  } | {
173
166
  kind: 'list';
167
+ agents: readonly ListedAgent[];
174
168
  entries: readonly ListedConversation[];
169
+ whole: boolean;
170
+ more: boolean;
171
+ cursor: string | null;
175
172
  } | {
176
173
  kind: 'listed';
177
174
  entry: ListedConversation;
175
+ } | {
176
+ kind: 'agent';
177
+ agent: ListedAgent;
178
178
  } | {
179
179
  kind: 'unlisted';
180
180
  conversation: string;
181
181
  };
182
+ export type AgentEnvironment = {
183
+ identity: string;
184
+ name: string;
185
+ state: 'online' | 'offline';
186
+ };
187
+ export type ListedOwner = {
188
+ readonly user: string;
189
+ readonly name: string;
190
+ };
191
+ export type ListedSpaceRef = {
192
+ readonly space_ref: string;
193
+ readonly name: string;
194
+ };
195
+ export type RoomListEntry = {
196
+ readonly room_ref: string;
197
+ readonly room_handle: string;
198
+ readonly name: string;
199
+ readonly level: 'search' | 'open' | 'keep';
200
+ readonly access: 'owner' | 'manage' | 'write' | 'read' | 'public';
201
+ readonly owner: ListedOwner;
202
+ readonly created: string;
203
+ readonly archived?: string;
204
+ readonly exportable?: true;
205
+ readonly space?: ListedSpaceRef;
206
+ };
207
+ export type SpaceListEntry = ListedSpaceRef & {
208
+ readonly owner: ListedOwner;
209
+ readonly created: string;
210
+ readonly manages?: true;
211
+ };
212
+ export type RoomList = {
213
+ readonly rooms: readonly RoomListEntry[];
214
+ readonly spaces: readonly SpaceListEntry[];
215
+ };
216
+ export type ListedAgent = {
217
+ id: string;
218
+ name: string;
219
+ revision: number;
220
+ environment: string;
221
+ environment_name: string;
222
+ environment_connected: boolean;
223
+ launch_directory: string;
224
+ cli: string;
225
+ model: string | null;
226
+ effort: string | null;
227
+ mode: string | null;
228
+ base_instructions: string;
229
+ in_telegram: boolean;
230
+ created: string;
231
+ retired_at: string | null;
232
+ };
182
233
  export type ConversationStream = {
183
234
  replicate(conversations: readonly string[]): void;
235
+ hold(cursor: string | null): void;
184
236
  observe(notify: (event: ConversationEvent) => void): () => void;
237
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
185
238
  };
186
239
  export type ActionDeclaration = {
187
240
  name: string;
188
241
  inputShape: unknown;
189
242
  resultKind: unknown;
243
+ room?: string;
190
244
  };
191
245
  export type ProviderLimit = {
192
246
  name: string;
@@ -200,9 +254,13 @@ export type HistoryRetention = {
200
254
  };
201
255
  export type Retention = {
202
256
  history: HistoryRetention;
203
- outcome: number;
204
257
  refreshHorizon: number;
205
258
  };
259
+ export type QueriedRoom = {
260
+ readonly locator: string;
261
+ readonly handle: string;
262
+ readonly name: string;
263
+ };
206
264
  export type Discovery = {
207
265
  kind: 'discovery';
208
266
  rooms: readonly DiscoveredRoom[];
@@ -210,9 +268,13 @@ export type Discovery = {
210
268
  providerLimits: readonly ProviderLimit[];
211
269
  retention: Retention;
212
270
  member?: Member;
271
+ timeZone?: string | null;
272
+ roomList?: RoomList;
273
+ queriesOnly?: readonly QueriedRoom[];
213
274
  };
214
275
  export type TransportUncertainty = {
215
276
  kind: 'transport-uncertainty';
277
+ failure?: unknown;
216
278
  };
217
279
  export type RoomNotReadable = {
218
280
  kind: 'room-not-readable';
@@ -229,7 +291,7 @@ export type ProviderRefusal = {
229
291
  export type ScopedRefusal = ProviderRefusal & {
230
292
  kind: 'scoped-refusal';
231
293
  locator: string;
232
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
294
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
233
295
  };
234
296
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
235
297
  export type ContractUnavailable = ProviderRefusal & {
@@ -238,54 +300,63 @@ export type ContractUnavailable = ProviderRefusal & {
238
300
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
239
301
  export type PageToken = string;
240
302
  export type ChangeAuthor = {
241
- kind: 'user';
303
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
242
304
  id: string;
243
305
  name: string;
244
- } | {
245
- kind: 'site';
306
+ };
307
+ export type Member = {
308
+ kind: Open<'user'>;
246
309
  id: string;
247
310
  name: string;
248
311
  };
249
- export type Member = Extract<ChangeAuthor, {
250
- kind: 'user';
251
- }>;
252
312
  export type HeadChange = {
253
313
  author: ChangeAuthor | null;
254
314
  time: string;
255
315
  };
256
316
  export type BinaryFile = {
257
- fileRef: string;
258
317
  byteLength: number;
259
318
  mediaType: string;
260
319
  sha256: string;
261
320
  };
262
- export type HeldContent = {
263
- documents: Readonly<Record<string, string>>;
264
- revisions: Readonly<Record<string, string>>;
265
- };
266
321
  export type BootstrapRequest = {
267
322
  locator: string;
268
323
  selection: string;
269
324
  pageToken?: PageToken;
270
- held?: HeldContent;
325
+ arriving?: (bytes: number) => void;
326
+ signal?: AbortSignal;
327
+ };
328
+ export type BootstrapPart = {
329
+ readonly id: string;
330
+ readonly bytes: number;
331
+ };
332
+ export type BootstrapInventory = {
333
+ readonly bytes: number;
271
334
  };
272
335
  export type RoomModels = {
273
336
  collection?: ModelResult;
274
- selection?: ModelResult;
275
337
  };
276
338
  export type BootstrapPage = {
277
339
  kind: 'bootstrap';
278
340
  roomVersion: string;
279
341
  models?: RoomModels;
280
342
  documents: Readonly<Record<string, string>>;
343
+ facts: Readonly<Record<string, SavedFacts>>;
281
344
  revisions: Readonly<Record<string, string>>;
345
+ fileIds?: Readonly<Record<string, string>>;
346
+ created?: Readonly<Record<string, string>>;
282
347
  changes: Readonly<Record<string, HeadChange>>;
283
348
  binaryFiles: Readonly<Record<string, BinaryFile>>;
349
+ folders?: readonly string[];
284
350
  pageToken?: PageToken;
351
+ parts?: readonly BootstrapPart[];
352
+ bytes?: number;
353
+ };
354
+ export type NotReady = {
355
+ kind: 'not-ready';
285
356
  };
286
357
  export type BootstrapResult = BootstrapPage | {
287
358
  kind: 'beyond-horizon';
288
- } | AdapterFailure;
359
+ } | NotReady | AdapterFailure;
289
360
  export type RefreshRequest = {
290
361
  locator: string;
291
362
  selection: string;
@@ -297,10 +368,15 @@ export type RefreshPage = {
297
368
  roomVersion: string;
298
369
  models?: RoomModels;
299
370
  documents: Readonly<Record<string, string>>;
371
+ facts: Readonly<Record<string, SavedFacts>>;
300
372
  revisions: Readonly<Record<string, string>>;
373
+ fileIds?: Readonly<Record<string, string>>;
374
+ created?: Readonly<Record<string, string>>;
301
375
  changes: Readonly<Record<string, HeadChange>>;
302
376
  binaryFiles: Readonly<Record<string, BinaryFile>>;
303
377
  removals: readonly string[];
378
+ folders?: readonly string[];
379
+ folderRemovals?: readonly string[];
304
380
  pageToken?: PageToken;
305
381
  };
306
382
  export type RefreshResult = {
@@ -311,6 +387,7 @@ export type RefreshResult = {
311
387
  export type MutationRequest = {
312
388
  locator: string;
313
389
  changeBatch: ChangeBatch;
390
+ file(localId: string): Promise<Blob>;
314
391
  upload?: unknown;
315
392
  };
316
393
  export type RetryableRefusal = ProviderRefusal & {
@@ -321,34 +398,29 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
321
398
  export type ServiceModeSignal = {
322
399
  observe(notify: (mode: ServiceMode) => void): () => void;
323
400
  };
324
- export type MutationResult = {
325
- kind: 'accepted';
401
+ export type AcceptedRoom = {
326
402
  roomVersion: string;
327
403
  documents: Readonly<Record<string, string>>;
328
404
  revisions: Readonly<Record<string, string>>;
405
+ fileIds?: Readonly<Record<string, string>>;
329
406
  changes: Readonly<Record<string, HeadChange>>;
330
407
  removals: readonly string[];
331
408
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
332
- author?: string;
333
- time?: string;
334
- } | (ProviderRefusal & {
409
+ };
410
+ export type MutationResult = (AcceptedRoom & {
411
+ kind: 'accepted';
412
+ destination?: AcceptedRoom;
413
+ }) | (ProviderRefusal & {
335
414
  kind: 'conflicted';
336
- roomVersion?: string;
337
415
  affected: Readonly<Record<string, string>>;
338
416
  }) | (ProviderRefusal & {
339
417
  kind: 'rejected';
340
418
  affected: Readonly<Record<string, string>>;
341
419
  }) | RetryableRefusal | {
342
420
  kind: 'write-halted';
343
- } | {
344
- kind: 'expired';
345
- restored?: true;
346
421
  } | AdapterFailure;
347
422
  export type HistoryAuthor = {
348
- kind: 'user';
349
- id: string;
350
- } | {
351
- kind: 'site';
423
+ kind: 'user' | 'site' | 'inbox' | 'app';
352
424
  id: string;
353
425
  name: string;
354
426
  };
@@ -380,22 +452,42 @@ export type BinaryRequest = {
380
452
  locator: string;
381
453
  path: string;
382
454
  revision: string;
383
- fileRef?: string;
384
- } | {
385
- kind: 'reference';
386
- fileRef: string;
387
- referrer: unknown;
388
455
  };
389
- export type ReferrerScope = {
390
- kind: 'room';
391
- locator: string;
392
- path?: string;
393
- } | {
394
- kind: 'conversations';
456
+ export type KeyedRequest = {
457
+ kind: 'key';
458
+ link: string;
395
459
  };
396
460
  export type BinaryResult = {
397
461
  kind: 'binary';
462
+ body: ReadableStream<Uint8Array>;
463
+ mediaType: string;
464
+ sha256?: string;
465
+ } | (ProviderRefusal & {
466
+ kind: 'rejected';
467
+ }) | AdapterFailure;
468
+ export type BinaryLinkResult = {
469
+ kind: 'link';
470
+ url: string;
471
+ name: string;
472
+ mediaType?: string;
473
+ } | (ProviderRefusal & {
474
+ kind: 'rejected';
475
+ }) | AdapterFailure;
476
+ export type AttachRequest = {
477
+ locator?: string;
478
+ name: string;
479
+ mediaType: string;
480
+ byteLength: number;
481
+ sha256: string;
398
482
  blob: Blob;
483
+ };
484
+ export type AttachResult = {
485
+ kind: 'attached';
486
+ path: string;
487
+ revision: string;
488
+ } | {
489
+ kind: 'linked';
490
+ link: string;
399
491
  } | (ProviderRefusal & {
400
492
  kind: 'rejected';
401
493
  }) | AdapterFailure;
@@ -411,63 +503,101 @@ export type ActionResult = {
411
503
  kind: 'action';
412
504
  result: unknown;
413
505
  at?: RoomVersionAt;
506
+ } | (ProviderRefusal & {
507
+ kind: 'rejected';
508
+ reset?: string;
509
+ }) | AdapterFailure;
510
+ export type SearchHit = {
511
+ room: string;
512
+ path: string;
513
+ line?: number;
514
+ snippet?: string;
515
+ };
516
+ export type SearchAsk = {
517
+ text: string;
518
+ rooms: readonly string[] | null;
519
+ };
520
+ export type SearchAnswer = {
521
+ kind: 'found';
522
+ documents: readonly SearchHit[];
523
+ } | (ProviderRefusal & {
524
+ kind: 'rejected';
525
+ }) | AdapterFailure;
526
+ export type HouseQueryAsk = {
527
+ room: string;
528
+ query: Readonly<Record<string, unknown>>;
529
+ };
530
+ export type HouseQueryAnswer = {
531
+ kind: 'rows';
532
+ documents: readonly QueryDocument[];
533
+ next?: string;
414
534
  } | (ProviderRefusal & {
415
535
  kind: 'rejected';
416
536
  }) | AdapterFailure;
417
537
  export type HeldRoom = {
418
538
  locator: string;
539
+ roomVersion: string | null;
540
+ };
541
+ export type RoomChange = {
542
+ kind: 'room-change';
543
+ locator: string;
544
+ from: string | null;
419
545
  roomVersion: string;
420
- documents: Readonly<Record<string, string>>;
421
- revisions: Readonly<Record<string, string>>;
546
+ read(): Promise<RefreshPage>;
547
+ };
548
+ export type AuthorityChange = {
549
+ kind: 'authority-changed';
550
+ rooms: readonly DiscoveredRoom[];
551
+ left: readonly string[];
552
+ member?: Member;
553
+ timeZone?: string | null;
554
+ roomList?: RoomList & {
555
+ readonly left: readonly string[];
556
+ };
422
557
  };
423
558
  export type RoomStreamEvent = {
424
559
  kind: 'opened';
560
+ } | {
561
+ kind: 'discovered';
562
+ discovery: Discovery;
425
563
  } | {
426
564
  kind: 'closed';
427
565
  revoked: boolean;
566
+ lost: boolean;
567
+ authorityChanged: boolean;
428
568
  } | {
429
- kind: 'opening';
569
+ kind: 'caught-up';
430
570
  expired: readonly string[];
431
571
  } | {
432
- kind: 'room-version';
433
- locator: string;
434
- roomVersion: string;
435
- };
436
- export type KeptReceipt = {
437
- key: string;
438
- head: unknown;
439
- };
440
- export type StreamReceipts = {
441
- heads(): Promise<readonly KeptReceipt[]>;
442
- parts(key: string, count: number): Promise<readonly unknown[]>;
443
- keep(key: string, head: unknown, part?: {
444
- index: number;
445
- value: unknown;
446
- }): Promise<void>;
447
- drop(keys: readonly string[]): Promise<void>;
448
- };
572
+ kind: 'reported';
573
+ } | AuthorityChange | RoomChange;
449
574
  export type RoomStream = {
450
575
  hold(rooms: readonly HeldRoom[]): void;
451
- reopen(): void;
452
- published(locator: string, roomVersion: string): void;
453
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
576
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
454
577
  };
578
+ export type PathRule = (path: string) => boolean;
455
579
  export type Adapter = {
456
580
  readonly localSaves?: true;
457
- readonly exhaustiveDiscovery?: true;
581
+ readonly roomTypes?: VerifiedModel;
582
+ readonly typedPaths?: readonly TypedPath[];
583
+ readonly pathRule?: PathRule;
584
+ readonly unkeptReads?: readonly string[];
585
+ readonly leadingReads?: readonly string[];
458
586
  authorize(): Promise<Authorization>;
459
- discover(authorization: Authorization): Promise<DiscoverResult>;
587
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
460
588
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
461
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
589
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
462
590
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
463
591
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
464
592
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
465
- referrerScope(referrer: unknown): ReferrerScope | null;
593
+ link(authorization: Authorization, request: BinaryRequest | KeyedRequest): Promise<BinaryLinkResult>;
594
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
466
595
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
596
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
597
+ queryHouse?(authorization: Authorization, request: HouseQueryAsk): Promise<HouseQueryAnswer>;
467
598
  reached(locator: string, roomVersion: string, target: string): boolean;
468
599
  follows(locator: string, roomVersion: string, next: string): boolean;
469
600
  roomStream?: RoomStream;
470
601
  conversations?: ConversationStream;
471
602
  serviceMode?: ServiceModeSignal;
472
603
  };
473
- export {};
@@ -0,0 +1,6 @@
1
+ import { type VerifiedModel } from '../mdmodel/index.js';
2
+ import type { ModelResult, ModelState } from './model.js';
3
+ export declare const NO_ROOM_TYPES: VerifiedModel;
4
+ export declare function builtInModel(roomTypes: VerifiedModel): ModelState;
5
+ export declare function schemaTypes(schema: string | null, roomTypes: VerifiedModel): VerifiedModel['types'];
6
+ export declare function attachedModel(answer: ModelResult, roomTypes: VerifiedModel): ModelState;
@@ -0,0 +1,87 @@
1
+ import type { UnsentWork } from './durability.js';
2
+ import type { Connection, FileSpool, HeldStatus } from './tables.js';
3
+ export declare const FILE_PART_BYTES = 1048576;
4
+ export declare const AUTHORED_TABLES: readonly string[];
5
+ export type AuthoredFact = 'holder' | 'generation' | 'format';
6
+ export type StoredFile = {
7
+ readonly key: string;
8
+ readonly blob: Blob;
9
+ };
10
+ type KeptPending = {
11
+ readonly id: string;
12
+ readonly batch: string;
13
+ readonly state: string;
14
+ readonly files: readonly string[];
15
+ readonly paths: readonly string[];
16
+ readonly moving: boolean;
17
+ };
18
+ export type KeptRecord = {
19
+ readonly record: string;
20
+ readonly files: readonly string[];
21
+ };
22
+ export type AuthoredRows = {
23
+ readonly locator: string;
24
+ readonly order?: readonly string[];
25
+ readonly added?: readonly KeptPending[];
26
+ readonly founded?: readonly Omit<KeptPending, 'state'>[];
27
+ readonly roomDrafts?: readonly (KeptRecord & {
28
+ readonly path: string;
29
+ })[];
30
+ readonly consumedRoomDrafts?: readonly string[];
31
+ };
32
+ export type AuthoredWrite = {
33
+ readonly writes: readonly AuthoredRows[];
34
+ readonly files: readonly StoredFile[];
35
+ readonly whole: boolean;
36
+ };
37
+ export type HeldQueues = {
38
+ readonly queues: readonly {
39
+ readonly locator: string;
40
+ readonly ids: readonly string[];
41
+ }[];
42
+ readonly pending: readonly QueuedRow[];
43
+ };
44
+ type QueuedRow = {
45
+ readonly locator: string;
46
+ readonly id: string;
47
+ readonly batch: string;
48
+ readonly state: string;
49
+ };
50
+ export declare function authoredTable(name: string): boolean;
51
+ export declare function heldTables(connection: Connection): string[];
52
+ export declare function formatted(connection: Connection, format: string, tables: readonly string[]): void;
53
+ export declare function fact(connection: Connection, name: AuthoredFact): string | null;
54
+ export declare function remember(connection: Connection, name: AuthoredFact, value: string): null;
55
+ export declare function fenced(connection: Connection, locator: string): boolean;
56
+ export declare function authoredPart(connection: Connection, key: string, part: number): Uint8Array | null;
57
+ export declare function spooled(connection: Connection, spool: FileSpool, key: string, type: string): Promise<Blob>;
58
+ export declare function queues(connection: Connection): HeldQueues['queues'];
59
+ export declare function queuedLocators(connection: Connection): string[];
60
+ export declare function authoredLocators(connection: Connection): string[];
61
+ export declare function heldOrder(connection: Connection, locator: string): readonly string[];
62
+ export declare function queueOf(connection: Connection, locator: string): Omit<QueuedRow, 'locator'>[];
63
+ export declare function moving(connection: Connection): HeldQueues;
64
+ export declare function unsentStatus(connection: Connection): Omit<HeldStatus, 'lastCompleted'>;
65
+ export declare function pendingState(connection: Connection, locator: string, id: string): string | null;
66
+ export declare function pendingBatch(connection: Connection, locator: string, id: string): string | null;
67
+ export declare function roomDraftRecords(connection: Connection, locator: string | null, paths: readonly string[] | null): string[];
68
+ export declare function chatDraftRecord(connection: Connection, conversation: string): string | null;
69
+ export declare function chatDraftRecords(connection: Connection): string[];
70
+ export declare function chatDraftConversations(connection: Connection, conversations: readonly string[] | null): string[];
71
+ export declare function chatDraftsDropped(connection: Connection, conversations: readonly string[]): void;
72
+ export declare function callRecords(connection: Connection): string[];
73
+ export declare function fences(connection: Connection): string[];
74
+ export declare function kept(connection: Connection, { writes, files, whole }: AuthoredWrite): Promise<string | null>;
75
+ export declare function amended(connection: Connection, locator: string, id: string, amendment: string): null;
76
+ export declare function roomDraft(connection: Connection, locator: string, path: string, draft: KeptRecord | null, files: readonly StoredFile[]): Promise<string | null>;
77
+ export declare function chatDraft(connection: Connection, drafts: readonly {
78
+ readonly conversation: string;
79
+ readonly record: string;
80
+ }[], dropped: readonly string[]): null;
81
+ export declare function call(connection: Connection, operation: string, held: KeptRecord | null, files: readonly StoredFile[]): Promise<null>;
82
+ export declare function fencedWork(connection: Connection, locators: readonly string[]): void;
83
+ export declare function unfenced(connection: Connection, locators: readonly string[]): void;
84
+ export declare function claim(connection: Connection, holder: string): boolean;
85
+ export declare function authoredEmptied(connection: Connection): void;
86
+ export declare function unsent(connection: Connection): UnsentWork[];
87
+ export {};