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

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 (41) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +73 -8
  3. package/dist/mdmodel/definition.d.ts +4 -0
  4. package/dist/mdmodel/house-model.d.ts +6 -2
  5. package/dist/mdmodel/index.d.ts +6 -2
  6. package/dist/mdmodel/indexed.d.ts +8 -0
  7. package/dist/mdmodel/kinds.d.ts +2 -0
  8. package/dist/mdmodel/moment.d.ts +6 -0
  9. package/dist/mdruntime/adapter.d.ts +30 -2
  10. package/dist/mdruntime/client.d.ts +6 -1
  11. package/dist/mdruntime/collection.d.ts +2 -1
  12. package/dist/mdruntime/conversation.d.ts +5 -2
  13. package/dist/mdruntime/durability.d.ts +1 -0
  14. package/dist/mdruntime/house-query.d.ts +20 -0
  15. package/dist/mdruntime/listing.d.ts +20 -12
  16. package/dist/mdruntime/media.d.ts +13 -1
  17. package/dist/mdruntime/messages.d.ts +1 -1
  18. package/dist/mdruntime/modal.d.ts +1 -0
  19. package/dist/mdruntime/model.d.ts +4 -2
  20. package/dist/mdruntime/observation.d.ts +2 -0
  21. package/dist/mdruntime/outcome.d.ts +6 -1
  22. package/dist/mdruntime/reach.d.ts +12 -3
  23. package/dist/mdruntime/recovery.d.ts +1 -0
  24. package/dist/mdruntime/runtime.d.ts +3 -1
  25. package/dist/mdruntime/saves.d.ts +2 -0
  26. package/dist/mdruntime/socket/session.d.ts +4 -1
  27. package/dist/mdruntime/socket.d.ts +1 -0
  28. package/dist/mdruntime/store/records.d.ts +4 -1
  29. package/dist/mdruntime/store.d.ts +2 -0
  30. package/dist/mdruntime/surface.d.ts +8 -4
  31. package/dist/mdruntime/wire.d.ts +21 -0
  32. package/dist/session-content/check.d.ts +0 -1
  33. package/dist/session-content/index.d.ts +2 -3
  34. package/dist/session-content/parts.d.ts +10 -83
  35. package/dist/session-content/state.d.ts +4 -6
  36. package/dist/session-content/turn.d.ts +28 -219
  37. package/dist/test-host.d.ts +2 -2
  38. package/dist/test-host.js +5 -1
  39. package/docs/families.md +24 -16
  40. package/package.json +2 -2
  41. package/dist/session-content/bounds.d.ts +0 -7
package/README.md CHANGED
@@ -4,7 +4,7 @@ The types of the agents.house App bridge, an accessor and an in-page test host.
4
4
  House builds the bridge object in every App it serves and hands it to the page
5
5
  before the App's own scripts run; `houseBridge()` returns that object, so an App
6
6
  carries no bridge code of its own. It carries these families: navigation,
7
- ceremonies, installation, notifications, Telegram, status, App
7
+ ceremonies, notifications, Telegram, status, App
8
8
  release code, external calls, App messages, App and Site screenshot reads and the
9
9
  Chat. [docs/families.md](docs/families.md) describes each and the test host.
10
10
 
package/dist/index.d.ts CHANGED
@@ -271,11 +271,18 @@ export interface HouseMethods {
271
271
  readonly room_ref: string;
272
272
  };
273
273
  readonly result: {
274
- readonly history?: readonly {
274
+ readonly history?: readonly ({
275
+ readonly agent_name?: string;
276
+ readonly at: string;
277
+ readonly by?: string;
278
+ readonly kind: "role_given" | "role_taken";
279
+ readonly role: string;
280
+ readonly user: string;
281
+ } | {
275
282
  readonly at: string;
276
283
  readonly kind: "granted" | "revoked";
277
284
  readonly user: string;
278
- }[];
285
+ })[];
279
286
  readonly members: readonly {
280
287
  readonly access?: "manage" | "owner" | "read" | "write";
281
288
  readonly copies?: "online_only" | "search_only";
@@ -284,6 +291,12 @@ export interface HouseMethods {
284
291
  readonly member_document: null | string;
285
292
  readonly owner: boolean;
286
293
  readonly schema_roles?: readonly string[];
294
+ readonly schema_roles_given?: readonly {
295
+ readonly agent_name?: string;
296
+ readonly at: string;
297
+ readonly by?: string;
298
+ readonly role: string;
299
+ }[];
287
300
  readonly since: null | string;
288
301
  readonly through_space?: true;
289
302
  readonly user: string;
@@ -324,6 +337,35 @@ export interface HouseMethods {
324
337
  readonly writable: boolean;
325
338
  };
326
339
  };
340
+ readonly "service-keys/signatures/check": {
341
+ readonly params: {
342
+ readonly operation_id?: string;
343
+ readonly origin: string;
344
+ readonly room_ref: string;
345
+ readonly signature: string;
346
+ readonly text: string;
347
+ };
348
+ readonly result: {
349
+ readonly matched: boolean;
350
+ };
351
+ };
352
+ readonly "sites/functions/call": {
353
+ readonly params: {
354
+ readonly function: string;
355
+ readonly input?: readonly (readonly unknown[] | boolean | null | number | {
356
+ readonly [key: string]: unknown;
357
+ } | string)[] | boolean | null | number | {
358
+ readonly [key: string]: readonly unknown[] | boolean | null | number | {
359
+ readonly [key: string]: unknown;
360
+ } | string;
361
+ } | string;
362
+ };
363
+ readonly result: {
364
+ readonly answer: readonly unknown[] | boolean | null | number | {
365
+ readonly [key: string]: unknown;
366
+ } | string;
367
+ };
368
+ };
327
369
  readonly "sites/submissions/create": {
328
370
  readonly params: {
329
371
  readonly content: string;
@@ -483,17 +525,22 @@ export interface HouseMethods {
483
525
  readonly value: string;
484
526
  } | {
485
527
  readonly code: "limit_reached";
486
- readonly limit: "custom_domains" | "external_calls" | "publish_data" | "sites";
528
+ readonly limit: "custom_domains" | "external_calls" | "publish_data" | "site_function_calls" | "sites";
487
529
  readonly outcome: "refused";
488
530
  readonly position: number;
489
531
  readonly retry_at: string;
490
532
  } | {
491
533
  readonly code: "limit_reached";
492
- readonly limit: "custom_domains" | "external_calls" | "publish_data" | "sites";
534
+ readonly limit: "custom_domains" | "external_calls" | "publish_data" | "site_function_calls" | "sites";
493
535
  readonly outcome: "refused";
494
536
  readonly position: number;
495
537
  } | {
496
- readonly code: "agent_function_retired" | "environment_offline" | "no_recipient" | "not_found" | "target_agent_unavailable";
538
+ readonly code: "post_not_confirmed";
539
+ readonly final: true;
540
+ readonly outcome: "failed";
541
+ readonly position: number;
542
+ } | {
543
+ readonly code: "agent_function_retired" | "environment_offline" | "no_group" | "no_recipient" | "not_found" | "target_agent_unavailable";
497
544
  readonly outcome: "no_target";
498
545
  readonly position: number;
499
546
  } | {
@@ -511,6 +558,10 @@ export interface HouseMethods {
511
558
  readonly output?: string;
512
559
  readonly position: number;
513
560
  readonly run: string;
561
+ } | {
562
+ readonly mentioned: number;
563
+ readonly outcome: "posted";
564
+ readonly position: number;
514
565
  } | {
515
566
  readonly outcome: "continued";
516
567
  readonly position: number;
@@ -602,6 +653,7 @@ export type HouseNavigationMode = 'push' | 'replace';
602
653
  export interface HouseTab {
603
654
  readonly title?: string;
604
655
  readonly icon?: string;
656
+ readonly scheme?: 'light' | 'dark' | null;
605
657
  }
606
658
  interface HouseRelease {
607
659
  readonly app_ref: string;
@@ -652,7 +704,16 @@ export interface HouseAppMessage {
652
704
  readonly from: string;
653
705
  readonly body: unknown;
654
706
  }
655
- export type HouseInstallation = Open<'accepted' | 'dismissed' | 'manual'>;
707
+ export interface HouseBox {
708
+ readonly x: number;
709
+ readonly y: number;
710
+ readonly width: number;
711
+ readonly height: number;
712
+ }
713
+ export interface HouseTitleRow {
714
+ readonly height: number;
715
+ readonly controls: readonly HouseBox[];
716
+ }
656
717
  export type HouseNotifications = Open<'on' | 'off' | 'blocked' | 'unavailable'>;
657
718
  export interface HouseTelegram {
658
719
  readonly state: Open<'available' | 'linked' | 'unavailable'>;
@@ -700,6 +761,9 @@ export interface HouseChatButtonOptions {
700
761
  readonly onOpen?: (opened: HouseChatOpened) => void;
701
762
  readonly onLink?: (href: string) => void;
702
763
  }
764
+ export interface HouseChatButtonMount extends HouseChatButtonOptions {
765
+ readonly agent?: string | null;
766
+ }
703
767
  export interface HouseChatTarget {
704
768
  readonly conversation?: string | null;
705
769
  readonly agent?: string | null;
@@ -713,7 +777,7 @@ export interface HouseChatButton {
713
777
  }
714
778
  export interface HouseChat {
715
779
  mount(element: object, options?: HouseChatOptions): Promise<HouseMountedChat>;
716
- mountButton(options?: HouseChatButtonOptions): Promise<HouseChatButton>;
780
+ mountButton(options?: HouseChatButtonMount): Promise<HouseChatButton>;
717
781
  }
718
782
  export interface HouseBridge {
719
783
  readonly runtime: Promise<HouseRuntime>;
@@ -723,7 +787,8 @@ export interface HouseBridge {
723
787
  push(address: string): Promise<string>;
724
788
  replace(address: string): Promise<string>;
725
789
  ceremony(path: string): Promise<HouseCeremonyEnded>;
726
- install(): Promise<HouseInstallation>;
790
+ onTitleBar(listener: (area: HouseBox | null) => void): () => void;
791
+ setTitleBar(row: HouseTitleRow | null): void;
727
792
  notifications(on?: boolean): Promise<HouseNotifications>;
728
793
  telegram(link?: true): Promise<HouseTelegram>;
729
794
  setTab(tab: HouseTab): void;
@@ -14,6 +14,7 @@ export type ValueFacts = {
14
14
  readonly prefix?: readonly ValueFacts[];
15
15
  readonly items?: ValueFacts;
16
16
  readonly properties?: Readonly<Record<string, ValueFacts>>;
17
+ readonly required?: readonly string[];
17
18
  readonly patterns?: readonly PatternFacts[];
18
19
  readonly additional?: ValueFacts;
19
20
  };
@@ -44,6 +45,7 @@ export type Definition = {
44
45
  readonly rules: Readonly<Record<string, FieldRules>>;
45
46
  readonly createRoles?: readonly string[];
46
47
  readonly deleteRoles?: readonly string[];
48
+ readonly indexed?: readonly string[];
47
49
  readonly shape: Shape;
48
50
  };
49
51
  export type Failure = {
@@ -58,6 +60,7 @@ export declare const JSON_TYPES: readonly JsonType[];
58
60
  export declare const BUILT_IN_TYPE = "any";
59
61
  export declare const ATTACHMENT = "attachment";
60
62
  export declare const OPENING: readonly string[];
63
+ export declare const UNIONS: readonly string[];
61
64
  export declare const ARRAY_INDEX: RegExp;
62
65
  export declare const JSON_POINTER: RegExp;
63
66
  export declare function refuse(rule: string, location: string): Failure;
@@ -75,6 +78,7 @@ export declare function conjoined(declared: readonly {
75
78
  readonly ancestry: ReadonlySet<unknown>;
76
79
  };
77
80
  export declare function variantsOf({ node, at }: Placed): Placed[];
81
+ export declare function admitted(nodes: readonly unknown[], defs: Readonly<Record<string, unknown>>, ancestry: ReadonlySet<unknown>): Set<string> | null;
78
82
  export declare function valueFacts(node: unknown, defs: Readonly<Record<string, unknown>>): ValueFacts;
79
83
  export declare function itemFacts(facts: ValueFacts, index: number): ValueFacts | undefined;
80
84
  export declare function memberFacts(facts: ValueFacts, key: string): ValueFacts | undefined;
@@ -411,7 +411,7 @@ export declare const HOUSE_MODEL_DECLARATION: {
411
411
  readonly code: {
412
412
  readonly title: 'Code';
413
413
  readonly type: 'string';
414
- readonly enum: readonly ['failed', 'internal_error', 'agent_function_unreadable', 'function_failed', 'function_not_started', 'agent_function_request_not_started'];
414
+ readonly enum: readonly ['failed', 'internal_error', 'agent_function_unreadable', 'function_failed', 'function_not_started', 'agent_function_request_not_started', 'post_not_confirmed'];
415
415
  };
416
416
  readonly action: {
417
417
  readonly title: 'Action';
@@ -571,7 +571,7 @@ export declare const HOUSE_MODEL_DECLARATION: {
571
571
  readonly required: readonly ['description', 'input', 'agent'];
572
572
  };
573
573
  readonly 'house-trigger': {
574
- readonly description: "One Trigger of this Room as its acts wrote it, which House alone writes: its `description`, the `condition` it fires on, its `actions` in order, whether each action and the Trigger are `enabled`, `paused_by` `types` while a change of the Room's types paused it, its `creator` by `user` and the `name` they had then, and when it was `created`. A `notify` action reaches the `users` its `to` names, the members its `fields` name in the matched document and the holders of its `roles`; an `agent_function` action sends its `payload` to the Agent function whose card under this Room's `house/agent-functions/` its `card` names, absent while this Room holds no card of that Agent function; a `message` action puts its `text` into the active conversation that Agent function started for what the Event is about, or starts that Agent function when none is active; a `done` action marks Done every active conversation an Agent function request of this Room started for the Event's document; a `function` action runs the `function` its `app`'s latest release declares, on House's servers, or, naming no `app`, the Room owner's Environment function of that name on its Environment, which only a Trigger of their Private Room holds. Whether an action's target holds is not written: it follows from the Room's members, the Agent function's card, the App's latest release and the owner's functions.";
574
+ readonly description: "One Trigger of this Room as its acts wrote it, which House alone writes: its `description`, the `condition` it fires on, its `actions` in order, whether each action and the Trigger are `enabled`, `paused_by` `types` while a change of the Room's types paused it, its `creator` by `user` and the `name` they had then, and when it was `created`. A `notify` action reaches the `users` its `to` names, the members its `fields` name in the matched document and the holders of its `roles`, or, `in_group`, posts once in this Room's Telegram group in their place, mentioning each; an `agent_function` action sends its `payload` to the Agent function whose card under this Room's `house/agent-functions/` its `card` names, absent while this Room holds no card of that Agent function; a `message` action puts its `text` into the active conversation that Agent function started for what the Event is about, or starts that Agent function when none is active; a `done` action marks Done every active conversation an Agent function request of this Room started for the Event's document; a `function` action runs the `function` its `app`'s latest release declares, on House's servers, or, naming no `app`, the Room owner's Environment function of that name on its Environment, which only a Trigger of their Private Room holds. Whether an action's target holds is not written: it follows from the Room's members, the Agent function's card, the App's latest release and the owner's functions.";
575
575
  readonly properties: {
576
576
  readonly reflected: {
577
577
  readonly title: 'Reflected';
@@ -653,6 +653,10 @@ export declare const HOUSE_MODEL_DECLARATION: {
653
653
  };
654
654
  readonly required: readonly ['users', 'fields', 'roles'];
655
655
  };
656
+ readonly in_group: {
657
+ readonly title: 'In group';
658
+ readonly const: true;
659
+ };
656
660
  };
657
661
  readonly required: readonly ['kind', 'enabled', 'title', 'text', 'to'];
658
662
  }, {
@@ -1,9 +1,11 @@
1
1
  export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
2
2
  export type { Actor, DocumentEvent, DocumentFacts, Fact, ItemFacts, MessageFacts, Resolved, WriteDoor, } from './event.js';
3
- export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
3
+ export { byCodePoint, compared, dated, fitsKind, indexKey, instant, instantKey, kindOf, kindWords, } from './kinds.js';
4
4
  export type { Kind, Ordering } from './kinds.js';
5
5
  export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
6
6
  export type { Clause, Continuation, Direction, DocumentQuery, DocumentShape, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, GroupShape, HeldRooms, Key, KeyPlan, LocalQuery, OrderOptions, Place, Predicate, QueryErrorCode, QueryPlan, Related, RoomFacts, Scope, Select, Test, Value, Where, } from './query/language.js';
7
+ export { verifyIndexBounds } from './indexed.js';
8
+ export type { IndexBounds } from './indexed.js';
7
9
  export { heldAt, matches } from './query/match.js';
8
10
  export type { Candidate } from './query/match.js';
9
11
  export { heldKind, indexed } from './query/rows.js';
@@ -12,6 +14,8 @@ export * as sql from './query/sql.js';
12
14
  export { headingLines } from './markdown.js';
13
15
  export type { HeadingLine } from './markdown.js';
14
16
  export { acceptsType, dataUrl, dataUrlPattern, declaresUtf8, FILE_MEDIA_TYPES, fileExtension, formDataType, gitMediaType, isAudioType, isImageType, isVideoType, MEDIA_TYPES, mediaTypeEssence, SCRIPT_MEDIA_TYPES, servedMediaType, UTF8_TEXT, withCharset, } from './media-type.js';
17
+ export { shownDay, shownMoment } from './moment.js';
18
+ export type { MomentReader } from './moment.js';
15
19
  export { labelAt, NAME_FIELD } from './body.js';
16
20
  export type { Naming } from './body.js';
17
21
  export { divide } from './divide.js';
@@ -27,7 +31,7 @@ export { APP_REFERENCE_PATTERN, APP_REFERENCE_PREFIX, ROOM_REFERENCE_PATTERN, RE
27
31
  export type { HouseDocumentFields, HouseModelType } from './house-model.js';
28
32
  export { CHAT_MESSAGE_TYPE, CHAT_TYPE, INBOX_CHANNEL_KINDS, INBOX_TYPES } from './room-types.js';
29
33
  export type { InboxChannelKind } from './room-types.js';
30
- export { keyedDestination, linkedPath, relative, retarget, roomPath, roomTarget, target, } from './paths.js';
34
+ export { keyedDestination, keyedLink, linkedPath, relative, retarget, roomPath, roomTarget, target, } from './paths.js';
31
35
  export { openPatternBudget } from './pattern.js';
32
36
  export type { LinkedPath, RoomTarget } from './paths.js';
33
37
  export { project } from './project.js';
@@ -0,0 +1,8 @@
1
+ import { type Failure } from './definition.js';
2
+ import type { ModelVerification, VerifiedModel } from './types.js';
3
+ export type IndexBounds = {
4
+ readonly perType: number;
5
+ readonly longestText: number;
6
+ };
7
+ export declare function indexedFailure(model: VerifiedModel): Failure | undefined;
8
+ export declare function verifyIndexBounds(model: VerifiedModel, bounds: IndexBounds): ModelVerification;
@@ -13,5 +13,7 @@ export declare function kindWords(facts: ValueFacts | undefined): readonly strin
13
13
  export declare function dated(value: unknown): value is string;
14
14
  export declare function instant(value: unknown): bigint | undefined;
15
15
  export declare function instantKey(value: unknown): string | null;
16
+ export declare function instantOf(facts: ValueFacts | undefined, value: unknown): string | null;
17
+ export declare function indexKey(facts: ValueFacts, value: unknown): Uint8Array;
16
18
  export declare function byCodePoint(left: string, right: string): number;
17
19
  export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
@@ -0,0 +1,6 @@
1
+ export interface MomentReader {
2
+ readonly language: string;
3
+ readonly zone: string | null;
4
+ }
5
+ export declare function shownMoment(at: Date, reader: MomentReader): string;
6
+ export declare function shownDay(at: Date, reader: MomentReader): string;
@@ -4,6 +4,7 @@ import type { ModelResult } from './model.js';
4
4
  export type { SavedFacts, TypedPath };
5
5
  import type { Open } from './open.js';
6
6
  import type { ChangeBatch } from './change.js';
7
+ import type { QueryDocument } from './query.js';
7
8
  export type Authorization = object;
8
9
  export type MdModelIdentity = {
9
10
  identity: string;
@@ -255,6 +256,11 @@ export type Retention = {
255
256
  history: HistoryRetention;
256
257
  refreshHorizon: number;
257
258
  };
259
+ export type QueriedRoom = {
260
+ readonly locator: string;
261
+ readonly handle: string;
262
+ readonly name: string;
263
+ };
258
264
  export type Discovery = {
259
265
  kind: 'discovery';
260
266
  rooms: readonly DiscoveredRoom[];
@@ -262,7 +268,9 @@ export type Discovery = {
262
268
  providerLimits: readonly ProviderLimit[];
263
269
  retention: Retention;
264
270
  member?: Member;
271
+ timeZone?: string | null;
265
272
  roomList?: RoomList;
273
+ queriesOnly?: readonly QueriedRoom[];
266
274
  };
267
275
  export type TransportUncertainty = {
268
276
  kind: 'transport-uncertainty';
@@ -445,6 +453,10 @@ export type BinaryRequest = {
445
453
  path: string;
446
454
  revision: string;
447
455
  };
456
+ export type KeyedRequest = {
457
+ kind: 'key';
458
+ link: string;
459
+ };
448
460
  export type BinaryResult = {
449
461
  kind: 'binary';
450
462
  body: ReadableStream<Uint8Array>;
@@ -462,7 +474,7 @@ export type BinaryLinkResult = {
462
474
  kind: 'rejected';
463
475
  }) | AdapterFailure;
464
476
  export type AttachRequest = {
465
- locator: string;
477
+ locator?: string;
466
478
  name: string;
467
479
  mediaType: string;
468
480
  byteLength: number;
@@ -473,6 +485,9 @@ export type AttachResult = {
473
485
  kind: 'attached';
474
486
  path: string;
475
487
  revision: string;
488
+ } | {
489
+ kind: 'linked';
490
+ link: string;
476
491
  } | (ProviderRefusal & {
477
492
  kind: 'rejected';
478
493
  }) | AdapterFailure;
@@ -508,6 +523,17 @@ export type SearchAnswer = {
508
523
  } | (ProviderRefusal & {
509
524
  kind: 'rejected';
510
525
  }) | AdapterFailure;
526
+ export type HouseQueryAsk = {
527
+ room: string;
528
+ query: Readonly<Record<string, unknown>>;
529
+ };
530
+ export type HouseQueryAnswer = {
531
+ kind: 'rows';
532
+ documents: readonly QueryDocument[];
533
+ next?: string;
534
+ } | (ProviderRefusal & {
535
+ kind: 'rejected';
536
+ }) | AdapterFailure;
511
537
  export type HeldRoom = {
512
538
  locator: string;
513
539
  roomVersion: string | null;
@@ -524,6 +550,7 @@ export type AuthorityChange = {
524
550
  rooms: readonly DiscoveredRoom[];
525
551
  left: readonly string[];
526
552
  member?: Member;
553
+ timeZone?: string | null;
527
554
  roomList?: RoomList & {
528
555
  readonly left: readonly string[];
529
556
  };
@@ -563,10 +590,11 @@ export type Adapter = {
563
590
  mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
564
591
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
565
592
  binary(authorization: Authorization, request: BinaryRequest): Promise<BinaryResult>;
566
- link(authorization: Authorization, request: BinaryRequest): Promise<BinaryLinkResult>;
593
+ link(authorization: Authorization, request: BinaryRequest | KeyedRequest): Promise<BinaryLinkResult>;
567
594
  attach(authorization: Authorization, request: AttachRequest): Promise<AttachResult>;
568
595
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
569
596
  search?(authorization: Authorization, request: SearchAsk): Promise<SearchAnswer>;
597
+ queryHouse?(authorization: Authorization, request: HouseQueryAsk): Promise<HouseQueryAnswer>;
570
598
  reached(locator: string, roomVersion: string, target: string): boolean;
571
599
  follows(locator: string, roomVersion: string, next: string): boolean;
572
600
  roomStream?: RoomStream;
@@ -14,6 +14,7 @@ import type { Holdings } from './holdings.js';
14
14
  import type { DocumentResult, GroupResult, PendingResult } from './query.js';
15
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
16
16
  import type { SearchRequest, SearchResult } from './search.js';
17
+ import type { HouseQuery, HouseQueryResult } from './house-query.js';
17
18
  import type { Readiness } from './readiness.js';
18
19
  import type { ObservedRead } from './reads.js';
19
20
  import type { SyncStatus } from './status.js';
@@ -27,6 +28,7 @@ export type MdRuntimeClient = {
27
28
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
28
29
  };
29
30
  search(request: SearchRequest): Promise<SearchResult>;
31
+ queryHouse(query: HouseQuery): Promise<HouseQueryResult>;
30
32
  types(locator: string): Promise<RoomSchemas>;
31
33
  roomDraft: {
32
34
  list(): Promise<readonly RoomDraft[]>;
@@ -59,6 +61,7 @@ export type MdRuntimeClient = {
59
61
  retry(): Promise<void>;
60
62
  cleanUp(): Promise<number>;
61
63
  unsent(): Promise<readonly UnsentWork[]>;
64
+ sent(): Promise<void>;
62
65
  reset(): Promise<void>;
63
66
  readAgain(): Promise<void>;
64
67
  observe: {
@@ -70,6 +73,7 @@ export type MdRuntimeClient = {
70
73
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
71
74
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
72
75
  (topic: 'member'): Promise<Observation<Member | null>>;
76
+ (topic: 'time-zone'): Promise<Observation<string | null>>;
73
77
  (topic: 'authority-changes'): Promise<Observation<number>>;
74
78
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
75
79
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
@@ -93,6 +97,7 @@ export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void
93
97
  export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
94
98
  export { roomDraftRevision } from './identity.js';
95
99
  export { defineRoomMedia, ROOM_MEDIA, viewFile } from './media.js';
100
+ export { shownModal } from './modal.js';
96
101
  export type { Observation } from './observation.js';
97
102
  export type { Open } from './open.js';
98
- export { unanswered, type RuntimePort, type WireMember } from './wire.js';
103
+ export { unanswered, undelivered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,4 +1,4 @@
1
- import { type DefinitionOf, type Document, type ParseResult, type TypedPath } from '../mdmodel/index.js';
1
+ import { type DefinitionOf, type Document, type ParseResult, type TypedPath, type VerifiedModel } from '../mdmodel/index.js';
2
2
  import type { ModelState, TypesResult } from './model.js';
3
3
  import type { AppTypedSelection } from './listing.js';
4
4
  import type { MdModelIdentity } from './adapter.js';
@@ -20,6 +20,7 @@ export type Composed = {
20
20
  readonly composition: Composition;
21
21
  readonly fingerprint: string;
22
22
  };
23
+ export declare function typesPrint(types: VerifiedModel['types']): string;
23
24
  export declare function composedOf(composition: Composition): Composed;
24
25
  type Selecting<M> = {
25
26
  readonly model: M;
@@ -4,7 +4,7 @@ import { type ChangeSet } from './change-set.js';
4
4
  import { type LiveConversations } from './conversation-live.js';
5
5
  import { type ConversationHeld } from './conversation-row.js';
6
6
  import type { Open } from './open.js';
7
- import { type CallResult, type Offline } from './outcome.js';
7
+ import { type BinaryLinkAnswer, type CallResult, type ConversationAttachAnswer, type Offline } from './outcome.js';
8
8
  import type { ChatRequest } from './source.js';
9
9
  import type { CycleProgress } from './status.js';
10
10
  import type { RuntimeStore } from './store.js';
@@ -96,7 +96,10 @@ export type ConversationSurface = {
96
96
  pin(figures: readonly string[]): Promise<void>;
97
97
  openTurn(conversation: string, turn: string): Promise<void>;
98
98
  dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
99
+ attach(file: File): Promise<ConversationAttachAnswer>;
100
+ attachment(link: string): Promise<BinaryLinkAnswer>;
99
101
  };
102
+ export type ConversationFiles = Pick<ConversationSurface, 'attach' | 'attachment'>;
100
103
  export type ConversationAnswer = {
101
104
  interaction_id: string;
102
105
  response: unknown;
@@ -120,7 +123,7 @@ export type Asked = {
120
123
  };
121
124
  export declare function joinedDraft(first: string, second: string): string;
122
125
  export declare function conversationsLearned(alive: LiveConversations): void;
123
- export declare function conversationSurface(alive: LiveConversations): ConversationSurface;
126
+ export declare function conversationSurface(alive: LiveConversations, files: ConversationFiles): ConversationSurface;
124
127
  export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
125
128
  export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
126
129
  export declare function reconcileOpening(alive: LiveConversations): Promise<void>;
@@ -5,6 +5,7 @@ export type UnsentWork = {
5
5
  readonly kind: UnsentKind;
6
6
  readonly count: number;
7
7
  };
8
+ export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
8
9
  export type AppCode = {
9
10
  readonly running: number;
10
11
  readonly older: number;
@@ -0,0 +1,20 @@
1
+ import { type DocumentQuery } from '../mdmodel/index.js';
2
+ import type { ProviderRefusal } from './adapter.js';
3
+ import { type Failure, type Offline } from './outcome.js';
4
+ import type { QueryDocument } from './query.js';
5
+ import { type PortReach } from './reach.js';
6
+ import type { Runtime } from './runtime.js';
7
+ export type HouseQuery = DocumentQuery & {
8
+ rooms: readonly [string];
9
+ };
10
+ export type HouseQueryRows = {
11
+ kind: 'rows';
12
+ documents: readonly QueryDocument[];
13
+ next?: string;
14
+ };
15
+ export type HouseQueryResult = HouseQueryRows | Offline | (ProviderRefusal & {
16
+ kind: 'rejected';
17
+ }) | (ProviderRefusal & {
18
+ kind: 'undeclared';
19
+ }) | Failure;
20
+ export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null): Promise<HouseQueryResult>;
@@ -1,24 +1,24 @@
1
1
  import type { HeldRooms } from '../mdmodel/index.js';
2
2
  import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
3
- import type { Composition } from './collection.js';
3
+ import { type Composition } from './collection.js';
4
4
  import type { KeyedChange } from './observation.js';
5
- import { type ModelState, type TypesResult } from './model.js';
5
+ import { type MdType, type ModelState, type TypesResult } from './model.js';
6
6
  import { type PortReach } from './reach.js';
7
7
  import type { ReplicaRecord } from './replica.js';
8
8
  import type { Runtime } from './runtime.js';
9
9
  import type { Stored } from './store.js';
10
- export type AppTypedSelection = {
10
+ type Selection<Model> = {
11
11
  roots: readonly string[];
12
- model: TypesResult;
12
+ model: Model;
13
13
  };
14
- export type AppRoom = {
14
+ type Shown<Model> = {
15
15
  name: string;
16
16
  locator: string;
17
17
  handle: string;
18
18
  operations: OperationScopes;
19
19
  replica: ReplicaAdmission;
20
- model: TypesResult;
21
- typedSelection: AppTypedSelection | null;
20
+ model: Model;
21
+ typedSelection: Selection<Model> | null;
22
22
  providerOwnedPaths: readonly string[];
23
23
  authoredPaths: readonly string[];
24
24
  roomVersion: string | null;
@@ -26,13 +26,21 @@ export type AppRoom = {
26
26
  synchronizationAvailable: boolean;
27
27
  refusal: ProviderRefusal | null;
28
28
  locked: boolean;
29
+ queriesOnly?: true;
29
30
  };
30
- type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
31
- export type ListedEntry = ListedRoom & {
32
- readonly documents: number;
31
+ export type AppTypedSelection = Selection<TypesResult>;
32
+ export type AppRoom = Shown<TypesResult>;
33
+ export type ListedRoom = Shown<TypesResult<string>>;
34
+ export type ListedModels = Readonly<Record<string, readonly MdType[]>>;
35
+ export type ListedRooms = {
36
+ readonly rooms: readonly ListedRoom[];
37
+ readonly models: ListedModels;
33
38
  };
39
+ export type ListedEntry = Omit<Shown<ModelState>, 'locked'>;
34
40
  export type Listing = ReadonlyMap<string, ListedEntry>;
35
- export type RoomsChange = KeyedChange<string, AppRoom>;
41
+ export type RoomsChange = KeyedChange<string, ListedRoom> & {
42
+ readonly models: ListedModels;
43
+ };
36
44
  export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
37
45
  export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
38
46
  export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
@@ -43,7 +51,7 @@ export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<
43
51
  export declare function listedOrHeld({ presence }: Runtime, held: ReadonlyMap<string, unknown>, locator: string): boolean;
44
52
  export declare function listedEntries(runtime: Runtime, touched: readonly string[]): Promise<readonly ListedEntry[] | null>;
45
53
  export declare function listingNow(runtime: Runtime): Promise<Listing>;
46
- export declare function shownRooms(runtime: Runtime, listing: Listing): readonly AppRoom[];
54
+ export declare function shownRooms(runtime: Runtime, listing: Listing): ListedRooms;
47
55
  export declare function shownChange(runtime: Runtime, entries: readonly ListedEntry[]): RoomsChange;
48
56
  export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
49
57
  export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
@@ -1,10 +1,22 @@
1
1
  import type { MdRuntimeClient } from './client.js';
2
- import { type ShownAnswer } from './outcome.js';
2
+ import { type DownloadAnswer, type ShownAnswer } from './outcome.js';
3
3
  export declare const ROOM_MEDIA = "room-media";
4
+ export declare const KEYED_MEDIA = "ahc-attachment";
5
+ export declare const MEDIA = "room-media, ahc-attachment";
4
6
  export declare const DIAGRAM = "md-diagram";
5
7
  export declare const VIEWING = "ahc-viewer";
6
8
  type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
9
+ export type MediaAt = {
10
+ readonly link: string;
11
+ } | {
12
+ readonly room: string;
13
+ readonly path: string;
14
+ readonly revision: string | undefined;
15
+ };
7
16
  export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
17
+ export declare function mediaAt(media: Element): MediaAt | null;
18
+ export declare function mediaTag(at: MediaAt): string;
19
+ export declare function downloadAt(client: MdRuntimeClient, at: MediaAt): Promise<DownloadAnswer>;
8
20
  export declare function rendered(element: Element): boolean;
9
21
  export declare function viewable(element: Element): boolean;
10
22
  export declare function viewFile(client: MdRuntimeClient, media: Element): void;
@@ -1,7 +1,7 @@
1
1
  import type { AcceptedMessage } from './adapter.js';
2
2
  import type { Connection } from './tables.js';
3
3
  export declare const MESSAGE_TABLES: readonly string[];
4
- export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n answer.turn AS answered,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn') AS opened_turn,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
4
+ export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n answer.turn AS answered,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n COALESCE(\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),\n CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < (SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil') THEN answer.turn END\n ) AS opened_turn,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
5
5
  export type HeldConversation = {
6
6
  readonly conversation: string;
7
7
  readonly read: string | null | undefined;
@@ -0,0 +1 @@
1
+ export declare function shownModal(dialog: HTMLDialogElement): void;
@@ -31,7 +31,7 @@ export type StoredModel = Extract<ModelState, {
31
31
  }> | Omit<Extract<ModelState, {
32
32
  status: 'current' | 'cached';
33
33
  }>, 'types'>;
34
- export type TypesResult = {
34
+ export type TypesResult<Types = readonly MdType[]> = {
35
35
  status: Open<'unavailable'>;
36
36
  reason: ModelUnavailableReason;
37
37
  types: null;
@@ -40,7 +40,7 @@ export type TypesResult = {
40
40
  identity: string;
41
41
  version: string;
42
42
  verifiedWith: ModelIdentity;
43
- types: readonly MdType[];
43
+ types: Types;
44
44
  schema: string | null;
45
45
  revision: string | null;
46
46
  };
@@ -50,5 +50,7 @@ export type ValidationReceipt = {
50
50
  source: Open<'current' | 'cached'>;
51
51
  };
52
52
  export declare const NO_MODEL: ModelState;
53
+ export declare function sortedTypes(types: VerifiedModel['types']): readonly MdType[];
53
54
  export declare function modelTypes(state: ModelState): TypesResult;
55
+ export declare function modelResult<Types>(state: ModelState, types: (held: VerifiedModel['types']) => Types): TypesResult<Types>;
54
56
  export declare function storedModel(state: ModelState): StoredModel;