@agentshouse/app-bridge 0.1.0-cedebf3bb1f58 → 0.1.0-cefd2eeb54a01

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 (64) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +881 -19
  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 +24 -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/pattern.d.ts +9 -0
  12. package/dist/mdmodel/project.d.ts +1 -0
  13. package/dist/mdmodel/query/language.d.ts +222 -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 +4 -0
  18. package/dist/mdmodel/types.d.ts +35 -4
  19. package/dist/mdmodel/validate.d.ts +30 -4
  20. package/dist/mdruntime/adapter.d.ts +144 -79
  21. package/dist/mdruntime/binary.d.ts +0 -5
  22. package/dist/mdruntime/chain.d.ts +11 -0
  23. package/dist/mdruntime/change-set.d.ts +9 -16
  24. package/dist/mdruntime/change.d.ts +32 -1
  25. package/dist/mdruntime/client.d.ts +22 -10
  26. package/dist/mdruntime/collection.d.ts +11 -21
  27. package/dist/mdruntime/compile.d.ts +10 -0
  28. package/dist/mdruntime/connection.d.ts +32 -19
  29. package/dist/mdruntime/conversation.d.ts +34 -17
  30. package/dist/mdruntime/durability.d.ts +7 -4
  31. package/dist/mdruntime/identity.d.ts +5 -0
  32. package/dist/mdruntime/media.d.ts +7 -0
  33. package/dist/mdruntime/messages.d.ts +27 -0
  34. package/dist/mdruntime/model.d.ts +8 -10
  35. package/dist/mdruntime/observation.d.ts +17 -2
  36. package/dist/mdruntime/opened.d.ts +21 -0
  37. package/dist/mdruntime/outcome.d.ts +45 -7
  38. package/dist/mdruntime/overlay.d.ts +3 -5
  39. package/dist/mdruntime/query.d.ts +15 -190
  40. package/dist/mdruntime/reach.d.ts +18 -9
  41. package/dist/mdruntime/readiness.d.ts +14 -17
  42. package/dist/mdruntime/recovery.d.ts +3 -2
  43. package/dist/mdruntime/replica.d.ts +58 -33
  44. package/dist/mdruntime/room-draft.d.ts +25 -6
  45. package/dist/mdruntime/save.d.ts +53 -14
  46. package/dist/mdruntime/search.d.ts +12 -82
  47. package/dist/mdruntime/status.d.ts +4 -5
  48. package/dist/mdruntime/store.d.ts +156 -108
  49. package/dist/mdruntime/stored.d.ts +155 -0
  50. package/dist/mdruntime/tables.d.ts +380 -0
  51. package/dist/mdruntime/wire.d.ts +42 -5
  52. package/dist/test-host.d.ts +7 -4
  53. package/dist/test-host.js +19 -29
  54. package/docs/families.md +69 -53
  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/acquisition.d.ts +0 -13
  60. package/dist/mdruntime/file.d.ts +0 -19
  61. package/dist/mdruntime/rows.d.ts +0 -37
  62. package/dist/mdruntime/shared.d.ts +0 -10
  63. package/dist/mdruntime/transfer.d.ts +0 -9
  64. package/dist/mdruntime/turn.d.ts +0 -6
@@ -1,10 +1,11 @@
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';
10
11
  import type { Readiness } from './readiness.js';
@@ -21,39 +22,46 @@ export type MdRuntimeClient = {
21
22
  roomDraft: {
22
23
  list(): Promise<readonly RoomDraft[]>;
23
24
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- 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>;
25
26
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
27
  };
27
28
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
29
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
28
30
  presentation: {
29
31
  read(): Promise<unknown>;
30
32
  write(value: unknown): Promise<void>;
33
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
31
34
  };
32
35
  conversation: {
33
36
  list(): Promise<readonly ConversationEntry[]>;
34
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
37
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
35
38
  create(input: unknown): Promise<CallResult>;
36
39
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
37
- answer(conversation: string, answer: unknown): Promise<CallResult>;
40
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
38
41
  interrupt(conversation: string): Promise<CallResult>;
39
42
  kill(conversation: string): Promise<CallResult>;
40
- cancel(conversation: string, turn: string): Promise<CallResult>;
41
43
  delete(conversation: string): Promise<CallResult>;
42
44
  };
43
45
  chatDraft: {
44
46
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
47
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
45
48
  discard(conversation: string): Promise<void>;
46
49
  };
47
50
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
51
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
48
52
  binaryFile: {
49
53
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
50
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
54
+ attach(room: string, file: File): Promise<AttachAnswer>;
55
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
51
56
  };
52
57
  call(name: string, input: unknown): Promise<CallResult>;
53
58
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
54
59
  log(): Promise<string>;
55
60
  persistence(): Promise<boolean>;
56
61
  retry(): Promise<void>;
62
+ cleanUp(): Promise<number>;
63
+ unsent(): Promise<readonly UnsentWork[]>;
64
+ reset(): Promise<void>;
57
65
  observe: {
58
66
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
59
67
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -63,6 +71,7 @@ export type MdRuntimeClient = {
63
71
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
64
72
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
65
73
  (topic: 'member'): Promise<Observation<Member | null>>;
74
+ (topic: 'authority-changes'): Promise<Observation<number>>;
66
75
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
76
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
68
77
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -77,6 +86,9 @@ export type MdRuntimeClient = {
77
86
  };
78
87
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
79
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';
80
92
  export type { Observation } from './observation.js';
81
93
  export type { Open } from './open.js';
82
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,21 +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';
4
5
  import { type EntrySeed } from './seed.js';
5
6
  import { type SearchRequest, type SearchResult } from './search.js';
6
7
  import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
7
8
  import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
8
9
  import { type WrittenBy } from './change.js';
9
10
  import type { Open } from './open.js';
10
- import { type BinaryReference } from './binary.js';
11
- 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';
12
12
  import { type Recovery } from './recovery.js';
13
13
  import { type SaveRefusal } from './save.js';
14
- import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
14
+ import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
15
15
  import { type SyncStatus } from './status.js';
16
- import { type RuntimeShell } from './durability.js';
17
- import { type RuntimeDemand } from './acquisition.js';
18
- import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness, type SearchObligation } from './readiness.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';
19
19
  import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
20
20
  export type AppTypedSelection = {
21
21
  roots: readonly string[];
@@ -34,6 +34,7 @@ export type AppRoom = {
34
34
  documents: number;
35
35
  synchronizationAvailable: boolean;
36
36
  refusal: ProviderRefusal | null;
37
+ locked: boolean;
37
38
  };
38
39
  export type RoomSchemas = {
39
40
  collection: TypesResult;
@@ -50,9 +51,11 @@ export type ConnectionRefusal = {
50
51
  export type MdRuntimeOptions = {
51
52
  adapter: Adapter;
52
53
  shell: RuntimeShell;
54
+ database: RuntimeDatabase;
53
55
  authorization?: Authorization;
54
56
  signal?: AbortSignal;
55
57
  recovery?: Recovery;
58
+ usableWhenHeld?: readonly string[];
56
59
  };
57
60
  export type SaveResult = {
58
61
  outcome: 'saved';
@@ -64,19 +67,27 @@ export type SavedRoomDraft = {
64
67
  readonly path: string;
65
68
  readonly revision: string;
66
69
  };
70
+ export type SavedParts = {
71
+ readonly path: string;
72
+ readonly parts: RoomDraftParts;
73
+ };
67
74
  export type RoomDraftSurface = {
68
75
  list(): Promise<readonly RoomDraft[]>;
69
- read(room: string, path: string): RoomDraft | null;
70
- 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>;
71
78
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
72
79
  };
73
80
  export type PresentationSurface = {
74
81
  read(app: string): Promise<unknown>;
75
82
  write(app: string, value: unknown): Promise<void>;
83
+ edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
76
84
  };
77
85
  export type BinaryFileSurface = {
78
- read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
79
- 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>;
80
91
  };
81
92
  export type HistoryQuery = {
82
93
  revision?: string;
@@ -84,25 +95,30 @@ export type HistoryQuery = {
84
95
  };
85
96
  export type MdRuntime = {
86
97
  loaded(): Promise<void>;
87
- rooms(): readonly AppRoom[];
98
+ rooms(): Promise<readonly AppRoom[]>;
88
99
  query: {
89
100
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
90
101
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
91
102
  };
92
103
  search(request: SearchRequest): Promise<SearchResult>;
93
- types(locator: string): RoomSchemas;
104
+ types(locator: string): Promise<RoomSchemas>;
94
105
  roomDraft: RoomDraftSurface;
95
106
  conversation: ConversationSurface;
96
107
  chatDraft: ChatDraftSurface;
97
108
  presentation: PresentationSurface;
98
109
  save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
110
+ saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
99
111
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
112
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
100
113
  binaryFile: BinaryFileSurface;
101
114
  call(name: string, input: unknown): Promise<CallResult>;
102
- reached(locator: string, roomVersion: string, path?: string): boolean;
115
+ reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
103
116
  log(): string;
104
117
  persistence(): boolean;
105
118
  retry(): Promise<void>;
119
+ cleanUp(): Promise<number>;
120
+ unsent(): Promise<readonly UnsentWork[]>;
121
+ reset(): Promise<void>;
106
122
  observe: {
107
123
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
108
124
  (topic: 'readiness'): Promise<Observation<Readiness>>;
@@ -111,6 +127,7 @@ export type MdRuntime = {
111
127
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
112
128
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
113
129
  (topic: 'member'): Promise<Observation<Member | null>>;
130
+ (topic: 'authority-changes'): Promise<Observation<number>>;
114
131
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
115
132
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
116
133
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -122,18 +139,14 @@ export type MdRuntime = {
122
139
  };
123
140
  reauthorize(): Promise<void>;
124
141
  };
125
- export type RuntimeTopic = 'rooms' | 'readiness' | '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';
126
143
  export type ReadinessPort = {
127
144
  readonly target: string;
128
145
  readonly code: CodeAvailability;
129
- readonly capacity: CapacityCause | null;
130
- readonly search: SearchObligation;
131
146
  };
132
147
  export type ComposedRuntime = RuntimeView & {
133
148
  seed(entry: EntrySeed): void;
134
149
  stop(): Promise<void>;
135
- lose(locators: readonly string[]): Promise<void>;
136
- acquire(demand: RuntimeDemand): void;
137
150
  persisted(answer: Persistence): void;
138
151
  within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
139
152
  };
@@ -1,22 +1,21 @@
1
- import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
1
+ import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, 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
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
6
+ import type { RuntimeStore } from './store.js';
9
7
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
10
8
  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,74 +31,92 @@ 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>;
89
+ local(): Promise<RuntimeStore>;
90
+ again(): void;
91
+ settled(): void;
74
92
  stream(): ConversationStream | undefined;
75
93
  publish(set: ChangeSet): void;
76
94
  online(): boolean;
95
+ full(): boolean;
77
96
  closed(): boolean;
78
97
  unanswered(): void;
79
- expired(operation: string): boolean;
80
98
  };
81
99
  export type ConversationStore = {
82
100
  surface: ConversationSurface;
83
101
  chatDraft: ChatDraftSurface;
84
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
102
+ opened(local: RuntimeStore): Promise<void>;
85
103
  reconcile(): Promise<void>;
86
104
  catchUp(progress: CycleProgress): Promise<void>;
87
105
  resend(progress: CycleProgress): Promise<void>;
88
106
  current(): boolean;
89
107
  known(): boolean;
90
- reconnected(): void;
108
+ learned(): void;
91
109
  reopened(): void;
92
110
  lost(): void;
93
111
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
94
112
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
95
113
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
96
114
  changed(set: ChangeSet): void;
97
- receive(event: ConversationEvent): boolean;
98
- searchable(): readonly string[];
99
- acquired(conversation: string): boolean;
115
+ receive(event: ConversationEvent): void;
100
116
  close(): void;
101
117
  };
102
118
  export declare function unheldView(conversation: string): ConversationView;
103
119
  export declare const SESSION_STARTED = "Session started";
120
+ export declare const HISTORY_CONVERSATIONS = 64;
104
121
  export declare function newChat(agent: string): string;
105
122
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,14 +1,17 @@
1
1
  import type { Persistence } from './readiness.js';
2
- export type StorageEstimate = {
3
- readonly usage: number;
4
- readonly quota: number;
2
+ export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
3
+ export type UnsentWork = {
4
+ readonly kind: UnsentKind;
5
+ readonly count: number;
5
6
  };
6
7
  export type RuntimeShell = {
7
8
  persistence: Persistence;
8
9
  generation: string | null;
9
10
  keepGeneration(value: string): void | Promise<void>;
10
11
  dropGeneration(): void | Promise<void>;
11
- estimate?(): Promise<StorageEstimate | null>;
12
+ cleanUp?(): Promise<number>;
13
+ reset(): Promise<void>;
12
14
  };
15
+ export declare function refusedForSpace(error: unknown): boolean;
13
16
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
14
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, conversations: readonly string[] | null): 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,20 +20,21 @@ 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
  };
29
+ export type StoredModel = Extract<ModelState, {
30
+ status: 'unavailable';
31
+ }> | Omit<Extract<ModelState, {
32
+ status: 'current' | 'cached';
33
+ }>, 'types'>;
31
34
  export type TypesResult = {
32
35
  status: Open<'unavailable'>;
33
36
  reason: ModelUnavailableReason;
34
37
  types: null;
35
- schema?: string | null;
36
- revision?: string | null;
37
38
  } | {
38
39
  status: Open<'current' | 'cached'>;
39
40
  identity: string;
@@ -51,7 +52,4 @@ export type ValidationReceipt = {
51
52
  export declare const NO_MODEL: ModelState;
52
53
  export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
53
54
  export declare function modelTypes(state: ModelState): TypesResult;
54
- export declare function cached(state: ModelState): ModelState;
55
- export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
56
- export declare function sameTyping(left: ModelState, right: ModelState): boolean;
57
- export declare function referenceField(facts: ValueFacts | undefined): boolean;
55
+ export declare function storedModel(state: ModelState): StoredModel;
@@ -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;