@agentshouse/app-bridge 0.1.0-c646d0da70608 → 0.1.0-c64bbf5cda7ef

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 (100) hide show
  1. package/README.md +11 -11
  2. package/dist/index.d.ts +943 -19
  3. package/dist/mdmodel/definition.d.ts +17 -1
  4. package/dist/mdmodel/document.d.ts +6 -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 +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 +4 -0
  18. package/dist/mdmodel/types.d.ts +39 -4
  19. package/dist/mdmodel/validate.d.ts +30 -4
  20. package/dist/mdruntime/actions.d.ts +19 -0
  21. package/dist/mdruntime/adapter.d.ts +151 -79
  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 +9 -16
  28. package/dist/mdruntime/change.d.ts +32 -1
  29. package/dist/mdruntime/client.d.ts +33 -10
  30. package/dist/mdruntime/collection.d.ts +11 -21
  31. package/dist/mdruntime/compile.d.ts +15 -0
  32. package/dist/mdruntime/conversation-row.d.ts +32 -0
  33. package/dist/mdruntime/conversation.d.ts +43 -18
  34. package/dist/mdruntime/durability.d.ts +16 -4
  35. package/dist/mdruntime/figures.d.ts +47 -0
  36. package/dist/mdruntime/holdings.d.ts +28 -0
  37. package/dist/mdruntime/identity.d.ts +5 -0
  38. package/dist/mdruntime/install.d.ts +55 -0
  39. package/dist/mdruntime/job.d.ts +32 -0
  40. package/dist/mdruntime/listing.d.ts +52 -0
  41. package/dist/mdruntime/live.d.ts +22 -0
  42. package/dist/mdruntime/log.d.ts +5 -0
  43. package/dist/mdruntime/media.d.ts +7 -0
  44. package/dist/mdruntime/messages.d.ts +51 -0
  45. package/dist/mdruntime/model.d.ts +8 -10
  46. package/dist/mdruntime/observation.d.ts +17 -2
  47. package/dist/mdruntime/opened.d.ts +21 -0
  48. package/dist/mdruntime/outcome.d.ts +49 -8
  49. package/dist/mdruntime/overlay.d.ts +4 -5
  50. package/dist/mdruntime/preparation.d.ts +19 -0
  51. package/dist/mdruntime/query.d.ts +26 -185
  52. package/dist/mdruntime/reach.d.ts +19 -9
  53. package/dist/mdruntime/readiness.d.ts +14 -17
  54. package/dist/mdruntime/reads.d.ts +35 -0
  55. package/dist/mdruntime/recovery.d.ts +3 -2
  56. package/dist/mdruntime/refresh.d.ts +26 -0
  57. package/dist/mdruntime/replica.d.ts +55 -33
  58. package/dist/mdruntime/room-draft.d.ts +37 -6
  59. package/dist/mdruntime/room-drafts.d.ts +23 -0
  60. package/dist/mdruntime/runtime.d.ts +41 -0
  61. package/dist/mdruntime/save.d.ts +53 -14
  62. package/dist/mdruntime/saves.d.ts +69 -0
  63. package/dist/mdruntime/search.d.ts +15 -78
  64. package/dist/mdruntime/seed.d.ts +24 -0
  65. package/dist/mdruntime/socket/admission.d.ts +6 -0
  66. package/dist/mdruntime/socket/answers.d.ts +5 -0
  67. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  68. package/dist/mdruntime/socket/rooms.d.ts +42 -0
  69. package/dist/mdruntime/socket/session.d.ts +38 -0
  70. package/dist/mdruntime/socket.d.ts +69 -0
  71. package/dist/mdruntime/source.d.ts +60 -0
  72. package/dist/mdruntime/status.d.ts +4 -5
  73. package/dist/mdruntime/store/fences.d.ts +15 -0
  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 +211 -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 +106 -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 +414 -0
  85. package/dist/mdruntime/tallies.d.ts +17 -0
  86. package/dist/mdruntime/transfer.d.ts +0 -5
  87. package/dist/mdruntime/turn.d.ts +5 -3
  88. package/dist/mdruntime/wire.d.ts +50 -6
  89. package/dist/test-host.d.ts +7 -4
  90. package/dist/test-host.js +19 -29
  91. package/docs/families.md +69 -53
  92. package/package.json +8 -3
  93. package/dist/calls.d.ts +0 -117
  94. package/dist/calls.js +0 -1
  95. package/dist/mdmodel/condition.d.ts +0 -149
  96. package/dist/mdruntime/acquisition.d.ts +0 -13
  97. package/dist/mdruntime/connection.d.ts +0 -138
  98. package/dist/mdruntime/file.d.ts +0 -19
  99. package/dist/mdruntime/rows.d.ts +0 -36
  100. package/dist/mdruntime/shared.d.ts +0 -10
@@ -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,17 @@ 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[];
25
15
  };
26
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
16
+ type Changed = {
17
+ documents?: readonly string[] | null;
27
18
  drafts?: readonly string[];
28
19
  room?: boolean;
29
20
  queue?: boolean;
30
21
  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;
22
+ };
23
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
24
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
34
25
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
26
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
27
+ 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,13 +1,21 @@
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';
13
21
  export type MdRuntimeClient = {
@@ -21,39 +29,47 @@ export type MdRuntimeClient = {
21
29
  roomDraft: {
22
30
  list(): Promise<readonly RoomDraft[]>;
23
31
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
32
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
25
33
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
34
  };
27
35
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
36
+ saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
28
37
  presentation: {
29
38
  read(): Promise<unknown>;
30
39
  write(value: unknown): Promise<void>;
40
+ edit(members: Readonly<Record<string, unknown>>): Promise<void>;
31
41
  };
32
42
  conversation: {
33
43
  list(): Promise<readonly ConversationEntry[]>;
34
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
44
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
35
45
  create(input: unknown): Promise<CallResult>;
36
46
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
37
- answer(conversation: string, answer: unknown): Promise<CallResult>;
47
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
38
48
  interrupt(conversation: string): Promise<CallResult>;
39
49
  kill(conversation: string): Promise<CallResult>;
40
- cancel(conversation: string, turn: string): Promise<CallResult>;
41
50
  delete(conversation: string): Promise<CallResult>;
42
51
  };
43
52
  chatDraft: {
44
53
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
54
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
45
55
  discard(conversation: string): Promise<void>;
46
56
  };
47
57
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
58
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
48
59
  binaryFile: {
49
60
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
50
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
61
+ attach(room: string, file: File): Promise<AttachAnswer>;
62
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
51
63
  };
52
64
  call(name: string, input: unknown): Promise<CallResult>;
53
65
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
54
66
  log(): Promise<string>;
55
67
  persistence(): Promise<boolean>;
56
68
  retry(): Promise<void>;
69
+ cleanUp(): Promise<number>;
70
+ unsent(): Promise<readonly UnsentWork[]>;
71
+ reset(): Promise<void>;
72
+ readAgain(): Promise<void>;
57
73
  observe: {
58
74
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
59
75
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -63,6 +79,7 @@ export type MdRuntimeClient = {
63
79
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
64
80
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
65
81
  (topic: 'member'): Promise<Observation<Member | null>>;
82
+ (topic: 'authority-changes'): Promise<Observation<number>>;
66
83
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
67
84
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
68
85
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -71,12 +88,18 @@ export type MdRuntimeClient = {
71
88
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
72
89
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
73
90
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
91
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
92
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
93
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
74
94
  };
75
95
  reauthorize(): Promise<void>;
76
96
  settled(): Promise<void>;
77
97
  };
78
98
  export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
79
99
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
100
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
101
+ export { roomDraftRevision } from './identity.js';
102
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
80
103
  export type { Observation } from './observation.js';
81
104
  export type { Open } from './open.js';
82
105
  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,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,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;
@@ -1,24 +1,29 @@
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';
3
+ import { type ConversationHeld } from './conversation-row.js';
4
+ import type { OpenJob } from './job.js';
4
5
  import type { Open } from './open.js';
5
6
  import { type CallResult, type Offline } from './outcome.js';
6
- import type { DocumentResult, PendingResult } from './query.js';
7
7
  import type { CycleProgress } from './status.js';
8
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
8
+ import type { RuntimeStore } from './store.js';
9
9
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
10
- export type ConversationEntry = {
10
+ export type ConversationEntry = ConversationHeld & {
11
11
  conversation: string;
12
12
  agent: {
13
13
  identity: string;
14
- name: string | null;
14
+ name: string;
15
+ retired: boolean;
15
16
  };
16
17
  name: string;
17
18
  created: string;
18
19
  finished: string | null;
19
20
  outcome: string | null;
21
+ waiting: boolean;
20
22
  state: ConversationState;
21
23
  started: string | null;
24
+ line: string | null;
25
+ question: string | null;
26
+ asked: string | null;
22
27
  };
23
28
  export type ConversationAgent = {
24
29
  identity: string;
@@ -32,73 +37,93 @@ export type RunningTurn = {
32
37
  };
33
38
  export type ChatDraft = {
34
39
  text: string;
35
- files: readonly ChatDraftFile[];
36
40
  };
37
41
  export type ConversationOptions = {
38
42
  limit?: number;
43
+ after?: string;
44
+ total?: true;
45
+ };
46
+ export type ConversationRead = ConversationOptions & {
47
+ text?: string;
39
48
  };
40
49
  export type ConversationView = {
41
50
  conversation: string;
42
51
  messages: readonly ConversationMessage[];
52
+ next?: string;
53
+ total?: number;
43
54
  turn: RunningTurn | null;
44
55
  questions: readonly unknown[];
45
56
  process: {
46
57
  running: boolean;
47
58
  } | null;
59
+ processEnded: string | null;
48
60
  commands: readonly ProcessCommand[];
49
61
  options: readonly SessionOption[];
62
+ starting: string | null;
63
+ subagents: readonly RunningSubagent[];
64
+ link: {
65
+ connected: boolean;
66
+ } | null;
67
+ deliveryUnknown: readonly string[];
50
68
  chatDraft: (ChatDraft & {
51
69
  readonly revision: string;
52
70
  }) | null;
71
+ jobs: readonly OpenJob[];
53
72
  };
54
73
  export type ConversationSurface = {
55
74
  list(): Promise<readonly ConversationEntry[]>;
56
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
75
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
57
76
  create(input: unknown): Promise<CallResult>;
58
77
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
59
- answer(conversation: string, answer: unknown): Promise<CallResult>;
78
+ answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
60
79
  interrupt(conversation: string): Promise<CallResult>;
61
80
  kill(conversation: string): Promise<CallResult>;
62
- cancel(conversation: string, turn: string): Promise<CallResult>;
63
81
  delete(conversation: string): Promise<CallResult>;
64
82
  };
83
+ export type ConversationAnswer = {
84
+ interaction_id: string;
85
+ response: unknown;
86
+ };
65
87
  export type ChatDraftSurface = {
66
88
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
89
+ prepend(conversation: string, draft: ChatDraft): Promise<void>;
67
90
  discard(conversation: string): Promise<void>;
68
91
  };
69
92
  export type ConversationDependencies = {
70
- agents(): ConversationAgents | undefined;
71
- documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
72
93
  call(name: ConversationAction, input: unknown): Promise<CallResult>;
94
+ history(request: ConversationHistoryRequest): Promise<CallResult>;
73
95
  durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
96
+ local(): Promise<RuntimeStore>;
97
+ again(): void;
98
+ settled(): void;
74
99
  stream(): ConversationStream | undefined;
75
100
  publish(set: ChangeSet): void;
76
101
  online(): boolean;
102
+ full(): boolean;
77
103
  closed(): boolean;
78
104
  unanswered(): void;
79
- expired(operation: string): boolean;
80
105
  };
81
106
  export type ConversationStore = {
82
107
  surface: ConversationSurface;
83
108
  chatDraft: ChatDraftSurface;
84
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
109
+ opened(local: RuntimeStore): Promise<void>;
85
110
  reconcile(): Promise<void>;
86
111
  catchUp(progress: CycleProgress): Promise<void>;
87
112
  resend(progress: CycleProgress): Promise<void>;
88
113
  current(): boolean;
89
114
  known(): boolean;
90
- reconnected(): void;
115
+ learned(): void;
91
116
  reopened(): void;
117
+ lost(): void;
92
118
  watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
93
119
  watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
94
120
  watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
95
121
  changed(set: ChangeSet): void;
96
- receive(event: ConversationEvent): boolean;
97
- searchable(): readonly string[];
98
- acquired(conversation: string): boolean;
122
+ receive(event: ConversationEvent): void;
99
123
  close(): void;
100
124
  };
101
125
  export declare function unheldView(conversation: string): ConversationView;
102
126
  export declare const SESSION_STARTED = "Session started";
127
+ export declare const HISTORY_CONVERSATIONS = 64;
103
128
  export declare function newChat(agent: string): string;
104
129
  export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
@@ -1,14 +1,26 @@
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;
6
+ };
7
+ export type AppCode = {
8
+ readonly running: number;
9
+ readonly older: number;
10
+ };
11
+ export type HeldCode = {
12
+ readonly house: number | null;
13
+ readonly apps: readonly string[];
5
14
  };
6
15
  export type RuntimeShell = {
7
16
  persistence: Persistence;
8
17
  generation: string | null;
9
18
  keepGeneration(value: string): void | Promise<void>;
10
19
  dropGeneration(): void | Promise<void>;
11
- estimate?(): Promise<StorageEstimate | null>;
20
+ cleanUp?(): Promise<number>;
21
+ measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
22
+ reset(): Promise<void>;
12
23
  };
24
+ export declare function refusedForSpace(error: unknown): boolean;
13
25
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
14
26
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -0,0 +1,47 @@
1
+ import type { ChangeSet } from './change-set.js';
2
+ import type { GroupTotal, PendingResult } from './query.js';
3
+ import type { Deliver, Fail } from './reach.js';
4
+ import type { ConversationTally, RoomTally } from './tallies.js';
5
+ import type { QueryRoom } from './tables.js';
6
+ export declare const HOUSE_DIRECTORY = "house";
7
+ export declare const ROOM_TOTALS: {
8
+ readonly outside: readonly ["house"];
9
+ readonly groupBy: readonly ["room"];
10
+ readonly select: {
11
+ readonly size: true;
12
+ };
13
+ };
14
+ export type DayFigures = {
15
+ readonly created: number;
16
+ readonly changed: number;
17
+ readonly chats: number;
18
+ readonly messages: number;
19
+ };
20
+ export type RoomFigures = {
21
+ readonly room: string;
22
+ readonly day: DayFigures;
23
+ readonly total: {
24
+ readonly documents: GroupTotal;
25
+ readonly files: GroupTotal;
26
+ };
27
+ };
28
+ export type Figures = {
29
+ readonly rooms: readonly RoomFigures[];
30
+ readonly agentMessages: number;
31
+ };
32
+ export type FiguresResult = Figures | PendingResult;
33
+ export type FiguresCover = PendingResult | {
34
+ readonly rooms: readonly QueryRoom[];
35
+ };
36
+ export type FiguresSources = {
37
+ cover(): Promise<FiguresCover>;
38
+ rooms(rooms: readonly QueryRoom[], since: string): Promise<readonly RoomTally[]>;
39
+ conversations(conversations: readonly string[] | null, since: string): Promise<readonly ConversationTally[]>;
40
+ };
41
+ export type FiguresRead = {
42
+ watch(deliver: Deliver, fail: Fail): () => void;
43
+ touched(set: ChangeSet): void;
44
+ recover(): void;
45
+ close(): void;
46
+ };
47
+ export declare function createFigures(sources: FiguresSources): FiguresRead;
@@ -0,0 +1,28 @@
1
+ import type { AppCode } from './durability.js';
2
+ import type { GroupTotal, PendingResult } from './query.js';
3
+ import type { Deliver, Fail } from './reach.js';
4
+ import type { Runtime } from './runtime.js';
5
+ import type { OpenedRoom } from './tables.js';
6
+ export type RoomDocuments = {
7
+ readonly room: string;
8
+ readonly documents: GroupTotal;
9
+ };
10
+ export type HeldApp = ({
11
+ readonly app: string;
12
+ readonly state: 'measured';
13
+ } & AppCode) | {
14
+ readonly app: string;
15
+ readonly state: 'asking' | 'unknown';
16
+ };
17
+ export type Holdings = {
18
+ readonly rooms: readonly RoomDocuments[] | PendingResult;
19
+ readonly opened: GroupTotal & {
20
+ readonly rooms: readonly OpenedRoom[];
21
+ };
22
+ readonly apps: readonly HeldApp[];
23
+ readonly house: number | null;
24
+ readonly total: number | null;
25
+ readonly cleanUp: number | null;
26
+ };
27
+ export declare const CLEANED_TOPIC = "cleaned";
28
+ export declare function watchHoldings({ store, figures, shell }: Runtime, deliver: Deliver, fail: Fail): () => void;
@@ -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,55 @@
1
+ import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
2
+ import { type Reads } from './bootstrap.js';
3
+ import type { Installation, RoomCoverage } from './readiness.js';
4
+ import { advancement, type Refresher } from './refresh.js';
5
+ import type { ReplicaRecord } from './replica.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import type { Live } from './socket.js';
8
+ import { type CoveredRoom, type InstallHold, type RuntimeStore, type Store } from './store.js';
9
+ import { type Unconfirmed } from './transfer.js';
10
+ type Standing = {
11
+ readonly key: number | null;
12
+ readonly confirmed: number;
13
+ };
14
+ export type Unheld = {
15
+ readonly staged: boolean;
16
+ };
17
+ export type Withheld = AdapterFailure | RetryableRefusal | NotReady | Unconfirmed;
18
+ type Landing = {
19
+ readonly kind: 'refreshed';
20
+ readonly from: Standing;
21
+ readonly remodelled: boolean;
22
+ } | {
23
+ readonly kind: 'bootstrapped';
24
+ readonly refreshed: boolean;
25
+ readonly from: Standing;
26
+ };
27
+ type Refreshed = {
28
+ kind: 'advanced';
29
+ record: ReplicaRecord;
30
+ from: Standing;
31
+ remodelled: boolean;
32
+ } | Exclude<Awaited<ReturnType<typeof advancement>>, {
33
+ kind: 'advanced';
34
+ }>;
35
+ export declare const ERASE_BATCH = 512;
36
+ export declare function installationOf(store: Store, coverage: readonly RoomCoverage[], held: ReadonlyMap<string, CoveredRoom>): Installation;
37
+ export declare function roomInFlight(store: Store, locator: string): boolean;
38
+ export declare function sweep({ store, socket, journal }: Runtime): void;
39
+ export declare function forgetInstall(store: Store, locator: string): void;
40
+ export declare function caughtUpTo(runtime: Runtime, locator: string): void;
41
+ export declare function catching(store: Store, locator: string): void;
42
+ export declare function confirmedAgain(store: Store, locator: string): void;
43
+ export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
44
+ export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
45
+ export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
46
+ export declare function replaced(store: Store, locators: readonly string[]): void;
47
+ export declare function reachedBy({ store, socket }: Runtime, locator: string, roomVersion: string): Promise<boolean>;
48
+ export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
49
+ export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
50
+ export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
51
+ export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
52
+ readonly kind: 'transport-uncertainty';
53
+ } | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
54
+ export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
55
+ export {};
@@ -0,0 +1,32 @@
1
+ type Job = {
2
+ readonly label: string;
3
+ readonly kind: 'started' | 'scheduled' | 'ended';
4
+ readonly state: string;
5
+ readonly next: string | null;
6
+ };
7
+ export type RunningJob = {
8
+ readonly name: string;
9
+ readonly running_since: string;
10
+ };
11
+ export type JobMarker = {
12
+ readonly said: string;
13
+ readonly at: string;
14
+ };
15
+ export type OpenJob<At = string | null> = {
16
+ readonly name: string;
17
+ readonly started: At;
18
+ };
19
+ export declare function jobOf(said: string): Job;
20
+ export declare function closeLast(open: {
21
+ readonly key: string;
22
+ }[], key: string): void;
23
+ export declare function markerMoved<Kept extends {
24
+ readonly key: string;
25
+ }>(open: Kept[], said: string, opened: (job: Job, key: string) => Kept | null): void;
26
+ export declare function openJobs<At>(markers: readonly {
27
+ readonly said: string;
28
+ readonly at: At;
29
+ }[]): readonly OpenJob<At>[];
30
+ export declare function jobsRunning(jobs: readonly RunningJob[], now: number): string[];
31
+ export declare function sessionEnded(jobs: readonly RunningJob[], now: number): string;
32
+ export {};