@agentshouse/app-bridge 0.1.0-cfb5ca35059bb → 0.1.0-cfbb2e428ff88

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 +4 -4
  2. package/dist/index.d.ts +56 -36
  3. package/dist/mdmodel/definition.d.ts +1 -1
  4. package/dist/mdmodel/event.d.ts +77 -0
  5. package/dist/mdmodel/facts.d.ts +14 -0
  6. package/dist/mdmodel/index.d.ts +17 -5
  7. package/dist/mdmodel/kinds.d.ts +18 -0
  8. package/dist/mdmodel/query/language.d.ts +222 -0
  9. package/dist/mdmodel/query/match.d.ts +13 -0
  10. package/dist/mdmodel/query/rows.d.ts +31 -0
  11. package/dist/mdmodel/query/sql.d.ts +38 -0
  12. package/dist/mdmodel/reserved.d.ts +4 -0
  13. package/dist/mdmodel/types.d.ts +7 -0
  14. package/dist/mdmodel/validate.d.ts +4 -3
  15. package/dist/mdruntime/adapter.d.ts +25 -9
  16. package/dist/mdruntime/chain.d.ts +2 -1
  17. package/dist/mdruntime/client.d.ts +8 -3
  18. package/dist/mdruntime/collection.d.ts +2 -1
  19. package/dist/mdruntime/compile.d.ts +1 -6
  20. package/dist/mdruntime/connection.d.ts +8 -6
  21. package/dist/mdruntime/conversation.d.ts +5 -4
  22. package/dist/mdruntime/durability.d.ts +6 -0
  23. package/dist/mdruntime/identity.d.ts +0 -1
  24. package/dist/mdruntime/messages.d.ts +2 -2
  25. package/dist/mdruntime/model.d.ts +2 -7
  26. package/dist/mdruntime/observation.d.ts +2 -2
  27. package/dist/mdruntime/query.d.ts +3 -208
  28. package/dist/mdruntime/reach.d.ts +6 -6
  29. package/dist/mdruntime/readiness.d.ts +0 -2
  30. package/dist/mdruntime/replica.d.ts +8 -5
  31. package/dist/mdruntime/room-draft.d.ts +4 -3
  32. package/dist/mdruntime/search.d.ts +12 -63
  33. package/dist/mdruntime/store.d.ts +4 -7
  34. package/dist/mdruntime/stored.d.ts +3 -4
  35. package/dist/mdruntime/tables.d.ts +8 -6
  36. package/dist/mdruntime/wire.d.ts +9 -0
  37. package/dist/test-host.js +1 -0
  38. package/docs/families.md +14 -1
  39. package/package.json +1 -1
  40. package/dist/mdmodel/condition.d.ts +0 -179
  41. package/dist/mdruntime/fulltext.d.ts +0 -26
@@ -1,93 +1,7 @@
1
- import { type Definition } from '../mdmodel/index.js';
1
+ import { type HeldRooms, type QueryPlan } from '../mdmodel/index.js';
2
2
  import type { HeadChange } from './adapter.js';
3
3
  import type { BinaryFileRecord } from './binary.js';
4
4
  import type { Open } from './open.js';
5
- export type Value = string | number | boolean | null;
6
- export type Predicate = Value | {
7
- $eq: Value;
8
- } | {
9
- $ne: Value;
10
- } | {
11
- $in: readonly Value[];
12
- } | {
13
- $nin: readonly Value[];
14
- } | {
15
- $gt?: Value;
16
- $gte?: Value;
17
- $lt?: Value;
18
- $lte?: Value;
19
- } | {
20
- $all: readonly Value[];
21
- } | {
22
- $size: number;
23
- } | {
24
- $exists: boolean;
25
- };
26
- export type Where = {
27
- $and?: readonly Where[];
28
- $or?: readonly Where[];
29
- [field: string]: Predicate | readonly Where[] | undefined;
30
- };
31
- export type Related = {
32
- types?: readonly string[];
33
- where?: Where;
34
- pathPrefix?: string;
35
- };
36
- export type Filter = {
37
- rooms?: readonly string[];
38
- types?: readonly string[];
39
- where?: Where;
40
- pathPrefix?: string;
41
- folder?: string;
42
- paths?: readonly string[];
43
- hop?: Related & {
44
- field: string;
45
- };
46
- backlinks?: Related & {
47
- field?: string;
48
- };
49
- };
50
- export type Key = 'room' | 'path' | 'type' | 'folder' | {
51
- field: string;
52
- };
53
- export type Select = 'all' | {
54
- fields?: 'all' | readonly string[];
55
- sections?: 'all' | readonly string[];
56
- preamble?: true;
57
- markdown?: true;
58
- backlinks?: true;
59
- change?: true;
60
- fileId?: true;
61
- revision?: true;
62
- };
63
- export type OrderOptions = {
64
- nulls?: 'first' | 'last';
65
- stringSort?: 'lexical' | 'locale';
66
- locale?: string;
67
- localeOptions?: Readonly<Record<string, unknown>>;
68
- };
69
- export type Direction = 'asc' | 'desc';
70
- export type DocumentQuery = Filter & {
71
- select: Select;
72
- orderBy?: readonly ({
73
- by: Key;
74
- direction?: Direction;
75
- } & OrderOptions)[];
76
- limit?: number;
77
- after?: string;
78
- total?: true;
79
- };
80
- export type GroupQuery = Filter & {
81
- groupBy: readonly Exclude<Key, 'path'>[];
82
- orderBy?: readonly {
83
- by: 'count' | Exclude<Key, 'path'>;
84
- direction?: Direction;
85
- }[];
86
- limit?: number;
87
- after?: string;
88
- total?: true;
89
- };
90
- export type LocalQuery = DocumentQuery | GroupQuery;
91
5
  export type Backlink = {
92
6
  path: string;
93
7
  type: string;
@@ -147,91 +61,6 @@ export type GroupResult = GroupRows & {
147
61
  coverage: QueryCoverage;
148
62
  };
149
63
  export type QueryResult = DocumentResult | GroupResult | PendingResult;
150
- export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
151
- export type RoomFacts = {
152
- locator: string;
153
- available: boolean;
154
- types: readonly Definition[];
155
- };
156
- export type HeldRooms = {
157
- listed: boolean;
158
- rooms: readonly RoomFacts[];
159
- };
160
- export type Test = {
161
- op: 'eq';
162
- value: Value;
163
- } | {
164
- op: 'ne';
165
- value: Value;
166
- } | {
167
- op: 'in';
168
- values: readonly Value[];
169
- } | {
170
- op: 'nin';
171
- values: readonly Value[];
172
- } | {
173
- op: 'range';
174
- bounds: readonly (readonly ['gt' | 'gte' | 'lt' | 'lte', Value])[];
175
- } | {
176
- op: 'all';
177
- values: readonly Value[];
178
- } | {
179
- op: 'size';
180
- size: number;
181
- } | {
182
- op: 'exists';
183
- exists: boolean;
184
- };
185
- export type Condition = {
186
- every: readonly Condition[];
187
- } | {
188
- some: readonly Condition[];
189
- } | {
190
- field: string;
191
- test: Test;
192
- };
193
- export type Scope = {
194
- types: readonly string[] | null;
195
- where: Condition | null;
196
- pathPrefix: string | null;
197
- };
198
- export type KeyPlan = {
199
- of: 'room';
200
- } | {
201
- of: 'path';
202
- } | {
203
- of: 'type';
204
- } | {
205
- of: 'folder';
206
- } | {
207
- of: 'field';
208
- field: string;
209
- };
210
- export type DocumentShape = {
211
- kind: 'documents';
212
- fields: 'all' | readonly string[] | null;
213
- sections: 'all' | readonly string[] | null;
214
- preamble: boolean;
215
- markdown: boolean;
216
- backlinks: boolean;
217
- change: boolean;
218
- fileId: boolean;
219
- revision: boolean;
220
- orderBy: readonly {
221
- key: KeyPlan;
222
- options: OrderOptions & {
223
- direction: Direction;
224
- };
225
- }[];
226
- };
227
- export type GroupShape = {
228
- kind: 'groups';
229
- groupBy: readonly KeyPlan[];
230
- orderBy: readonly {
231
- by: 'count' | number;
232
- direction: Direction;
233
- }[];
234
- };
235
64
  export type PlanArea = {
236
65
  room: string;
237
66
  path: string;
@@ -242,42 +71,8 @@ export type PlanReach = {
242
71
  documents: readonly string[];
243
72
  areas: readonly PlanArea[];
244
73
  };
245
- export type Continuation = {
246
- text: string;
247
- values: readonly unknown[] | null;
248
- };
249
- export type Plan = {
250
- key: string;
251
- rooms: readonly string[] | null;
74
+ export type Plan = QueryPlan & {
252
75
  reach: PlanReach | null;
253
76
  locked: readonly string[];
254
- root: Scope;
255
- folder: string | null;
256
- paths: readonly string[] | null;
257
- hop: (Scope & {
258
- field: string;
259
- }) | null;
260
- backlinks: (Scope & {
261
- field: string | null;
262
- }) | null;
263
- shape: DocumentShape | GroupShape;
264
- limit: number | null;
265
- after: Continuation | null;
266
- total: boolean;
267
77
  };
268
- export declare class QueryError extends Error {
269
- readonly code: QueryErrorCode;
270
- readonly retryable = false;
271
- constructor(code: QueryErrorCode, at: string, problem: string);
272
- }
273
- type Entries = Readonly<Record<string, unknown>>;
274
- export declare function invalid(at: string, problem: string): never;
275
- export declare function plain(value: unknown): value is Entries;
276
- export declare function known(value: Entries, allowed: readonly string[], at: string): void;
277
- export declare function flag(input: unknown, at: string): boolean;
278
- export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
279
- export declare function limitOf(input: unknown): number | null;
280
- export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
281
- export declare function queryKey(query: unknown): string;
282
- export declare function identityOf(plan: Plan): string;
283
- export {};
78
+ export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
@@ -1,7 +1,7 @@
1
1
  import type { AppRoom, MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
2
2
  import type { Plan, PlanReach, QueryResult } from './query.js';
3
3
  import type { Readiness } from './readiness.js';
4
- import { type SearchResult } from './search.js';
4
+ import type { SearchResult } from './search.js';
5
5
  export type ReachedDocument = {
6
6
  readonly room: string;
7
7
  readonly path: string;
@@ -18,20 +18,20 @@ export type PortReach = {
18
18
  readonly conversations: boolean;
19
19
  };
20
20
  export type Deliver = (message: unknown) => void;
21
- export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver) => () => void;
21
+ export type Fail = (error: unknown) => void;
22
+ export type Watch = (topic: RuntimeTopic, input: readonly unknown[], deliver: Deliver, fail: Fail) => () => void;
22
23
  export type RuntimeView = {
23
24
  md: MdRuntime;
24
25
  watch: Watch;
25
26
  };
26
27
  export type NarrowedView = RuntimeView & {
27
28
  narrow(reach: PortReach | null): void;
28
- facts(port: ReadinessPort): void;
29
29
  };
30
30
  export type Reachable = RuntimeView & {
31
31
  plan(input: unknown, reach: PortReach | null): Plan;
32
32
  query(plan: Plan): Promise<QueryResult>;
33
- watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
34
- search(input: unknown, reach: PortReach | null, locked: readonly string[]): Promise<SearchResult>;
33
+ watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
34
+ search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
35
35
  watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
36
36
  locked(room: string): boolean;
37
37
  lockedRooms(): readonly string[];
@@ -50,4 +50,4 @@ export declare function governs(reach: PortReach | null, room: {
50
50
  readonly selection: boolean;
51
51
  };
52
52
  export declare function planReach(reach: PortReach | null): PlanReach | null;
53
- export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
53
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
@@ -6,13 +6,11 @@ export type RoomCoverage = {
6
6
  readonly state: RoomPreparation;
7
7
  };
8
8
  export type ConversationCoverage = Open<'complete' | 'acquiring' | 'undeclared'>;
9
- export type SearchObligation = Open<'required' | 'unused'>;
10
9
  export type TargetCoverage = {
11
10
  readonly complete: boolean;
12
11
  readonly listed: boolean;
13
12
  readonly rooms: readonly RoomCoverage[];
14
13
  readonly conversations: ConversationCoverage;
15
- readonly search: SearchObligation;
16
14
  };
17
15
  export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
18
16
  export type Durability = Open<'persistent' | 'best-effort'>;
@@ -1,4 +1,5 @@
1
- import type { BootstrapInventory, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
1
+ import { type TypedPath } from '../mdmodel/index.js';
2
+ import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
2
3
  import { type ChangeBatch, type Precondition } from './change.js';
3
4
  import { type Collection, type Composition } from './collection.js';
4
5
  import { type ModelState } from './model.js';
@@ -31,14 +32,16 @@ export type VisibleLayer = Layer & {
31
32
  };
32
33
  export type Slice = Layer & {
33
34
  readonly written: Readonly<Record<string, string>>;
35
+ readonly facts: Readonly<Record<string, SavedFacts>>;
34
36
  readonly held: ReadonlySet<string>;
35
37
  };
36
- export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState): Composition;
38
+ export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
37
39
  export declare function storedRecord(record: ReplicaRecord): string;
38
40
  export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
41
+ export type LayerEntry = Omit<StoredEntry, 'facts'>;
39
42
  export declare function entryAt(layer: Layer & {
40
43
  readonly written?: Readonly<Record<string, string>>;
41
- }, path: string): StoredEntry | null;
44
+ }, path: string): LayerEntry | null;
42
45
  export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
43
46
  export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
44
47
  export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
@@ -47,7 +50,7 @@ export type Replayed = {
47
50
  readonly touched: ReadonlySet<string>;
48
51
  };
49
52
  export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
50
- export declare function overlayOf(visible: Layer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
53
+ export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
51
54
  export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
52
55
  export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
53
56
  export type Standing = {
@@ -63,5 +66,5 @@ export type Returned = {
63
66
  readonly removed: readonly string[];
64
67
  };
65
68
  export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
66
- export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
69
+ export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
67
70
  export {};
@@ -90,9 +90,9 @@ type ChangedUnderneath = {
90
90
  readonly file?: string | null;
91
91
  };
92
92
  export type ReturnReason = ProviderRefusal & {
93
- readonly kind: Open<'conflicted' | 'rejected' | 'expired' | 'withdrawn'>;
93
+ readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
94
94
  };
95
- export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
95
+ export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
96
96
  export type RoomDraft = {
97
97
  readonly room: string;
98
98
  readonly path: string;
@@ -127,13 +127,14 @@ export type SavedDraft = {
127
127
  readonly path: string;
128
128
  readonly parts: HeldParts;
129
129
  };
130
- export declare function readParts(value: unknown): RoomDraftParts;
130
+ export declare function readParts(value: unknown, path: string): RoomDraftParts;
131
131
  export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
132
132
  export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
133
133
  export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
134
134
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
135
135
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
136
136
  export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
137
+ export declare function lineEnded(text: string): string;
137
138
  export type TextParts = {
138
139
  readonly fields?: Readonly<Record<string, {
139
140
  readonly value: unknown;
@@ -1,72 +1,21 @@
1
- import type { ProviderRefusal } from './adapter.js';
2
- import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
3
- import type { Open } from './open.js';
4
- export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
1
+ import type { ProviderRefusal, SearchHit } from './adapter.js';
2
+ import type { Failure, Offline } from './outcome.js';
5
3
  export type SearchRequest = {
6
4
  text: string;
7
- documents?: Filter;
8
- collection?: true;
9
- conversations?: readonly string[];
10
- limit?: number;
11
- after?: string;
12
- total?: true;
5
+ rooms?: readonly string[];
13
6
  };
14
- export type MessagePart = Open<'text'>;
15
- export type Snippet<Part extends string> = {
16
- part: Part;
17
- text: string;
18
- at: readonly [number, number];
19
- };
20
- export type DocumentHit = {
21
- room: string;
22
- path: string;
23
- type: string;
24
- score: number;
25
- matches: Readonly<Record<string, readonly DocumentPart[]>>;
26
- snippet?: Snippet<DocumentPart>;
27
- };
28
- export type MessageHit = {
29
- conversation: string;
30
- identity: string;
31
- score: number;
32
- matches: Readonly<Record<string, readonly MessagePart[]>>;
33
- snippet?: Snippet<MessagePart>;
34
- };
35
- export type SearchCoverage = {
36
- rooms: readonly CoveredRoom[];
37
- conversations: readonly string[];
38
- overlay: readonly string[];
7
+ export type { SearchHit } from './adapter.js';
8
+ export type SearchFound = {
9
+ kind: 'found';
10
+ documents: readonly SearchHit[];
39
11
  };
40
- export type SearchHits = {
41
- documents: readonly DocumentHit[];
42
- messages: readonly MessageHit[];
43
- };
44
- export type SearchWindow = SearchHits & {
45
- next?: string;
46
- total?: {
47
- documents: number;
48
- messages: number;
49
- };
50
- };
51
- export type SearchPending = SearchHits & {
52
- pending: readonly PendingRoom[];
53
- coverage: SearchCoverage;
54
- };
55
- export type SearchUndeclared = ProviderRefusal & {
12
+ export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
13
+ kind: 'rejected';
14
+ }) | (ProviderRefusal & {
56
15
  kind: 'undeclared';
57
- };
58
- export type SearchResult = (SearchWindow & {
59
- coverage: SearchCoverage;
60
- }) | SearchPending | SearchUndeclared;
61
- export declare function undeclaredSearch(): SearchUndeclared;
62
- export type HitCursor = readonly [number, string, string] | readonly [] | null;
16
+ }) | Failure;
63
17
  export type SearchPlan = {
64
18
  text: string;
65
- documents: unknown;
66
- collection: boolean;
67
- conversations: readonly string[] | null;
68
- limit: number | null;
69
- after: readonly [HitCursor, HitCursor] | null;
70
- total: boolean;
19
+ rooms: readonly string[] | null;
71
20
  };
72
21
  export declare function searchPlanOf(input: unknown): SearchPlan;
@@ -6,8 +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 { SearchWindow } from './search.js';
10
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
9
+ import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
11
10
  export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
12
11
  export type TransferRecord = {
13
12
  readonly locator: string;
@@ -97,7 +96,6 @@ export type Commit = {
97
96
  readonly writes?: readonly AuthoredWrite[];
98
97
  readonly files?: readonly StoredFile[];
99
98
  readonly whole?: boolean;
100
- readonly discards?: readonly string[];
101
99
  };
102
100
  export type RuntimeStore = {
103
101
  opened(): Promise<Opened>;
@@ -106,14 +104,13 @@ export type RuntimeStore = {
106
104
  changes(keys: readonly number[]): number;
107
105
  entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
108
106
  typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
109
- referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
107
+ referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
110
108
  files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
111
109
  readonly path: string;
112
110
  readonly revision: string;
113
111
  }[]>;
114
112
  folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
115
113
  typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
116
- search(ask: SearchAsk): Promise<SearchWindow>;
117
114
  stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
118
115
  refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
119
116
  unrefresh(key: number): Promise<void>;
@@ -134,8 +131,8 @@ export type RuntimeStore = {
134
131
  present(record: PresentationRecord): Promise<void>;
135
132
  conversations(): Promise<readonly HeldConversation[]>;
136
133
  keepMessages(write: ConversationWrite): Promise<void>;
137
- messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
138
- messageCount(conversation: string): Promise<number>;
134
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
135
+ messageCount(conversation: string, phrase?: string | null): Promise<number>;
139
136
  turnArrived(conversation: string, turn: string): Promise<boolean>;
140
137
  dropConversations(conversations: readonly string[]): Promise<void>;
141
138
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
@@ -1,4 +1,4 @@
1
- import type { HeadChange } from './adapter.js';
1
+ import type { SavedFacts, HeadChange } from './adapter.js';
2
2
  import { type Composed, type Composition } from './collection.js';
3
3
  import type { HeldBinary } from './overlay.js';
4
4
  import type { Connection } from './tables.js';
@@ -12,6 +12,7 @@ export type StoredEntry = {
12
12
  readonly fileId: string | null;
13
13
  readonly change: HeadChange | null;
14
14
  readonly written: string | null;
15
+ readonly facts: SavedFacts | null;
15
16
  };
16
17
  export type OverlayEntry = StoredEntry & {
17
18
  readonly present: boolean;
@@ -27,14 +28,12 @@ export type TypedEntry = {
27
28
  export type Referrer = {
28
29
  readonly path: string;
29
30
  readonly target: string;
30
- readonly kind: string;
31
31
  };
32
32
  export type HeldKey = {
33
33
  readonly key: number;
34
34
  readonly locator: string;
35
35
  readonly transfer: string;
36
36
  readonly rederiving: number | null;
37
- readonly searching: number | null;
38
37
  };
39
38
  export type ReplicaOpened = {
40
39
  readonly rooms: readonly {
@@ -118,7 +117,7 @@ export declare function rederive(connection: Connection, key: number, composed:
118
117
  };
119
118
  export declare function entries(connection: Connection, key: number, view: View, list: readonly string[]): HeldEntry[];
120
119
  export declare function typed(connection: Connection, key: number, view: View, list: readonly string[]): TypedEntry[];
121
- export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[], kinds: readonly string[]): Referrer[];
120
+ export declare function referrers(connection: Connection, key: number, view: View, targets: readonly string[]): Referrer[];
122
121
  export declare function files(connection: Connection, key: number, view: View, after: string | null, limit: number): {
123
122
  readonly path: string;
124
123
  readonly revision: string;
@@ -1,13 +1,11 @@
1
1
  import { type QueryAnswer, type QueryRoom } from './compile.js';
2
2
  import type { Composed } from './collection.js';
3
- import { type SearchAsk } from './fulltext.js';
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 { SearchWindow } from './search.js';
7
6
  import { type Committed, type CountedRoom, type HeldEntry, type ReplicaOpened, type Referrer, type RoomCommit, type StoredEntry, type TypedEntry, type View } from './stored.js';
8
7
  export type { Committed, CountedRoom, HeldEntry, OverlayEntry, ReplicaOpened, Referrer, RoomCommit, StoredEntry, TypedEntry, View, } from './stored.js';
9
8
  export type { QueryAnswer, QueryRoom } from './compile.js';
10
- export type { SearchAsk } from './fulltext.js';
11
9
  export type { ConversationWrite, HeldConversation, MessageWindow } from './messages.js';
12
10
  export type Value = string | number | bigint | Uint8Array | null;
13
11
  export type Row = Readonly<Record<string, Value>>;
@@ -36,6 +34,10 @@ export interface SqliteStatement {
36
34
  }
37
35
  export interface SqliteDatabase {
38
36
  readonly pointer: number;
37
+ createFunction(name: string, run: (context: number, ...values: Value[]) => Value, options: {
38
+ readonly arity: number;
39
+ readonly deterministic: true;
40
+ }): unknown;
39
41
  exec(options: {
40
42
  readonly sql: string;
41
43
  readonly bind: readonly Value[];
@@ -107,7 +109,6 @@ export type AuthoredWrite = {
107
109
  readonly writes: readonly AuthoredRows[];
108
110
  readonly files: readonly StoredFile[];
109
111
  readonly whole: boolean;
110
- readonly discards?: readonly string[];
111
112
  };
112
113
  export interface RuntimeRequests {
113
114
  readonly 'authored.queues': Asked<Nothing, HeldQueues>;
@@ -115,6 +116,7 @@ export interface RuntimeRequests {
115
116
  readonly 'authored.chatDrafts': Asked<Nothing, readonly string[]>;
116
117
  readonly 'authored.calls': Asked<Nothing, readonly string[]>;
117
118
  readonly 'authored.fences': Asked<Nothing, readonly string[]>;
119
+ readonly 'authored.unsent': Asked<Nothing, readonly UnsentWork[]>;
118
120
  readonly 'authored.fact': Asked<{
119
121
  readonly name: AuthoredFact;
120
122
  }, string | null>;
@@ -175,7 +177,6 @@ export interface RuntimeRequests {
175
177
  readonly key: number;
176
178
  readonly view: View;
177
179
  readonly targets: readonly string[];
178
- readonly kinds: readonly string[];
179
180
  }, readonly Referrer[]>;
180
181
  readonly 'replica.files': Asked<{
181
182
  readonly key: number;
@@ -200,7 +201,6 @@ export interface RuntimeRequests {
200
201
  readonly 'replica.counts': Asked<{
201
202
  readonly rooms: readonly CountedRoom[];
202
203
  }, readonly number[]>;
203
- readonly 'replica.search': Asked<SearchAsk, SearchWindow>;
204
204
  readonly 'replica.stage': Asked<{
205
205
  readonly locator: string;
206
206
  readonly transfer: string;
@@ -294,9 +294,11 @@ export interface RuntimeRequests {
294
294
  readonly conversation: string;
295
295
  readonly limit: number;
296
296
  readonly before: readonly [string, string] | null;
297
+ readonly phrase: string | null;
297
298
  }, MessageWindow>;
298
299
  readonly 'conversation.count': Asked<{
299
300
  readonly conversation: string;
301
+ readonly phrase: string | null;
300
302
  }, number>;
301
303
  readonly 'conversation.turn': Asked<{
302
304
  readonly conversation: string;
@@ -82,6 +82,14 @@ declare const MEMBERS: {
82
82
  readonly reach: 'whole';
83
83
  readonly effect: 'write';
84
84
  };
85
+ readonly unsent: {
86
+ readonly reach: 'whole';
87
+ readonly effect: 'read';
88
+ };
89
+ readonly reset: {
90
+ readonly reach: 'whole';
91
+ readonly effect: 'write';
92
+ };
85
93
  readonly persistence: {
86
94
  readonly reach: 'runtime';
87
95
  readonly effect: 'read';
@@ -176,6 +184,7 @@ declare const TOPICS: {
176
184
  readonly 'sync-status': 'within';
177
185
  readonly 'service-mode': 'runtime';
178
186
  readonly member: 'runtime';
187
+ readonly 'authority-changes': 'runtime';
179
188
  readonly query: 'within';
180
189
  readonly queue: 'within';
181
190
  readonly 'room-drafts': 'within';
package/dist/test-host.js CHANGED
@@ -129,6 +129,7 @@ export function createHouseBridgeTestHost(options = {}) {
129
129
  },
130
130
  install: () => Promise.resolve('manual'),
131
131
  notifications: () => Promise.resolve('unavailable'),
132
+ telegram: () => Promise.resolve({ state: 'unavailable', name: null, username: null }),
132
133
  setBadge: () => Promise.resolve(),
133
134
  setTab(tab) {
134
135
  tabs.push(tab);
package/docs/families.md CHANGED
@@ -13,7 +13,8 @@
13
13
  absolute path, carries its current address as the return target, and the page
14
14
  returns there when it completes. An App names an address House gave it in a
15
15
  reading and composes one only for `/bind/<app_ref>`, where the User binds
16
- its Rooms, with `?slot=<name>` to open at one slot.
16
+ its Rooms, with `?slot=<name>` to open at one slot, and `/sign-out`, which
17
+ signs the User out and opens sign-in.
17
18
  - **Installation** - `install()` offers the page as a Home-screen app. Where the
18
19
  browser has an install prompt ready the shell shows it and the call resolves
19
20
  `'accepted'` or `'dismissed'` with the User's choice, spending that prompt;
@@ -33,6 +34,18 @@
33
34
  click. `setBadge(unread)` takes the identifiers of the Human Notifications
34
35
  unread in this storage and sets the icon's badge to their number, or clears
35
36
  it at none, where the browser shows one.
37
+ - **Telegram** - House's own panel alone, refused to an App or a Site the same
38
+ way. `telegram()` answers `{ state, name, username }`: `state` is
39
+ `'available'` where the page runs inside a House bot's Mini App that gave it
40
+ Telegram's launch data naming an account, with that account's `name` and its
41
+ `username` or `null`, and `'unavailable'` with both `null` elsewhere.
42
+ `telegram(true)` links the signed-in User to that account and answers
43
+ `'linked'` with it; where the User's sign-in is
44
+ not recent, the page goes to sign in again, and nothing links until a later
45
+ `telegram(true)`.
46
+ Telegram's refusal rejects with an error coded `linked_elsewhere`,
47
+ `rate_limited` or `refused`, and a failed request with the browser's own
48
+ error name.
36
49
  - **Status** - the App reference the runtime client is attached under,
37
50
  `preferences`: the `roomRef` and Path of the App's own preferences document,
38
51
  or `null` until the runtime holds that Room, sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/app-bridge",
3
- "version": "0.1.0-cfb5ca35059bb",
3
+ "version": "0.1.0-cfbb2e428ff88",
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",