@agentshouse/app-bridge 0.1.0-c10bc03340d5c → 0.1.0-c120f682ecb11

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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ The bridge carries no credential handling and no Runtime family. House builds
12
12
  the MD Runtime client into the page beside the bridge and serves it the Chat, so
13
13
  the App imports, constructs and bundles neither: `bridge.runtime` resolves to the client.
14
14
 
15
- House's guide to building an App is its Guide's `apps/` pages, which `open_guide` opens.
15
+ House's guide to building an App is its Guide's `apps/` pages, which `guide/open` opens.
16
16
 
17
17
  ## Use
18
18
 
@@ -42,7 +42,7 @@ async function manageSecurity(securityPath) {
42
42
 
43
43
  `bridge.runtime` resolves to the `MdRuntimeClient` of `@agentshouse/mdruntime/client`,
44
44
  whose README describes its members. Its `call(method, params)` is a remote procedure call
45
- to a House act by its name, such as `call('rooms/members', { room_ref })`: `HouseMethods`
45
+ to a House act by its name, such as `call('rooms/members/list', { room_ref })`: `HouseMethods`
46
46
  names each with House's own input, `HouseParams<Name>`, and answer, `HouseResult<Name>`.
47
47
 
48
48
  ## Test without a House
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { MdRuntimeClient, Open } from './mdruntime/client.js';
2
2
  export interface HouseMethods {
3
- readonly "agent-functions/requests": {
3
+ readonly "agent-functions/requests/list": {
4
4
  readonly params: {
5
5
  readonly room_ref: string;
6
6
  };
@@ -15,7 +15,7 @@ export interface HouseMethods {
15
15
  }[];
16
16
  };
17
17
  };
18
- readonly "apps/features/read": {
18
+ readonly "apps/features/list": {
19
19
  readonly params: {};
20
20
  readonly result: {
21
21
  readonly features: readonly {
@@ -24,11 +24,10 @@ export interface HouseMethods {
24
24
  }[];
25
25
  };
26
26
  };
27
- readonly "apps/holders": {
27
+ readonly "apps/holders/list": {
28
28
  readonly params: {};
29
29
  readonly result: {
30
30
  readonly holders: readonly {
31
- readonly email: string;
32
31
  readonly name: string;
33
32
  readonly user: string;
34
33
  }[];
@@ -43,7 +42,7 @@ export interface HouseMethods {
43
42
  readonly [key: string]: never;
44
43
  };
45
44
  };
46
- readonly "apps/relay": {
45
+ readonly "apps/relay/read": {
47
46
  readonly params: {
48
47
  readonly [key: string]: never;
49
48
  };
@@ -73,6 +72,7 @@ export interface HouseMethods {
73
72
  } | {
74
73
  readonly user: string;
75
74
  };
75
+ readonly operation_id: string;
76
76
  readonly path: string;
77
77
  readonly room_ref: string;
78
78
  };
@@ -146,6 +146,7 @@ export interface HouseMethods {
146
146
  };
147
147
  readonly "chats/take-control": {
148
148
  readonly params: {
149
+ readonly operation_id: string;
149
150
  readonly path: string;
150
151
  readonly room_ref: string;
151
152
  };
@@ -214,7 +215,7 @@ export interface HouseMethods {
214
215
  readonly url: string;
215
216
  };
216
217
  };
217
- readonly "conversations/history": {
218
+ readonly "conversations/history/list": {
218
219
  readonly params: {
219
220
  readonly conversations: readonly {
220
221
  readonly after?: {
@@ -355,6 +356,12 @@ export interface HouseMethods {
355
356
  };
356
357
  readonly telegram_undelivered?: true;
357
358
  readonly text: string;
359
+ readonly tokens?: {
360
+ readonly cache_read: number;
361
+ readonly cache_write: number;
362
+ readonly input: number;
363
+ readonly output: number;
364
+ };
358
365
  readonly transcripts?: readonly {
359
366
  readonly path: string;
360
367
  readonly text: string;
@@ -418,7 +425,7 @@ export interface HouseMethods {
418
425
  readonly url: string;
419
426
  };
420
427
  };
421
- readonly "conversations/option": {
428
+ readonly "conversations/option/set": {
422
429
  readonly params: {
423
430
  readonly conversation_id: string;
424
431
  readonly operation_id: string;
@@ -482,7 +489,7 @@ export interface HouseMethods {
482
489
  readonly url: string;
483
490
  };
484
491
  };
485
- readonly "records/read": {
492
+ readonly "records/list": {
486
493
  readonly params: {
487
494
  readonly order?: "asc" | "desc";
488
495
  readonly room_ref: string;
@@ -497,7 +504,7 @@ export interface HouseMethods {
497
504
  }[];
498
505
  };
499
506
  };
500
- readonly "rooms/access/read": {
507
+ readonly "rooms/access/list": {
501
508
  readonly params: {
502
509
  readonly room_ref: string;
503
510
  };
@@ -508,21 +515,22 @@ export interface HouseMethods {
508
515
  readonly direct: readonly {
509
516
  readonly level: null | "keep" | "open" | "search";
510
517
  readonly namespace: string;
511
- readonly operations: readonly ("delete" | "export" | "manageAccess" | "write")[];
518
+ readonly operations: readonly ("erase" | "export" | "manageAccess" | "write")[];
512
519
  }[];
513
520
  readonly entries: readonly {
514
521
  readonly level: null | "keep" | "open" | "search";
515
522
  readonly namespace: string;
516
- readonly operations: readonly ("delete" | "export" | "manageAccess" | "write")[];
523
+ readonly operations: readonly ("erase" | "export" | "manageAccess" | "write")[];
517
524
  readonly sources: readonly {
518
525
  readonly kind: "direct" | "inherited";
519
526
  readonly level: null | "keep" | "open" | "search";
520
527
  readonly namespace: string;
521
- readonly operations: readonly ("delete" | "export" | "manageAccess" | "write")[];
528
+ readonly operations: readonly ("erase" | "export" | "manageAccess" | "write")[];
522
529
  }[];
523
530
  }[];
524
531
  readonly key: null | string;
525
532
  readonly schema_roles: readonly string[];
533
+ readonly through_space?: true;
526
534
  readonly user: string;
527
535
  readonly user_name: string;
528
536
  }[];
@@ -533,7 +541,7 @@ export interface HouseMethods {
533
541
  readonly viewer: string;
534
542
  };
535
543
  };
536
- readonly "rooms/members": {
544
+ readonly "rooms/members/list": {
537
545
  readonly params: {
538
546
  readonly history?: boolean;
539
547
  readonly room_ref: string;
@@ -545,14 +553,15 @@ export interface HouseMethods {
545
553
  readonly user: string;
546
554
  }[];
547
555
  readonly members: readonly {
548
- readonly access?: "edit" | "keep" | "manage" | "open" | "owner" | "search";
556
+ readonly access?: "manage" | "owner" | "read" | "write";
557
+ readonly copies?: "online_only" | "search_only";
549
558
  readonly display_name: string;
550
559
  readonly email?: string;
551
560
  readonly member_document: null | string;
552
- readonly only_while_online?: true;
553
561
  readonly owner: boolean;
554
562
  readonly schema_roles?: readonly string[];
555
563
  readonly since: null | string;
564
+ readonly through_space?: true;
556
565
  readonly user: string;
557
566
  }[];
558
567
  };
@@ -590,7 +599,7 @@ export interface HouseMethods {
590
599
  readonly writable: boolean;
591
600
  };
592
601
  };
593
- readonly "site/submission": {
602
+ readonly "sites/submissions/create": {
594
603
  readonly params: {
595
604
  readonly content: string;
596
605
  };
@@ -598,7 +607,7 @@ export interface HouseMethods {
598
607
  readonly submitted: true;
599
608
  };
600
609
  };
601
- readonly "storage/inventory": {
610
+ readonly "storage/inventory/read": {
602
611
  readonly params: {
603
612
  readonly room_ref?: string;
604
613
  };
@@ -689,20 +698,20 @@ export interface HouseMethods {
689
698
  };
690
699
  };
691
700
  };
692
- readonly "triggers/fired": {
701
+ readonly "triggers/fired/list": {
693
702
  readonly params: {
694
703
  readonly room_ref: string;
695
704
  };
696
705
  readonly result: {
697
706
  readonly events: readonly {
698
707
  readonly actions: readonly ({
699
- readonly cap: "address_submissions" | "app_sockets" | "environment_functions" | "export_starts" | "kit_connections" | "live_shares" | "open_uploads" | "ownership_offers" | "push_addresses" | "push_deliveries" | "room_triggers" | "service_keys" | "share_creations" | "share_room_creations" | "site_rooms" | "slot_rooms" | "spaces" | "waiting_web_wizards" | "writes";
708
+ readonly cap: "address_submissions" | "app_sockets" | "environment_functions" | "export_starts" | "kit_connections" | "live_shares" | "open_uploads" | "ownership_offers" | "push_addresses" | "push_deliveries" | "room_triggers" | "service_keys" | "share_creations" | "share_room_creations" | "site_published_bytes" | "site_rooms" | "slot_rooms" | "spaces" | "waiting_web_wizards" | "writes";
700
709
  readonly code: "cap_reached";
701
710
  readonly outcome: "refused";
702
711
  readonly position: number;
703
712
  readonly retry_at: string;
704
713
  } | {
705
- readonly cap: "address_submissions" | "app_sockets" | "environment_functions" | "export_starts" | "kit_connections" | "live_shares" | "open_uploads" | "ownership_offers" | "push_addresses" | "push_deliveries" | "room_triggers" | "service_keys" | "share_creations" | "share_room_creations" | "site_rooms" | "slot_rooms" | "spaces" | "waiting_web_wizards" | "writes";
714
+ readonly cap: "address_submissions" | "app_sockets" | "environment_functions" | "export_starts" | "kit_connections" | "live_shares" | "open_uploads" | "ownership_offers" | "push_addresses" | "push_deliveries" | "room_triggers" | "service_keys" | "share_creations" | "share_room_creations" | "site_published_bytes" | "site_rooms" | "slot_rooms" | "spaces" | "waiting_web_wizards" | "writes";
706
715
  readonly code: "cap_reached";
707
716
  readonly outcome: "refused";
708
717
  readonly position: number;
@@ -987,7 +996,6 @@ export interface HouseBridge {
987
996
  install(): Promise<HouseInstallation>;
988
997
  notifications(on?: boolean): Promise<HouseNotifications>;
989
998
  telegram(link?: true): Promise<HouseTelegram>;
990
- setBadge(unread: readonly string[]): Promise<void>;
991
999
  setTab(tab: HouseTab): void;
992
1000
  sourceTop(app: string, release?: string): Promise<HouseSourceTop | HouseRefusal | null>;
993
1001
  sourceDownload(app: string, release?: string): Promise<HouseSourceDownload | HouseRefusal | null>;
@@ -13,7 +13,7 @@ export type TypedSelection = {
13
13
  };
14
14
  export type OperationScopes = {
15
15
  write: readonly string[];
16
- delete: readonly string[];
16
+ erase: readonly string[];
17
17
  };
18
18
  export type ReplicaAdmission = {
19
19
  selection: string;
@@ -285,25 +285,17 @@ export type BinaryFile = {
285
285
  mediaType: string;
286
286
  sha256: string;
287
287
  };
288
- export type HeldFile = {
289
- readonly path: string;
290
- readonly revision: string;
291
- };
292
- export type HeldContent = {
293
- files(after: string | null, limit: number): Promise<readonly HeldFile[]>;
294
- contents(paths: readonly string[]): Promise<ReadonlyMap<string, {
295
- readonly content: string;
296
- readonly revision: string;
297
- }>>;
298
- };
299
288
  export type BootstrapRequest = {
300
289
  locator: string;
301
290
  selection: string;
302
291
  pageToken?: PageToken;
303
- held?: HeldContent;
304
292
  arriving?: (bytes: number) => void;
305
293
  signal?: AbortSignal;
306
294
  };
295
+ export type BootstrapPart = {
296
+ readonly id: string;
297
+ readonly bytes: number;
298
+ };
307
299
  export type BootstrapInventory = {
308
300
  readonly bytes: number;
309
301
  };
@@ -318,15 +310,20 @@ export type BootstrapPage = {
318
310
  facts: Readonly<Record<string, SavedFacts>>;
319
311
  revisions: Readonly<Record<string, string>>;
320
312
  fileIds?: Readonly<Record<string, string>>;
313
+ created?: Readonly<Record<string, string>>;
321
314
  changes: Readonly<Record<string, HeadChange>>;
322
315
  binaryFiles: Readonly<Record<string, BinaryFile>>;
323
316
  folders?: readonly string[];
324
317
  pageToken?: PageToken;
318
+ parts?: readonly BootstrapPart[];
325
319
  bytes?: number;
326
320
  };
321
+ export type NotReady = {
322
+ kind: 'not-ready';
323
+ };
327
324
  export type BootstrapResult = BootstrapPage | {
328
325
  kind: 'beyond-horizon';
329
- } | AdapterFailure;
326
+ } | NotReady | AdapterFailure;
330
327
  export type RefreshRequest = {
331
328
  locator: string;
332
329
  selection: string;
@@ -341,6 +338,7 @@ export type RefreshPage = {
341
338
  facts: Readonly<Record<string, SavedFacts>>;
342
339
  revisions: Readonly<Record<string, string>>;
343
340
  fileIds?: Readonly<Record<string, string>>;
341
+ created?: Readonly<Record<string, string>>;
344
342
  changes: Readonly<Record<string, HeadChange>>;
345
343
  binaryFiles: Readonly<Record<string, BinaryFile>>;
346
344
  removals: readonly string[];
@@ -489,12 +487,12 @@ export type SearchAnswer = {
489
487
  }) | AdapterFailure;
490
488
  export type HeldRoom = {
491
489
  locator: string;
492
- roomVersion: string;
490
+ roomVersion: string | null;
493
491
  };
494
492
  export type RoomChange = {
495
493
  kind: 'room-change';
496
494
  locator: string;
497
- from: string;
495
+ from: string | null;
498
496
  roomVersion: string;
499
497
  read(): Promise<RefreshPage>;
500
498
  };
@@ -50,6 +50,7 @@ type Arriving = {
50
50
  readonly path: string;
51
51
  readonly revision?: string;
52
52
  readonly fileId?: string;
53
+ readonly created?: string;
53
54
  readonly change?: HeadChange;
54
55
  };
55
56
  export type RoomMove = {
@@ -101,7 +101,7 @@ export type MdRuntime = {
101
101
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
102
102
  };
103
103
  search(request: SearchRequest): Promise<SearchResult>;
104
- types(locator: string): RoomSchemas;
104
+ types(locator: string): Promise<RoomSchemas>;
105
105
  roomDraft: RoomDraftSurface;
106
106
  conversation: ConversationSurface;
107
107
  chatDraft: ChatDraftSurface;
@@ -1,9 +1,9 @@
1
- import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
1
+ import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
2
2
  import { type ChangeSet } from './change-set.js';
3
3
  import type { Open } from './open.js';
4
4
  import { type CallResult, type Offline } from './outcome.js';
5
5
  import type { CycleProgress } from './status.js';
6
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
6
+ import type { RuntimeStore } from './store.js';
7
7
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
8
8
  export type ConversationEntry = {
9
9
  conversation: string;
@@ -86,6 +86,9 @@ export type ConversationDependencies = {
86
86
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
87
87
  history(request: ConversationHistoryRequest): Promise<CallResult>;
88
88
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
89
+ local(): Promise<RuntimeStore>;
90
+ again(): void;
91
+ settled(): void;
89
92
  stream(): ConversationStream | undefined;
90
93
  publish(set: ChangeSet): void;
91
94
  online(): boolean;
@@ -96,7 +99,7 @@ export type ConversationDependencies = {
96
99
  export type ConversationStore = {
97
100
  surface: ConversationSurface;
98
101
  chatDraft: ChatDraftSurface;
99
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
102
+ opened(local: RuntimeStore): Promise<void>;
100
103
  reconcile(): Promise<void>;
101
104
  catchUp(progress: CycleProgress): Promise<void>;
102
105
  resend(progress: CycleProgress): Promise<void>;
@@ -109,7 +112,7 @@ export type ConversationStore = {
109
112
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
110
113
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
111
114
  changed(set: ChangeSet): void;
112
- receive(event: ConversationEvent): boolean;
115
+ receive(event: ConversationEvent): void;
113
116
  close(): void;
114
117
  };
115
118
  export declare function unheldView(conversation: string): ConversationView;
@@ -18,7 +18,7 @@ export type ConversationWrite = {
18
18
  readonly partial: boolean;
19
19
  };
20
20
  };
21
- export declare function heldConversations(connection: Connection): HeldConversation[];
21
+ export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
22
22
  export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
23
23
  export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
24
24
  export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
@@ -53,5 +53,3 @@ export declare const NO_MODEL: ModelState;
53
53
  export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
54
54
  export declare function modelTypes(state: ModelState): TypesResult;
55
55
  export declare function storedModel(state: ModelState): StoredModel;
56
- export declare function cached(state: ModelState): ModelState;
57
- export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
@@ -3,6 +3,7 @@ import type { ChangeBatch } from './change.js';
3
3
  export type Heads = {
4
4
  revisions: Readonly<Record<string, string>>;
5
5
  fileIds: Readonly<Record<string, string>>;
6
+ created: Readonly<Record<string, string>>;
6
7
  changes: Readonly<Record<string, HeadChange>>;
7
8
  };
8
9
  export type HeldBinary = ({
@@ -28,16 +28,16 @@ export type NarrowedView = RuntimeView & {
28
28
  narrow(reach: PortReach | null): void;
29
29
  };
30
30
  export type Reachable = RuntimeView & {
31
- plan(input: unknown, reach: PortReach | null): Plan;
31
+ plan(input: unknown, reach: PortReach | null): Promise<Plan>;
32
32
  query(plan: Plan): Promise<QueryResult>;
33
33
  watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
34
34
  search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
35
35
  watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
36
- locked(room: string): boolean;
37
- lockedRooms(): readonly string[];
36
+ locked(room: string): Promise<boolean>;
37
+ lockedRooms(): Promise<readonly string[]>;
38
38
  watchLocks(notify: () => void): () => void;
39
- located(room: string, path: string, destination: string): ReachedDocument | null;
40
- room(locator: string): AppRoom | undefined;
39
+ located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
40
+ room(locator: string): Promise<AppRoom | undefined>;
41
41
  };
42
42
  export declare function holds(reach: PortReach | null, room: string): boolean;
43
43
  export declare function governs(reach: PortReach | null, room: {
@@ -22,6 +22,4 @@ export type CycleProgress = {
22
22
  reachable: boolean;
23
23
  };
24
24
  export declare const STARTING: SyncStatus;
25
- export declare function transferring(status: SyncStatus): SyncStatus;
26
- export declare function saving(status: SyncStatus): SyncStatus;
27
25
  export declare function same(one: SyncStatus, other: SyncStatus): boolean;
@@ -6,7 +6,7 @@ import type { ReplicaRecord } from './replica.js';
6
6
  import type { Submission } from './outcome.js';
7
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
8
8
  import type { ModelState, StoredModel } from './model.js';
9
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
9
+ import type { CommittedWrite, ConversationWrite, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, ReplicaOpened, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
10
10
  export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
11
11
  export type TransferRecord = {
12
12
  readonly locator: string;
@@ -32,13 +32,6 @@ export type PendingState = {
32
32
  export type TargetRecord = {
33
33
  established: boolean;
34
34
  };
35
- export type QueueRecord = {
36
- locator: string;
37
- pending: readonly {
38
- batch: ChangeBatch;
39
- state: PendingState;
40
- }[];
41
- };
42
35
  export type PresentationRecord = {
43
36
  app: string;
44
37
  value: unknown;
@@ -63,6 +56,7 @@ export type CallRecord = {
63
56
  export type AuthoredWrite = {
64
57
  locator: string;
65
58
  queue?: readonly ChangeBatch[];
59
+ stored?: readonly ChangeBatch[];
66
60
  founded?: readonly ChangeBatch[];
67
61
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
68
62
  roomDrafts?: readonly RoomDraftRecord[];
@@ -71,23 +65,64 @@ export type AuthoredWrite = {
71
65
  export type StagedPage = {
72
66
  readonly entries: readonly StoredEntry[];
73
67
  readonly folders: readonly string[];
68
+ readonly part?: string;
69
+ };
70
+ export type ResumedTransfer = {
71
+ readonly key: number | null;
72
+ readonly transfer: string;
73
+ readonly staged: readonly string[];
74
74
  };
75
75
  export type RefreshedPage = StagedPage & {
76
76
  readonly removals: readonly string[];
77
77
  readonly folderRemovals: readonly string[];
78
78
  };
79
- export type Opened = {
80
- readonly rooms: ReadonlyMap<string, StoredReplica>;
81
- readonly unindexed: ReadonlySet<number>;
82
- readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
83
- readonly erasing: boolean;
84
- readonly orphans: readonly number[];
79
+ export type HeldRoom = {
80
+ readonly record: StoredReplica;
81
+ readonly indexed: boolean;
82
+ readonly documents: number;
83
+ };
84
+ export type QueuedChange = {
85
+ readonly batch: ChangeBatch;
86
+ readonly state: PendingState;
87
+ };
88
+ export type HeldWork = {
89
+ readonly room: (HeldRoom & {
90
+ readonly overlaid: ReadonlySet<string>;
91
+ }) | null;
92
+ readonly queue: readonly QueuedChange[];
93
+ };
94
+ export type CoveredRoom = {
95
+ readonly key: number;
96
+ readonly transfer: string;
97
+ readonly roomVersion: string;
98
+ readonly indexed: boolean;
99
+ readonly documents: number;
100
+ readonly bytes: number;
101
+ readonly offline: string;
102
+ };
103
+ export type HeldCover = {
104
+ readonly rooms: ReadonlyMap<string, CoveredRoom>;
105
+ readonly queues: ReadonlyMap<string, readonly string[]>;
106
+ };
107
+ export type HeldStatus = {
108
+ readonly queued: readonly string[];
109
+ readonly lastCompleted: string | null;
110
+ readonly unsent: readonly {
111
+ readonly room: string;
112
+ readonly path: string;
113
+ }[];
114
+ readonly resets: readonly {
115
+ readonly locator: string;
116
+ readonly reset: string;
117
+ }[];
118
+ readonly returned: readonly RoomDraftRecord[];
119
+ };
120
+ export type Facts = {
85
121
  readonly lastCompleted: string | null;
86
122
  readonly providerLimits: readonly ProviderLimit[];
87
123
  readonly capabilities: readonly Capability[];
88
124
  readonly member: Member | null;
89
125
  readonly targets: Readonly<Record<string, TargetRecord>>;
90
- readonly presentation: readonly PresentationRecord[];
91
126
  readonly conversationList: readonly ListedConversation[] | null;
92
127
  readonly conversationCursor: string | null;
93
128
  };
@@ -98,44 +133,66 @@ export type Commit = {
98
133
  readonly whole?: boolean;
99
134
  };
100
135
  export type RuntimeStore = {
101
- opened(): Promise<Opened>;
102
- counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
136
+ opened(): Promise<ReplicaOpened>;
137
+ rooms(locators?: readonly string[]): Promise<readonly HeldRoom[]>;
138
+ room(locator: string): Promise<HeldWork>;
139
+ covering(): Promise<HeldCover>;
140
+ offline(locator: string): Promise<string | null>;
141
+ held(): Promise<{
142
+ readonly held: ReadonlySet<string>;
143
+ readonly staged: ReadonlySet<string>;
144
+ }>;
145
+ status(): Promise<HeldStatus>;
146
+ batch(locator: string, id: string): Promise<ChangeBatch | null>;
147
+ order(locator: string): Promise<readonly string[]>;
148
+ queued(): Promise<readonly string[]>;
149
+ moving(): Promise<{
150
+ readonly queued: ReadonlyMap<string, readonly string[]>;
151
+ readonly moving: readonly (QueuedChange & {
152
+ readonly locator: string;
153
+ })[];
154
+ }>;
155
+ pending(locator: string, id: string): Promise<{
156
+ readonly state: PendingState | undefined;
157
+ readonly room: boolean;
158
+ }>;
159
+ facts(): Promise<Facts>;
160
+ presentation(app: string): Promise<unknown>;
161
+ demote(): Promise<void>;
103
162
  query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
104
163
  changes(keys: readonly number[]): number;
105
164
  entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
106
165
  typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
107
166
  referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
108
- files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
109
- readonly path: string;
110
- readonly revision: string;
111
- }[]>;
112
167
  folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
113
168
  typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
114
169
  stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
170
+ resume(record: TransferRecord, composition: Composition, parts: readonly string[], published: number | null): Promise<ResumedTransfer | null>;
115
171
  refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
116
172
  unrefresh(key: number): Promise<void>;
117
173
  commit(commit: Commit): Promise<CommittedWrite>;
118
174
  fence(locators: readonly string[]): Promise<void>;
119
175
  erase(locator: string | null, limit: number): Promise<boolean>;
120
176
  abandon(locator: string): Promise<void>;
177
+ unfence(locators: readonly string[]): Promise<ReadonlySet<string>>;
121
178
  release(key: number): Promise<void>;
122
179
  rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
123
180
  readonly done: boolean;
124
181
  readonly text: number;
125
182
  }>;
126
183
  fact(name: string, value: unknown): Promise<void>;
127
- queues(): Promise<readonly QueueRecord[]>;
128
184
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
129
185
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
130
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
186
+ roomDrafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
131
187
  present(record: PresentationRecord): Promise<void>;
132
- conversations(): Promise<readonly HeldConversation[]>;
188
+ conversations(conversations?: readonly string[]): Promise<readonly HeldConversation[]>;
133
189
  keepMessages(write: ConversationWrite): Promise<void>;
134
190
  messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
135
191
  messageCount(conversation: string, phrase?: string | null): Promise<number>;
136
192
  turnArrived(conversation: string, turn: string): Promise<boolean>;
137
193
  dropConversations(conversations: readonly string[]): Promise<void>;
138
194
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
195
+ chatDraft(conversation: string): Promise<ChatDraftRecord | null>;
139
196
  keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
140
197
  dropChatDraft(conversation: string): Promise<void>;
141
198
  calls(): Promise<readonly CallRecord[]>;
@@ -148,4 +205,4 @@ export type RuntimeStore = {
148
205
  rememberGeneration(value: string): Promise<void>;
149
206
  file(key: string, type: string): Promise<Blob>;
150
207
  };
151
- export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
208
+ export declare function openRuntimeStore(authored: RuntimeDatabase): RuntimeStore;
@@ -10,6 +10,7 @@ export type StoredEntry = {
10
10
  readonly binary: HeldBinary | null;
11
11
  readonly revision: string | null;
12
12
  readonly fileId: string | null;
13
+ readonly created: string | null;
13
14
  readonly change: HeadChange | null;
14
15
  readonly written: string | null;
15
16
  readonly facts: SavedFacts | null;
@@ -29,32 +30,45 @@ export type Referrer = {
29
30
  readonly path: string;
30
31
  readonly target: string;
31
32
  };
32
- export type HeldKey = {
33
- readonly key: number;
33
+ export type HeldRoomRow = {
34
34
  readonly locator: string;
35
- readonly transfer: string;
36
- readonly rederiving: number | null;
35
+ readonly key: number;
36
+ readonly record: string;
37
+ readonly indexed: boolean;
38
+ readonly documents: number;
37
39
  };
38
- export type ReplicaOpened = {
40
+ export type HeldRoomWork = {
41
+ readonly room: (HeldRoomRow & {
42
+ readonly overlaid: readonly string[];
43
+ }) | null;
44
+ readonly queue: readonly {
45
+ readonly id: string;
46
+ readonly batch: string;
47
+ readonly state: string;
48
+ }[];
49
+ };
50
+ export type Covering = {
39
51
  readonly rooms: readonly {
40
52
  readonly locator: string;
41
53
  readonly key: number;
42
- readonly record: string;
54
+ readonly transfer: string;
55
+ readonly roomVersion: string;
56
+ readonly indexed: boolean;
57
+ readonly documents: number;
58
+ readonly bytes: number;
59
+ readonly offline: string;
43
60
  }[];
44
- readonly keys: readonly HeldKey[];
45
- readonly facts: Readonly<Record<string, string>>;
46
- readonly presentation: readonly {
47
- readonly app: string;
48
- readonly value: string;
49
- }[];
50
- readonly overlaid: readonly {
51
- readonly key: number;
52
- readonly path: string;
53
- }[];
54
- readonly erasing: readonly {
55
- readonly key: number;
61
+ readonly queues: readonly {
56
62
  readonly locator: string;
63
+ readonly ids: readonly string[];
57
64
  }[];
65
+ };
66
+ export type HeldLocators = {
67
+ readonly held: readonly string[];
68
+ readonly staged: readonly string[];
69
+ };
70
+ export type ReplicaOpened = {
71
+ readonly erasing: boolean;
58
72
  readonly orphans: readonly number[];
59
73
  };
60
74
  export type RoomCommit = {
@@ -77,14 +91,9 @@ export type RoomCommit = {
77
91
  };
78
92
  };
79
93
  export type Committed = {
80
- readonly counts: Readonly<Record<string, number>>;
81
94
  readonly changed: Readonly<Record<string, readonly string[] | null>>;
82
95
  readonly indexed: Readonly<Record<string, boolean>>;
83
96
  };
84
- export type CountedRoom = {
85
- readonly key: number;
86
- readonly roots: readonly string[];
87
- };
88
97
  export declare function entered(connection: Connection, locator: string, composition: Composition, rows: readonly StoredEntry[]): number;
89
98
  export declare function stage(connection: Connection, request: {
90
99
  readonly locator: string;
@@ -93,7 +102,20 @@ export declare function stage(connection: Connection, request: {
93
102
  readonly fingerprint: string;
94
103
  readonly entries: readonly StoredEntry[];
95
104
  readonly folders: readonly string[];
105
+ readonly part: string | null;
96
106
  }): number;
107
+ export type Resumed = {
108
+ readonly key: number | null;
109
+ readonly transfer: string;
110
+ readonly staged: readonly string[];
111
+ };
112
+ export declare function resume(connection: Connection, request: {
113
+ readonly locator: string;
114
+ readonly transfer: string;
115
+ readonly fingerprint: string;
116
+ readonly parts: readonly string[];
117
+ readonly published: number | null;
118
+ }): Resumed;
97
119
  export declare function refreshing(connection: Connection, request: {
98
120
  readonly key: number;
99
121
  readonly composed: Composed;
@@ -103,7 +125,6 @@ export declare function refreshing(connection: Connection, request: {
103
125
  readonly folderRemovals: readonly string[];
104
126
  }): null;
105
127
  export declare function unrefresh(connection: Connection, key: number): null;
106
- export declare function counts(connection: Connection, rooms: readonly CountedRoom[]): number[];
107
128
  export declare function commit(connection: Connection, rooms: readonly RoomCommit[]): Committed;
108
129
  export declare function fenceRooms(connection: Connection, locators: readonly string[]): null;
109
130
  export declare function abandon(connection: Connection, locator: string): null;
@@ -118,11 +139,17 @@ export declare function rederive(connection: Connection, key: number, composed:
118
139
  export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
119
140
  export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
120
141
  export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
121
- export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
122
- readonly path: string;
123
- readonly revision: string;
124
- }[];
125
142
  export declare function folders(connection: Connection, key: number, view: View, list: readonly string[]): string[];
126
143
  export declare function typedWithin(connection: Connection, key: number, view: View, roots: readonly string[], within: boolean): boolean;
127
144
  export declare function opened(connection: Connection): ReplicaOpened;
145
+ export declare function heldRooms(connection: Connection, locators: readonly string[] | null): readonly HeldRoomRow[];
146
+ export declare function heldRoom(connection: Connection, locator: string): HeldRoomRow | null;
147
+ export declare function overlaid(connection: Connection, key: number): readonly string[];
148
+ export declare function covering(connection: Connection): Covering['rooms'];
149
+ export declare function offlineMode(connection: Connection, locator: string): string | null;
150
+ export declare function stagedLocators(connection: Connection): readonly string[];
151
+ export declare function heldLocators(connection: Connection): readonly string[];
152
+ export declare function demoted(connection: Connection): null;
153
+ export declare function facts(connection: Connection): Readonly<Record<string, string>>;
154
+ export declare function presentation(connection: Connection, app: string): string | null;
128
155
  export declare function ended(connection: Connection): void;
@@ -3,8 +3,8 @@ import type { Composed } from './collection.js';
3
3
  import type { UnsentWork } from './durability.js';
4
4
  import { type ConversationWrite, type HeldConversation, type MessageWindow } from './messages.js';
5
5
  import type { Plan } from './query.js';
6
- import { type Committed, type CountedRoom, type HeldEntry, type ReplicaOpened, type Referrer, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
7
- export type { Committed, CountedRoom, HeldEntry, OverlayEntry, ReplicaOpened, Referrer, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
6
+ import { type Committed, type Covering, type HeldEntry, type HeldLocators, type HeldRoomRow, type HeldRoomWork, type ReplicaOpened, type Referrer, type Resumed, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
7
+ export type { Committed, Covering, HeldEntry, HeldLocators, HeldRoomRow, HeldRoomWork, OverlayEntry, ReplicaOpened, Referrer, Resumed, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
8
8
  export type { QueryAnswer, QueryRoom } from './compile.js';
9
9
  export type { ConversationWrite, HeldConversation, MessageWindow } from './messages.js';
10
10
  export type Value = string | number | bigint | Uint8Array | null;
@@ -65,6 +65,8 @@ export type KeptPending = {
65
65
  readonly batch: string;
66
66
  readonly state: string;
67
67
  readonly files: readonly string[];
68
+ readonly paths: readonly string[];
69
+ readonly moving: boolean;
68
70
  };
69
71
  export type KeptRecord = {
70
72
  readonly record: string;
@@ -92,6 +94,19 @@ export type HeldQueues = {
92
94
  readonly state: string;
93
95
  }[];
94
96
  };
97
+ export type HeldStatus = {
98
+ readonly queued: readonly string[];
99
+ readonly lastCompleted: string | null;
100
+ readonly changes: readonly {
101
+ readonly locator: string;
102
+ readonly path: string;
103
+ }[];
104
+ readonly resets: readonly {
105
+ readonly locator: string;
106
+ readonly reset: string;
107
+ }[];
108
+ readonly returned: readonly string[];
109
+ };
95
110
  export type OpenedFile = {
96
111
  readonly key: string;
97
112
  readonly byteLength: number;
@@ -111,8 +126,30 @@ export type AuthoredWrite = {
111
126
  readonly whole: boolean;
112
127
  };
113
128
  export interface RuntimeRequests {
114
- readonly 'authored.queues': Asked<Nothing, HeldQueues>;
115
- readonly 'authored.roomDrafts': Asked<Nothing, readonly string[]>;
129
+ readonly 'authored.status': Asked<Nothing, HeldStatus>;
130
+ readonly 'authored.moving': Asked<Nothing, HeldQueues>;
131
+ readonly 'authored.pending': Asked<{
132
+ readonly locator: string;
133
+ readonly id: string;
134
+ }, {
135
+ readonly state: string | null;
136
+ readonly room: boolean;
137
+ }>;
138
+ readonly 'authored.batch': Asked<{
139
+ readonly locator: string;
140
+ readonly id: string;
141
+ }, string | null>;
142
+ readonly 'authored.order': Asked<{
143
+ readonly locator: string;
144
+ }, readonly string[]>;
145
+ readonly 'authored.queued': Asked<Nothing, readonly string[]>;
146
+ readonly 'authored.roomDrafts': Asked<{
147
+ readonly locator: string | null;
148
+ readonly paths: readonly string[] | null;
149
+ }, readonly string[]>;
150
+ readonly 'authored.chatDraft.read': Asked<{
151
+ readonly conversation: string;
152
+ }, string | null>;
116
153
  readonly 'authored.chatDrafts': Asked<Nothing, readonly string[]>;
117
154
  readonly 'authored.calls': Asked<Nothing, readonly string[]>;
118
155
  readonly 'authored.fences': Asked<Nothing, readonly string[]>;
@@ -158,6 +195,22 @@ export interface RuntimeRequests {
158
195
  readonly holder: string | null;
159
196
  }, boolean>;
160
197
  readonly 'replica.open': Asked<Nothing, ReplicaOpened>;
198
+ readonly 'replica.rooms': Asked<{
199
+ readonly locators: readonly string[] | null;
200
+ }, readonly HeldRoomRow[]>;
201
+ readonly 'replica.room': Asked<{
202
+ readonly locator: string;
203
+ }, HeldRoomWork>;
204
+ readonly 'replica.covering': Asked<Nothing, Covering>;
205
+ readonly 'replica.offline': Asked<{
206
+ readonly locator: string;
207
+ }, string | null>;
208
+ readonly 'replica.held': Asked<Nothing, HeldLocators>;
209
+ readonly 'replica.demote': Asked<Nothing, null>;
210
+ readonly 'replica.facts': Asked<Nothing, Readonly<Record<string, string>>>;
211
+ readonly 'replica.presentation': Asked<{
212
+ readonly app: string;
213
+ }, string | null>;
161
214
  readonly 'replica.query': Asked<{
162
215
  readonly plan: Plan;
163
216
  readonly rooms: readonly QueryRoom[];
@@ -178,15 +231,6 @@ export interface RuntimeRequests {
178
231
  readonly view: View;
179
232
  readonly targets: readonly string[];
180
233
  }, readonly Referrer[]>;
181
- readonly 'replica.files': Asked<{
182
- readonly key: number;
183
- readonly view: View;
184
- readonly after: string | null;
185
- readonly limit: number;
186
- }, readonly {
187
- readonly path: string;
188
- readonly revision: string;
189
- }[]>;
190
234
  readonly 'replica.folders': Asked<{
191
235
  readonly key: number;
192
236
  readonly view: View;
@@ -198,9 +242,6 @@ export interface RuntimeRequests {
198
242
  readonly roots: readonly string[];
199
243
  readonly within: boolean;
200
244
  }, boolean>;
201
- readonly 'replica.counts': Asked<{
202
- readonly rooms: readonly CountedRoom[];
203
- }, readonly number[]>;
204
245
  readonly 'replica.stage': Asked<{
205
246
  readonly locator: string;
206
247
  readonly transfer: string;
@@ -208,7 +249,15 @@ export interface RuntimeRequests {
208
249
  readonly fingerprint: string;
209
250
  readonly entries: readonly StoredEntry[];
210
251
  readonly folders: readonly string[];
252
+ readonly part: string | null;
211
253
  }, number | null>;
254
+ readonly 'replica.resume': Asked<{
255
+ readonly locator: string;
256
+ readonly transfer: string;
257
+ readonly fingerprint: string;
258
+ readonly parts: readonly string[];
259
+ readonly published: number | null;
260
+ }, Resumed | null>;
212
261
  readonly 'replica.refresh': Asked<{
213
262
  readonly key: number;
214
263
  readonly composed: Composed;
@@ -236,6 +285,9 @@ export interface RuntimeRequests {
236
285
  readonly 'replica.abandon': Asked<{
237
286
  readonly locator: string;
238
287
  }, null>;
288
+ readonly 'replica.unfence': Asked<{
289
+ readonly locators: readonly string[];
290
+ }, readonly string[]>;
239
291
  readonly 'replica.release': Asked<{
240
292
  readonly key: number;
241
293
  }, null>;
@@ -288,7 +340,9 @@ export interface RuntimeRequests {
288
340
  readonly key: string;
289
341
  readonly part: number;
290
342
  }, Uint8Array | null>;
291
- readonly 'conversation.held': Asked<Nothing, readonly HeldConversation[]>;
343
+ readonly 'conversation.held': Asked<{
344
+ readonly conversations: readonly string[] | null;
345
+ }, readonly HeldConversation[]>;
292
346
  readonly 'conversation.keep': Asked<ConversationWrite, null>;
293
347
  readonly 'conversation.window': Asked<{
294
348
  readonly conversation: string;
package/dist/test-host.js CHANGED
@@ -130,7 +130,6 @@ export function createHouseBridgeTestHost(options = {}) {
130
130
  install: () => Promise.resolve('manual'),
131
131
  notifications: () => Promise.resolve('unavailable'),
132
132
  telegram: () => Promise.resolve({ state: 'unavailable', name: null, username: null }),
133
- setBadge: () => Promise.resolve(),
134
133
  setTab(tab) {
135
134
  tabs.push(tab);
136
135
  },
package/docs/families.md CHANGED
@@ -29,11 +29,10 @@
29
29
  notifications, or `'unavailable'` where it has no push, as on an iPhone or
30
30
  iPad outside a Home-screen app. `notifications(true)` asks the browser's
31
31
  permission and subscribes, `notifications(false)` unsubscribes, and each
32
- answers the state it leaves; a failure of the browser's push service, and
33
- of `setBadge`, rejects the same way. Call `notifications(true)` from a
34
- click. `setBadge(unread)` takes the identifiers of the Notifications
35
- unread in this storage and sets the icon's badge to their number, or clears
36
- it at none, where the browser shows one.
32
+ answers the state it leaves; a failure of the browser's push service
33
+ rejects the same way. Call `notifications(true)` from a click. House's
34
+ service worker counts the icon's badge itself, as pushes arrive and as
35
+ read marks reach this storage.
37
36
  - **Telegram** - House's own panel alone, refused to an App or a Site the same
38
37
  way. `telegram()` answers `{ state, name, username }`: `state` is
39
38
  `'available'` where the page runs inside a House bot's Mini App that gave it
@@ -155,7 +154,7 @@ records in `tabs` each `setTab`, answers a release code read from the
155
154
  by App reference and `readSiteScreenshot` from the `siteScreenshots` it was
156
155
  given by Site identifier, answers every `install()` `'manual'`, as a browser
157
156
  with no install prompt does, answers every `notifications()` `'unavailable'`,
158
- as a browser without push does, settles every `setBadge`, records in `chats`
157
+ as a browser without push does, records in `chats`
159
158
  each Chat `chat.mount` places, with its `element`, the `options` it was last
160
159
  given and whether it is still `mounted`, drawing nothing, delivers each App
161
160
  message `message({ from, body })` plays, and hands `bridge.runtime` the MD
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-c10bc03340d5c",
3
+ "version": "0.1.0-c120f682ecb11",
4
4
  "description": "Types of the agents.house App bridge House hands every App: navigation, the tab title and icon, ceremonies, installation, notifications and the icon badge, status, Site image reads, App release code, App and Site screenshot reads, App messages and the Chat, with an accessor and an in-page test host.",
5
5
  "license": "MIT",
6
6
  "type": "module",