@agentshouse/app-bridge 0.1.0-cfb240c3fb89d → 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 (63) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +865 -8
  3. package/dist/mdmodel/definition.d.ts +17 -1
  4. package/dist/mdmodel/document.d.ts +5 -5
  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 +23 -9
  8. package/dist/mdmodel/kinds.d.ts +18 -0
  9. package/dist/mdmodel/links.d.ts +28 -0
  10. package/dist/mdmodel/paths.d.ts +9 -1
  11. package/dist/mdmodel/project.d.ts +1 -0
  12. package/dist/mdmodel/query/language.d.ts +222 -0
  13. package/dist/mdmodel/query/match.d.ts +13 -0
  14. package/dist/mdmodel/query/rows.d.ts +31 -0
  15. package/dist/mdmodel/query/sql.d.ts +38 -0
  16. package/dist/mdmodel/reserved.d.ts +4 -0
  17. package/dist/mdmodel/types.d.ts +35 -4
  18. package/dist/mdmodel/validate.d.ts +29 -4
  19. package/dist/mdruntime/adapter.d.ts +147 -74
  20. package/dist/mdruntime/binary.d.ts +0 -5
  21. package/dist/mdruntime/chain.d.ts +11 -0
  22. package/dist/mdruntime/change-set.d.ts +9 -16
  23. package/dist/mdruntime/change.d.ts +31 -1
  24. package/dist/mdruntime/client.d.ts +27 -11
  25. package/dist/mdruntime/collection.d.ts +11 -21
  26. package/dist/mdruntime/compile.d.ts +10 -0
  27. package/dist/mdruntime/connection.d.ts +41 -14
  28. package/dist/mdruntime/conversation.d.ts +32 -15
  29. package/dist/mdruntime/durability.d.ts +10 -1
  30. package/dist/mdruntime/identity.d.ts +5 -0
  31. package/dist/mdruntime/media.d.ts +7 -0
  32. package/dist/mdruntime/messages.d.ts +27 -0
  33. package/dist/mdruntime/model.d.ts +11 -10
  34. package/dist/mdruntime/observation.d.ts +17 -2
  35. package/dist/mdruntime/opened.d.ts +21 -0
  36. package/dist/mdruntime/outcome.d.ts +45 -7
  37. package/dist/mdruntime/overlay.d.ts +3 -5
  38. package/dist/mdruntime/query.d.ts +17 -185
  39. package/dist/mdruntime/reach.d.ts +18 -6
  40. package/dist/mdruntime/readiness.d.ts +49 -0
  41. package/dist/mdruntime/recovery.d.ts +3 -2
  42. package/dist/mdruntime/replica.d.ts +58 -33
  43. package/dist/mdruntime/room-draft.d.ts +37 -6
  44. package/dist/mdruntime/save.d.ts +53 -14
  45. package/dist/mdruntime/search.d.ts +15 -77
  46. package/dist/mdruntime/seed.d.ts +15 -0
  47. package/dist/mdruntime/status.d.ts +5 -0
  48. package/dist/mdruntime/store.d.ts +93 -94
  49. package/dist/mdruntime/stored.d.ts +128 -0
  50. package/dist/mdruntime/tables.d.ts +326 -0
  51. package/dist/mdruntime/wire.d.ts +173 -32
  52. package/dist/test-host.d.ts +7 -1
  53. package/dist/test-host.js +19 -1
  54. package/docs/families.md +66 -12
  55. package/package.json +8 -3
  56. package/dist/calls.d.ts +0 -117
  57. package/dist/calls.js +0 -1
  58. package/dist/mdmodel/condition.d.ts +0 -149
  59. package/dist/mdruntime/file.d.ts +0 -19
  60. package/dist/mdruntime/rows.d.ts +0 -36
  61. package/dist/mdruntime/shared.d.ts +0 -10
  62. package/dist/mdruntime/transfer.d.ts +0 -9
  63. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,12 +1,14 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
1
+ import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
2
+ import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
3
  import type { Member, ServiceMode } from './adapter.js';
3
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
4
+ import type { UnsentWork } from './durability.js';
5
+ import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
4
6
  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';
7
+ import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
8
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
8
9
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
10
  import type { SearchRequest, SearchResult } from './search.js';
11
+ import type { Readiness } from './readiness.js';
10
12
  import type { SyncStatus } from './status.js';
11
13
  import { type RuntimePort } from './wire.js';
12
14
  export type MdRuntimeClient = {
@@ -20,46 +22,56 @@ export type MdRuntimeClient = {
20
22
  roomDraft: {
21
23
  list(): Promise<readonly RoomDraft[]>;
22
24
  read(room: string, path: string): Promise<RoomDraft | null>;
23
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
25
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
24
26
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
25
27
  };
26
28
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
29
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
27
30
  presentation: {
28
31
  read(): Promise<unknown>;
29
32
  write(value: unknown): Promise<void>;
33
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
30
34
  };
31
35
  conversation: {
32
36
  list(): Promise<readonly ConversationEntry[]>;
33
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
37
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
34
38
  create(input: unknown): Promise<CallResult>;
35
39
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
36
- answer(conversation: string, answer: unknown): Promise<CallResult>;
40
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
37
41
  interrupt(conversation: string): Promise<CallResult>;
38
42
  kill(conversation: string): Promise<CallResult>;
39
- cancel(conversation: string, turn: string): Promise<CallResult>;
40
43
  delete(conversation: string): Promise<CallResult>;
41
44
  };
42
45
  chatDraft: {
43
46
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
47
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
44
48
  discard(conversation: string): Promise<void>;
45
49
  };
46
50
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
51
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
47
52
  binaryFile: {
48
53
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
49
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
54
+ attach(room: string, file: File): Promise<AttachAnswer>;
55
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
50
56
  };
51
57
  call(name: string, input: unknown): Promise<CallResult>;
52
58
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
53
59
  log(): Promise<string>;
54
60
  persistence(): Promise<boolean>;
61
+ retry(): Promise<void>;
62
+ cleanUp(): Promise<number>;
63
+ unsent(): Promise<readonly UnsentWork[]>;
64
+ reset(): Promise<void>;
55
65
  observe: {
56
66
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
57
67
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
68
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
58
69
  (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
59
70
  (topic: 'storage-loss'): Promise<Observation<string | null>>;
60
71
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
61
72
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
62
73
  (topic: 'member'): Promise<Observation<Member | null>>;
74
+ (topic: 'authority-changes'): Promise<Observation<number>>;
63
75
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
64
76
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
65
77
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -74,5 +86,9 @@ export type MdRuntimeClient = {
74
86
  };
75
87
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
76
88
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
89
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
90
+ export { roomDraftRevision } from './identity.js';
91
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
77
92
  export type { Observation } from './observation.js';
78
- export type { RuntimePort } from './wire.js';
93
+ export type { Open } from './open.js';
94
+ export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,6 @@
1
- import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
2
- import { type ModelState } from './model.js';
1
+ import { type Document, type TypedPath } from '../mdmodel/index.js';
2
+ import type { ModelState } from './model.js';
3
3
  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
4
  export declare const MD_MODEL: MdModelIdentity;
8
5
  export type Collection = {
9
6
  text: Readonly<Record<string, string>>;
@@ -16,23 +13,16 @@ export type Composition = {
16
13
  roots: readonly string[];
17
14
  model: ModelState;
18
15
  } | null;
16
+ typedPaths: readonly TypedPath[];
19
17
  };
18
+ export type Composed = {
19
+ readonly composition: Composition;
20
+ readonly fingerprint: string;
21
+ };
22
+ export declare function composedOf(composition: Composition): Composed;
23
+ export declare function selected(composition: Composition, path: string): boolean;
20
24
  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 collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
26
+ export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
25
27
  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>;
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;
34
28
  export declare function available(composition: Composition): boolean;
35
- export declare function changedCleanly(next: Held, previous: Held & {
36
- composition: Composition;
37
- }, composition: Composition): boolean;
38
- export {};
@@ -0,0 +1,10 @@
1
+ import type { Plan, QueryRows } from './query.js';
2
+ import type { Connection } from './tables.js';
3
+ export type QueryRoom = {
4
+ readonly locator: string;
5
+ readonly key: number;
6
+ };
7
+ export type QueryAnswer = QueryRows & {
8
+ readonly more?: string;
9
+ };
10
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
@@ -1,18 +1,21 @@
1
+ import { type DocumentQuery, type GroupQuery } from '../mdmodel/index.js';
1
2
  import { type TypesResult } from './model.js';
2
3
  import { type Observation } from './observation.js';
3
- import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
4
+ import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
5
+ import { type EntrySeed } from './seed.js';
4
6
  import { type SearchRequest, type SearchResult } from './search.js';
5
7
  import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
6
8
  import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
7
9
  import { type WrittenBy } from './change.js';
8
10
  import type { Open } from './open.js';
9
- import { type BinaryReference } from './binary.js';
10
- import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
11
+ import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
11
12
  import { type Recovery } from './recovery.js';
12
13
  import { type SaveRefusal } from './save.js';
13
- import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
14
+ import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
14
15
  import { type SyncStatus } from './status.js';
15
- import { type RuntimeShell } from './durability.js';
16
+ import { type RuntimeShell, type UnsentWork } from './durability.js';
17
+ import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
18
+ import type { RuntimeDatabase } from './tables.js';
16
19
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
17
20
  export type AppTypedSelection = {
18
21
  roots: readonly string[];
@@ -31,6 +34,7 @@ export type AppRoom = {
31
34
  documents: number;
32
35
  synchronizationAvailable: boolean;
33
36
  refusal: ProviderRefusal | null;
37
+ locked: boolean;
34
38
  };
35
39
  export type RoomSchemas = {
36
40
  collection: TypesResult;
@@ -47,9 +51,11 @@ export type ConnectionRefusal = {
47
51
  export type MdRuntimeOptions = {
48
52
  adapter: Adapter;
49
53
  shell: RuntimeShell;
54
+ database: RuntimeDatabase;
50
55
  authorization?: Authorization;
51
56
  signal?: AbortSignal;
52
57
  recovery?: Recovery;
58
+ usableWhenHeld?: readonly string[];
53
59
  };
54
60
  export type SaveResult = {
55
61
  outcome: 'saved';
@@ -61,19 +67,27 @@ export type SavedRoomDraft = {
61
67
  readonly path: string;
62
68
  readonly revision: string;
63
69
  };
70
+ export type SavedParts = {
71
+ readonly path: string;
72
+ readonly parts: RoomDraftParts;
73
+ };
64
74
  export type RoomDraftSurface = {
65
75
  list(): Promise<readonly RoomDraft[]>;
66
- read(room: string, path: string): RoomDraft | null;
67
- write(room: string, path: string, revision: string | null, parts: unknown): Promise<RoomDraftWrite>;
76
+ read(room: string, path: string): Promise<RoomDraft | null>;
77
+ write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
68
78
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
69
79
  };
70
80
  export type PresentationSurface = {
71
81
  read(app: string): Promise<unknown>;
72
82
  write(app: string, value: unknown): Promise<void>;
83
+ edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
73
84
  };
74
85
  export type BinaryFileSurface = {
75
- read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
76
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
86
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
87
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
88
+ show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
89
+ attach(room: string, file: File): Promise<AttachAnswer>;
90
+ part(file: string, part: number): Promise<Uint8Array | null>;
77
91
  };
78
92
  export type HistoryQuery = {
79
93
  revision?: string;
@@ -81,7 +95,7 @@ export type HistoryQuery = {
81
95
  };
82
96
  export type MdRuntime = {
83
97
  loaded(): Promise<void>;
84
- rooms(): readonly AppRoom[];
98
+ rooms(): Promise<readonly AppRoom[]>;
85
99
  query: {
86
100
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
87
101
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
@@ -93,19 +107,27 @@ export type MdRuntime = {
93
107
  chatDraft: ChatDraftSurface;
94
108
  presentation: PresentationSurface;
95
109
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
110
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
96
111
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
112
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
97
113
  binaryFile: BinaryFileSurface;
98
114
  call(name: string, input: unknown): Promise<CallResult>;
99
- reached(locator: string, roomVersion: string, path?: string): boolean;
115
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
100
116
  log(): string;
101
117
  persistence(): boolean;
118
+ retry(): Promise<void>;
119
+ cleanUp(): Promise<number>;
120
+ unsent(): Promise<readonly UnsentWork[]>;
121
+ reset(): Promise<void>;
102
122
  observe: {
103
123
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
124
+ (topic: 'readiness'): Promise<Observation<Readiness>>;
104
125
  (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
105
126
  (topic: 'storage-loss'): Promise<Observation<string | null>>;
106
127
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
107
128
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
108
129
  (topic: 'member'): Promise<Observation<Member | null>>;
130
+ (topic: 'authority-changes'): Promise<Observation<number>>;
109
131
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
110
132
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
111
133
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -117,11 +139,16 @@ export type MdRuntime = {
117
139
  };
118
140
  reauthorize(): Promise<void>;
119
141
  };
120
- export type RuntimeTopic = 'rooms' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
142
+ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
143
+ export type ReadinessPort = {
144
+ readonly target: string;
145
+ readonly code: CodeAvailability;
146
+ };
121
147
  export type ComposedRuntime = RuntimeView & {
148
+ seed(entry: EntrySeed): void;
122
149
  stop(): Promise<void>;
123
- lose(locators: readonly string[]): Promise<void>;
124
- within(reach: PortReach | null): NarrowedView;
150
+ persisted(answer: Persistence): void;
151
+ within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
125
152
  };
126
153
  export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
127
154
  export {};
@@ -1,9 +1,7 @@
1
- import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
1
+ import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
2
2
  import { type ChangeSet } from './change-set.js';
3
- import { type ChatDraftFile } from './file.js';
4
3
  import type { Open } from './open.js';
5
4
  import { type CallResult, type Offline } from './outcome.js';
6
- import type { DocumentResult, PendingResult } from './query.js';
7
5
  import type { CycleProgress } from './status.js';
8
6
  import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
9
7
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
@@ -11,12 +9,13 @@ export type ConversationEntry = {
11
9
  conversation: string;
12
10
  agent: {
13
11
  identity: string;
14
- name: string | null;
12
+ name: string;
15
13
  };
16
14
  name: string;
17
15
  created: string;
18
16
  finished: string | null;
19
17
  outcome: string | null;
18
+ waiting: boolean;
20
19
  state: ConversationState;
21
20
  started: string | null;
22
21
  };
@@ -32,71 +31,89 @@ export type RunningTurn = {
32
31
  };
33
32
  export type ChatDraft = {
34
33
  text: string;
35
- files: readonly ChatDraftFile[];
36
34
  };
37
35
  export type ConversationOptions = {
38
36
  limit?: number;
37
+ after?: string;
38
+ total?: true;
39
+ };
40
+ export type ConversationRead = ConversationOptions & {
41
+ text?: string;
39
42
  };
40
43
  export type ConversationView = {
41
44
  conversation: string;
42
45
  messages: readonly ConversationMessage[];
46
+ next?: string;
47
+ total?: number;
43
48
  turn: RunningTurn | null;
44
49
  questions: readonly unknown[];
45
50
  process: {
46
51
  running: boolean;
47
52
  } | null;
53
+ processEnded: string | null;
48
54
  commands: readonly ProcessCommand[];
49
55
  options: readonly SessionOption[];
56
+ starting: string | null;
57
+ subagents: readonly RunningSubagent[];
58
+ link: {
59
+ connected: boolean;
60
+ } | null;
61
+ deliveryUnknown: readonly string[];
50
62
  chatDraft: (ChatDraft & {
51
63
  readonly revision: string;
52
64
  }) | null;
53
65
  };
54
66
  export type ConversationSurface = {
55
67
  list(): Promise<readonly ConversationEntry[]>;
56
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
68
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
57
69
  create(input: unknown): Promise<CallResult>;
58
70
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
59
- answer(conversation: string, answer: unknown): Promise<CallResult>;
71
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
60
72
  interrupt(conversation: string): Promise<CallResult>;
61
73
  kill(conversation: string): Promise<CallResult>;
62
- cancel(conversation: string, turn: string): Promise<CallResult>;
63
74
  delete(conversation: string): Promise<CallResult>;
64
75
  };
76
+ export type ConversationAnswer = {
77
+ interaction_id: string;
78
+ response: unknown;
79
+ };
65
80
  export type ChatDraftSurface = {
66
81
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
82
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
67
83
  discard(conversation: string): Promise<void>;
68
84
  };
69
85
  export type ConversationDependencies = {
70
- agents(): ConversationAgents | undefined;
71
- documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
72
86
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
87
+ history(request: ConversationHistoryRequest): Promise<CallResult>;
73
88
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
74
89
  stream(): ConversationStream | undefined;
75
90
  publish(set: ChangeSet): void;
76
91
  online(): boolean;
92
+ full(): boolean;
77
93
  closed(): boolean;
78
94
  unanswered(): void;
79
- expired(operation: string): boolean;
80
95
  };
81
96
  export type ConversationStore = {
82
97
  surface: ConversationSurface;
83
98
  chatDraft: ChatDraftSurface;
84
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
99
+ hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
85
100
  reconcile(): Promise<void>;
86
101
  catchUp(progress: CycleProgress): Promise<void>;
87
102
  resend(progress: CycleProgress): Promise<void>;
88
103
  current(): boolean;
89
- reconnected(): void;
104
+ known(): boolean;
105
+ learned(): void;
90
106
  reopened(): void;
107
+ lost(): void;
91
108
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
92
109
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
93
110
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
94
111
  changed(set: ChangeSet): void;
95
112
  receive(event: ConversationEvent): boolean;
96
- searchable(): readonly string[];
97
- acquired(conversation: string): boolean;
98
113
  close(): void;
99
114
  };
100
115
  export declare function unheldView(conversation: string): ConversationView;
101
116
  export declare const SESSION_STARTED = "Session started";
117
+ export declare const HISTORY_CONVERSATIONS = 64;
118
+ export declare function newChat(agent: string): string;
102
119
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,8 +1,17 @@
1
+ import type { Persistence } from './readiness.js';
2
+ export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
3
+ export type UnsentWork = {
4
+ readonly kind: UnsentKind;
5
+ readonly count: number;
6
+ };
1
7
  export type RuntimeShell = {
2
- persistentStorage: boolean;
8
+ persistence: Persistence;
3
9
  generation: string | null;
4
10
  keepGeneration(value: string): void | Promise<void>;
5
11
  dropGeneration(): void | Promise<void>;
12
+ cleanUp?(): Promise<number>;
13
+ reset(): Promise<void>;
6
14
  };
15
+ export declare function refusedForSpace(error: unknown): boolean;
7
16
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
8
17
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -0,0 +1,5 @@
1
+ export declare function changeBatchIdentity(at?: number): string;
2
+ export declare function roomDraftRevision(): string;
3
+ export declare function chatDraftRevision(): string;
4
+ export declare function transferIdentity(): string;
5
+ export declare function binaryLocalId(): string;
@@ -0,0 +1,7 @@
1
+ import type { MdRuntimeClient } from './client.js';
2
+ import { type ShownAnswer } from './outcome.js';
3
+ export declare const ROOM_MEDIA = "room-media";
4
+ type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
5
+ export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
6
+ export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
7
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { AcceptedMessage } from './adapter.js';
2
+ import type { Connection } from './tables.js';
3
+ export declare const MESSAGE_TABLES: readonly string[];
4
+ export type HeldConversation = {
5
+ readonly conversation: string;
6
+ readonly read: string | null | undefined;
7
+ readonly partial: boolean;
8
+ };
9
+ export type MessageWindow = {
10
+ readonly messages: AcceptedMessage[];
11
+ readonly more: boolean;
12
+ };
13
+ export type ConversationWrite = {
14
+ readonly conversation: string;
15
+ readonly messages: readonly AcceptedMessage[];
16
+ readonly read?: {
17
+ readonly at: string | null;
18
+ readonly partial: boolean;
19
+ };
20
+ };
21
+ export declare function heldConversations(connection: Connection): HeldConversation[];
22
+ export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
23
+ export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
24
+ export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
25
+ export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
26
+ export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
27
+ export declare function forgottenMessages(connection: Connection): void;
@@ -1,4 +1,4 @@
1
- import type { Definition, ValueFacts, VerifiedModel } from '../mdmodel/index.js';
1
+ import type { Definition, VerifiedModel } from '../mdmodel/index.js';
2
2
  import type { Open } from './open.js';
3
3
  export type ModelIdentity = {
4
4
  identity: string;
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
8
8
  schema: string | null;
9
9
  revision: string | null;
10
10
  };
11
- export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
11
+ export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
12
12
  export type ModelResult = {
13
13
  kind: 'model';
14
14
  snapshot: ModelSnapshot;
@@ -20,21 +20,23 @@ export type MdType = Definition;
20
20
  export type ModelState = {
21
21
  status: 'unavailable';
22
22
  reason: ModelUnavailableReason;
23
- schema?: string | null;
24
- revision?: string | null;
25
23
  } | {
26
24
  status: 'current' | 'cached';
27
25
  snapshot: ModelSnapshot;
28
26
  verifiedWith: ModelIdentity;
29
27
  types: VerifiedModel['types'];
30
28
  };
31
- export type TypesResult = {
29
+ export type StoredModel = Extract<ModelState, {
32
30
  status: 'unavailable';
31
+ }> | Omit<Extract<ModelState, {
32
+ status: 'current' | 'cached';
33
+ }>, 'types'>;
34
+ export type TypesResult = {
35
+ status: Open<'unavailable'>;
33
36
  reason: ModelUnavailableReason;
34
- schema?: string | null;
35
- revision?: string | null;
37
+ types: null;
36
38
  } | {
37
- status: 'current' | 'cached';
39
+ status: Open<'current' | 'cached'>;
38
40
  identity: string;
39
41
  version: string;
40
42
  verifiedWith: ModelIdentity;
@@ -50,7 +52,6 @@ export type ValidationReceipt = {
50
52
  export declare const NO_MODEL: ModelState;
51
53
  export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
52
54
  export declare function modelTypes(state: ModelState): TypesResult;
55
+ export declare function storedModel(state: ModelState): StoredModel;
53
56
  export declare function cached(state: ModelState): ModelState;
54
57
  export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
55
- export declare function sameTyping(left: ModelState, right: ModelState): boolean;
56
- export declare function referenceField(facts: ValueFacts | undefined): boolean;
@@ -14,6 +14,8 @@ export type QueryChange = {
14
14
  removed: readonly RowKey[];
15
15
  order: readonly RowKey[] | null;
16
16
  coverage?: QueryCoverage;
17
+ next?: string | null;
18
+ total?: number;
17
19
  };
18
20
  export type QueryMessage = KeyedResult | QueryChange;
19
21
  export type Observed = {
@@ -25,5 +27,18 @@ export declare function rowsOf(result: QueryResult): readonly (QueryDocument | Q
25
27
  export declare function whole(message: QueryMessage): message is KeyedResult;
26
28
  export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
27
29
  export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
28
- export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
29
- export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
30
+ export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
31
+ export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
32
+ export type Digest = {
33
+ readonly pending: string;
34
+ } | {
35
+ readonly keys: readonly RowKey[];
36
+ readonly rows: ReadonlyMap<RowKey, number>;
37
+ readonly coverage: string;
38
+ readonly next: string | undefined;
39
+ readonly total: number | undefined;
40
+ };
41
+ export declare function hashed(text: string): number;
42
+ export declare function digestOf({ result, keys }: KeyedResult): Digest;
43
+ export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
44
+ export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
@@ -0,0 +1,21 @@
1
+ import type { BinaryResult } from './adapter.js';
2
+ import { type RuntimeDatabase } from './tables.js';
3
+ export type OpenedName = {
4
+ readonly locator: string;
5
+ readonly path: string;
6
+ readonly revision: string;
7
+ };
8
+ export type KeptBinary = {
9
+ readonly kind: 'binary';
10
+ readonly file: string;
11
+ readonly byteLength: number;
12
+ readonly mediaType: string;
13
+ };
14
+ export type KeptResult = KeptBinary | Exclude<BinaryResult, {
15
+ kind: 'binary';
16
+ }>;
17
+ export type OpenedFiles = {
18
+ find(name: OpenedName): Promise<KeptBinary | null>;
19
+ fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
+ };
21
+ export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;