@agentshouse/app-bridge 0.1.0-c1bc683ed8f4e → 0.1.0-c1ccced28150f

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 (57) hide show
  1. package/README.md +9 -9
  2. package/dist/index.d.ts +826 -18
  3. package/dist/mdmodel/condition.d.ts +41 -11
  4. package/dist/mdmodel/definition.d.ts +17 -1
  5. package/dist/mdmodel/document.d.ts +5 -5
  6. package/dist/mdmodel/index.d.ts +11 -9
  7. package/dist/mdmodel/links.d.ts +28 -0
  8. package/dist/mdmodel/paths.d.ts +9 -1
  9. package/dist/mdmodel/project.d.ts +1 -0
  10. package/dist/mdmodel/types.d.ts +28 -4
  11. package/dist/mdmodel/validate.d.ts +27 -3
  12. package/dist/mdruntime/adapter.d.ts +121 -66
  13. package/dist/mdruntime/binary.d.ts +0 -5
  14. package/dist/mdruntime/chain.d.ts +10 -0
  15. package/dist/mdruntime/change-set.d.ts +9 -16
  16. package/dist/mdruntime/change.d.ts +31 -1
  17. package/dist/mdruntime/client.d.ts +15 -8
  18. package/dist/mdruntime/collection.d.ts +10 -21
  19. package/dist/mdruntime/compile.d.ts +15 -0
  20. package/dist/mdruntime/connection.d.ts +28 -14
  21. package/dist/mdruntime/conversation.d.ts +26 -11
  22. package/dist/mdruntime/durability.d.ts +2 -5
  23. package/dist/mdruntime/fulltext.d.ts +26 -0
  24. package/dist/mdruntime/identity.d.ts +6 -0
  25. package/dist/mdruntime/media.d.ts +7 -0
  26. package/dist/mdruntime/messages.d.ts +27 -0
  27. package/dist/mdruntime/model.d.ts +6 -1
  28. package/dist/mdruntime/observation.d.ts +15 -0
  29. package/dist/mdruntime/opened.d.ts +21 -0
  30. package/dist/mdruntime/outcome.d.ts +45 -7
  31. package/dist/mdruntime/overlay.d.ts +3 -5
  32. package/dist/mdruntime/query.d.ts +38 -2
  33. package/dist/mdruntime/reach.d.ts +14 -6
  34. package/dist/mdruntime/readiness.d.ts +14 -15
  35. package/dist/mdruntime/recovery.d.ts +3 -2
  36. package/dist/mdruntime/replica.d.ts +55 -33
  37. package/dist/mdruntime/room-draft.d.ts +33 -3
  38. package/dist/mdruntime/save.d.ts +53 -14
  39. package/dist/mdruntime/search.d.ts +32 -43
  40. package/dist/mdruntime/seed.d.ts +15 -0
  41. package/dist/mdruntime/status.d.ts +4 -3
  42. package/dist/mdruntime/store.d.ts +93 -98
  43. package/dist/mdruntime/stored.d.ts +129 -0
  44. package/dist/mdruntime/tables.d.ts +324 -0
  45. package/dist/mdruntime/wire.d.ts +33 -5
  46. package/dist/test-host.d.ts +7 -4
  47. package/dist/test-host.js +18 -28
  48. package/docs/families.md +52 -47
  49. package/package.json +8 -3
  50. package/dist/calls.d.ts +0 -117
  51. package/dist/calls.js +0 -1
  52. package/dist/mdruntime/acquisition.d.ts +0 -13
  53. package/dist/mdruntime/file.d.ts +0 -19
  54. package/dist/mdruntime/rows.d.ts +0 -36
  55. package/dist/mdruntime/shared.d.ts +0 -10
  56. package/dist/mdruntime/transfer.d.ts +0 -9
  57. package/dist/mdruntime/turn.d.ts +0 -6
@@ -0,0 +1,324 @@
1
+ import { type QueryAnswer, type QueryRoom } from './compile.js';
2
+ import type { Composed } from './collection.js';
3
+ import { type SearchAsk } from './fulltext.js';
4
+ import { type ConversationWrite, type HeldConversation, type MessageWindow } from './messages.js';
5
+ import type { Plan } from './query.js';
6
+ import type { SearchWindow } from './search.js';
7
+ import { type Committed, type CountedRoom, type HeldEntry, type ReplicaOpened, type Referrer, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
8
+ export type { Committed, CountedRoom, HeldEntry, OverlayEntry, ReplicaOpened, Referrer, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
9
+ export type { QueryAnswer, QueryRoom } from './compile.js';
10
+ export type { SearchAsk } from './fulltext.js';
11
+ export type { ConversationWrite, HeldConversation, MessageWindow } from './messages.js';
12
+ export type Value = string | number | bigint | Uint8Array | null;
13
+ export type Row = Readonly<Record<string, Value>>;
14
+ export interface Connection {
15
+ run(sql: string, bind?: readonly Value[]): void;
16
+ rows(sql: string, bind?: readonly Value[]): readonly Row[];
17
+ collate(name: string, compare: (left: string, right: string) => number): void;
18
+ }
19
+ export interface SqliteEngine {
20
+ readonly capi: {
21
+ readonly SQLITE_UTF8: number;
22
+ sqlite3_create_collation_v2(database: number, name: string, encoding: number, argument: number, compare: (argument: number, leftLength: number, left: number, rightLength: number, right: number) => number, destroy: number): number;
23
+ };
24
+ readonly wasm: {
25
+ heap8u(): Uint8Array;
26
+ };
27
+ }
28
+ export interface SqliteStatement {
29
+ readonly parameterCount: number;
30
+ bind(values: readonly Value[]): unknown;
31
+ step(): boolean;
32
+ get(values: Value[]): Value[];
33
+ getColumnNames(names: string[]): string[];
34
+ resetNoThrow(clearBindings: boolean): number;
35
+ finalize(): unknown;
36
+ }
37
+ export interface SqliteDatabase {
38
+ readonly pointer: number;
39
+ exec(options: {
40
+ readonly sql: string;
41
+ readonly bind: readonly Value[];
42
+ readonly rowMode?: 'object';
43
+ readonly returnValue?: 'resultRows';
44
+ }): Row[];
45
+ prepare(sql: string): SqliteStatement;
46
+ }
47
+ export declare function sqliteConnection(engine: SqliteEngine, database: SqliteDatabase): Connection;
48
+ export declare const FILE_PART_BYTES = 1048576;
49
+ export declare const RUNTIME_TABLES: readonly string[];
50
+ export type AuthoredFact = 'holder' | 'binding' | 'generation';
51
+ export type StoredFile = {
52
+ readonly key: string;
53
+ readonly blob: Blob;
54
+ };
55
+ export interface FileSpool {
56
+ held(): Iterable<string>;
57
+ spool(key: string, type: string, parts: Iterable<Uint8Array>): Promise<Blob>;
58
+ drop(key: string): Promise<void>;
59
+ probe(bytes: number): Promise<void>;
60
+ }
61
+ export type KeptPending = {
62
+ readonly id: string;
63
+ readonly batch: string;
64
+ readonly state: string;
65
+ readonly files: readonly string[];
66
+ };
67
+ export type KeptRecord = {
68
+ readonly record: string;
69
+ readonly files: readonly string[];
70
+ };
71
+ export type AuthoredRows = {
72
+ readonly locator: string;
73
+ readonly order?: readonly string[];
74
+ readonly added?: readonly KeptPending[];
75
+ readonly founded?: readonly Omit<KeptPending, 'state'>[];
76
+ readonly roomDrafts?: readonly (KeptRecord & {
77
+ readonly path: string;
78
+ })[];
79
+ readonly consumedRoomDrafts?: readonly string[];
80
+ };
81
+ export type HeldQueues = {
82
+ readonly queues: readonly {
83
+ readonly locator: string;
84
+ readonly ids: readonly string[];
85
+ }[];
86
+ readonly pending: readonly {
87
+ readonly locator: string;
88
+ readonly id: string;
89
+ readonly batch: string;
90
+ readonly state: string;
91
+ }[];
92
+ };
93
+ export type OpenedFile = {
94
+ readonly key: string;
95
+ readonly byteLength: number;
96
+ readonly mediaType: string;
97
+ };
98
+ type Asked<A, R> = {
99
+ readonly asked: A;
100
+ readonly answer: R;
101
+ };
102
+ type Nothing = Readonly<Record<never, never>>;
103
+ export type CommittedWrite = Committed & {
104
+ readonly fenced: string | null;
105
+ };
106
+ export type AuthoredWrite = {
107
+ readonly writes: readonly AuthoredRows[];
108
+ readonly files: readonly StoredFile[];
109
+ readonly whole: boolean;
110
+ readonly discards?: readonly string[];
111
+ };
112
+ export interface RuntimeRequests {
113
+ readonly 'authored.queues': Asked<Nothing, HeldQueues>;
114
+ readonly 'authored.roomDrafts': Asked<Nothing, readonly string[]>;
115
+ readonly 'authored.chatDrafts': Asked<Nothing, readonly string[]>;
116
+ readonly 'authored.calls': Asked<Nothing, readonly string[]>;
117
+ readonly 'authored.fences': Asked<Nothing, readonly string[]>;
118
+ readonly 'authored.fact': Asked<{
119
+ readonly name: AuthoredFact;
120
+ }, string | null>;
121
+ readonly 'authored.file': Asked<{
122
+ readonly key: string;
123
+ readonly type: string;
124
+ }, Blob>;
125
+ readonly 'authored.amend': Asked<{
126
+ readonly locator: string;
127
+ readonly id: string;
128
+ readonly amendment: string;
129
+ }, null>;
130
+ readonly 'authored.roomDraft': Asked<{
131
+ readonly locator: string;
132
+ readonly path: string;
133
+ readonly kept: KeptRecord | null;
134
+ readonly files: readonly StoredFile[];
135
+ }, string | null>;
136
+ readonly 'authored.chatDraft': Asked<{
137
+ readonly kept: readonly {
138
+ readonly conversation: string;
139
+ readonly record: string;
140
+ }[];
141
+ readonly dropped: readonly string[];
142
+ }, null>;
143
+ readonly 'authored.call': Asked<{
144
+ readonly operation: string;
145
+ readonly kept: KeptRecord | null;
146
+ readonly files: readonly StoredFile[];
147
+ }, null>;
148
+ readonly 'authored.remember': Asked<{
149
+ readonly name: AuthoredFact;
150
+ readonly value: string;
151
+ }, null>;
152
+ readonly 'authored.claim': Asked<{
153
+ readonly holder: string;
154
+ }, boolean>;
155
+ readonly 'authored.end': Asked<{
156
+ readonly holder: string | null;
157
+ }, boolean>;
158
+ readonly 'replica.open': Asked<Nothing, ReplicaOpened>;
159
+ readonly 'replica.query': Asked<{
160
+ readonly plan: Plan;
161
+ readonly rooms: readonly QueryRoom[];
162
+ readonly budget: number | null;
163
+ }, QueryAnswer>;
164
+ readonly 'replica.entries': Asked<{
165
+ readonly key: number;
166
+ readonly view: View;
167
+ readonly paths: readonly string[];
168
+ }, readonly HeldEntry[]>;
169
+ readonly 'replica.typed': Asked<{
170
+ readonly key: number;
171
+ readonly view: View;
172
+ readonly paths: readonly string[];
173
+ }, readonly TypedEntry[]>;
174
+ readonly 'replica.referrers': Asked<{
175
+ readonly key: number;
176
+ readonly view: View;
177
+ readonly targets: readonly string[];
178
+ readonly kinds: readonly string[];
179
+ }, readonly Referrer[]>;
180
+ readonly 'replica.files': Asked<{
181
+ readonly key: number;
182
+ readonly view: View;
183
+ readonly after: string | null;
184
+ readonly limit: number;
185
+ }, readonly {
186
+ readonly path: string;
187
+ readonly revision: string;
188
+ }[]>;
189
+ readonly 'replica.folders': Asked<{
190
+ readonly key: number;
191
+ readonly view: View;
192
+ readonly paths: readonly string[];
193
+ }, readonly string[]>;
194
+ readonly 'replica.typedWithin': Asked<{
195
+ readonly key: number;
196
+ readonly view: View;
197
+ readonly roots: readonly string[];
198
+ readonly within: boolean;
199
+ }, boolean>;
200
+ readonly 'replica.counts': Asked<{
201
+ readonly rooms: readonly CountedRoom[];
202
+ }, readonly number[]>;
203
+ readonly 'replica.search': Asked<SearchAsk, SearchWindow>;
204
+ readonly 'replica.stage': Asked<{
205
+ readonly locator: string;
206
+ readonly transfer: string;
207
+ readonly key: number | null;
208
+ readonly fingerprint: string;
209
+ readonly entries: readonly StoredEntry[];
210
+ readonly folders: readonly string[];
211
+ }, number | null>;
212
+ readonly 'replica.refresh': Asked<{
213
+ readonly key: number;
214
+ readonly composed: Composed;
215
+ readonly entries: readonly StoredEntry[];
216
+ readonly removals: readonly string[];
217
+ readonly folders: readonly string[];
218
+ readonly folderRemovals: readonly string[];
219
+ }, null>;
220
+ readonly 'replica.unrefresh': Asked<{
221
+ readonly key: number;
222
+ }, null>;
223
+ readonly 'replica.commit': Asked<{
224
+ readonly authored?: AuthoredWrite;
225
+ readonly rooms: readonly RoomCommit[];
226
+ }, CommittedWrite>;
227
+ readonly 'replica.fence': Asked<{
228
+ readonly locators: readonly string[];
229
+ }, null>;
230
+ readonly 'replica.erase': Asked<{
231
+ readonly locator: string | null;
232
+ readonly limit: number;
233
+ }, {
234
+ readonly remaining: boolean;
235
+ }>;
236
+ readonly 'replica.abandon': Asked<{
237
+ readonly locator: string;
238
+ }, null>;
239
+ readonly 'replica.release': Asked<{
240
+ readonly key: number;
241
+ }, null>;
242
+ readonly 'replica.rederive': Asked<{
243
+ readonly key: number;
244
+ readonly composed: Composed;
245
+ readonly bytes: number;
246
+ readonly ms: number;
247
+ readonly floor: number;
248
+ }, {
249
+ readonly done: boolean;
250
+ readonly text: number;
251
+ }>;
252
+ readonly 'replica.fact': Asked<{
253
+ readonly name: string;
254
+ readonly value: string;
255
+ }, null>;
256
+ readonly 'replica.present': Asked<{
257
+ readonly app: string;
258
+ readonly value: string;
259
+ }, null>;
260
+ readonly 'opened.find': Asked<{
261
+ readonly locator: string;
262
+ readonly path: string;
263
+ readonly revision: string;
264
+ }, OpenedFile | null>;
265
+ readonly 'opened.begin': Asked<{
266
+ readonly key: string;
267
+ readonly locator: string;
268
+ readonly path: string;
269
+ readonly revision: string;
270
+ readonly mediaType: string;
271
+ }, boolean>;
272
+ readonly 'opened.part': Asked<{
273
+ readonly key: string;
274
+ readonly part: number;
275
+ readonly bytes: Uint8Array;
276
+ }, boolean>;
277
+ readonly 'opened.keep': Asked<{
278
+ readonly key: string;
279
+ readonly sha256: string;
280
+ readonly byteLength: number;
281
+ readonly parts: number;
282
+ }, boolean>;
283
+ readonly 'opened.drop': Asked<{
284
+ readonly key: string;
285
+ }, null>;
286
+ readonly 'opened.clean': Asked<Nothing, number>;
287
+ readonly 'file.part': Asked<{
288
+ readonly key: string;
289
+ readonly part: number;
290
+ }, Uint8Array | null>;
291
+ readonly 'conversation.held': Asked<Nothing, readonly HeldConversation[]>;
292
+ readonly 'conversation.keep': Asked<ConversationWrite, null>;
293
+ readonly 'conversation.window': Asked<{
294
+ readonly conversation: string;
295
+ readonly limit: number;
296
+ readonly before: readonly [string, string] | null;
297
+ }, MessageWindow>;
298
+ readonly 'conversation.count': Asked<{
299
+ readonly conversation: string;
300
+ }, number>;
301
+ readonly 'conversation.turn': Asked<{
302
+ readonly conversation: string;
303
+ readonly turn: string;
304
+ }, boolean>;
305
+ readonly 'conversation.drop': Asked<{
306
+ readonly conversations: readonly string[];
307
+ }, null>;
308
+ readonly 'space.probe': Asked<Nothing, null>;
309
+ }
310
+ export type RuntimeKind = keyof RuntimeRequests;
311
+ export type RuntimeRequest<K extends RuntimeKind = RuntimeKind> = {
312
+ readonly [Kind in K]: {
313
+ readonly kind: Kind;
314
+ } & RuntimeRequests[Kind]['asked'];
315
+ }[K];
316
+ export type RuntimeAnswer<K extends RuntimeKind> = RuntimeRequests[K]['answer'];
317
+ export interface RuntimeDatabase {
318
+ ask<K extends RuntimeKind>(request: RuntimeRequest<K>): Promise<RuntimeAnswer<K>>;
319
+ }
320
+ export declare function isRuntime(request: {
321
+ readonly kind: string;
322
+ }): request is RuntimeRequest;
323
+ export declare function readsRuntime(request: RuntimeRequest): boolean;
324
+ export declare function answerRuntime(connection: Connection, request: RuntimeRequest, spool: FileSpool): unknown;
@@ -34,15 +34,35 @@ declare const MEMBERS: {
34
34
  readonly reach: 'within';
35
35
  readonly effect: 'write';
36
36
  };
37
+ readonly saveParts: {
38
+ readonly reach: 'within';
39
+ readonly effect: 'write';
40
+ };
37
41
  readonly history: {
38
42
  readonly reach: 'within';
39
43
  readonly effect: 'read';
40
44
  };
45
+ readonly resolve: {
46
+ readonly reach: 'within';
47
+ readonly effect: 'read';
48
+ };
41
49
  readonly 'binaryFile.read': {
42
50
  readonly reach: 'within';
43
51
  readonly effect: 'read';
44
52
  };
45
- readonly 'binaryFile.readReference': {
53
+ readonly 'binaryFile.link': {
54
+ readonly reach: 'within';
55
+ readonly effect: 'read';
56
+ };
57
+ readonly 'binaryFile.show': {
58
+ readonly reach: 'within';
59
+ readonly effect: 'read';
60
+ };
61
+ readonly 'binaryFile.attach': {
62
+ readonly reach: 'within';
63
+ readonly effect: 'action';
64
+ };
65
+ readonly 'binaryFile.part': {
46
66
  readonly reach: 'within';
47
67
  readonly effect: 'read';
48
68
  };
@@ -58,6 +78,10 @@ declare const MEMBERS: {
58
78
  readonly reach: 'whole';
59
79
  readonly effect: 'read';
60
80
  };
81
+ readonly cleanUp: {
82
+ readonly reach: 'whole';
83
+ readonly effect: 'write';
84
+ };
61
85
  readonly persistence: {
62
86
  readonly reach: 'runtime';
63
87
  readonly effect: 'read';
@@ -94,6 +118,10 @@ declare const MEMBERS: {
94
118
  readonly reach: 'app';
95
119
  readonly effect: 'write';
96
120
  };
121
+ readonly 'presentation.edit': {
122
+ readonly reach: 'app';
123
+ readonly effect: 'write';
124
+ };
97
125
  readonly 'conversation.list': {
98
126
  readonly reach: 'within';
99
127
  readonly effect: 'read';
@@ -122,10 +150,6 @@ declare const MEMBERS: {
122
150
  readonly reach: 'within';
123
151
  readonly effect: 'action';
124
152
  };
125
- readonly 'conversation.cancel': {
126
- readonly reach: 'within';
127
- readonly effect: 'action';
128
- };
129
153
  readonly 'conversation.delete': {
130
154
  readonly reach: 'within';
131
155
  readonly effect: 'action';
@@ -134,6 +158,10 @@ declare const MEMBERS: {
134
158
  readonly reach: 'within';
135
159
  readonly effect: 'write';
136
160
  };
161
+ readonly 'chatDraft.prepend': {
162
+ readonly reach: 'within';
163
+ readonly effect: 'write';
164
+ };
137
165
  readonly 'chatDraft.discard': {
138
166
  readonly reach: 'within';
139
167
  readonly effect: 'write';
@@ -1,11 +1,17 @@
1
1
  import type { MdRuntimeClient } from './mdruntime/client.js';
2
- import type { HouseActivation, HouseAnalyticsChoice, HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab, HouseTask } from './index.js';
2
+ import type { HouseAnalyticsChoice, HouseAppMessage, HouseChatOptions, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './index.js';
3
3
  export interface HouseBridgeNavigation {
4
4
  readonly mode: HouseNavigationMode;
5
5
  readonly address: string;
6
6
  }
7
+ export interface HouseBridgeChat {
8
+ readonly element: object;
9
+ readonly options: HouseChatOptions;
10
+ readonly mounted: boolean;
11
+ }
7
12
  export interface HouseBridgeTestHost {
8
13
  readonly navigations: readonly HouseBridgeNavigation[];
14
+ readonly chats: readonly HouseBridgeChat[];
9
15
  readonly ceremonies: readonly string[];
10
16
  readonly consents: readonly HouseAnalyticsChoice[];
11
17
  readonly tabs: readonly HouseTab[];
@@ -15,9 +21,6 @@ export interface HouseBridgeTestHost {
15
21
  publish(status: HouseStatus): void;
16
22
  message(message: HouseAppMessage): void;
17
23
  attachRuntime(runtime: MdRuntimeClient): void;
18
- checkpoint(): Promise<HouseTask>;
19
- restore(task: HouseTask | null): Promise<boolean>;
20
- settle(activation: HouseActivation): void;
21
24
  }
22
25
  export interface HouseBridgeTestHostOptions {
23
26
  readonly address?: string;
package/dist/test-host.js CHANGED
@@ -50,6 +50,7 @@ export function createHouseBridgeTestHost(options = {}) {
50
50
  const consents = [];
51
51
  const tabs = [];
52
52
  const externalCalls = [];
53
+ const chats = [];
53
54
  const addressListeners = new Set();
54
55
  const statusListeners = new Set();
55
56
  const messageListeners = new Set();
@@ -57,7 +58,6 @@ export function createHouseBridgeTestHost(options = {}) {
57
58
  let published = options.status ?? null;
58
59
  let shown = null;
59
60
  let seen = null;
60
- let cooperation = null;
61
61
  let attached = () => { };
62
62
  const runtime = new Promise((resolve) => {
63
63
  attached = resolve;
@@ -99,7 +99,21 @@ export function createHouseBridgeTestHost(options = {}) {
99
99
  });
100
100
  }
101
101
  const bridge = {
102
- runtime,
102
+ runtime: runtime,
103
+ chat: {
104
+ mount(element, options = {}) {
105
+ const chat = { element, options, mounted: true };
106
+ chats.push(chat);
107
+ return Promise.resolve({
108
+ update(next) {
109
+ chat.options = next;
110
+ },
111
+ unmount() {
112
+ chat.mounted = false;
113
+ },
114
+ });
115
+ },
116
+ },
103
117
  address: () => shown,
104
118
  onAddress(listener) {
105
119
  return followHeld(addressListeners, listener, () => shown);
@@ -145,25 +159,15 @@ export function createHouseBridgeTestHost(options = {}) {
145
159
  consents.push(choice);
146
160
  publish({ ...published, analytics: { measures: true, choice } });
147
161
  },
148
- cooperate(given) {
149
- cooperation = given;
150
- return () => {
151
- if (cooperation === given)
152
- cooperation = null;
153
- };
154
- },
162
+ cooperate: () => () => { },
155
163
  };
156
- function cooperating() {
157
- if (cooperation === null)
158
- throw new Error('the App registered no cooperation');
159
- return cooperation;
160
- }
161
164
  Object.defineProperty(globalThis, 'houseBridge', { value: bridge, configurable: true });
162
165
  if (published !== null)
163
166
  publish(published);
164
167
  arrive(current);
165
168
  return {
166
169
  navigations,
170
+ chats,
167
171
  ceremonies,
168
172
  consents,
169
173
  tabs,
@@ -182,19 +186,5 @@ export function createHouseBridgeTestHost(options = {}) {
182
186
  attachRuntime(client) {
183
187
  attached(client);
184
188
  },
185
- async checkpoint() {
186
- const held = cooperating();
187
- await held.checkpoint();
188
- await held.persist();
189
- return JSON.parse(JSON.stringify((await held.capture()) ?? null));
190
- },
191
- async restore(task) {
192
- const held = cooperating();
193
- await held.restore(task);
194
- return (await held.ready()) === true;
195
- },
196
- settle(activation) {
197
- cooperating().settle(activation);
198
- },
199
189
  };
200
190
  }
package/docs/families.md CHANGED
@@ -12,7 +12,8 @@
12
12
  purpose-bound authenticated pages. The shell navigates only to a same-origin
13
13
  absolute path, carries its current address as the return target, and the page
14
14
  returns there when it completes. An App names an address House gave it in a
15
- reading and composes none.
15
+ reading and composes one only for `/bind/<app_ref>`, where the User binds
16
+ its Rooms, with `?slot=<name>` to open at one slot.
16
17
  - **Installation** - `install()` offers the page as a Home-screen app. Where the
17
18
  browser has an install prompt ready the shell shows it and the call resolves
18
19
  `'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
@@ -45,17 +46,21 @@
45
46
  The App reports the visitor's choice with `analyticsConsent('accept')` or
46
47
  `analyticsConsent('decline')`; the shell hands it to House's analytics loader, and
47
48
  the choice never reaches House.
48
- - **Handoff** - when House hands its runtime over to a newer build, the App keeps
49
- running, its `runtime` client and observations included: a call it makes
50
- meanwhile waits for the newer runtime, however long that takes, and is
51
- answered once, by it; each observation goes on with the newer runtime's
52
- values; and the status and the address arrive again. A runtime that ended
53
- before answering has its reads answered by the next one; since it may have
54
- applied any other call, an act on House is answered the outcome
55
- `transport-uncertainty`, and every other call, a Save or a draft write among
56
- them, fails with the retryable code `transport-uncertainty`.
57
- - **Site image read** - given a Published Room and an original attachment
58
- reference, it answers the web copy's path and metadata, or `null` when no
49
+ - **Releases and builds** - an open App keeps the release it loaded: a newer
50
+ release, or a newer House build, takes effect at the App's next load, offline
51
+ too once the browser stored it. When one tab loads a newer House build, the
52
+ other House tabs reload into it; Room Drafts, chat drafts and unsent changes
53
+ survive the reload.
54
+ - **A runtime that ends** - when the browser ends House's runtime under an open
55
+ App, the App keeps running, its `runtime` client and observations included:
56
+ each observation goes on with the next runtime's values, and the status and
57
+ the address arrive again. A runtime that ended before answering has its reads
58
+ answered by the next one; since it may have applied any other call, an act on
59
+ House is answered the outcome `transport-uncertainty`, and every other call,
60
+ a Save or a draft write among them, fails with the retryable code
61
+ `transport-uncertainty`.
62
+ - **Site image read** - given a Published Room and the Path of one of its
63
+ binary entries, it answers the web copy's path and metadata, or `null` when no
59
64
  copy exists. The original bytes never cross this bridge at a Site.
60
65
  - **App release code** - `sourceTop(app, release)` answers the top level of
61
66
  the latest successful release of an App the User may use: its folders, its
@@ -67,21 +72,21 @@
67
72
  refusal is House's `{ error: { code, retryable } }`, `app_release_not_found` for an
68
73
  App with no release; a read House does not answer, or one that outlived
69
74
  the browser's signed-in User, is `null`.
70
- - **External calls** - `callExternal({ url, method, headers, body, slot })`
75
+ - **External calls** - `callExternal({ url, method, headers, body, room_ref })`
71
76
  has House's server send an HTTPS request to one of the release's declared
72
77
  external origins and resolves with the service's `status`, `headers` and its
73
78
  body as `body` text or `body_base64`, or a refusal as House's
74
79
  `{ error: { code, retryable } }`, or `null` when House does not answer. House fills in the
75
- App and its running release; naming an account slot places the key of the
76
- account the User connected to it, which the App never sees, and naming none
77
- sends no key. A Site's call names no slot, and the House panel names an
78
- `account` instead. `body_base64` replaces `body` for bytes.
80
+ App and its running release. A `room_ref` names a Room the signed-in User binds to the App
81
+ in a `write` slot, and House adds that Room's Service key for the URL's origin, which App
82
+ code never sees; a call naming no Room carries no key, and a Site's call names no Room.
83
+ `body_base64` replaces `body` for bytes.
79
84
  - **App messages** - `messages(listener)` hands the listener each message
80
85
  another holder of this App sends to this User's running copies, as `from`,
81
86
  the sender's User id, and `body`, the JSON value they sent, until the
82
87
  function it returns is called. App code sends one through the Runtime's
83
- `call('message.send', { to, body })` with the recipient's User id and
84
- a body of at most 32 KiB of JSON; House fills in the App and relays it only
88
+ `call('apps/messages/send', { to, body })` with the recipient's User id and
89
+ a body of at most 32 kB of JSON; House fills in the App and relays it only
85
90
  to copies running now, storing nothing. The panel sends none.
86
91
  - **App screenshot read** - given an App reference, `readScreenshot(app)`
87
92
  answers the image this browser captured of that App's screen the first time
@@ -93,29 +98,29 @@
93
98
  after its latest release, as a JPEG `Blob`, or `null` when House holds none
94
99
  or does not answer. A Site's own renderer reads none.
95
100
 
96
- - **Cooperation** - `cooperate({ checkpoint, persist, capture, restore,
97
- ready, settle })` lets House activate a newer release of the App while it
98
- runs, keeping the User's task; the function it returns withdraws it.
99
- Register it in the entry script, before the first draw, or House treats the
100
- page as not cooperating and the newer release waits for the App's next
101
- open. When a newer release is stored, House calls `checkpoint()`, which
102
- resolves at the App's next safe checkpoint and may never resolve, then
103
- `persist()`, which makes authored work durable, then `capture()`, which
104
- answers the meaningful task the App owns, such as the selected record,
105
- filters, cursor, selection and scroll position, as JSON of at most 65,536
106
- characters; House keeps the address itself. In the newer release House
107
- calls `restore(task)`, or `restore(null)` when it opens the release without
108
- a task, then `ready()`, the App's own check that its local data and
109
- capabilities work, and finally `settle('committed')` once the release is
110
- active or `settle('abandoned')` when House returns to the release before
111
- it, restoring the same task there. A release House opens already active is
112
- settled `'committed'` at once, after `restore(task)` when House hands it a
113
- task, and a cooperation registered after House settled is settled at its
114
- registration. Until `settle('committed')` House fails the release's outside
115
- calls at once, as offline, those of the workers it starts included, and
116
- refuses its Saves, write acts and external calls with the retryable code
117
- `house_trial_withheld`, so a start-up effect is not repeated; run start-up
118
- effects after `settle('committed')`.
101
+ - **Chat** - `chat.mount(element, options)` places House's Chat, the one chat
102
+ in which the User's Agent conversations show, in `element` over the page's
103
+ `runtime` client, and resolves to a handle: `update(options)` replaces its
104
+ options and `unmount()` removes it. House serves the Chat with the page and
105
+ keeps it current, so the App installs and bundles nothing for it. The
106
+ options: `conversation` opens one, `null` for a new chat, `agent` is the
107
+ Agent a new chat goes to, `showChats` adds its conversation list, `width` is
108
+ `full`, the element, or `3/4`, `1/2` or `1/3` of the window docked at its
109
+ right edge, `onOpen` hears each conversation it opens as
110
+ `{ conversation, agent }`, and `onLink` takes a link without a scheme in
111
+ place of the browser. CSS custom properties named `--chat-*` on the element
112
+ or an ancestor set its look. It shows conversations only to a release that
113
+ declares them. A Site and the House panel have none: their call rejects with
114
+ an error named and coded `NotSupportedError`, with `retryable` false.
115
+
116
+ - **First place** - `cooperate({ placed })` tells House when the page has
117
+ drawn the place it opened on; the function it returns withdraws it. Register
118
+ it in the entry script, before the first draw. `placed()` resolves once the
119
+ page has drawn that place with what it shows: House keeps its
120
+ first-preparation surface over a page registered by its first draw until
121
+ then, and lifts it at the first draw of a page that registered none, so the
122
+ User goes from the surface to a drawn place in one change. House asks the
123
+ page for nothing else.
119
124
 
120
125
  ## The test host
121
126
 
@@ -137,9 +142,9 @@ records in `tabs` each `setTab`, answers a release code read from the
137
142
  by App reference and `readSiteScreenshot` from the `siteScreenshots` it was
138
143
  given by Site identifier, answers every `install()` `'manual'`, as a browser
139
144
  with no install prompt does, answers every `notifications()` `'unavailable'`,
140
- as a browser without push does, settles every `setBadge`, delivers each App
145
+ as a browser without push does, settles every `setBadge`, records in `chats`
146
+ each Chat `chat.mount` places, with its `element`, the `options` it was last
147
+ given and whether it is still `mounted`, drawing nothing, delivers each App
141
148
  message `message({ from, body })` plays, and hands `bridge.runtime` the MD
142
- Runtime client `attachRuntime(client)` gives it. `checkpoint()` runs the
143
- registered cooperation's checkpoint, persist and capture and answers the task,
144
- `restore(task)` runs its restore and answers its readiness check, and
145
- `settle(activation)` hands it the outcome.
149
+ Runtime client `attachRuntime(client)` gives it. It takes a `cooperate` and
150
+ never calls `placed()`.