@agentshouse/app-bridge 0.1.0-ca559eade7c19 → 0.1.0-ca61ac777c0b7

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 (108) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +1033 -20
  3. package/dist/mdmodel/definition.d.ts +18 -1
  4. package/dist/mdmodel/document.d.ts +10 -6
  5. package/dist/mdmodel/event.d.ts +77 -0
  6. package/dist/mdmodel/facts.d.ts +14 -0
  7. package/dist/mdmodel/index.d.ts +25 -11
  8. package/dist/mdmodel/kinds.d.ts +17 -0
  9. package/dist/mdmodel/markdown.d.ts +50 -0
  10. package/dist/mdmodel/paths.d.ts +9 -1
  11. package/dist/mdmodel/pattern.d.ts +9 -0
  12. package/dist/mdmodel/project.d.ts +1 -0
  13. package/dist/mdmodel/query/language.d.ts +253 -0
  14. package/dist/mdmodel/query/match.d.ts +13 -0
  15. package/dist/mdmodel/query/rows.d.ts +31 -0
  16. package/dist/mdmodel/query/sql.d.ts +38 -0
  17. package/dist/mdmodel/reserved.d.ts +5 -0
  18. package/dist/mdmodel/types.d.ts +46 -5
  19. package/dist/mdmodel/validate.d.ts +31 -4
  20. package/dist/mdruntime/actions.d.ts +19 -0
  21. package/dist/mdruntime/adapter.d.ts +161 -116
  22. package/dist/mdruntime/attached-model.d.ts +7 -0
  23. package/dist/mdruntime/binary.d.ts +0 -5
  24. package/dist/mdruntime/bootstrap.d.ts +43 -0
  25. package/dist/mdruntime/cell.d.ts +5 -0
  26. package/dist/mdruntime/chain.d.ts +11 -0
  27. package/dist/mdruntime/change-set.d.ts +13 -16
  28. package/dist/mdruntime/change.d.ts +32 -1
  29. package/dist/mdruntime/client.d.ts +36 -11
  30. package/dist/mdruntime/collection.d.ts +29 -21
  31. package/dist/mdruntime/compile.d.ts +15 -0
  32. package/dist/mdruntime/conversation-live.d.ts +135 -0
  33. package/dist/mdruntime/conversation-row.d.ts +32 -0
  34. package/dist/mdruntime/conversation.d.ts +54 -46
  35. package/dist/mdruntime/declaration.d.ts +9 -0
  36. package/dist/mdruntime/durability.d.ts +16 -4
  37. package/dist/mdruntime/failure.d.ts +1 -0
  38. package/dist/mdruntime/figures.d.ts +48 -0
  39. package/dist/mdruntime/holdings.d.ts +28 -0
  40. package/dist/mdruntime/identity.d.ts +5 -0
  41. package/dist/mdruntime/listing.d.ts +47 -0
  42. package/dist/mdruntime/live.d.ts +22 -0
  43. package/dist/mdruntime/log.d.ts +5 -0
  44. package/dist/mdruntime/media.d.ts +7 -0
  45. package/dist/mdruntime/messages.d.ts +48 -0
  46. package/dist/mdruntime/model.d.ts +8 -11
  47. package/dist/mdruntime/observation.d.ts +17 -2
  48. package/dist/mdruntime/opened.d.ts +21 -0
  49. package/dist/mdruntime/outcome.d.ts +49 -8
  50. package/dist/mdruntime/overlay.d.ts +4 -5
  51. package/dist/mdruntime/preparation.d.ts +19 -0
  52. package/dist/mdruntime/presence.d.ts +51 -0
  53. package/dist/mdruntime/query.d.ts +25 -191
  54. package/dist/mdruntime/reach.d.ts +20 -9
  55. package/dist/mdruntime/readiness.d.ts +13 -17
  56. package/dist/mdruntime/reads.d.ts +36 -0
  57. package/dist/mdruntime/recovery.d.ts +3 -2
  58. package/dist/mdruntime/refresh.d.ts +26 -0
  59. package/dist/mdruntime/replica.d.ts +50 -33
  60. package/dist/mdruntime/room-draft.d.ts +28 -11
  61. package/dist/mdruntime/room-drafts.d.ts +23 -0
  62. package/dist/mdruntime/runtime.d.ts +33 -0
  63. package/dist/mdruntime/save.d.ts +42 -48
  64. package/dist/mdruntime/saves.d.ts +31 -0
  65. package/dist/mdruntime/search.d.ts +12 -82
  66. package/dist/mdruntime/seed.d.ts +11 -2
  67. package/dist/mdruntime/socket/admission.d.ts +6 -0
  68. package/dist/mdruntime/socket/answers.d.ts +5 -0
  69. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  70. package/dist/mdruntime/socket/session.d.ts +37 -0
  71. package/dist/mdruntime/socket.d.ts +66 -0
  72. package/dist/mdruntime/source.d.ts +60 -0
  73. package/dist/mdruntime/status.d.ts +4 -5
  74. package/dist/mdruntime/store/installs.d.ts +29 -0
  75. package/dist/mdruntime/store/readiness.d.ts +9 -0
  76. package/dist/mdruntime/store/records.d.ts +209 -0
  77. package/dist/mdruntime/store/room-held.d.ts +7 -0
  78. package/dist/mdruntime/store/space.d.ts +10 -0
  79. package/dist/mdruntime/store/watchers.d.ts +16 -0
  80. package/dist/mdruntime/store/writes.d.ts +23 -0
  81. package/dist/mdruntime/store.d.ts +109 -150
  82. package/dist/mdruntime/stored.d.ts +155 -0
  83. package/dist/mdruntime/surface.d.ts +87 -0
  84. package/dist/mdruntime/tables.d.ts +411 -0
  85. package/dist/mdruntime/tallies.d.ts +17 -0
  86. package/dist/mdruntime/transfer.d.ts +0 -5
  87. package/dist/mdruntime/wire.d.ts +54 -10
  88. package/dist/session-content/bounds.d.ts +7 -0
  89. package/dist/session-content/check.d.ts +18 -0
  90. package/dist/session-content/index.d.ts +7 -0
  91. package/dist/session-content/parts.d.ts +102 -0
  92. package/dist/session-content/state.d.ts +61 -0
  93. package/dist/session-content/turn.d.ts +328 -0
  94. package/dist/test-host.d.ts +7 -4
  95. package/dist/test-host.js +19 -29
  96. package/docs/families.md +69 -56
  97. package/package.json +8 -3
  98. package/dist/calls.d.ts +0 -118
  99. package/dist/calls.js +0 -1
  100. package/dist/mdmodel/blocks.d.ts +0 -10
  101. package/dist/mdmodel/condition.d.ts +0 -149
  102. package/dist/mdmodel/profile.d.ts +0 -5
  103. package/dist/mdruntime/acquisition.d.ts +0 -13
  104. package/dist/mdruntime/connection.d.ts +0 -141
  105. package/dist/mdruntime/file.d.ts +0 -19
  106. package/dist/mdruntime/rows.d.ts +0 -37
  107. package/dist/mdruntime/shared.d.ts +0 -10
  108. package/dist/mdruntime/turn.d.ts +0 -6
@@ -0,0 +1,43 @@
1
+ import type { ModelState } from './model.js';
2
+ import type { Adapter, TypedPath, AdapterFailure, Authorization, BootstrapPart, DiscoveredRoom, NotReady, RetryableRefusal, RoomModels } from './adapter.js';
3
+ import type { Composition } from './collection.js';
4
+ import type { InstallationStep } from './readiness.js';
5
+ import { type Refreshing } from './refresh.js';
6
+ import { type ReplicaRecord } from './replica.js';
7
+ import type { StagedPage, TransferRecord } from './store.js';
8
+ import { type Unconfirmed } from './transfer.js';
9
+ export type Bootstrapped = {
10
+ kind: 'staged';
11
+ record: ReplicaRecord;
12
+ refreshed: boolean;
13
+ };
14
+ export type BootstrapOutcome = Bootstrapped | Unconfirmed | NotReady | RetryableRefusal | AdapterFailure;
15
+ export type HeldModels = {
16
+ collection: ModelState;
17
+ };
18
+ export type Remodel = (models: RoomModels | undefined, held: HeldModels) => HeldModels;
19
+ export type Reads = Pick<Adapter, 'bootstrap' | 'refresh' | 'reached'>;
20
+ export type Arriving = {
21
+ at(bytes: number): void;
22
+ end(): void;
23
+ };
24
+ export type Resumed = {
25
+ readonly record: TransferRecord | null;
26
+ readonly staged: ReadonlySet<string>;
27
+ };
28
+ export type Staging = {
29
+ held(locator: string): TransferRecord | null;
30
+ turn(locator: string, step: InstallationStep): Promise<() => void>;
31
+ unqueued(): Promise<void>;
32
+ queued(text: number): () => void;
33
+ arriving(locator: string): Arriving;
34
+ readonly streamed: boolean;
35
+ stage(record: TransferRecord, page: StagedPage, composition: Composition): Promise<TransferRecord | null>;
36
+ resume(record: TransferRecord, parts: readonly BootstrapPart[], composition: Composition): Promise<Resumed | null>;
37
+ derive(locator: string, key: number, composition: Composition): Promise<boolean>;
38
+ refreshing(locator: string, key: number, composition: Composition): Promise<Refreshing>;
39
+ abandon(locator: string): Promise<void>;
40
+ setAside(locator: string): Promise<void>;
41
+ release(key: number): Promise<void>;
42
+ };
43
+ export declare function bootstrapRoom(adapter: Reads, authorization: Authorization, room: DiscoveredRoom, held: HeldModels, builtIn: ModelState, typedPaths: readonly TypedPath[], remodel: Remodel, continuing: () => boolean, staging: Staging): Promise<BootstrapOutcome>;
@@ -0,0 +1,5 @@
1
+ export type Cell<T> = {
2
+ now(): T;
3
+ set(change: Partial<T>): void;
4
+ };
5
+ export declare function createCell<T extends object>(first: T): Cell<T>;
@@ -0,0 +1,11 @@
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import type { MdRuntimeClient } from './client.js';
3
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
4
+ type Rows = DocumentResult | GroupResult;
5
+ export type WindowAnswer = Rows | PendingResult;
6
+ export type WindowChain = {
7
+ want(count: number): void;
8
+ close(): void;
9
+ };
10
+ export declare function chainedWindows(runtime: MdRuntimeClient, query: DocumentQuery | GroupQuery, count: number, publish: (answers: readonly (WindowAnswer | null)[], settled: boolean) => void): WindowChain;
11
+ export {};
@@ -1,15 +1,6 @@
1
- import { type Replica } from './replica.js';
2
- import { type Row } from './rows.js';
3
1
  export type DocumentChange = {
4
- locator: string;
5
- path: string;
6
- before: readonly Row[];
7
- after: readonly Row[];
8
- };
9
- export type MessageChange = {
10
- conversation: string;
11
- identity: string;
12
- text: string | null;
2
+ readonly locator: string;
3
+ readonly path: string | null;
13
4
  };
14
5
  export type ChangeSet = {
15
6
  documents: readonly DocumentChange[];
@@ -20,15 +11,21 @@ export type ChangeSet = {
20
11
  rooms: readonly string[];
21
12
  queues: readonly string[];
22
13
  presentations: readonly string[];
23
- messages: readonly MessageChange[];
24
14
  conversations: readonly string[];
15
+ unindexed: readonly string[];
16
+ due: readonly string[];
25
17
  };
26
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
18
+ type Changed = {
19
+ documents?: readonly string[] | null;
27
20
  drafts?: readonly string[];
28
21
  room?: boolean;
29
22
  queue?: boolean;
30
23
  presentation?: string;
31
- }): ChangeSet;
32
- export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
33
- export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
24
+ unindexed?: boolean;
25
+ due?: boolean;
26
+ };
27
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
28
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
34
29
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
30
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
31
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { BinaryFile, HeadChange } from './adapter.js';
1
2
  export type Change = {
2
3
  readonly kind: 'field';
3
4
  readonly path: string;
@@ -29,7 +30,6 @@ export type Change = {
29
30
  readonly kind: 'binary';
30
31
  readonly path: string;
31
32
  readonly localId: string;
32
- readonly blob: Blob;
33
33
  readonly byteLength: number;
34
34
  readonly mediaType: string;
35
35
  readonly sha256: string;
@@ -40,6 +40,33 @@ export type Change = {
40
40
  } | {
41
41
  readonly kind: 'remove';
42
42
  readonly path: string;
43
+ } | (Arriving & {
44
+ readonly content: string;
45
+ }) | (Arriving & {
46
+ readonly binary: BinaryFile;
47
+ });
48
+ type Arriving = {
49
+ readonly kind: 'arrival';
50
+ readonly path: string;
51
+ readonly revision?: string;
52
+ readonly fileId?: string;
53
+ readonly created?: string;
54
+ readonly change?: HeadChange;
55
+ };
56
+ export type RoomMove = {
57
+ readonly source: {
58
+ readonly room: string;
59
+ readonly baseRoomVersion: string;
60
+ };
61
+ readonly destination: {
62
+ readonly room: string;
63
+ readonly baseRoomVersion: string;
64
+ readonly handle: string;
65
+ };
66
+ readonly moves: readonly {
67
+ readonly path: string;
68
+ readonly to: string;
69
+ }[];
43
70
  };
44
71
  export type Precondition = {
45
72
  readonly kind: 'field';
@@ -81,8 +108,12 @@ export type ChangeBatch = {
81
108
  readonly changes: readonly Change[];
82
109
  readonly preconditions: readonly Precondition[];
83
110
  readonly writtenBy?: WrittenBy;
111
+ readonly between?: RoomMove;
84
112
  };
85
113
  export declare function immutable(batch: ChangeBatch): ChangeBatch;
114
+ export declare function partnerOf(batch: ChangeBatch, locator: string): string | null;
115
+ export declare function leaving(batch: ChangeBatch, locator: string): boolean;
86
116
  export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
87
117
  export declare function departure(changes: readonly Change[], index: number): string;
88
118
  export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
119
+ export {};
@@ -1,16 +1,26 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import type { HistoryQuery } from './actions.js';
3
+ import type { AppRoom } from './listing.js';
4
+ import type { ConnectionRefusal } from './socket.js';
5
+ import type { RoomSchemas } from './surface.js';
6
+ import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
2
7
  import type { Member, ServiceMode } from './adapter.js';
3
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
8
+ import type { UnsentWork } from './durability.js';
9
+ import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
4
10
  import { type Observation } from './observation.js';
5
- import type { BinaryReference } from './binary.js';
6
- import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
7
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
11
+ import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
12
+ import type { FiguresResult } from './figures.js';
13
+ import type { Holdings } from './holdings.js';
14
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
8
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
16
  import type { SearchRequest, SearchResult } from './search.js';
10
17
  import type { Readiness } from './readiness.js';
18
+ import type { ObservedRead } from './reads.js';
11
19
  import type { SyncStatus } from './status.js';
12
20
  import { type RuntimePort } from './wire.js';
21
+ export type BuildFile = (name: string) => Promise<Blob | null>;
13
22
  export type MdRuntimeClient = {
23
+ buildFile(name: string): Promise<Blob | null>;
14
24
  rooms(): Promise<readonly AppRoom[]>;
15
25
  query: {
16
26
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
@@ -21,39 +31,47 @@ export type MdRuntimeClient = {
21
31
  roomDraft: {
22
32
  list(): Promise<readonly RoomDraft[]>;
23
33
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
34
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
25
35
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
36
  };
27
37
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
38
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
28
39
  presentation: {
29
40
  read(): Promise<unknown>;
30
41
  write(value: unknown): Promise<void>;
42
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
31
43
  };
32
44
  conversation: {
33
45
  list(): Promise<readonly ConversationEntry[]>;
34
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
46
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
35
47
  create(input: unknown): Promise<CallResult>;
36
48
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
37
- answer(conversation: string, answer: unknown): Promise<CallResult>;
49
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
38
50
  interrupt(conversation: string): Promise<CallResult>;
39
51
  kill(conversation: string): Promise<CallResult>;
40
- cancel(conversation: string, turn: string): Promise<CallResult>;
41
52
  delete(conversation: string): Promise<CallResult>;
42
53
  };
43
54
  chatDraft: {
44
55
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
56
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
45
57
  discard(conversation: string): Promise<void>;
46
58
  };
47
59
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
60
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
48
61
  binaryFile: {
49
62
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
50
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
63
+ attach(room: string, file: File): Promise<AttachAnswer>;
64
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
51
65
  };
52
66
  call(name: string, input: unknown): Promise<CallResult>;
53
67
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
54
68
  log(): Promise<string>;
55
69
  persistence(): Promise<boolean>;
56
70
  retry(): Promise<void>;
71
+ cleanUp(): Promise<number>;
72
+ unsent(): Promise<readonly UnsentWork[]>;
73
+ reset(): Promise<void>;
74
+ readAgain(): Promise<void>;
57
75
  observe: {
58
76
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
59
77
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -63,6 +81,7 @@ export type MdRuntimeClient = {
63
81
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
64
82
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
65
83
  (topic: 'member'): Promise<Observation<Member | null>>;
84
+ (topic: 'authority-changes'): Promise<Observation<number>>;
66
85
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
86
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
68
87
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -71,12 +90,18 @@ export type MdRuntimeClient = {
71
90
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
72
91
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
73
92
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
93
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
94
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
95
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
74
96
  };
75
97
  reauthorize(): Promise<void>;
76
98
  settled(): Promise<void>;
77
99
  };
78
- export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
100
+ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFile): MdRuntimeClient;
79
101
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
102
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
103
+ export { roomDraftRevision } from './identity.js';
104
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
80
105
  export type { Observation } from './observation.js';
81
106
  export type { Open } from './open.js';
82
107
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,7 @@
1
- import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
2
- import { type ModelState } from './model.js';
1
+ import { type DefinitionOf, type Document, type TypedPath } from '../mdmodel/index.js';
2
+ import type { ModelState, TypesResult } from './model.js';
3
+ import type { AppTypedSelection } from './listing.js';
3
4
  import type { MdModelIdentity } from './adapter.js';
4
- import { type Paths } from './shared.js';
5
- import type { Refused } from './transfer.js';
6
- import { type Later } from './turn.js';
7
5
  export declare const MD_MODEL: MdModelIdentity;
8
6
  export type Collection = {
9
7
  text: Readonly<Record<string, string>>;
@@ -16,23 +14,33 @@ export type Composition = {
16
14
  roots: readonly string[];
17
15
  model: ModelState;
18
16
  } | null;
17
+ typedPaths: readonly TypedPath[];
19
18
  };
20
- export declare function governing(composition: Composition, path: string): ModelState;
21
- export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
22
- export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
23
- export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
24
- export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
25
- export declare function validRoot(root: unknown): root is string;
26
- export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
27
- type Held = {
28
- text: Paths<string>;
29
- binaries: Paths<unknown>;
19
+ export type Composed = {
20
+ readonly composition: Composition;
21
+ readonly fingerprint: string;
22
+ };
23
+ export declare function composedOf(composition: Composition): Composed;
24
+ type Selecting<M> = {
25
+ readonly model: M;
26
+ readonly selection: {
27
+ readonly roots: readonly string[];
28
+ readonly model: M;
29
+ } | null;
30
30
  };
31
- export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
32
- export declare function referencesIndexed(held: Held, composition: Composition): boolean;
33
- export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
31
+ export declare function selected(composition: {
32
+ readonly selection: {
33
+ readonly roots: readonly string[];
34
+ } | null;
35
+ }, path: string): boolean;
36
+ export declare function governing<M>(composition: Selecting<M>, path: string): M;
37
+ export declare function definitionsAt(composition: Composition, path: string): DefinitionOf;
38
+ export declare function definitionsIn(room: {
39
+ readonly model: TypesResult;
40
+ readonly typedSelection: AppTypedSelection | null;
41
+ }, path: string, typedPaths: readonly TypedPath[]): DefinitionOf;
42
+ export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
43
+ export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
44
+ export declare function validRoot(root: unknown): root is string;
34
45
  export declare function available(composition: Composition): boolean;
35
- export declare function changedCleanly(next: Held, previous: Held & {
36
- composition: Composition;
37
- }, composition: Composition): boolean;
38
46
  export {};
@@ -0,0 +1,15 @@
1
+ import { sql } from '../mdmodel/index.js';
2
+ import type { Plan, QueryRows } from './query.js';
3
+ import type { Connection } from './tables.js';
4
+ export type QueryRoom = {
5
+ readonly locator: string;
6
+ readonly key: number;
7
+ };
8
+ type Fragment = sql.Fragment;
9
+ export declare const VISIBLE: (alias: string) => string;
10
+ export declare function within(alias: string, path: string): Fragment;
11
+ export type QueryAnswer = QueryRows & {
12
+ readonly more?: string;
13
+ };
14
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
15
+ export {};
@@ -0,0 +1,135 @@
1
+ import type { SessionState } from '../session-content/index.js';
2
+ import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, SessionOption } from './adapter.js';
3
+ import { type Cell } from './cell.js';
4
+ import type { ChangeSet } from './change-set.js';
5
+ import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
6
+ import type { CallResult } from './outcome.js';
7
+ import type { Recovery } from './recovery.js';
8
+ import type { ChatDraftRecord, RuntimeStore } from './store.js';
9
+ export type ConversationDependencies = {
10
+ call(name: ConversationAction, input: unknown): Promise<CallResult>;
11
+ history(request: ConversationHistoryRequest): Promise<CallResult>;
12
+ durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
13
+ local(): Promise<RuntimeStore>;
14
+ again(): void;
15
+ settled(): void;
16
+ stream(): ConversationStream | undefined;
17
+ publish(set: ChangeSet): void;
18
+ online(): boolean;
19
+ full(): boolean;
20
+ closed(): boolean;
21
+ unanswered(): void;
22
+ readonly recovery: Recovery;
23
+ };
24
+ export type Live = {
25
+ turn: RunningTurn | null;
26
+ questions: readonly unknown[];
27
+ process: {
28
+ running: boolean;
29
+ } | null;
30
+ commands: readonly ProcessCommand[];
31
+ options: readonly SessionOption[];
32
+ starting: string | null;
33
+ state: SessionState | null;
34
+ link: {
35
+ connected: boolean;
36
+ } | null;
37
+ deliveryWaiting: readonly string[];
38
+ deliveryUnknown: readonly string[];
39
+ };
40
+ export declare const QUIET: Live;
41
+ export type Fact = Exclude<keyof Live, 'turn'>;
42
+ export declare const FACTS: readonly Fact[];
43
+ type Watcher = {
44
+ readonly notify: (view: ConversationView) => void;
45
+ };
46
+ type HeldWindow = {
47
+ readonly window: readonly AcceptedMessage[] | null;
48
+ readonly draft: ChatDraftRecord | null;
49
+ readonly ended: string | null;
50
+ readonly more: boolean;
51
+ readonly total: number | null;
52
+ };
53
+ export type SharedView = {
54
+ readonly conversation: string;
55
+ readonly asked: Asked;
56
+ readonly held: Cell<HeldWindow>;
57
+ ready(): readonly Watcher[];
58
+ join(watcher: Watcher): void;
59
+ admit(watcher: Watcher): boolean;
60
+ leave(watcher: Watcher): boolean;
61
+ empty(): boolean;
62
+ };
63
+ type Listing<T> = (value: T) => void;
64
+ export type Audience<T> = {
65
+ waiting(): boolean;
66
+ told(): boolean;
67
+ join(watcher: Listing<T>): void;
68
+ leave(watcher: Listing<T>): void;
69
+ tell(value: T): void;
70
+ welcome(value: T): void;
71
+ clear(): void;
72
+ };
73
+ type HeldFacts = {
74
+ readonly listKnown: boolean;
75
+ readonly listOwed: boolean;
76
+ readonly listTelling: boolean;
77
+ readonly agentsShown: string | null;
78
+ readonly listedAgents: readonly ListedAgent[] | null;
79
+ readonly agentsReading: boolean;
80
+ readonly replicated: ReadonlySet<string>;
81
+ readonly handedReplicated: string | undefined;
82
+ };
83
+ export type Dispatch = Cell<{
84
+ readonly answered: boolean;
85
+ }>;
86
+ export type LiveConversations = {
87
+ readonly deps: ConversationDependencies;
88
+ readonly held: Cell<HeldFacts>;
89
+ readonly closing: AbortSignal;
90
+ readonly listeners: Audience<readonly ConversationEntry[]>;
91
+ readonly agentListeners: Audience<readonly ConversationAgent[]>;
92
+ views(): Iterable<SharedView>;
93
+ viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
94
+ readonly view: SharedView;
95
+ readonly watcher: Watcher;
96
+ };
97
+ viewLeft(key: string, view: SharedView, watcher: Watcher): void;
98
+ liveOf(conversation: string): Live;
99
+ liveHeld(conversation: string): Live | undefined;
100
+ holdLive(conversation: string, next: Live | null): void;
101
+ factsOwed(conversation: string): void;
102
+ factsHeard(conversation: string, facts: readonly Fact[]): void;
103
+ factsTaken(): readonly (readonly [string, ReadonlySet<Fact>])[];
104
+ behind(conversation: string): boolean;
105
+ behindAll(): readonly string[];
106
+ fellBehind(conversation: string): void;
107
+ caughtUpTo(conversation: string): void;
108
+ gapOpened(conversation: string): void;
109
+ generation(conversation: string): number;
110
+ heardAt(conversation: string, change: string): void;
111
+ newestHeard(conversation: string): string | undefined;
112
+ catching(conversation: string): Promise<void> | undefined;
113
+ catchingUntil(conversation: string, ended: Promise<void>): void;
114
+ creating(conversation: string): void;
115
+ created(conversation: string): void;
116
+ isCreating(conversation: string): boolean;
117
+ relisting(): boolean;
118
+ relistBegun(): void;
119
+ relistHeard(entries: readonly ListedConversation[]): void;
120
+ relistDropped(conversation: string): void;
121
+ relistTaken(): ReadonlyMap<string, ListedConversation> | null;
122
+ sendingBegan(operation: string): Dispatch;
123
+ sendingEnded(operation: string, dispatch: Dispatch): void;
124
+ sending(operation: string): boolean;
125
+ rowSoon(tell: () => void): void;
126
+ inOrder(work: () => Promise<void>): void;
127
+ forget(conversation: string): void;
128
+ current(): boolean;
129
+ known(): boolean;
130
+ reopened(): void;
131
+ lost(): void;
132
+ close(): void;
133
+ };
134
+ export declare function createLiveConversations(deps: ConversationDependencies): LiveConversations;
135
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { HeldRow } from './messages.js';
2
+ import { type HouseSource } from './source.js';
3
+ export type ConversationLast = {
4
+ readonly text: string;
5
+ readonly by: 'owner' | 'agent' | 'house';
6
+ readonly at: string;
7
+ };
8
+ export type ConversationStart = Extract<HouseSource, {
9
+ readonly kind: 'request' | 'trigger';
10
+ }>;
11
+ export type ConversationAsk = {
12
+ readonly who: string;
13
+ readonly agent: string | null;
14
+ readonly room: {
15
+ readonly ref: string;
16
+ readonly name: string;
17
+ };
18
+ readonly prompt: string;
19
+ readonly at: string;
20
+ readonly request: string;
21
+ readonly message?: string;
22
+ };
23
+ export type ConversationHeld = {
24
+ readonly last: ConversationLast | null;
25
+ readonly failure: string | null;
26
+ readonly startedBy: ConversationStart | null;
27
+ readonly asks: ConversationAsk | null;
28
+ };
29
+ export declare function heldFacts(held: HeldRow | undefined, listed: {
30
+ readonly outcome: string | null;
31
+ readonly waiting: boolean;
32
+ }): ConversationHeld;