@agentshouse/app-bridge 0.1.0-c7cde22995b9e → 0.1.0-c7d445aecf994

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 (76) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +107 -56
  3. package/dist/mdmodel/built-in.d.ts +3 -0
  4. package/dist/mdmodel/definition.d.ts +2 -2
  5. package/dist/mdmodel/document.d.ts +1 -2
  6. package/dist/mdmodel/fields.d.ts +1 -1
  7. package/dist/mdmodel/house-model.d.ts +869 -0
  8. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  9. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  10. package/dist/mdmodel/index.d.ts +18 -7
  11. package/dist/mdmodel/media-type.d.ts +71 -0
  12. package/dist/mdmodel/moment.d.ts +6 -0
  13. package/dist/mdmodel/not-ready.d.ts +1 -0
  14. package/dist/mdmodel/paths.d.ts +5 -0
  15. package/dist/mdmodel/query/match.d.ts +1 -1
  16. package/dist/mdmodel/query/rows.d.ts +1 -1
  17. package/dist/mdmodel/references.d.ts +2 -2
  18. package/dist/mdmodel/room-types.d.ts +6 -0
  19. package/dist/mdmodel/types.d.ts +1 -10
  20. package/dist/mdmodel/validate.d.ts +2 -0
  21. package/dist/mdmodel/yaml.d.ts +4 -4
  22. package/dist/mdruntime/actions.d.ts +1 -0
  23. package/dist/mdruntime/adapter.d.ts +85 -14
  24. package/dist/mdruntime/attached-model.d.ts +0 -1
  25. package/dist/mdruntime/authored.d.ts +87 -0
  26. package/dist/mdruntime/change.d.ts +4 -0
  27. package/dist/mdruntime/client.d.ts +14 -11
  28. package/dist/mdruntime/collection.d.ts +5 -1
  29. package/dist/mdruntime/conversation-live.d.ts +18 -6
  30. package/dist/mdruntime/conversation-row.d.ts +8 -1
  31. package/dist/mdruntime/conversation.d.ts +19 -7
  32. package/dist/mdruntime/durability.d.ts +2 -0
  33. package/dist/mdruntime/house-query.d.ts +20 -0
  34. package/dist/mdruntime/install.d.ts +59 -0
  35. package/dist/mdruntime/listing.d.ts +24 -12
  36. package/dist/mdruntime/live.d.ts +5 -3
  37. package/dist/mdruntime/media.d.ts +18 -1
  38. package/dist/mdruntime/messages.d.ts +12 -3
  39. package/dist/mdruntime/modal.d.ts +1 -0
  40. package/dist/mdruntime/model.d.ts +4 -2
  41. package/dist/mdruntime/observation.d.ts +29 -12
  42. package/dist/mdruntime/outcome.d.ts +10 -1
  43. package/dist/mdruntime/overlay.d.ts +1 -1
  44. package/dist/mdruntime/preparation.d.ts +27 -6
  45. package/dist/mdruntime/presence.d.ts +8 -2
  46. package/dist/mdruntime/reach.d.ts +11 -5
  47. package/dist/mdruntime/readiness.d.ts +9 -3
  48. package/dist/mdruntime/reads.d.ts +1 -1
  49. package/dist/mdruntime/recovery.d.ts +1 -0
  50. package/dist/mdruntime/room-draft.d.ts +28 -3
  51. package/dist/mdruntime/runtime.d.ts +1 -2
  52. package/dist/mdruntime/saves.d.ts +2 -0
  53. package/dist/mdruntime/socket/lanes.d.ts +10 -3
  54. package/dist/mdruntime/socket/session.d.ts +2 -1
  55. package/dist/mdruntime/socket.d.ts +3 -3
  56. package/dist/mdruntime/source.d.ts +5 -0
  57. package/dist/mdruntime/store/installs.d.ts +2 -2
  58. package/dist/mdruntime/store/readiness.d.ts +5 -4
  59. package/dist/mdruntime/store/records.d.ts +19 -5
  60. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  61. package/dist/mdruntime/store.d.ts +13 -9
  62. package/dist/mdruntime/stored.d.ts +24 -13
  63. package/dist/mdruntime/surface.d.ts +12 -6
  64. package/dist/mdruntime/tables.d.ts +16 -52
  65. package/dist/mdruntime/wire.d.ts +33 -10
  66. package/dist/session-content/check.d.ts +0 -1
  67. package/dist/session-content/index.d.ts +2 -3
  68. package/dist/session-content/parts.d.ts +12 -84
  69. package/dist/session-content/state.d.ts +4 -6
  70. package/dist/session-content/turn.d.ts +28 -219
  71. package/dist/test-host.d.ts +8 -1
  72. package/dist/test-host.js +31 -1
  73. package/docs/families.md +53 -24
  74. package/package.json +2 -2
  75. package/dist/mdruntime/log.d.ts +0 -5
  76. package/dist/session-content/bounds.d.ts +0 -7
@@ -4,16 +4,17 @@ import type { AppRoom } from './listing.js';
4
4
  import type { ConnectionRefusal } from './socket.js';
5
5
  import type { RoomSchemas } from './surface.js';
6
6
  import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
7
- import type { Member, ServiceMode } from './adapter.js';
7
+ import type { ListedAgent, Member, RoomList, ServiceMode } from './adapter.js';
8
8
  import type { UnsentWork } from './durability.js';
9
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
9
+ import type { ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
10
10
  import { type Observation } from './observation.js';
11
- import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, QueueEntry, Resolution } from './outcome.js';
11
+ import { type AttachAnswer, type BinaryAnswer, type CallResult, type DownloadAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
12
12
  import type { FiguresResult } from './figures.js';
13
13
  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[]>;
@@ -44,11 +46,7 @@ export type MdRuntimeClient = {
44
46
  conversation: ConversationSurface & {
45
47
  pageMetadata(app: string, address: string): Promise<string>;
46
48
  };
47
- chatDraft: {
48
- write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
49
- prepend(conversation: string, draft: ChatDraft): Promise<void>;
50
- discard(conversation: string): Promise<void>;
51
- };
49
+ chatDraft: ChatDraftSurface;
52
50
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
53
51
  resolve(room: string, path: string, destination: string): Promise<Resolution>;
54
52
  binaryFile: {
@@ -57,12 +55,13 @@ export type MdRuntimeClient = {
57
55
  download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
58
56
  };
59
57
  call(name: string, input: unknown): Promise<CallResult>;
58
+ answered(operation: string): Promise<boolean>;
60
59
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
61
- log(): Promise<string>;
62
60
  persistence(): Promise<boolean>;
63
61
  retry(): Promise<void>;
64
62
  cleanUp(): Promise<number>;
65
63
  unsent(): Promise<readonly UnsentWork[]>;
64
+ sent(): Promise<void>;
66
65
  reset(): Promise<void>;
67
66
  readAgain(): Promise<void>;
68
67
  observe: {
@@ -74,6 +73,7 @@ export type MdRuntimeClient = {
74
73
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
75
74
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
76
75
  (topic: 'member'): Promise<Observation<Member | null>>;
76
+ (topic: 'time-zone'): Promise<Observation<string | null>>;
77
77
  (topic: 'authority-changes'): Promise<Observation<number>>;
78
78
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
79
79
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
@@ -83,6 +83,8 @@ export type MdRuntimeClient = {
83
83
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
84
84
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
85
85
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
86
+ (topic: 'listed-agents'): Promise<Observation<readonly ListedAgent[]>>;
87
+ (topic: 'room-list'): Promise<Observation<RoomList | null>>;
86
88
  (topic: 'figures'): Promise<Observation<FiguresResult>>;
87
89
  (topic: 'holdings'): Promise<Observation<Holdings>>;
88
90
  (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
@@ -94,7 +96,8 @@ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFil
94
96
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
95
97
  export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
96
98
  export { roomDraftRevision } from './identity.js';
97
- export { defineRoomMedia, ROOM_MEDIA } from './media.js';
99
+ export { defineRoomMedia, ROOM_MEDIA, viewFile } from './media.js';
100
+ export { shownModal } from './modal.js';
98
101
  export type { Observation } from './observation.js';
99
102
  export type { Open } from './open.js';
100
- 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 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;
@@ -42,5 +43,8 @@ export declare function definitionsIn(room: {
42
43
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
43
44
  export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
44
45
  export declare function validRoot(root: unknown): root is string;
46
+ export declare const UNTYPED = "any";
47
+ export declare function textType(read: ParseResult): string | undefined;
48
+ export declare function typedText(read: ParseResult): boolean;
45
49
  export declare function available(composition: Composition): boolean;
46
50
  export {};
@@ -20,6 +20,7 @@ export type ConversationDependencies = {
20
20
  full(): boolean;
21
21
  closed(): boolean;
22
22
  unanswered(): void;
23
+ heard(operation: string, lost: boolean): void;
23
24
  readonly recovery: Recovery;
24
25
  readonly retries: Retries;
25
26
  };
@@ -45,10 +46,14 @@ export declare const FACTS: readonly Fact[];
45
46
  type Watcher = {
46
47
  readonly notify: (view: ConversationView) => void;
47
48
  };
48
- type HeldWindow = {
49
- readonly window: readonly AcceptedMessage[] | null;
49
+ export type Kept = {
50
50
  readonly draft: ChatDraftRecord | null;
51
51
  readonly ended: string | null;
52
+ readonly dismissed: string | null;
53
+ readonly pins: readonly string[];
54
+ };
55
+ type HeldWindow = Kept & {
56
+ readonly window: readonly AcceptedMessage[] | null;
52
57
  readonly more: boolean;
53
58
  readonly total: number | null;
54
59
  };
@@ -74,23 +79,29 @@ export type Audience<T> = {
74
79
  };
75
80
  type HeldFacts = {
76
81
  readonly listKnown: boolean;
82
+ readonly openingRead: boolean;
83
+ readonly openingListed: boolean;
77
84
  readonly listOwed: boolean;
78
85
  readonly listTelling: boolean;
79
86
  readonly agentsShown: string | null;
80
- readonly listedAgents: readonly ListedAgent[] | null;
81
- readonly agentsReading: boolean;
87
+ readonly listedShown: string | null;
82
88
  readonly replicated: ReadonlySet<string>;
83
89
  readonly handedReplicated: string | undefined;
84
90
  };
85
91
  export type Dispatch = Cell<{
86
92
  readonly answered: boolean;
87
93
  }>;
94
+ export type Relisted = {
95
+ readonly conversations: ReadonlyMap<string, ListedConversation>;
96
+ readonly agents: ReadonlyMap<string, ListedAgent>;
97
+ };
88
98
  export type LiveConversations = {
89
99
  readonly deps: ConversationDependencies;
90
100
  readonly held: Cell<HeldFacts>;
91
101
  readonly closing: AbortSignal;
92
102
  readonly listeners: Audience<readonly ConversationEntry[]>;
93
103
  readonly agentListeners: Audience<readonly ConversationAgent[]>;
104
+ readonly listedListeners: Audience<readonly ListedAgent[]>;
94
105
  views(): Iterable<SharedView>;
95
106
  viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
96
107
  readonly view: SharedView;
@@ -118,9 +129,9 @@ export type LiveConversations = {
118
129
  isCreating(conversation: string): boolean;
119
130
  relisting(): boolean;
120
131
  relistBegun(): void;
121
- relistHeard(entries: readonly ListedConversation[]): void;
132
+ relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
122
133
  relistDropped(conversation: string): void;
123
- relistTaken(): ReadonlyMap<string, ListedConversation> | null;
134
+ relistTaken(): Relisted | null;
124
135
  sendingBegan(operation: string): Dispatch;
125
136
  sendingEnded(operation: string, dispatch: Dispatch): void;
126
137
  sending(operation: string): boolean;
@@ -129,6 +140,7 @@ export type LiveConversations = {
129
140
  forget(conversation: string): void;
130
141
  current(): boolean;
131
142
  known(): boolean;
143
+ listed(): boolean;
132
144
  reopened(): void;
133
145
  lost(): void;
134
146
  close(): void;
@@ -1,5 +1,5 @@
1
1
  import type { HeldRow } from './messages.js';
2
- import { type HouseSource } from './source.js';
2
+ import { type HouseSource, type RequestAnswer } from './source.js';
3
3
  export type ConversationLast = {
4
4
  readonly text: string;
5
5
  readonly by: 'owner' | 'agent' | 'house';
@@ -10,18 +10,25 @@ export type ConversationStart = Extract<HouseSource, {
10
10
  }>;
11
11
  export type ConversationAsk = {
12
12
  readonly who: string;
13
+ readonly fromRoom: boolean;
13
14
  readonly agent: string | null;
14
15
  readonly room: {
15
16
  readonly ref: string;
17
+ readonly handle: string;
16
18
  readonly name: string;
17
19
  };
18
20
  readonly prompt: string;
21
+ readonly agentFunction: string | null;
22
+ readonly answer: RequestAnswer | null;
23
+ readonly instruction: string | null;
19
24
  readonly at: string;
20
25
  readonly request: string;
21
26
  readonly message?: string;
22
27
  };
23
28
  export type ConversationHeld = {
24
29
  readonly last: ConversationLast | null;
30
+ readonly answered: string | null;
31
+ readonly opened: string | null;
25
32
  readonly failure: string | null;
26
33
  readonly startedBy: ConversationStart | null;
27
34
  readonly asks: ConversationAsk | null;
@@ -1,10 +1,10 @@
1
1
  import { type Part, type SessionState } from '../session-content/index.js';
2
- import type { AgentEnvironment, ConversationEvent, ConversationMessage, ProcessCommand, SessionOption } from './adapter.js';
2
+ import type { AgentEnvironment, ConversationEvent, ConversationMessage, ListedAgent, ProcessCommand, SessionOption } from './adapter.js';
3
3
  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';
@@ -21,6 +21,7 @@ export type ConversationEntry = ConversationHeld & {
21
21
  finished: string | null;
22
22
  outcome: string | null;
23
23
  waiting: boolean;
24
+ subject: string | null;
24
25
  state: ConversationState;
25
26
  started: string | null;
26
27
  line: string | null;
@@ -30,8 +31,10 @@ export type ConversationEntry = ConversationHeld & {
30
31
  export type ConversationAgent = {
31
32
  identity: string;
32
33
  name: string;
33
- cli?: string;
34
- environment?: AgentEnvironment;
34
+ cli: string;
35
+ model: string | null;
36
+ effort: string | null;
37
+ environment: AgentEnvironment;
35
38
  };
36
39
  export type RunningTurn = {
37
40
  turn: string;
@@ -72,6 +75,8 @@ export type ConversationView = {
72
75
  chatDraft: (ChatDraft & {
73
76
  readonly revision: string;
74
77
  }) | null;
78
+ dismissedSuggestion: string | null;
79
+ pins: readonly string[];
75
80
  };
76
81
  export type RequestDecision = 'approve' | 'decline';
77
82
  export type ConversationSurface = {
@@ -88,11 +93,13 @@ export type ConversationSurface = {
88
93
  rename(conversation: string, name: string, operation: string): Promise<CallResult>;
89
94
  option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
90
95
  retry(conversation: string, message: string, operation: string): Promise<CallResult>;
91
- pins(): Promise<readonly string[]>;
92
96
  pin(figures: readonly string[]): Promise<void>;
93
- openedTurns(): Promise<Readonly<Record<string, string>>>;
94
97
  openTurn(conversation: string, turn: string): Promise<void>;
98
+ dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
99
+ attach(file: File): Promise<ConversationAttachAnswer>;
100
+ attachment(link: string): Promise<BinaryLinkAnswer>;
95
101
  };
102
+ export type ConversationFiles = Pick<ConversationSurface, 'attach' | 'attachment'>;
96
103
  export type ConversationAnswer = {
97
104
  interaction_id: string;
98
105
  response: unknown;
@@ -100,6 +107,7 @@ export type ConversationAnswer = {
100
107
  export type ChatDraftSurface = {
101
108
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
102
109
  prepend(conversation: string, draft: ChatDraft): Promise<void>;
110
+ append(conversation: string, draft: ChatDraft): Promise<void>;
103
111
  discard(conversation: string): Promise<void>;
104
112
  };
105
113
  export declare function unheldView(conversation: string): ConversationView;
@@ -113,15 +121,19 @@ export type Asked = {
113
121
  before: readonly [string, string] | null;
114
122
  total: boolean;
115
123
  };
124
+ export declare function joinedDraft(first: string, second: string): string;
116
125
  export declare function conversationsLearned(alive: LiveConversations): void;
117
- export declare function conversationSurface(alive: LiveConversations): ConversationSurface;
126
+ export declare function conversationSurface(alive: LiveConversations, files: ConversationFiles): ConversationSurface;
118
127
  export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
119
128
  export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
129
+ export declare function reconcileOpening(alive: LiveConversations): Promise<void>;
120
130
  export declare function reconcileConversations(alive: LiveConversations): Promise<void>;
121
131
  export declare function catchUpConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
132
+ export declare function holdsSubmission(alive: LiveConversations, operation: string): Promise<boolean>;
122
133
  export declare function resendConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
123
134
  export declare function watchConversation(alive: LiveConversations, conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
124
135
  export declare function watchConversationList(alive: LiveConversations, deliver: (entries: readonly ConversationEntry[]) => void): () => void;
125
136
  export declare function watchConversationAgents(alive: LiveConversations, deliver: (agents: readonly ConversationAgent[]) => void): () => void;
137
+ export declare function watchListedAgents(alive: LiveConversations, deliver: (agents: readonly ListedAgent[]) => void): () => void;
126
138
  export declare function conversationsChanged(alive: LiveConversations, set: ChangeSet): void;
127
139
  export declare function receiveConversationEvent(alive: LiveConversations, event: ConversationEvent): 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;
@@ -26,4 +27,5 @@ export type RuntimeShell = {
26
27
  };
27
28
  export declare function refusedForSpace(error: unknown): boolean;
28
29
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
30
+ export declare function lossStated(persistence: Persistence, loss: string | null): string | null;
29
31
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -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>;
@@ -0,0 +1,59 @@
1
+ import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
2
+ import { type Reads } from './bootstrap.js';
3
+ import type { Installation, InstallationAmount, RoomCoverage } from './readiness.js';
4
+ import { advancement, type Refresher } from './refresh.js';
5
+ import type { ReplicaRecord } from './replica.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import type { Live } from './socket.js';
8
+ import { type CoveredRoom, type InstallHold, type RuntimeStore, type Store } from './store.js';
9
+ import { type Unconfirmed } from './transfer.js';
10
+ type Standing = {
11
+ readonly key: number | null;
12
+ readonly confirmed: number;
13
+ };
14
+ export type Unheld = {
15
+ readonly staged: boolean;
16
+ };
17
+ export type Withheld = AdapterFailure | RetryableRefusal | NotReady | Unconfirmed;
18
+ type Landing = {
19
+ readonly kind: 'refreshed';
20
+ readonly from: Standing;
21
+ readonly remodelled: boolean;
22
+ } | {
23
+ readonly kind: 'bootstrapped';
24
+ readonly refreshed: boolean;
25
+ readonly from: Standing;
26
+ };
27
+ type Refreshed = {
28
+ kind: 'advanced';
29
+ record: ReplicaRecord;
30
+ from: Standing;
31
+ remodelled: boolean;
32
+ } | Exclude<Awaited<ReturnType<typeof advancement>>, {
33
+ kind: 'advanced';
34
+ }>;
35
+ export declare const ERASE_BATCH = 512;
36
+ export type InstallShare = {
37
+ readonly installing: boolean;
38
+ readonly downloading: boolean;
39
+ readonly bytes: InstallationAmount;
40
+ };
41
+ export declare function installShare(store: Store, { room, state }: RoomCoverage, held: ReadonlyMap<string, CoveredRoom>): InstallShare;
42
+ export declare function installationOf(installing: number, downloading: number, bytes: InstallationAmount): Installation;
43
+ export declare function roomInFlight(store: Store, locator: string): boolean;
44
+ export declare function sweep({ store, socket }: Runtime): void;
45
+ export declare function caughtUpTo(runtime: Runtime, locator: string): void;
46
+ export declare function catching(store: Store, locator: string): void;
47
+ export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
48
+ export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
49
+ export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
50
+ export declare function replaced(store: Store, locators: readonly string[]): void;
51
+ export declare function reachedBy({ store, socket }: Runtime, locator: string, roomVersion: string): Promise<boolean>;
52
+ export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
53
+ export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
54
+ export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
55
+ export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | import("./adapter.js").TransportUncertainty | Unconfirmed | {
56
+ readonly kind: 'transport-uncertainty';
57
+ } | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
58
+ export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
59
+ export {};
@@ -1,23 +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';
4
- import { type ModelState, type TypesResult } from './model.js';
3
+ import { type Composition } from './collection.js';
4
+ import type { KeyedChange } from './observation.js';
5
+ import { type MdType, type ModelState, type TypesResult } from './model.js';
5
6
  import { type PortReach } from './reach.js';
6
7
  import type { ReplicaRecord } from './replica.js';
7
8
  import type { Runtime } from './runtime.js';
8
9
  import type { Stored } from './store.js';
9
- export type AppTypedSelection = {
10
+ type Selection<Model> = {
10
11
  roots: readonly string[];
11
- model: TypesResult;
12
+ model: Model;
12
13
  };
13
- export type AppRoom = {
14
+ type Shown<Model> = {
14
15
  name: string;
15
16
  locator: string;
16
17
  handle: string;
17
18
  operations: OperationScopes;
18
19
  replica: ReplicaAdmission;
19
- model: TypesResult;
20
- typedSelection: AppTypedSelection | null;
20
+ model: Model;
21
+ typedSelection: Selection<Model> | null;
21
22
  providerOwnedPaths: readonly string[];
22
23
  authoredPaths: readonly string[];
23
24
  roomVersion: string | null;
@@ -25,12 +26,21 @@ export type AppRoom = {
25
26
  synchronizationAvailable: boolean;
26
27
  refusal: ProviderRefusal | null;
27
28
  locked: boolean;
29
+ queriesOnly?: true;
28
30
  };
29
- type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
30
- type ListedEntry = ListedRoom & {
31
- 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;
32
38
  };
39
+ export type ListedEntry = Omit<Shown<ModelState>, 'locked'>;
33
40
  export type Listing = ReadonlyMap<string, ListedEntry>;
41
+ export type RoomsChange = KeyedChange<string, ListedRoom> & {
42
+ readonly models: ListedModels;
43
+ };
34
44
  export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
35
45
  export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
36
46
  export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
@@ -38,9 +48,11 @@ export declare function declarationOf({ presence }: Runtime, locator: string, st
38
48
  readonly available: boolean;
39
49
  } | undefined;
40
50
  export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
41
- export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
51
+ export declare function listedOrHeld({ presence }: Runtime, held: ReadonlyMap<string, unknown>, locator: string): boolean;
52
+ export declare function listedEntries(runtime: Runtime, touched: readonly string[]): Promise<readonly ListedEntry[] | null>;
42
53
  export declare function listingNow(runtime: Runtime): Promise<Listing>;
43
- export declare function shownRooms({ presence }: Runtime, listing: Listing): readonly AppRoom[];
54
+ export declare function shownRooms(runtime: Runtime, listing: Listing): ListedRooms;
55
+ export declare function shownChange(runtime: Runtime, entries: readonly ListedEntry[]): RoomsChange;
44
56
  export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
45
57
  export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
46
58
  export declare function name(runtime: Runtime, locator: string): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  import type { ChangeSet } from './change-set.js';
2
2
  import { type KeyedResult, type QueryMessage } from './observation.js';
3
- import type { PendingResult, Plan, QueryCoverage } from './query.js';
3
+ import type { PendingResult, PendingRoom, Plan, QueryCoverage } from './query.js';
4
4
  import type { Fail } from './reach.js';
5
5
  import type { QueryRoom } from './tables.js';
6
6
  export type Cover = {
@@ -11,12 +11,14 @@ export type Ran = KeyedResult & {
11
11
  readonly current: () => boolean;
12
12
  };
13
13
  export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
14
+ export type PendingAt<H> = (held: H, rooms: readonly string[]) => ReadonlyMap<string, PendingRoom | null> | null;
14
15
  type Listener = (message: QueryMessage) => void;
15
16
  export type LiveQueries<H> = {
16
17
  touched(set: ChangeSet): void;
17
- recover(): void;
18
- watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
18
+ recover(locators?: readonly string[]): void;
19
+ watch(plan: Plan, identity: string, cover: (held: H) => Cover, pendingAt: PendingAt<H>, deliver: Listener, failed: Fail): () => void;
19
20
  close(): void;
20
21
  };
22
+ export declare function readerOf(plan: Plan): (locator: string) => boolean;
21
23
  export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
22
24
  export {};
@@ -1,7 +1,24 @@
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";
6
+ export declare const DIAGRAM = "md-diagram";
7
+ export declare const VIEWING = "ahc-viewer";
4
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
+ };
5
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>;
20
+ export declare function rendered(element: Element): boolean;
21
+ export declare function viewable(element: Element): boolean;
22
+ export declare function viewFile(client: MdRuntimeClient, media: Element): void;
6
23
  export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
7
24
  export {};
@@ -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 substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\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;
@@ -22,6 +22,8 @@ export type HeldRow = {
22
22
  readonly role: string | null;
23
23
  readonly at: string | null;
24
24
  } | null;
25
+ readonly answered: string | null;
26
+ readonly openedTurn: string | null;
25
27
  readonly failure: string | null;
26
28
  readonly opened: HeldSource | null;
27
29
  readonly asking: (HeldSource & {
@@ -30,6 +32,12 @@ export type HeldRow = {
30
32
  readonly at: string | null;
31
33
  }) | null;
32
34
  };
35
+ export type ConversationFact = 'openedTurn' | 'dismissedSuggestion';
36
+ export type HeldFact = {
37
+ readonly conversation: string;
38
+ readonly name: ConversationFact;
39
+ readonly value: string;
40
+ };
33
41
  export type ConversationWrite = {
34
42
  readonly conversation: string;
35
43
  readonly messages: readonly AcceptedMessage[];
@@ -44,5 +52,6 @@ export declare function messageWindow(connection: Connection, conversation: stri
44
52
  export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
45
53
  export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
46
54
  export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
47
- export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
48
- export declare function forgottenMessages(connection: Connection): void;
55
+ export declare function conversationFacts(connection: Connection): HeldFact[];
56
+ export declare function keptFact(connection: Connection, { conversation, name, value }: HeldFact): null;
57
+ export declare function forgottenConversations(connection: Connection): void;
@@ -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;