@agentshouse/app-bridge 0.1.0-caae3da69c1c2 → 0.1.0-cac2ee656ded8

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 (113) hide show
  1. package/README.md +9 -9
  2. package/dist/index.d.ts +571 -18
  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 +21 -10
  7. package/dist/mdmodel/document.d.ts +15 -8
  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 +1 -1
  11. package/dist/mdmodel/house-model.d.ts +826 -0
  12. package/dist/mdmodel/house-references.d.ts +3 -0
  13. package/dist/mdmodel/index.d.ts +35 -13
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/paths.d.ts +10 -1
  17. package/dist/mdmodel/pattern.d.ts +9 -0
  18. package/dist/mdmodel/query/language.d.ts +253 -0
  19. package/dist/mdmodel/query/match.d.ts +13 -0
  20. package/dist/mdmodel/query/rows.d.ts +31 -0
  21. package/dist/mdmodel/query/sql.d.ts +38 -0
  22. package/dist/mdmodel/reserved.d.ts +5 -0
  23. package/dist/mdmodel/room-types.d.ts +6 -0
  24. package/dist/mdmodel/types.d.ts +29 -10
  25. package/dist/mdmodel/validate.d.ts +31 -6
  26. package/dist/mdruntime/actions.d.ts +25 -0
  27. package/dist/mdruntime/adapter.d.ts +159 -122
  28. package/dist/mdruntime/attached-model.d.ts +6 -0
  29. package/dist/mdruntime/binary.d.ts +0 -5
  30. package/dist/mdruntime/bootstrap.d.ts +43 -0
  31. package/dist/mdruntime/cell.d.ts +5 -0
  32. package/dist/mdruntime/chain.d.ts +11 -0
  33. package/dist/mdruntime/change-set.d.ts +10 -16
  34. package/dist/mdruntime/change.d.ts +32 -1
  35. package/dist/mdruntime/client.d.ts +37 -26
  36. package/dist/mdruntime/collection.d.ts +29 -22
  37. package/dist/mdruntime/compile.d.ts +17 -0
  38. package/dist/mdruntime/conversation-live.d.ts +146 -0
  39. package/dist/mdruntime/conversation-row.d.ts +32 -0
  40. package/dist/mdruntime/conversation.d.ts +68 -49
  41. package/dist/mdruntime/declaration.d.ts +9 -0
  42. package/dist/mdruntime/durability.d.ts +20 -4
  43. package/dist/mdruntime/failure.d.ts +3 -0
  44. package/dist/mdruntime/figures.d.ts +48 -0
  45. package/dist/mdruntime/holdings.d.ts +28 -0
  46. package/dist/mdruntime/identity.d.ts +5 -0
  47. package/dist/mdruntime/listing.d.ts +47 -0
  48. package/dist/mdruntime/live.d.ts +22 -0
  49. package/dist/mdruntime/media.d.ts +7 -0
  50. package/dist/mdruntime/messages.d.ts +55 -0
  51. package/dist/mdruntime/model.d.ts +8 -11
  52. package/dist/mdruntime/observation.d.ts +17 -3
  53. package/dist/mdruntime/opened.d.ts +21 -0
  54. package/dist/mdruntime/outcome.d.ts +47 -9
  55. package/dist/mdruntime/overlay.d.ts +7 -5
  56. package/dist/mdruntime/preparation.d.ts +19 -0
  57. package/dist/mdruntime/presence.d.ts +51 -0
  58. package/dist/mdruntime/query.d.ts +21 -207
  59. package/dist/mdruntime/reach.d.ts +20 -9
  60. package/dist/mdruntime/readiness.d.ts +14 -18
  61. package/dist/mdruntime/reads.d.ts +38 -0
  62. package/dist/mdruntime/recovery.d.ts +5 -2
  63. package/dist/mdruntime/refresh.d.ts +26 -0
  64. package/dist/mdruntime/replica.d.ts +50 -39
  65. package/dist/mdruntime/retried.d.ts +29 -0
  66. package/dist/mdruntime/room-draft.d.ts +28 -11
  67. package/dist/mdruntime/room-drafts.d.ts +23 -0
  68. package/dist/mdruntime/runtime.d.ts +33 -0
  69. package/dist/mdruntime/save.d.ts +43 -50
  70. package/dist/mdruntime/saves.d.ts +31 -0
  71. package/dist/mdruntime/search.d.ts +12 -95
  72. package/dist/mdruntime/seed.d.ts +11 -2
  73. package/dist/mdruntime/socket/admission.d.ts +6 -0
  74. package/dist/mdruntime/socket/answers.d.ts +5 -0
  75. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  76. package/dist/mdruntime/socket/session.d.ts +37 -0
  77. package/dist/mdruntime/socket.d.ts +66 -0
  78. package/dist/mdruntime/source.d.ts +53 -0
  79. package/dist/mdruntime/status.d.ts +4 -5
  80. package/dist/mdruntime/store/installs.d.ts +29 -0
  81. package/dist/mdruntime/store/readiness.d.ts +9 -0
  82. package/dist/mdruntime/store/records.d.ts +214 -0
  83. package/dist/mdruntime/store/room-held.d.ts +7 -0
  84. package/dist/mdruntime/store/space.d.ts +10 -0
  85. package/dist/mdruntime/store/watchers.d.ts +16 -0
  86. package/dist/mdruntime/store/writes.d.ts +23 -0
  87. package/dist/mdruntime/store.d.ts +111 -166
  88. package/dist/mdruntime/stored.d.ts +156 -0
  89. package/dist/mdruntime/surface.d.ts +88 -0
  90. package/dist/mdruntime/tables.d.ts +414 -0
  91. package/dist/mdruntime/tallies.d.ts +17 -0
  92. package/dist/mdruntime/transfer.d.ts +0 -5
  93. package/dist/mdruntime/wire.d.ts +82 -9
  94. package/dist/session-content/bounds.d.ts +7 -0
  95. package/dist/session-content/check.d.ts +18 -0
  96. package/dist/session-content/index.d.ts +7 -0
  97. package/dist/session-content/parts.d.ts +103 -0
  98. package/dist/session-content/state.d.ts +61 -0
  99. package/dist/session-content/turn.d.ts +328 -0
  100. package/dist/test-host.d.ts +7 -4
  101. package/dist/test-host.js +18 -28
  102. package/docs/families.md +65 -57
  103. package/package.json +8 -3
  104. package/dist/calls.d.ts +0 -957
  105. package/dist/calls.js +0 -1
  106. package/dist/mdmodel/blocks.d.ts +0 -10
  107. package/dist/mdmodel/condition.d.ts +0 -147
  108. package/dist/mdmodel/profile.d.ts +0 -5
  109. package/dist/mdruntime/connection.d.ts +0 -146
  110. package/dist/mdruntime/file.d.ts +0 -19
  111. package/dist/mdruntime/rows.d.ts +0 -38
  112. package/dist/mdruntime/shared.d.ts +0 -14
  113. package/dist/mdruntime/turn.d.ts +0 -8
@@ -1,10 +1,35 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { DocumentCheck, Library, ModelVerification, Reached, RoomReference, Validation, ValidationContext, VerifiedModel } from './types.js';
2
+ import type { DefinitionOf, Document, DocumentCheck, Library, ModelVerification, ParseResult, Reached, RoomReference, TypedPath, Validation, ValidationContext, ValidationStep, VerifiedModel } from './types.js';
3
+ export declare function definitionAt(model: VerifiedModel, file: string, typedPaths?: readonly TypedPath[]): DefinitionOf;
3
4
  export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
4
- export declare function verify(schema: string): ModelVerification;
5
- export declare function checkDocument(file: string, content: string, model: VerifiedModel): DocumentCheck;
6
- export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
5
+ export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
6
+ export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
7
+ type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
8
+ export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
7
9
  export declare function bodyRoomLinks(body: string): RoomReference[];
8
- export declare function roomReferences(file: string, content: string, definition?: Definition): readonly RoomReference[];
9
- export declare function validating(library: Library, context?: ValidationContext, model?: VerifiedModel): Generator<string, Validation, void>;
10
+ export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
11
+ type Placed = {
12
+ readonly reference: Reached;
13
+ readonly location: string;
14
+ readonly line?: number;
15
+ };
16
+ export type Assessment = {
17
+ readonly file: string;
18
+ readonly type: string | undefined;
19
+ readonly targets: readonly string[];
20
+ readonly read: Validation | null;
21
+ readonly structured: Validation | null;
22
+ readonly fields: readonly Placed[];
23
+ readonly linked: boolean;
24
+ };
25
+ export declare function assess(file: string, parsed: ParseResult, binary: boolean, model?: VerifiedModel, context?: Placing): Assessment;
26
+ export declare function assessReferences(file: string, parsed: ParseResult, changed: ReadonlySet<string>, model?: VerifiedModel, context?: Placing): Assessment;
27
+ export type Verdicts = {
28
+ add(assessment: Assessment, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): number;
29
+ verdict(): Validation;
30
+ };
31
+ export declare function verdicts(): Verdicts;
32
+ export declare function validating(library: ReadonlyMap<string, string>, context?: ValidationContext, model?: VerifiedModel): Generator<ValidationStep, Validation, void>;
10
33
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
34
+ export declare function validateParsed(library: ReadonlyMap<string, ParseResult>, context?: ValidationContext, model?: VerifiedModel): Validation;
35
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { ConversationHistoryRequest } from './adapter.js';
2
+ import { type CallResult, type HistoryAnswer, type Resolution } from './outcome.js';
3
+ import type { Attempted } from './recovery.js';
4
+ import type { Attempt } from './retried.js';
5
+ import type { Runtime } from './runtime.js';
6
+ export type HistoryQuery = {
7
+ revision?: string;
8
+ pageToken?: string;
9
+ };
10
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
11
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
12
+ room: string;
13
+ path: string;
14
+ } | null>;
15
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
16
+ export type Invoked = {
17
+ readonly dispatching?: () => Promise<void>;
18
+ readonly attempt?: Attempt;
19
+ };
20
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, { dispatching, attempt }?: Invoked): Promise<CallResult>;
21
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
22
+ export declare function called(runtime: Runtime, name: string, input: unknown, attempt?: Attempt): Promise<CallResult>;
23
+ export declare function answeredCall(runtime: Runtime, operation: string): Promise<boolean>;
24
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
25
+ export declare function resendLater(runtime: Runtime): void;
@@ -1,4 +1,7 @@
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';
4
7
  export type Authorization = object;
@@ -11,34 +14,30 @@ export type TypedSelection = {
11
14
  };
12
15
  export type OperationScopes = {
13
16
  write: readonly string[];
14
- delete: readonly string[];
17
+ erase: readonly string[];
15
18
  };
16
19
  export type ReplicaAdmission = {
17
20
  selection: string;
18
21
  admission: Open<'admitted' | 'unavailable'>;
22
+ offline: Open<'locked' | 'open'>;
19
23
  };
20
- export type DiscoveredRoom = {
21
- name: string;
22
- locator: string;
23
- handle: string;
24
- roomVersion: string;
25
- operations: OperationScopes;
26
- replica: ReplicaAdmission;
27
- typedSelection?: TypedSelection;
28
- providerOwnedPaths: readonly string[];
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;
29
36
  };
30
37
  export type Capability = {
31
38
  name: string;
32
39
  limits?: readonly ProviderLimit[];
33
40
  actions?: readonly ActionDeclaration[];
34
- conversationAgents?: ConversationAgents;
35
- };
36
- export type ConversationAgents = {
37
- locator: string;
38
- type: string;
39
- identity: string;
40
- name: string;
41
- retired?: string;
42
41
  };
43
42
  export type ListedConversation = {
44
43
  conversation: string;
@@ -48,8 +47,11 @@ export type ListedConversation = {
48
47
  finished: string | null;
49
48
  outcome: string | null;
50
49
  waiting: boolean;
50
+ newest: string | null;
51
+ processEnded: string | null;
52
+ subject: string | null;
51
53
  };
52
- export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
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';
53
55
  export type ConversationMessage = {
54
56
  identity: string;
55
57
  turn: string;
@@ -58,6 +60,7 @@ export type ConversationMessage = {
58
60
  };
59
61
  export type AcceptedMessage = ConversationMessage & {
60
62
  position: string;
63
+ change: string;
61
64
  };
62
65
  export type ConversationHistoryRequest = {
63
66
  conversations: readonly {
@@ -73,37 +76,10 @@ export type ConversationHistoryPage = {
73
76
  export type ConversationHistories = {
74
77
  histories: readonly ConversationHistoryPage[];
75
78
  };
76
- export type TurnContext = {
77
- used: number;
78
- window: number;
79
- };
80
79
  export type TurnOperation = {
81
80
  op: 'begin';
82
81
  at: string;
83
- } | {
84
- op: 'start';
85
- index: number;
86
- part: unknown;
87
- } | {
88
- op: 'append';
89
- index: number;
90
- text: string;
91
- } | {
92
- op: 'status';
93
- index: number;
94
- status: string;
95
- result: unknown;
96
- } | {
97
- op: 'count';
98
- index: number;
99
- count: number;
100
- } | {
101
- op: 'plan';
102
- index: number;
103
- entries: readonly unknown[];
104
- } | ({
105
- op: 'context';
106
- } & TurnContext);
82
+ } | Operation;
107
83
  export type ProcessCommand = {
108
84
  [field: string]: unknown;
109
85
  name: string;
@@ -165,6 +141,10 @@ export type ConversationEvent = {
165
141
  kind: 'starting';
166
142
  conversation: string;
167
143
  step: string | null;
144
+ } | {
145
+ kind: 'state';
146
+ conversation: string;
147
+ state: SessionState | null;
168
148
  } | {
169
149
  kind: 'link';
170
150
  conversation: string;
@@ -172,6 +152,7 @@ export type ConversationEvent = {
172
152
  } | {
173
153
  kind: 'deliveries';
174
154
  conversation: string;
155
+ waiting: readonly string[];
175
156
  unknown: readonly string[];
176
157
  } | {
177
158
  kind: 'accepted-message';
@@ -182,22 +163,54 @@ export type ConversationEvent = {
182
163
  conversation: string;
183
164
  } | {
184
165
  kind: 'list';
166
+ agents: readonly ListedAgent[];
185
167
  entries: readonly ListedConversation[];
168
+ whole: boolean;
169
+ more: boolean;
170
+ cursor: string | null;
186
171
  } | {
187
172
  kind: 'listed';
188
173
  entry: ListedConversation;
174
+ } | {
175
+ kind: 'agent';
176
+ agent: ListedAgent;
189
177
  } | {
190
178
  kind: 'unlisted';
191
179
  conversation: string;
192
180
  };
181
+ export type AgentEnvironment = {
182
+ identity: string;
183
+ name: string;
184
+ state: 'online' | 'offline';
185
+ };
186
+ export type ListedAgent = {
187
+ id: string;
188
+ name: string;
189
+ revision: number;
190
+ environment: string;
191
+ environment_name: string;
192
+ environment_connected: boolean;
193
+ launch_directory: string;
194
+ cli: string;
195
+ model: string | null;
196
+ effort: string | null;
197
+ mode: string | null;
198
+ base_instructions: string;
199
+ in_telegram: boolean;
200
+ created: string;
201
+ retired_at: string | null;
202
+ };
193
203
  export type ConversationStream = {
194
204
  replicate(conversations: readonly string[]): void;
205
+ hold(cursor: string | null): void;
195
206
  observe(notify: (event: ConversationEvent) => void): () => void;
207
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
196
208
  };
197
209
  export type ActionDeclaration = {
198
210
  name: string;
199
211
  inputShape: unknown;
200
212
  resultKind: unknown;
213
+ room?: string;
201
214
  };
202
215
  export type ProviderLimit = {
203
216
  name: string;
@@ -211,7 +224,6 @@ export type HistoryRetention = {
211
224
  };
212
225
  export type Retention = {
213
226
  history: HistoryRetention;
214
- outcome: number;
215
227
  refreshHorizon: number;
216
228
  };
217
229
  export type Discovery = {
@@ -221,13 +233,10 @@ export type Discovery = {
221
233
  providerLimits: readonly ProviderLimit[];
222
234
  retention: Retention;
223
235
  member?: Member;
224
- covered?: readonly string[];
225
- };
226
- export type DiscoveryScope = {
227
- readonly authorities: readonly string[];
228
236
  };
229
237
  export type TransportUncertainty = {
230
238
  kind: 'transport-uncertainty';
239
+ failure?: unknown;
231
240
  };
232
241
  export type RoomNotReadable = {
233
242
  kind: 'room-not-readable';
@@ -253,7 +262,7 @@ export type ContractUnavailable = ProviderRefusal & {
253
262
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
254
263
  export type PageToken = string;
255
264
  export type ChangeAuthor = {
256
- kind: Open<'user' | 'site'>;
265
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
257
266
  id: string;
258
267
  name: string;
259
268
  };
@@ -267,39 +276,49 @@ export type HeadChange = {
267
276
  time: string;
268
277
  };
269
278
  export type BinaryFile = {
270
- fileRef: string;
271
279
  byteLength: number;
272
280
  mediaType: string;
273
281
  sha256: string;
274
282
  };
275
- export type HeldContent = {
276
- documents: Readonly<Record<string, string>>;
277
- revisions: Readonly<Record<string, string>>;
278
- };
279
283
  export type BootstrapRequest = {
280
284
  locator: string;
281
285
  selection: string;
282
286
  pageToken?: PageToken;
283
- held?: HeldContent;
287
+ arriving?: (bytes: number) => void;
288
+ signal?: AbortSignal;
289
+ };
290
+ export type BootstrapPart = {
291
+ readonly id: string;
292
+ readonly bytes: number;
293
+ };
294
+ export type BootstrapInventory = {
295
+ readonly bytes: number;
284
296
  };
285
297
  export type RoomModels = {
286
298
  collection?: ModelResult;
287
- selection?: ModelResult;
288
299
  };
289
300
  export type BootstrapPage = {
290
301
  kind: 'bootstrap';
291
302
  roomVersion: string;
292
303
  models?: RoomModels;
293
304
  documents: Readonly<Record<string, string>>;
305
+ facts: Readonly<Record<string, SavedFacts>>;
294
306
  revisions: Readonly<Record<string, string>>;
295
307
  fileIds?: Readonly<Record<string, string>>;
308
+ created?: Readonly<Record<string, string>>;
296
309
  changes: Readonly<Record<string, HeadChange>>;
297
310
  binaryFiles: Readonly<Record<string, BinaryFile>>;
311
+ folders?: readonly string[];
298
312
  pageToken?: PageToken;
313
+ parts?: readonly BootstrapPart[];
314
+ bytes?: number;
315
+ };
316
+ export type NotReady = {
317
+ kind: 'not-ready';
299
318
  };
300
319
  export type BootstrapResult = BootstrapPage | {
301
320
  kind: 'beyond-horizon';
302
- } | AdapterFailure;
321
+ } | NotReady | AdapterFailure;
303
322
  export type RefreshRequest = {
304
323
  locator: string;
305
324
  selection: string;
@@ -311,11 +330,15 @@ export type RefreshPage = {
311
330
  roomVersion: string;
312
331
  models?: RoomModels;
313
332
  documents: Readonly<Record<string, string>>;
333
+ facts: Readonly<Record<string, SavedFacts>>;
314
334
  revisions: Readonly<Record<string, string>>;
315
335
  fileIds?: Readonly<Record<string, string>>;
336
+ created?: Readonly<Record<string, string>>;
316
337
  changes: Readonly<Record<string, HeadChange>>;
317
338
  binaryFiles: Readonly<Record<string, BinaryFile>>;
318
339
  removals: readonly string[];
340
+ folders?: readonly string[];
341
+ folderRemovals?: readonly string[];
319
342
  pageToken?: PageToken;
320
343
  };
321
344
  export type RefreshResult = {
@@ -326,6 +349,7 @@ export type RefreshResult = {
326
349
  export type MutationRequest = {
327
350
  locator: string;
328
351
  changeBatch: ChangeBatch;
352
+ file(localId: string): Promise<Blob>;
329
353
  upload?: unknown;
330
354
  };
331
355
  export type RetryableRefusal = ProviderRefusal & {
@@ -336,8 +360,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
336
360
  export type ServiceModeSignal = {
337
361
  observe(notify: (mode: ServiceMode) => void): () => void;
338
362
  };
339
- export type MutationResult = {
340
- kind: 'accepted';
363
+ export type AcceptedRoom = {
341
364
  roomVersion: string;
342
365
  documents: Readonly<Record<string, string>>;
343
366
  revisions: Readonly<Record<string, string>>;
@@ -345,26 +368,21 @@ export type MutationResult = {
345
368
  changes: Readonly<Record<string, HeadChange>>;
346
369
  removals: readonly string[];
347
370
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
348
- author?: string;
349
- time?: string;
350
- } | (ProviderRefusal & {
371
+ };
372
+ export type MutationResult = (AcceptedRoom & {
373
+ kind: 'accepted';
374
+ destination?: AcceptedRoom;
375
+ }) | (ProviderRefusal & {
351
376
  kind: 'conflicted';
352
- roomVersion?: string;
353
377
  affected: Readonly<Record<string, string>>;
354
378
  }) | (ProviderRefusal & {
355
379
  kind: 'rejected';
356
380
  affected: Readonly<Record<string, string>>;
357
381
  }) | RetryableRefusal | {
358
382
  kind: 'write-halted';
359
- } | {
360
- kind: 'expired';
361
- restored?: true;
362
383
  } | AdapterFailure;
363
384
  export type HistoryAuthor = {
364
- kind: 'user';
365
- id: string;
366
- } | {
367
- kind: 'site';
385
+ kind: 'user' | 'site' | 'inbox' | 'app';
368
386
  id: string;
369
387
  name: string;
370
388
  };
@@ -396,22 +414,12 @@ export type BinaryRequest = {
396
414
  locator: string;
397
415
  path: string;
398
416
  revision: string;
399
- fileRef?: string;
400
- } | {
401
- kind: 'reference';
402
- fileRef: string;
403
- referrer: unknown;
404
- };
405
- export type ReferrerScope = {
406
- kind: 'room';
407
- locator: string;
408
- path?: string;
409
- } | {
410
- kind: 'conversations';
411
417
  };
412
418
  export type BinaryResult = {
413
419
  kind: 'binary';
414
- blob: Blob;
420
+ body: ReadableStream<Uint8Array>;
421
+ mediaType: string;
422
+ sha256?: string;
415
423
  } | (ProviderRefusal & {
416
424
  kind: 'rejected';
417
425
  }) | AdapterFailure;
@@ -419,6 +427,22 @@ export type BinaryLinkResult = {
419
427
  kind: 'link';
420
428
  url: string;
421
429
  name: string;
430
+ mediaType?: string;
431
+ } | (ProviderRefusal & {
432
+ kind: 'rejected';
433
+ }) | AdapterFailure;
434
+ export type AttachRequest = {
435
+ locator: string;
436
+ name: string;
437
+ mediaType: string;
438
+ byteLength: number;
439
+ sha256: string;
440
+ blob: Blob;
441
+ };
442
+ export type AttachResult = {
443
+ kind: 'attached';
444
+ path: string;
445
+ revision: string;
422
446
  } | (ProviderRefusal & {
423
447
  kind: 'rejected';
424
448
  }) | AdapterFailure;
@@ -434,70 +458,83 @@ export type ActionResult = {
434
458
  kind: 'action';
435
459
  result: unknown;
436
460
  at?: RoomVersionAt;
461
+ } | (ProviderRefusal & {
462
+ kind: 'rejected';
463
+ reset?: string;
464
+ }) | AdapterFailure;
465
+ export type SearchHit = {
466
+ room: string;
467
+ path: string;
468
+ line?: number;
469
+ snippet?: string;
470
+ };
471
+ export type SearchAsk = {
472
+ text: string;
473
+ rooms: readonly string[] | null;
474
+ };
475
+ export type SearchAnswer = {
476
+ kind: 'found';
477
+ documents: readonly SearchHit[];
437
478
  } | (ProviderRefusal & {
438
479
  kind: 'rejected';
439
480
  }) | AdapterFailure;
440
481
  export type HeldRoom = {
441
482
  locator: string;
483
+ roomVersion: string | null;
484
+ };
485
+ export type RoomChange = {
486
+ kind: 'room-change';
487
+ locator: string;
488
+ from: string | null;
442
489
  roomVersion: string;
443
- documents: Readonly<Record<string, string>>;
444
- revisions: Readonly<Record<string, string>>;
490
+ read(): Promise<RefreshPage>;
491
+ };
492
+ export type AuthorityChange = {
493
+ kind: 'authority-changed';
494
+ rooms: readonly DiscoveredRoom[];
495
+ left: readonly string[];
496
+ member?: Member;
445
497
  };
446
498
  export type RoomStreamEvent = {
447
499
  kind: 'opened';
500
+ } | {
501
+ kind: 'discovered';
502
+ discovery: Discovery;
448
503
  } | {
449
504
  kind: 'closed';
450
505
  revoked: boolean;
451
506
  lost: boolean;
507
+ authorityChanged: boolean;
452
508
  } | {
453
- kind: 'opening';
509
+ kind: 'caught-up';
454
510
  expired: readonly string[];
455
- } | {
456
- kind: 'authority-changed';
457
- scope?: DiscoveryScope;
458
- } | {
459
- kind: 'room-version';
460
- locator: string;
461
- roomVersion: string;
462
- };
463
- export type KeptReceipt = {
464
- key: string;
465
- head: unknown;
466
- };
467
- export type StreamReceipts = {
468
- heads(): Promise<readonly KeptReceipt[]>;
469
- parts(key: string, count: number): Promise<readonly unknown[]>;
470
- keep(key: string, head: unknown, part?: {
471
- index: number;
472
- value: unknown;
473
- }): Promise<void>;
474
- drop(keys: readonly string[]): Promise<void>;
475
- };
511
+ } | AuthorityChange | RoomChange;
476
512
  export type RoomStream = {
477
513
  hold(rooms: readonly HeldRoom[]): void;
478
- reopen(): void;
479
- published(locator: string, roomVersion: string): void;
480
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
514
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
481
515
  };
516
+ export type PathRule = (path: string) => boolean;
482
517
  export type Adapter = {
483
518
  readonly localSaves?: true;
484
- readonly exhaustiveDiscovery?: true;
519
+ readonly roomTypes?: VerifiedModel;
520
+ readonly typedPaths?: readonly TypedPath[];
521
+ readonly pathRule?: PathRule;
522
+ readonly unkeptReads?: readonly string[];
523
+ readonly leadingReads?: readonly string[];
485
524
  authorize(): Promise<Authorization>;
486
- discover(authorization: Authorization, scope?: DiscoveryScope): Promise<DiscoverResult>;
525
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
487
526
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
488
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
527
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
489
528
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
490
529
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
491
530
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
492
- link(authorization: Authorization, request: Extract<BinaryRequest, {
493
- kind: 'path';
494
- }>): Promise<BinaryLinkResult>;
495
- referrerScope(referrer: unknown): ReferrerScope | null;
531
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
532
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
496
533
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
534
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
497
535
  reached(locator: string, roomVersion: string, target: string): boolean;
498
536
  follows(locator: string, roomVersion: string, next: string): boolean;
499
537
  roomStream?: RoomStream;
500
538
  conversations?: ConversationStream;
501
539
  serviceMode?: ServiceModeSignal;
502
540
  };
503
- 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;
@@ -3,7 +3,6 @@ export type BinaryFileRecord = {
3
3
  readonly state: 'accepted';
4
4
  readonly revision: string;
5
5
  readonly path: string;
6
- readonly fileRef: string;
7
6
  readonly byteLength: number;
8
7
  readonly mediaType: string;
9
8
  readonly sha256: string;
@@ -15,8 +14,4 @@ export type BinaryFileRecord = {
15
14
  readonly mediaType: string;
16
15
  readonly sha256: string;
17
16
  };
18
- export type BinaryReference = {
19
- readonly fileRef: string;
20
- readonly referrer: unknown;
21
- };
22
17
  export declare function binaryRecord(path: string, held: HeldBinary, revision: string | undefined): BinaryFileRecord;
@@ -0,0 +1,43 @@
1
+ import type { ModelState } from './model.js';
2
+ import type { Adapter, TypedPath, AdapterFailure, Authorization, BootstrapPart, DiscoveredRoom, NotReady, RetryableRefusal, RoomModels } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import type { InstallationStep } from './readiness.js';
5
+ import { type Refreshing } from './refresh.js';
6
+ import { type ReplicaRecord } from './replica.js';
7
+ import type { StagedPage, TransferRecord } from './store.js';
8
+ import { type Unconfirmed } from './transfer.js';
9
+ export type Bootstrapped = {
10
+ kind: 'staged';
11
+ record: ReplicaRecord;
12
+ refreshed: boolean;
13
+ };
14
+ export type BootstrapOutcome = Bootstrapped | Unconfirmed | NotReady | RetryableRefusal | AdapterFailure;
15
+ export type HeldModels = {
16
+ collection: ModelState;
17
+ };
18
+ export type Remodel = (models: RoomModels | undefined, held: HeldModels) => HeldModels;
19
+ export type Reads = Pick<Adapter, 'bootstrap' | 'refresh' | 'reached'>;
20
+ export type Arriving = {
21
+ at(bytes: number): void;
22
+ end(): void;
23
+ };
24
+ export type Resumed = {
25
+ readonly record: TransferRecord | null;
26
+ readonly staged: ReadonlySet<string>;
27
+ };
28
+ export type Staging = {
29
+ held(locator: string): TransferRecord | null;
30
+ turn(locator: string, step: InstallationStep): Promise<() => void>;
31
+ unqueued(): Promise<void>;
32
+ queued(text: number): () => void;
33
+ arriving(locator: string): Arriving;
34
+ readonly streamed: boolean;
35
+ stage(record: TransferRecord, page: StagedPage, composition: Composition): Promise<TransferRecord | null>;
36
+ resume(record: TransferRecord, parts: readonly BootstrapPart[], composition: Composition): Promise<Resumed | null>;
37
+ derive(locator: string, key: number, composition: Composition): Promise<boolean>;
38
+ refreshing(locator: string, key: number, composition: Composition): Promise<Refreshing>;
39
+ abandon(locator: string): Promise<void>;
40
+ setAside(locator: string): Promise<void>;
41
+ release(key: number): Promise<void>;
42
+ };
43
+ export declare function bootstrapRoom(adapter: Reads, authorization: Authorization, room: DiscoveredRoom, held: HeldModels, builtIn: ModelState, typedPaths: readonly TypedPath[], remodel: Remodel, continuing: () => boolean, staging: Staging): Promise<BootstrapOutcome>;
@@ -0,0 +1,5 @@
1
+ export type Cell<T> = {
2
+ now(): T;
3
+ set(change: Partial<T>): void;
4
+ };
5
+ export declare function createCell<T extends object>(first: T): Cell<T>;
@@ -0,0 +1,11 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import type { MdRuntimeClient } from './client.js';
3
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
4
+ type Rows = DocumentResult | GroupResult;
5
+ export type WindowAnswer = Rows | PendingResult;
6
+ export type WindowChain = {
7
+ want(count: number): void;
8
+ close(): void;
9
+ };
10
+ export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
11
+ export {};