@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca61ac777c0b7

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 (108) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +1033 -20
  3. package/dist/mdmodel/definition.d.ts +18 -1
  4. package/dist/mdmodel/document.d.ts +10 -6
  5. package/dist/mdmodel/event.d.ts +77 -0
  6. package/dist/mdmodel/facts.d.ts +14 -0
  7. package/dist/mdmodel/index.d.ts +25 -11
  8. package/dist/mdmodel/kinds.d.ts +17 -0
  9. package/dist/mdmodel/markdown.d.ts +50 -0
  10. package/dist/mdmodel/paths.d.ts +9 -1
  11. package/dist/mdmodel/pattern.d.ts +9 -0
  12. package/dist/mdmodel/project.d.ts +1 -0
  13. package/dist/mdmodel/query/language.d.ts +253 -0
  14. package/dist/mdmodel/query/match.d.ts +13 -0
  15. package/dist/mdmodel/query/rows.d.ts +31 -0
  16. package/dist/mdmodel/query/sql.d.ts +38 -0
  17. package/dist/mdmodel/reserved.d.ts +5 -0
  18. package/dist/mdmodel/types.d.ts +46 -5
  19. package/dist/mdmodel/validate.d.ts +31 -4
  20. package/dist/mdruntime/actions.d.ts +19 -0
  21. package/dist/mdruntime/adapter.d.ts +161 -116
  22. package/dist/mdruntime/attached-model.d.ts +7 -0
  23. package/dist/mdruntime/binary.d.ts +0 -5
  24. package/dist/mdruntime/bootstrap.d.ts +43 -0
  25. package/dist/mdruntime/cell.d.ts +5 -0
  26. package/dist/mdruntime/chain.d.ts +11 -0
  27. package/dist/mdruntime/change-set.d.ts +13 -16
  28. package/dist/mdruntime/change.d.ts +32 -1
  29. package/dist/mdruntime/client.d.ts +36 -11
  30. package/dist/mdruntime/collection.d.ts +29 -21
  31. package/dist/mdruntime/compile.d.ts +15 -0
  32. package/dist/mdruntime/conversation-live.d.ts +135 -0
  33. package/dist/mdruntime/conversation-row.d.ts +32 -0
  34. package/dist/mdruntime/conversation.d.ts +54 -46
  35. package/dist/mdruntime/declaration.d.ts +9 -0
  36. package/dist/mdruntime/durability.d.ts +16 -4
  37. package/dist/mdruntime/failure.d.ts +1 -0
  38. package/dist/mdruntime/figures.d.ts +48 -0
  39. package/dist/mdruntime/holdings.d.ts +28 -0
  40. package/dist/mdruntime/identity.d.ts +5 -0
  41. package/dist/mdruntime/listing.d.ts +47 -0
  42. package/dist/mdruntime/live.d.ts +22 -0
  43. package/dist/mdruntime/log.d.ts +5 -0
  44. package/dist/mdruntime/media.d.ts +7 -0
  45. package/dist/mdruntime/messages.d.ts +48 -0
  46. package/dist/mdruntime/model.d.ts +8 -11
  47. package/dist/mdruntime/observation.d.ts +17 -2
  48. package/dist/mdruntime/opened.d.ts +21 -0
  49. package/dist/mdruntime/outcome.d.ts +49 -8
  50. package/dist/mdruntime/overlay.d.ts +4 -5
  51. package/dist/mdruntime/preparation.d.ts +19 -0
  52. package/dist/mdruntime/presence.d.ts +51 -0
  53. package/dist/mdruntime/query.d.ts +25 -191
  54. package/dist/mdruntime/reach.d.ts +20 -9
  55. package/dist/mdruntime/readiness.d.ts +13 -17
  56. package/dist/mdruntime/reads.d.ts +36 -0
  57. package/dist/mdruntime/recovery.d.ts +3 -2
  58. package/dist/mdruntime/refresh.d.ts +26 -0
  59. package/dist/mdruntime/replica.d.ts +50 -33
  60. package/dist/mdruntime/room-draft.d.ts +28 -11
  61. package/dist/mdruntime/room-drafts.d.ts +23 -0
  62. package/dist/mdruntime/runtime.d.ts +33 -0
  63. package/dist/mdruntime/save.d.ts +42 -48
  64. package/dist/mdruntime/saves.d.ts +31 -0
  65. package/dist/mdruntime/search.d.ts +12 -82
  66. package/dist/mdruntime/seed.d.ts +11 -2
  67. package/dist/mdruntime/socket/admission.d.ts +6 -0
  68. package/dist/mdruntime/socket/answers.d.ts +5 -0
  69. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  70. package/dist/mdruntime/socket/session.d.ts +37 -0
  71. package/dist/mdruntime/socket.d.ts +66 -0
  72. package/dist/mdruntime/source.d.ts +60 -0
  73. package/dist/mdruntime/status.d.ts +4 -5
  74. package/dist/mdruntime/store/installs.d.ts +29 -0
  75. package/dist/mdruntime/store/readiness.d.ts +9 -0
  76. package/dist/mdruntime/store/records.d.ts +209 -0
  77. package/dist/mdruntime/store/room-held.d.ts +7 -0
  78. package/dist/mdruntime/store/space.d.ts +10 -0
  79. package/dist/mdruntime/store/watchers.d.ts +16 -0
  80. package/dist/mdruntime/store/writes.d.ts +23 -0
  81. package/dist/mdruntime/store.d.ts +109 -150
  82. package/dist/mdruntime/stored.d.ts +155 -0
  83. package/dist/mdruntime/surface.d.ts +87 -0
  84. package/dist/mdruntime/tables.d.ts +411 -0
  85. package/dist/mdruntime/tallies.d.ts +17 -0
  86. package/dist/mdruntime/transfer.d.ts +0 -5
  87. package/dist/mdruntime/wire.d.ts +54 -10
  88. package/dist/session-content/bounds.d.ts +7 -0
  89. package/dist/session-content/check.d.ts +18 -0
  90. package/dist/session-content/index.d.ts +7 -0
  91. package/dist/session-content/parts.d.ts +102 -0
  92. package/dist/session-content/state.d.ts +61 -0
  93. package/dist/session-content/turn.d.ts +328 -0
  94. package/dist/test-host.d.ts +7 -4
  95. package/dist/test-host.js +19 -29
  96. package/docs/families.md +69 -56
  97. package/package.json +8 -3
  98. package/dist/calls.d.ts +0 -118
  99. package/dist/calls.js +0 -1
  100. package/dist/mdmodel/blocks.d.ts +0 -10
  101. package/dist/mdmodel/condition.d.ts +0 -149
  102. package/dist/mdmodel/profile.d.ts +0 -5
  103. package/dist/mdruntime/acquisition.d.ts +0 -13
  104. package/dist/mdruntime/connection.d.ts +0 -141
  105. package/dist/mdruntime/file.d.ts +0 -19
  106. package/dist/mdruntime/rows.d.ts +0 -37
  107. package/dist/mdruntime/shared.d.ts +0 -10
  108. package/dist/mdruntime/turn.d.ts +0 -6
@@ -2,6 +2,7 @@ import type { Definition } from './definition.js';
2
2
  export type Library = Readonly<Record<string, string>>;
3
3
  export type VerifiedModel = {
4
4
  readonly types: Readonly<Record<string, Definition>>;
5
+ readonly nameable?: readonly string[];
5
6
  };
6
7
  export type ModelVerification = {
7
8
  readonly verdict: 'accept';
@@ -11,15 +12,23 @@ export type ModelVerification = {
11
12
  readonly rule: string;
12
13
  readonly location?: string;
13
14
  };
15
+ export type TypedPath = {
16
+ readonly path: string;
17
+ readonly type: string;
18
+ readonly named: boolean;
19
+ readonly body: boolean;
20
+ };
14
21
  export type ValidationContext = {
15
22
  readonly binaryTargets: readonly string[];
23
+ readonly anyRoom?: true;
24
+ readonly typedPaths?: readonly TypedPath[];
16
25
  };
17
26
  export type ProjectionContext = {
18
27
  readonly documentTargets: readonly string[];
19
28
  readonly definition?: Definition;
20
29
  };
21
30
  export type DivisionContext = ProjectionContext & {
22
- readonly budget: number;
31
+ readonly bound: number;
23
32
  };
24
33
  export type Extent = {
25
34
  readonly start: number;
@@ -36,7 +45,9 @@ export type Frontmatter = {
36
45
  export type Document = Frontmatter & {
37
46
  readonly preamble: string;
38
47
  readonly sections: Readonly<Record<string, string>>;
48
+ readonly text: string;
39
49
  };
50
+ export type DefinitionOf = (type: string | undefined) => Definition | undefined;
40
51
  export type Refusal = {
41
52
  readonly file: string;
42
53
  readonly rule: string;
@@ -60,6 +71,10 @@ export type Validation = {
60
71
  } | ({
61
72
  readonly verdict: 'refuse';
62
73
  } & Refusal);
74
+ export type ValidationStep = {
75
+ readonly path: string;
76
+ readonly resolved: number;
77
+ };
63
78
  export type Projection = {
64
79
  readonly ok: true;
65
80
  readonly text: string;
@@ -92,14 +107,31 @@ export type Link = {
92
107
  readonly href: string;
93
108
  readonly target: string;
94
109
  };
95
- export type LinkOccurrence = Link & {
96
- readonly start: number;
97
- };
98
110
  export type Reference = {
99
111
  readonly pointer: string;
100
112
  readonly value: string;
101
113
  readonly to: readonly string[];
114
+ readonly crossRoom?: true;
102
115
  };
116
+ export type RoomReference = {
117
+ readonly handle: string;
118
+ readonly path: string;
119
+ } & ({
120
+ readonly kind: 'link';
121
+ readonly href: string;
122
+ } | {
123
+ readonly kind: 'field';
124
+ readonly pointer: string;
125
+ readonly value: string;
126
+ readonly to: readonly string[];
127
+ readonly crossRoom?: true;
128
+ } | {
129
+ readonly kind: 'item';
130
+ readonly section: string;
131
+ readonly href: string;
132
+ readonly to: readonly string[];
133
+ readonly crossRoom?: true;
134
+ });
103
135
  export type Change = {
104
136
  readonly kind: 'field';
105
137
  readonly name: string;
@@ -109,11 +141,15 @@ export type Change = {
109
141
  readonly kind: 'section';
110
142
  readonly name: string;
111
143
  readonly value: string;
112
- readonly prior: string;
144
+ readonly prior: string | undefined;
113
145
  } | {
114
146
  readonly kind: 'preamble';
115
147
  readonly value: string;
116
148
  readonly prior: string;
149
+ } | {
150
+ readonly kind: 'text';
151
+ readonly value: string;
152
+ readonly prior: string;
117
153
  } | {
118
154
  readonly kind: 'link';
119
155
  readonly href: string;
@@ -130,6 +166,7 @@ export type ApplyResult = {
130
166
  } | {
131
167
  readonly outcome: 'stale';
132
168
  readonly document: Document;
169
+ readonly stale: readonly number[];
133
170
  } | {
134
171
  readonly outcome: 'refuse';
135
172
  readonly refusal: Refusal;
@@ -141,3 +178,7 @@ export type BodyResult = {
141
178
  readonly outcome: 'refuse';
142
179
  readonly refusal: Refusal;
143
180
  };
181
+ export type UnlinkedBody = {
182
+ readonly body: string;
183
+ readonly links: ReadonlyMap<string, string>;
184
+ };
@@ -1,7 +1,34 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { DocumentCheck, Library, ModelVerification, Reached, 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;
9
+ export declare function bodyRoomLinks(body: string): RoomReference[];
10
+ export declare function roomReferences(document: Document, definition?: Definition): readonly RoomReference[];
11
+ type Placed = {
12
+ readonly reference: Reached;
13
+ readonly location: string;
14
+ };
15
+ export type Assessment = {
16
+ readonly file: string;
17
+ readonly type: string | undefined;
18
+ readonly targets: readonly string[];
19
+ readonly read: Validation | null;
20
+ readonly structured: Validation | null;
21
+ readonly fields: readonly Placed[];
22
+ readonly linked: boolean;
23
+ readonly sections: readonly Placed[];
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>;
7
33
  export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
34
+ export {};
@@ -0,0 +1,19 @@
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 { Runtime } from './runtime.js';
5
+ export type HistoryQuery = {
6
+ revision?: string;
7
+ pageToken?: string;
8
+ };
9
+ export declare function readHistory(runtime: Runtime, locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
10
+ export declare function located(runtime: Runtime, room: string, path: string, destination: string): Promise<{
11
+ room: string;
12
+ path: string;
13
+ } | null>;
14
+ export declare function resolveReference(runtime: Runtime, room: string, path: string, destination: string): Promise<Resolution>;
15
+ export declare function invokeAction(runtime: Runtime, name: string, input: unknown, dispatching?: () => Promise<void>): Promise<CallResult>;
16
+ export declare function readConversationHistory(runtime: Runtime, request: ConversationHistoryRequest): Promise<CallResult>;
17
+ export declare function called(runtime: Runtime, name: string, input: unknown): Promise<CallResult>;
18
+ export declare function resendCalls(runtime: Runtime, signal: AbortSignal): Promise<Attempted>;
19
+ export declare function resendLater(runtime: Runtime): void;
@@ -1,4 +1,7 @@
1
+ import type { SavedFacts, TypedPath } 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;
@@ -10,47 +13,46 @@ export type TypedSelection = {
10
13
  roots: readonly string[];
11
14
  };
12
15
  export type OperationScopes = {
13
- read: readonly string[];
14
- sync: readonly string[];
15
16
  write: readonly string[];
16
- delete: readonly string[];
17
+ erase: readonly string[];
17
18
  };
18
19
  export type ReplicaAdmission = {
19
20
  selection: string;
20
21
  admission: Open<'admitted' | 'unavailable'>;
22
+ offline: Open<'locked' | 'open'>;
21
23
  };
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[];
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;
31
36
  };
32
37
  export type Capability = {
33
38
  name: string;
34
39
  limits?: readonly ProviderLimit[];
35
40
  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
41
  };
45
42
  export type ListedConversation = {
46
43
  conversation: string;
47
44
  agent: string;
45
+ agentName: string;
46
+ agentRetired: boolean;
48
47
  name: string;
49
48
  created: string;
50
49
  finished: string | null;
51
50
  outcome: string | null;
51
+ waiting: boolean;
52
+ newest: string | null;
53
+ processEnded: 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';
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;
@@ -172,6 +165,9 @@ export type ConversationEvent = {
172
165
  } | {
173
166
  kind: 'list';
174
167
  entries: readonly ListedConversation[];
168
+ whole: boolean;
169
+ more: boolean;
170
+ cursor: string | null;
175
171
  } | {
176
172
  kind: 'listed';
177
173
  entry: ListedConversation;
@@ -179,14 +175,23 @@ export type ConversationEvent = {
179
175
  kind: 'unlisted';
180
176
  conversation: string;
181
177
  };
178
+ export type ListedAgent = {
179
+ agent: string;
180
+ name: string;
181
+ retired: boolean;
182
+ };
182
183
  export type ConversationStream = {
183
184
  replicate(conversations: readonly string[]): void;
185
+ hold(cursor: string | null): void;
184
186
  observe(notify: (event: ConversationEvent) => void): () => void;
187
+ agents?(): Promise<readonly ListedAgent[] | null>;
188
+ history?(request: ConversationHistoryRequest): Promise<ActionResult>;
185
189
  };
186
190
  export type ActionDeclaration = {
187
191
  name: string;
188
192
  inputShape: unknown;
189
193
  resultKind: unknown;
194
+ room?: string;
190
195
  };
191
196
  export type ProviderLimit = {
192
197
  name: string;
@@ -200,7 +205,6 @@ export type HistoryRetention = {
200
205
  };
201
206
  export type Retention = {
202
207
  history: HistoryRetention;
203
- outcome: number;
204
208
  refreshHorizon: number;
205
209
  };
206
210
  export type Discovery = {
@@ -229,7 +233,7 @@ export type ProviderRefusal = {
229
233
  export type ScopedRefusal = ProviderRefusal & {
230
234
  kind: 'scoped-refusal';
231
235
  locator: string;
232
- scope: Open<'content' | 'sync' | 'model' | 'operation' | 'undisclosed'>;
236
+ scope: Open<'content' | 'model' | 'operation' | 'undisclosed'>;
233
237
  };
234
238
  export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
235
239
  export type ContractUnavailable = ProviderRefusal & {
@@ -238,7 +242,7 @@ export type ContractUnavailable = ProviderRefusal & {
238
242
  export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
239
243
  export type PageToken = string;
240
244
  export type ChangeAuthor = {
241
- kind: Open<'user' | 'site'>;
245
+ kind: Open<'user' | 'site' | 'inbox' | 'app'>;
242
246
  id: string;
243
247
  name: string;
244
248
  };
@@ -252,39 +256,49 @@ export type HeadChange = {
252
256
  time: string;
253
257
  };
254
258
  export type BinaryFile = {
255
- fileRef: string;
256
259
  byteLength: number;
257
260
  mediaType: string;
258
261
  sha256: string;
259
262
  };
260
- export type HeldContent = {
261
- documents: Readonly<Record<string, string>>;
262
- revisions: Readonly<Record<string, string>>;
263
- };
264
263
  export type BootstrapRequest = {
265
264
  locator: string;
266
265
  selection: string;
267
266
  pageToken?: PageToken;
268
- held?: HeldContent;
267
+ arriving?: (bytes: number) => void;
268
+ signal?: AbortSignal;
269
+ };
270
+ export type BootstrapPart = {
271
+ readonly id: string;
272
+ readonly bytes: number;
273
+ };
274
+ export type BootstrapInventory = {
275
+ readonly bytes: number;
269
276
  };
270
277
  export type RoomModels = {
271
278
  collection?: ModelResult;
272
- selection?: ModelResult;
273
279
  };
274
280
  export type BootstrapPage = {
275
281
  kind: 'bootstrap';
276
282
  roomVersion: string;
277
283
  models?: RoomModels;
278
284
  documents: Readonly<Record<string, string>>;
285
+ facts: Readonly<Record<string, SavedFacts>>;
279
286
  revisions: Readonly<Record<string, string>>;
280
287
  fileIds?: Readonly<Record<string, string>>;
288
+ created?: Readonly<Record<string, string>>;
281
289
  changes: Readonly<Record<string, HeadChange>>;
282
290
  binaryFiles: Readonly<Record<string, BinaryFile>>;
291
+ folders?: readonly string[];
283
292
  pageToken?: PageToken;
293
+ parts?: readonly BootstrapPart[];
294
+ bytes?: number;
295
+ };
296
+ export type NotReady = {
297
+ kind: 'not-ready';
284
298
  };
285
299
  export type BootstrapResult = BootstrapPage | {
286
300
  kind: 'beyond-horizon';
287
- } | AdapterFailure;
301
+ } | NotReady | AdapterFailure;
288
302
  export type RefreshRequest = {
289
303
  locator: string;
290
304
  selection: string;
@@ -296,11 +310,15 @@ export type RefreshPage = {
296
310
  roomVersion: string;
297
311
  models?: RoomModels;
298
312
  documents: Readonly<Record<string, string>>;
313
+ facts: Readonly<Record<string, SavedFacts>>;
299
314
  revisions: Readonly<Record<string, string>>;
300
315
  fileIds?: Readonly<Record<string, string>>;
316
+ created?: Readonly<Record<string, string>>;
301
317
  changes: Readonly<Record<string, HeadChange>>;
302
318
  binaryFiles: Readonly<Record<string, BinaryFile>>;
303
319
  removals: readonly string[];
320
+ folders?: readonly string[];
321
+ folderRemovals?: readonly string[];
304
322
  pageToken?: PageToken;
305
323
  };
306
324
  export type RefreshResult = {
@@ -311,6 +329,7 @@ export type RefreshResult = {
311
329
  export type MutationRequest = {
312
330
  locator: string;
313
331
  changeBatch: ChangeBatch;
332
+ file(localId: string): Promise<Blob>;
314
333
  upload?: unknown;
315
334
  };
316
335
  export type RetryableRefusal = ProviderRefusal & {
@@ -321,8 +340,7 @@ export type ServiceMode = Open<'open' | 'write-halted'>;
321
340
  export type ServiceModeSignal = {
322
341
  observe(notify: (mode: ServiceMode) => void): () => void;
323
342
  };
324
- export type MutationResult = {
325
- kind: 'accepted';
343
+ export type AcceptedRoom = {
326
344
  roomVersion: string;
327
345
  documents: Readonly<Record<string, string>>;
328
346
  revisions: Readonly<Record<string, string>>;
@@ -330,9 +348,13 @@ export type MutationResult = {
330
348
  changes: Readonly<Record<string, HeadChange>>;
331
349
  removals: readonly string[];
332
350
  binaryFiles?: Readonly<Record<string, BinaryFile>>;
351
+ };
352
+ export type MutationResult = (AcceptedRoom & {
353
+ kind: 'accepted';
333
354
  author?: string;
334
355
  time?: string;
335
- } | (ProviderRefusal & {
356
+ destination?: AcceptedRoom;
357
+ }) | (ProviderRefusal & {
336
358
  kind: 'conflicted';
337
359
  roomVersion?: string;
338
360
  affected: Readonly<Record<string, string>>;
@@ -341,15 +363,9 @@ export type MutationResult = {
341
363
  affected: Readonly<Record<string, string>>;
342
364
  }) | RetryableRefusal | {
343
365
  kind: 'write-halted';
344
- } | {
345
- kind: 'expired';
346
- restored?: true;
347
366
  } | AdapterFailure;
348
367
  export type HistoryAuthor = {
349
- kind: 'user';
350
- id: string;
351
- } | {
352
- kind: 'site';
368
+ kind: 'user' | 'site' | 'inbox' | 'app';
353
369
  id: string;
354
370
  name: string;
355
371
  };
@@ -381,22 +397,35 @@ export type BinaryRequest = {
381
397
  locator: string;
382
398
  path: string;
383
399
  revision: string;
384
- fileRef?: string;
385
- } | {
386
- kind: 'reference';
387
- fileRef: string;
388
- referrer: unknown;
389
- };
390
- export type ReferrerScope = {
391
- kind: 'room';
392
- locator: string;
393
- path?: string;
394
- } | {
395
- kind: 'conversations';
396
400
  };
397
401
  export type BinaryResult = {
398
402
  kind: 'binary';
403
+ body: ReadableStream<Uint8Array>;
404
+ mediaType: string;
405
+ sha256?: string;
406
+ } | (ProviderRefusal & {
407
+ kind: 'rejected';
408
+ }) | AdapterFailure;
409
+ export type BinaryLinkResult = {
410
+ kind: 'link';
411
+ url: string;
412
+ name: string;
413
+ mediaType?: string;
414
+ } | (ProviderRefusal & {
415
+ kind: 'rejected';
416
+ }) | AdapterFailure;
417
+ export type AttachRequest = {
418
+ locator: string;
419
+ name: string;
420
+ mediaType: string;
421
+ byteLength: number;
422
+ sha256: string;
399
423
  blob: Blob;
424
+ };
425
+ export type AttachResult = {
426
+ kind: 'attached';
427
+ path: string;
428
+ revision: string;
400
429
  } | (ProviderRefusal & {
401
430
  kind: 'rejected';
402
431
  }) | AdapterFailure;
@@ -412,68 +441,84 @@ export type ActionResult = {
412
441
  kind: 'action';
413
442
  result: unknown;
414
443
  at?: RoomVersionAt;
444
+ } | (ProviderRefusal & {
445
+ kind: 'rejected';
446
+ reset?: string;
447
+ }) | AdapterFailure;
448
+ export type SearchHit = {
449
+ room: string;
450
+ path: string;
451
+ line?: number;
452
+ snippet?: string;
453
+ };
454
+ export type SearchAsk = {
455
+ text: string;
456
+ rooms: readonly string[] | null;
457
+ };
458
+ export type SearchAnswer = {
459
+ kind: 'found';
460
+ documents: readonly SearchHit[];
415
461
  } | (ProviderRefusal & {
416
462
  kind: 'rejected';
417
463
  }) | AdapterFailure;
418
464
  export type HeldRoom = {
419
465
  locator: string;
466
+ roomVersion: string | null;
467
+ };
468
+ export type RoomChange = {
469
+ kind: 'room-change';
470
+ locator: string;
471
+ from: string | null;
420
472
  roomVersion: string;
421
- documents: Readonly<Record<string, string>>;
422
- revisions: Readonly<Record<string, string>>;
473
+ read(): Promise<RefreshPage>;
474
+ };
475
+ export type AuthorityChange = {
476
+ kind: 'authority-changed';
477
+ rooms: readonly DiscoveredRoom[];
478
+ left: readonly string[];
479
+ member?: Member;
423
480
  };
424
481
  export type RoomStreamEvent = {
425
482
  kind: 'opened';
483
+ } | {
484
+ kind: 'discovered';
485
+ discovery: Discovery;
426
486
  } | {
427
487
  kind: 'closed';
428
488
  revoked: boolean;
429
489
  lost: boolean;
490
+ authorityChanged: boolean;
430
491
  } | {
431
- kind: 'opening';
492
+ kind: 'caught-up';
432
493
  expired: readonly string[];
433
- } | {
434
- kind: 'room-version';
435
- locator: string;
436
- roomVersion: string;
437
- };
438
- export type KeptReceipt = {
439
- key: string;
440
- head: unknown;
441
- };
442
- export type StreamReceipts = {
443
- heads(): Promise<readonly KeptReceipt[]>;
444
- parts(key: string, count: number): Promise<readonly unknown[]>;
445
- keep(key: string, head: unknown, part?: {
446
- index: number;
447
- value: unknown;
448
- }): Promise<void>;
449
- drop(keys: readonly string[]): Promise<void>;
450
- };
451
- export type AcquiredDemand = {
452
- rooms: readonly string[];
453
- conversations: boolean;
454
- };
494
+ } | AuthorityChange | RoomChange;
455
495
  export type RoomStream = {
456
- hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
457
- reopen(): void;
458
- published(locator: string, roomVersion: string): void;
459
- observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
496
+ hold(rooms: readonly HeldRoom[]): void;
497
+ observe(notify: (event: RoomStreamEvent) => void): () => void;
460
498
  };
499
+ export type PathRule = (path: string) => boolean;
461
500
  export type Adapter = {
462
501
  readonly localSaves?: true;
463
- readonly exhaustiveDiscovery?: true;
502
+ readonly roomTypes?: string;
503
+ readonly nameableRoomTypes?: readonly string[];
504
+ readonly typedPaths?: readonly TypedPath[];
505
+ readonly pathRule?: PathRule;
506
+ readonly unkeptReads?: readonly string[];
507
+ readonly leadingReads?: readonly string[];
464
508
  authorize(): Promise<Authorization>;
465
- discover(authorization: Authorization): Promise<DiscoverResult>;
509
+ discover?(authorization: Authorization): Promise<DiscoverResult>;
466
510
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
467
- refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
511
+ refresh?(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
468
512
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
469
513
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
470
514
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
471
- referrerScope(referrer: unknown): ReferrerScope | null;
515
+ link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
516
+ attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
472
517
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
518
+ search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
473
519
  reached(locator: string, roomVersion: string, target: string): boolean;
474
520
  follows(locator: string, roomVersion: string, next: string): boolean;
475
521
  roomStream?: RoomStream;
476
522
  conversations?: ConversationStream;
477
523
  serviceMode?: ServiceModeSignal;
478
524
  };
479
- export {};
@@ -0,0 +1,7 @@
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 roomTypesOf(schema: string | undefined, nameable?: readonly string[]): VerifiedModel;
5
+ export declare function builtInModel(roomTypes: VerifiedModel): ModelState;
6
+ export declare function schemaTypes(schema: string | null, roomTypes: VerifiedModel): VerifiedModel['types'];
7
+ 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;