@agentshouse/app-bridge 0.1.0-c58a055eeaa71 → 0.1.0-c59dd0a694516

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 (114) hide show
  1. package/README.md +11 -9
  2. package/dist/index.d.ts +620 -14
  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 +90 -0
  6. package/dist/mdmodel/divide.d.ts +2 -0
  7. package/dist/mdmodel/document.d.ts +21 -0
  8. package/dist/mdmodel/event.d.ts +76 -0
  9. package/dist/mdmodel/facts.d.ts +14 -0
  10. package/dist/mdmodel/fields.d.ts +5 -0
  11. package/dist/mdmodel/house-model.d.ts +865 -0
  12. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  13. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  14. package/dist/mdmodel/index.d.ts +43 -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/not-ready.d.ts +1 -0
  19. package/dist/mdmodel/paths.d.ts +39 -0
  20. package/dist/mdmodel/pattern.d.ts +9 -0
  21. package/dist/mdmodel/project.d.ts +21 -0
  22. package/dist/mdmodel/query/language.d.ts +253 -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 +38 -0
  26. package/dist/mdmodel/references.d.ts +3 -0
  27. package/dist/mdmodel/reserved.d.ts +5 -0
  28. package/dist/mdmodel/room-types.d.ts +6 -0
  29. package/dist/mdmodel/types.d.ts +172 -0
  30. package/dist/mdmodel/validate.d.ts +37 -0
  31. package/dist/mdmodel/version.d.ts +1 -0
  32. package/dist/mdmodel/yaml.d.ts +55 -0
  33. package/dist/mdruntime/actions.d.ts +25 -0
  34. package/dist/mdruntime/adapter.d.ts +575 -0
  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 +17 -0
  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 +31 -0
  42. package/dist/mdruntime/change.d.ts +123 -0
  43. package/dist/mdruntime/client.d.ts +98 -0
  44. package/dist/mdruntime/collection.d.ts +49 -0
  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 +136 -0
  49. package/dist/mdruntime/declaration.d.ts +9 -0
  50. package/dist/mdruntime/durability.d.ts +30 -0
  51. package/dist/mdruntime/failure.d.ts +15 -0
  52. package/dist/mdruntime/figures.d.ts +48 -0
  53. package/dist/mdruntime/holdings.d.ts +28 -0
  54. package/dist/mdruntime/identity.d.ts +5 -0
  55. package/dist/mdruntime/install.d.ts +59 -0
  56. package/dist/mdruntime/listing.d.ts +51 -0
  57. package/dist/mdruntime/live.d.ts +24 -0
  58. package/dist/mdruntime/media.d.ts +12 -0
  59. package/dist/mdruntime/messages.d.ts +57 -0
  60. package/dist/mdruntime/model.d.ts +54 -0
  61. package/dist/mdruntime/observation.d.ts +59 -0
  62. package/dist/mdruntime/open.d.ts +1 -0
  63. package/dist/mdruntime/opened.d.ts +21 -0
  64. package/dist/mdruntime/outcome.d.ts +94 -0
  65. package/dist/mdruntime/overlay.d.ts +29 -0
  66. package/dist/mdruntime/preparation.d.ts +40 -0
  67. package/dist/mdruntime/presence.d.ts +57 -0
  68. package/dist/mdruntime/query.d.ts +87 -0
  69. package/dist/mdruntime/reach.d.ts +54 -0
  70. package/dist/mdruntime/readiness.d.ts +54 -0
  71. package/dist/mdruntime/reads.d.ts +38 -0
  72. package/dist/mdruntime/recovery.d.ts +27 -0
  73. package/dist/mdruntime/refresh.d.ts +26 -0
  74. package/dist/mdruntime/replica.d.ts +62 -0
  75. package/dist/mdruntime/retried.d.ts +29 -0
  76. package/dist/mdruntime/room-draft.d.ts +197 -0
  77. package/dist/mdruntime/room-drafts.d.ts +23 -0
  78. package/dist/mdruntime/runtime.d.ts +33 -0
  79. package/dist/mdruntime/save.d.ts +58 -0
  80. package/dist/mdruntime/saves.d.ts +31 -0
  81. package/dist/mdruntime/search.d.ts +21 -0
  82. package/dist/mdruntime/seed.d.ts +24 -0
  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 +37 -0
  87. package/dist/mdruntime/socket.d.ts +66 -0
  88. package/dist/mdruntime/source.d.ts +58 -0
  89. package/dist/mdruntime/status.d.ts +25 -0
  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 +222 -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 +125 -0
  99. package/dist/mdruntime/stored.d.ts +166 -0
  100. package/dist/mdruntime/surface.d.ts +89 -0
  101. package/dist/mdruntime/tables.d.ts +375 -0
  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 +288 -0
  105. package/dist/session-content/bounds.d.ts +7 -0
  106. package/dist/session-content/check.d.ts +18 -0
  107. package/dist/session-content/index.d.ts +7 -0
  108. package/dist/session-content/parts.d.ts +103 -0
  109. package/dist/session-content/state.d.ts +61 -0
  110. package/dist/session-content/turn.d.ts +328 -0
  111. package/dist/test-host.d.ts +15 -5
  112. package/dist/test-host.js +74 -23
  113. package/docs/families.md +93 -22
  114. package/package.json +8 -6
@@ -0,0 +1,575 @@
1
+ import type { SavedFacts, TypedPath, VerifiedModel } from '../mdmodel/index.js';
2
+ import type { Operation, SessionState } from '../session-content/index.js';
3
+ import type { ModelResult } from './model.js';
4
+ export type { SavedFacts, TypedPath };
5
+ import type { Open } from './open.js';
6
+ import type { ChangeBatch } from './change.js';
7
+ export type Authorization = object;
8
+ export type MdModelIdentity = {
9
+ identity: string;
10
+ version: string;
11
+ };
12
+ export type TypedSelection = {
13
+ roots: readonly string[];
14
+ };
15
+ export type OperationScopes = {
16
+ write: readonly string[];
17
+ erase: readonly string[];
18
+ };
19
+ export type ReplicaAdmission = {
20
+ selection: string;
21
+ admission: Open<'admitted' | 'unavailable'>;
22
+ offline: Open<'locked' | 'open'>;
23
+ };
24
+ export type RoomDeclaration = {
25
+ readonly name: string;
26
+ readonly handle: string;
27
+ readonly operations: OperationScopes;
28
+ readonly replica: ReplicaAdmission;
29
+ readonly typedSelection: TypedSelection | null;
30
+ readonly providerOwnedPaths: readonly string[];
31
+ readonly authoredPaths: readonly string[];
32
+ };
33
+ export type DiscoveredRoom = RoomDeclaration & {
34
+ readonly locator: string;
35
+ readonly roomVersion: string;
36
+ };
37
+ export type Capability = {
38
+ name: string;
39
+ limits?: readonly ProviderLimit[];
40
+ actions?: readonly ActionDeclaration[];
41
+ };
42
+ export type ListedConversation = {
43
+ conversation: string;
44
+ agent: string;
45
+ name: string;
46
+ created: string;
47
+ finished: string | null;
48
+ outcome: string | null;
49
+ waiting: boolean;
50
+ newest: string | null;
51
+ processEnded: string | null;
52
+ subject: string | null;
53
+ };
54
+ 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';
55
+ export type ConversationMessage = {
56
+ identity: string;
57
+ turn: string;
58
+ text: string;
59
+ message: unknown;
60
+ };
61
+ export type AcceptedMessage = ConversationMessage & {
62
+ position: string;
63
+ change: string;
64
+ };
65
+ export type ConversationHistoryRequest = {
66
+ conversations: readonly {
67
+ conversation: string;
68
+ after?: string;
69
+ }[];
70
+ };
71
+ export type ConversationHistoryPage = {
72
+ conversation: string;
73
+ messages: readonly AcceptedMessage[];
74
+ next?: string;
75
+ };
76
+ export type ConversationHistories = {
77
+ histories: readonly ConversationHistoryPage[];
78
+ };
79
+ export type TurnOperation = {
80
+ op: 'begin';
81
+ at: string;
82
+ } | Operation;
83
+ export type ProcessCommand = {
84
+ [field: string]: unknown;
85
+ name: string;
86
+ description: string;
87
+ input?: {
88
+ [field: string]: unknown;
89
+ hint: string;
90
+ } | null;
91
+ };
92
+ type SelectValue = {
93
+ [field: string]: unknown;
94
+ value: string;
95
+ name: string;
96
+ description?: string | null;
97
+ };
98
+ type SelectGroup = {
99
+ [field: string]: unknown;
100
+ group: string;
101
+ name: string;
102
+ options: readonly SelectValue[];
103
+ };
104
+ type SessionOptionNaming = {
105
+ [field: string]: unknown;
106
+ id: string;
107
+ name: string;
108
+ description?: string | null;
109
+ category?: string | null;
110
+ };
111
+ export type SessionOption = (SessionOptionNaming & {
112
+ type: 'select';
113
+ currentValue: string;
114
+ options: readonly SelectValue[] | readonly SelectGroup[];
115
+ }) | (SessionOptionNaming & {
116
+ type: 'boolean';
117
+ currentValue: boolean;
118
+ });
119
+ export type ConversationEvent = {
120
+ kind: 'turn';
121
+ conversation: string;
122
+ turn: string;
123
+ operation: TurnOperation;
124
+ } | {
125
+ kind: 'questions';
126
+ conversation: string;
127
+ questions: readonly unknown[];
128
+ } | {
129
+ kind: 'process';
130
+ conversation: string;
131
+ running: boolean;
132
+ } | {
133
+ kind: 'commands';
134
+ conversation: string;
135
+ commands: readonly ProcessCommand[];
136
+ } | {
137
+ kind: 'options';
138
+ conversation: string;
139
+ options: readonly SessionOption[];
140
+ } | {
141
+ kind: 'starting';
142
+ conversation: string;
143
+ step: string | null;
144
+ } | {
145
+ kind: 'state';
146
+ conversation: string;
147
+ state: SessionState | null;
148
+ } | {
149
+ kind: 'link';
150
+ conversation: string;
151
+ connected: boolean;
152
+ } | {
153
+ kind: 'deliveries';
154
+ conversation: string;
155
+ waiting: readonly string[];
156
+ unknown: readonly string[];
157
+ } | {
158
+ kind: 'accepted-message';
159
+ conversation: string;
160
+ message: AcceptedMessage;
161
+ } | {
162
+ kind: 'gap';
163
+ conversation: string;
164
+ } | {
165
+ kind: 'list';
166
+ agents: readonly ListedAgent[];
167
+ entries: readonly ListedConversation[];
168
+ whole: boolean;
169
+ more: boolean;
170
+ cursor: string | null;
171
+ } | {
172
+ kind: 'listed';
173
+ entry: ListedConversation;
174
+ } | {
175
+ kind: 'agent';
176
+ agent: ListedAgent;
177
+ } | {
178
+ kind: 'unlisted';
179
+ conversation: string;
180
+ };
181
+ export type AgentEnvironment = {
182
+ identity: string;
183
+ name: string;
184
+ state: 'online' | 'offline';
185
+ };
186
+ export type ListedOwner = {
187
+ readonly user: string;
188
+ readonly name: string;
189
+ };
190
+ export type ListedSpaceRef = {
191
+ readonly space_ref: string;
192
+ readonly name: string;
193
+ };
194
+ export type RoomListEntry = {
195
+ readonly room_ref: string;
196
+ readonly room_handle: string;
197
+ readonly name: string;
198
+ readonly level: 'search' | 'open' | 'keep';
199
+ readonly access: 'owner' | 'manage' | 'write' | 'read' | 'public';
200
+ readonly owner: ListedOwner;
201
+ readonly created: string;
202
+ readonly archived?: string;
203
+ readonly exportable?: true;
204
+ readonly space?: ListedSpaceRef;
205
+ };
206
+ export type SpaceListEntry = ListedSpaceRef & {
207
+ readonly owner: ListedOwner;
208
+ readonly created: string;
209
+ readonly manages?: true;
210
+ };
211
+ export type RoomList = {
212
+ readonly rooms: readonly RoomListEntry[];
213
+ readonly spaces: readonly SpaceListEntry[];
214
+ };
215
+ export type ListedAgent = {
216
+ id: string;
217
+ name: string;
218
+ revision: number;
219
+ environment: string;
220
+ environment_name: string;
221
+ environment_connected: boolean;
222
+ launch_directory: string;
223
+ cli: string;
224
+ model: string | null;
225
+ effort: string | null;
226
+ mode: string | null;
227
+ base_instructions: string;
228
+ in_telegram: boolean;
229
+ created: string;
230
+ retired_at: string | null;
231
+ };
232
+ export type ConversationStream = {
233
+ replicate(conversations: readonly string[]): void;
234
+ hold(cursor: string | null): void;
235
+ observe(notify: (event: ConversationEvent) => void): () => void;
236
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
237
+ };
238
+ export type ActionDeclaration = {
239
+ name: string;
240
+ inputShape: unknown;
241
+ resultKind: unknown;
242
+ room?: string;
243
+ };
244
+ export type ProviderLimit = {
245
+ name: string;
246
+ value?: number | string;
247
+ };
248
+ export type HistoryRetention = {
249
+ kind: 'duration';
250
+ seconds: number;
251
+ } | {
252
+ kind: 'no-declared-time-bound';
253
+ };
254
+ export type Retention = {
255
+ history: HistoryRetention;
256
+ refreshHorizon: number;
257
+ };
258
+ export type Discovery = {
259
+ kind: 'discovery';
260
+ rooms: readonly DiscoveredRoom[];
261
+ capabilities: readonly Capability[];
262
+ providerLimits: readonly ProviderLimit[];
263
+ retention: Retention;
264
+ member?: Member;
265
+ roomList?: RoomList;
266
+ };
267
+ export type TransportUncertainty = {
268
+ kind: 'transport-uncertainty';
269
+ failure?: unknown;
270
+ };
271
+ export type RoomNotReadable = {
272
+ kind: 'room-not-readable';
273
+ locator: string;
274
+ };
275
+ export type RevokedAuthorization = {
276
+ kind: 'revoked-authorization';
277
+ };
278
+ export type ProviderRefusal = {
279
+ code: string;
280
+ fields: Readonly<Record<string, unknown>>;
281
+ retryable: boolean;
282
+ };
283
+ export type ScopedRefusal = ProviderRefusal & {
284
+ kind: 'scoped-refusal';
285
+ locator: string;
286
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
287
+ };
288
+ export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
289
+ export type ContractUnavailable = ProviderRefusal & {
290
+ kind: 'contract-unavailable';
291
+ };
292
+ export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
293
+ export type PageToken = string;
294
+ export type ChangeAuthor = {
295
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
296
+ id: string;
297
+ name: string;
298
+ };
299
+ export type Member = {
300
+ kind: Open<'user'>;
301
+ id: string;
302
+ name: string;
303
+ };
304
+ export type HeadChange = {
305
+ author: ChangeAuthor | null;
306
+ time: string;
307
+ };
308
+ export type BinaryFile = {
309
+ byteLength: number;
310
+ mediaType: string;
311
+ sha256: string;
312
+ };
313
+ export type BootstrapRequest = {
314
+ locator: string;
315
+ selection: string;
316
+ pageToken?: PageToken;
317
+ arriving?: (bytes: number) => void;
318
+ signal?: AbortSignal;
319
+ };
320
+ export type BootstrapPart = {
321
+ readonly id: string;
322
+ readonly bytes: number;
323
+ };
324
+ export type BootstrapInventory = {
325
+ readonly bytes: number;
326
+ };
327
+ export type RoomModels = {
328
+ collection?: ModelResult;
329
+ };
330
+ export type BootstrapPage = {
331
+ kind: 'bootstrap';
332
+ roomVersion: string;
333
+ models?: RoomModels;
334
+ documents: Readonly<Record<string, string>>;
335
+ facts: Readonly<Record<string, SavedFacts>>;
336
+ revisions: Readonly<Record<string, string>>;
337
+ fileIds?: Readonly<Record<string, string>>;
338
+ created?: Readonly<Record<string, string>>;
339
+ changes: Readonly<Record<string, HeadChange>>;
340
+ binaryFiles: Readonly<Record<string, BinaryFile>>;
341
+ folders?: readonly string[];
342
+ pageToken?: PageToken;
343
+ parts?: readonly BootstrapPart[];
344
+ bytes?: number;
345
+ };
346
+ export type NotReady = {
347
+ kind: 'not-ready';
348
+ };
349
+ export type BootstrapResult = BootstrapPage | {
350
+ kind: 'beyond-horizon';
351
+ } | NotReady | AdapterFailure;
352
+ export type RefreshRequest = {
353
+ locator: string;
354
+ selection: string;
355
+ fromRoomVersion: string;
356
+ pageToken?: PageToken;
357
+ };
358
+ export type RefreshPage = {
359
+ kind: 'net-advancement';
360
+ roomVersion: string;
361
+ models?: RoomModels;
362
+ documents: Readonly<Record<string, string>>;
363
+ facts: Readonly<Record<string, SavedFacts>>;
364
+ revisions: Readonly<Record<string, string>>;
365
+ fileIds?: Readonly<Record<string, string>>;
366
+ created?: Readonly<Record<string, string>>;
367
+ changes: Readonly<Record<string, HeadChange>>;
368
+ binaryFiles: Readonly<Record<string, BinaryFile>>;
369
+ removals: readonly string[];
370
+ folders?: readonly string[];
371
+ folderRemovals?: readonly string[];
372
+ pageToken?: PageToken;
373
+ };
374
+ export type RefreshResult = {
375
+ kind: 'still-current';
376
+ } | RefreshPage | {
377
+ kind: 'beyond-horizon';
378
+ } | RetryableRefusal | AdapterFailure;
379
+ export type MutationRequest = {
380
+ locator: string;
381
+ changeBatch: ChangeBatch;
382
+ file(localId: string): Promise<Blob>;
383
+ upload?: unknown;
384
+ };
385
+ export type RetryableRefusal = ProviderRefusal & {
386
+ kind: 'retryable-refusal';
387
+ reset?: string;
388
+ };
389
+ export type ServiceMode = Open<'open' | 'write-halted'>;
390
+ export type ServiceModeSignal = {
391
+ observe(notify: (mode: ServiceMode) => void): () => void;
392
+ };
393
+ export type AcceptedRoom = {
394
+ roomVersion: string;
395
+ documents: Readonly<Record<string, string>>;
396
+ revisions: Readonly<Record<string, string>>;
397
+ fileIds?: Readonly<Record<string, string>>;
398
+ changes: Readonly<Record<string, HeadChange>>;
399
+ removals: readonly string[];
400
+ binaryFiles?: Readonly<Record<string, BinaryFile>>;
401
+ };
402
+ export type MutationResult = (AcceptedRoom & {
403
+ kind: 'accepted';
404
+ destination?: AcceptedRoom;
405
+ }) | (ProviderRefusal & {
406
+ kind: 'conflicted';
407
+ affected: Readonly<Record<string, string>>;
408
+ }) | (ProviderRefusal & {
409
+ kind: 'rejected';
410
+ affected: Readonly<Record<string, string>>;
411
+ }) | RetryableRefusal | {
412
+ kind: 'write-halted';
413
+ } | AdapterFailure;
414
+ export type HistoryAuthor = {
415
+ kind: 'user' | 'site' | 'inbox' | 'app';
416
+ id: string;
417
+ name: string;
418
+ };
419
+ export type HistoryRevision = {
420
+ revision: string;
421
+ author: HistoryAuthor;
422
+ time: string;
423
+ binaryFile?: BinaryFile;
424
+ };
425
+ export type HistoryRequest = {
426
+ locator: string;
427
+ path: string;
428
+ revision?: string;
429
+ pageToken?: PageToken;
430
+ };
431
+ export type HistoryResult = {
432
+ kind: 'history';
433
+ revisions: readonly HistoryRevision[];
434
+ pageToken?: PageToken;
435
+ deleted?: true;
436
+ } | {
437
+ kind: 'revision';
438
+ content: string;
439
+ } | {
440
+ kind: 'no-history';
441
+ } | AdapterFailure;
442
+ export type BinaryRequest = {
443
+ kind: 'path';
444
+ locator: string;
445
+ path: string;
446
+ revision: string;
447
+ };
448
+ export type BinaryResult = {
449
+ kind: 'binary';
450
+ body: ReadableStream<Uint8Array>;
451
+ mediaType: string;
452
+ sha256?: string;
453
+ } | (ProviderRefusal & {
454
+ kind: 'rejected';
455
+ }) | AdapterFailure;
456
+ export type BinaryLinkResult = {
457
+ kind: 'link';
458
+ url: string;
459
+ name: string;
460
+ mediaType?: string;
461
+ } | (ProviderRefusal & {
462
+ kind: 'rejected';
463
+ }) | AdapterFailure;
464
+ export type AttachRequest = {
465
+ locator: string;
466
+ name: string;
467
+ mediaType: string;
468
+ byteLength: number;
469
+ sha256: string;
470
+ blob: Blob;
471
+ };
472
+ export type AttachResult = {
473
+ kind: 'attached';
474
+ path: string;
475
+ revision: string;
476
+ } | (ProviderRefusal & {
477
+ kind: 'rejected';
478
+ }) | AdapterFailure;
479
+ export type ActionRequest = {
480
+ name: string;
481
+ input: unknown;
482
+ };
483
+ export type RoomVersionAt = {
484
+ locator: string;
485
+ roomVersion: string;
486
+ };
487
+ export type ActionResult = {
488
+ kind: 'action';
489
+ result: unknown;
490
+ at?: RoomVersionAt;
491
+ } | (ProviderRefusal & {
492
+ kind: 'rejected';
493
+ reset?: string;
494
+ }) | AdapterFailure;
495
+ export type SearchHit = {
496
+ room: string;
497
+ path: string;
498
+ line?: number;
499
+ snippet?: string;
500
+ };
501
+ export type SearchAsk = {
502
+ text: string;
503
+ rooms: readonly string[] | null;
504
+ };
505
+ export type SearchAnswer = {
506
+ kind: 'found';
507
+ documents: readonly SearchHit[];
508
+ } | (ProviderRefusal & {
509
+ kind: 'rejected';
510
+ }) | AdapterFailure;
511
+ export type HeldRoom = {
512
+ locator: string;
513
+ roomVersion: string | null;
514
+ };
515
+ export type RoomChange = {
516
+ kind: 'room-change';
517
+ locator: string;
518
+ from: string | null;
519
+ roomVersion: string;
520
+ read(): Promise<RefreshPage>;
521
+ };
522
+ export type AuthorityChange = {
523
+ kind: 'authority-changed';
524
+ rooms: readonly DiscoveredRoom[];
525
+ left: readonly string[];
526
+ member?: Member;
527
+ roomList?: RoomList & {
528
+ readonly left: readonly string[];
529
+ };
530
+ };
531
+ export type RoomStreamEvent = {
532
+ kind: 'opened';
533
+ } | {
534
+ kind: 'discovered';
535
+ discovery: Discovery;
536
+ } | {
537
+ kind: 'closed';
538
+ revoked: boolean;
539
+ lost: boolean;
540
+ authorityChanged: boolean;
541
+ } | {
542
+ kind: 'caught-up';
543
+ expired: readonly string[];
544
+ } | {
545
+ kind: 'reported';
546
+ } | AuthorityChange | RoomChange;
547
+ export type RoomStream = {
548
+ hold(rooms: readonly HeldRoom[]): void;
549
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
550
+ };
551
+ export type PathRule = (path: string) => boolean;
552
+ export type Adapter = {
553
+ readonly localSaves?: true;
554
+ readonly roomTypes?: VerifiedModel;
555
+ readonly typedPaths?: readonly TypedPath[];
556
+ readonly pathRule?: PathRule;
557
+ readonly unkeptReads?: readonly string[];
558
+ readonly leadingReads?: readonly string[];
559
+ authorize(): Promise<Authorization>;
560
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
561
+ bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
562
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
563
+ mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
564
+ history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
565
+ binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
566
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
567
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
568
+ action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
569
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
570
+ reached(locator: string, roomVersion: string, target: string): boolean;
571
+ follows(locator: string, roomVersion: string, next: string): boolean;
572
+ roomStream?: RoomStream;
573
+ conversations?: ConversationStream;
574
+ serviceMode?: ServiceModeSignal;
575
+ };
@@ -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 {};
@@ -0,0 +1,17 @@
1
+ import type { HeldBinary } from './overlay.js';
2
+ export type BinaryFileRecord = {
3
+ readonly state: 'accepted';
4
+ readonly revision: string;
5
+ readonly path: string;
6
+ readonly byteLength: number;
7
+ readonly mediaType: string;
8
+ readonly sha256: string;
9
+ } | {
10
+ readonly state: 'pending';
11
+ readonly localId: string;
12
+ readonly path: string;
13
+ readonly byteLength: number;
14
+ readonly mediaType: string;
15
+ readonly sha256: string;
16
+ };
17
+ export declare function binaryRecord(path: string, held: HeldBinary, revision: string | undefined): BinaryFileRecord;