@agentshouse/app-bridge 0.1.0-caae3da69c1c2 → 0.1.0-cac2ee656ded8

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 (113) hide show
  1. package/README.md +9 -9
  2. package/dist/index.d.ts +571 -18
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/crockford.d.ts +3 -0
  6. package/dist/mdmodel/definition.d.ts +21 -10
  7. package/dist/mdmodel/document.d.ts +15 -8
  8. package/dist/mdmodel/event.d.ts +76 -0
  9. package/dist/mdmodel/facts.d.ts +14 -0
  10. package/dist/mdmodel/fields.d.ts +1 -1
  11. package/dist/mdmodel/house-model.d.ts +826 -0
  12. package/dist/mdmodel/house-references.d.ts +3 -0
  13. package/dist/mdmodel/index.d.ts +35 -13
  14. package/dist/mdmodel/kinds.d.ts +17 -0
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/paths.d.ts +10 -1
  17. package/dist/mdmodel/pattern.d.ts +9 -0
  18. package/dist/mdmodel/query/language.d.ts +253 -0
  19. package/dist/mdmodel/query/match.d.ts +13 -0
  20. package/dist/mdmodel/query/rows.d.ts +31 -0
  21. package/dist/mdmodel/query/sql.d.ts +38 -0
  22. package/dist/mdmodel/reserved.d.ts +5 -0
  23. package/dist/mdmodel/room-types.d.ts +6 -0
  24. package/dist/mdmodel/types.d.ts +29 -10
  25. package/dist/mdmodel/validate.d.ts +31 -6
  26. package/dist/mdruntime/actions.d.ts +25 -0
  27. package/dist/mdruntime/adapter.d.ts +159 -122
  28. package/dist/mdruntime/attached-model.d.ts +6 -0
  29. package/dist/mdruntime/binary.d.ts +0 -5
  30. package/dist/mdruntime/bootstrap.d.ts +43 -0
  31. package/dist/mdruntime/cell.d.ts +5 -0
  32. package/dist/mdruntime/chain.d.ts +11 -0
  33. package/dist/mdruntime/change-set.d.ts +10 -16
  34. package/dist/mdruntime/change.d.ts +32 -1
  35. package/dist/mdruntime/client.d.ts +37 -26
  36. package/dist/mdruntime/collection.d.ts +29 -22
  37. package/dist/mdruntime/compile.d.ts +17 -0
  38. package/dist/mdruntime/conversation-live.d.ts +146 -0
  39. package/dist/mdruntime/conversation-row.d.ts +32 -0
  40. package/dist/mdruntime/conversation.d.ts +68 -49
  41. package/dist/mdruntime/declaration.d.ts +9 -0
  42. package/dist/mdruntime/durability.d.ts +20 -4
  43. package/dist/mdruntime/failure.d.ts +3 -0
  44. package/dist/mdruntime/figures.d.ts +48 -0
  45. package/dist/mdruntime/holdings.d.ts +28 -0
  46. package/dist/mdruntime/identity.d.ts +5 -0
  47. package/dist/mdruntime/listing.d.ts +47 -0
  48. package/dist/mdruntime/live.d.ts +22 -0
  49. package/dist/mdruntime/media.d.ts +7 -0
  50. package/dist/mdruntime/messages.d.ts +55 -0
  51. package/dist/mdruntime/model.d.ts +8 -11
  52. package/dist/mdruntime/observation.d.ts +17 -3
  53. package/dist/mdruntime/opened.d.ts +21 -0
  54. package/dist/mdruntime/outcome.d.ts +47 -9
  55. package/dist/mdruntime/overlay.d.ts +7 -5
  56. package/dist/mdruntime/preparation.d.ts +19 -0
  57. package/dist/mdruntime/presence.d.ts +51 -0
  58. package/dist/mdruntime/query.d.ts +21 -207
  59. package/dist/mdruntime/reach.d.ts +20 -9
  60. package/dist/mdruntime/readiness.d.ts +14 -18
  61. package/dist/mdruntime/reads.d.ts +38 -0
  62. package/dist/mdruntime/recovery.d.ts +5 -2
  63. package/dist/mdruntime/refresh.d.ts +26 -0
  64. package/dist/mdruntime/replica.d.ts +50 -39
  65. package/dist/mdruntime/retried.d.ts +29 -0
  66. package/dist/mdruntime/room-draft.d.ts +28 -11
  67. package/dist/mdruntime/room-drafts.d.ts +23 -0
  68. package/dist/mdruntime/runtime.d.ts +33 -0
  69. package/dist/mdruntime/save.d.ts +43 -50
  70. package/dist/mdruntime/saves.d.ts +31 -0
  71. package/dist/mdruntime/search.d.ts +12 -95
  72. package/dist/mdruntime/seed.d.ts +11 -2
  73. package/dist/mdruntime/socket/admission.d.ts +6 -0
  74. package/dist/mdruntime/socket/answers.d.ts +5 -0
  75. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  76. package/dist/mdruntime/socket/session.d.ts +37 -0
  77. package/dist/mdruntime/socket.d.ts +66 -0
  78. package/dist/mdruntime/source.d.ts +53 -0
  79. package/dist/mdruntime/status.d.ts +4 -5
  80. package/dist/mdruntime/store/installs.d.ts +29 -0
  81. package/dist/mdruntime/store/readiness.d.ts +9 -0
  82. package/dist/mdruntime/store/records.d.ts +214 -0
  83. package/dist/mdruntime/store/room-held.d.ts +7 -0
  84. package/dist/mdruntime/store/space.d.ts +10 -0
  85. package/dist/mdruntime/store/watchers.d.ts +16 -0
  86. package/dist/mdruntime/store/writes.d.ts +23 -0
  87. package/dist/mdruntime/store.d.ts +111 -166
  88. package/dist/mdruntime/stored.d.ts +156 -0
  89. package/dist/mdruntime/surface.d.ts +88 -0
  90. package/dist/mdruntime/tables.d.ts +414 -0
  91. package/dist/mdruntime/tallies.d.ts +17 -0
  92. package/dist/mdruntime/transfer.d.ts +0 -5
  93. package/dist/mdruntime/wire.d.ts +82 -9
  94. package/dist/session-content/bounds.d.ts +7 -0
  95. package/dist/session-content/check.d.ts +18 -0
  96. package/dist/session-content/index.d.ts +7 -0
  97. package/dist/session-content/parts.d.ts +103 -0
  98. package/dist/session-content/state.d.ts +61 -0
  99. package/dist/session-content/turn.d.ts +328 -0
  100. package/dist/test-host.d.ts +7 -4
  101. package/dist/test-host.js +18 -28
  102. package/docs/families.md +65 -57
  103. package/package.json +8 -3
  104. package/dist/calls.d.ts +0 -957
  105. package/dist/calls.js +0 -1
  106. package/dist/mdmodel/blocks.d.ts +0 -10
  107. package/dist/mdmodel/condition.d.ts +0 -147
  108. package/dist/mdmodel/profile.d.ts +0 -5
  109. package/dist/mdruntime/connection.d.ts +0 -146
  110. package/dist/mdruntime/file.d.ts +0 -19
  111. package/dist/mdruntime/rows.d.ts +0 -38
  112. package/dist/mdruntime/shared.d.ts +0 -14
  113. package/dist/mdruntime/turn.d.ts +0 -8
@@ -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,18 +11,21 @@ export type ChangeSet = {
20
11
  rooms: readonly string[];
21
12
  queues: readonly string[];
22
13
  presentations: readonly string[];
23
- messages: readonly MessageChange[];
24
14
  conversations: readonly string[];
15
+ unindexed: readonly string[];
16
+ due: readonly string[];
25
17
  };
26
18
  type Changed = {
19
+ documents?: readonly string[] | null;
27
20
  drafts?: readonly string[];
28
21
  room?: boolean;
29
22
  queue?: boolean;
30
23
  presentation?: string;
24
+ unindexed?: boolean;
25
+ due?: boolean;
31
26
  };
32
- export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): ChangeSet;
33
- export declare function changing(locator: string, before: Replica | null, after: Replica | null, changed?: Changed): Generator<number, ChangeSet, void>;
34
- export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
35
- export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
27
+ export declare function changeSet(locator: string, changed?: Changed): ChangeSet;
28
+ export declare function conversationChangeSet(conversations: readonly string[]): ChangeSet;
36
29
  export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
30
+ export declare function touches(set: ChangeSet, locator: string, path: string): boolean;
37
31
  export {};
@@ -1,3 +1,4 @@
1
+ import type { BinaryFile, HeadChange } from './adapter.js';
1
2
  export type Change = {
2
3
  readonly kind: 'field';
3
4
  readonly path: string;
@@ -29,7 +30,6 @@ export type Change = {
29
30
  readonly kind: 'binary';
30
31
  readonly path: string;
31
32
  readonly localId: string;
32
- readonly blob: Blob;
33
33
  readonly byteLength: number;
34
34
  readonly mediaType: string;
35
35
  readonly sha256: string;
@@ -40,6 +40,33 @@ export type Change = {
40
40
  } | {
41
41
  readonly kind: 'remove';
42
42
  readonly path: string;
43
+ } | (Arriving & {
44
+ readonly content: string;
45
+ }) | (Arriving & {
46
+ readonly binary: BinaryFile;
47
+ });
48
+ type Arriving = {
49
+ readonly kind: 'arrival';
50
+ readonly path: string;
51
+ readonly revision?: string;
52
+ readonly fileId?: string;
53
+ readonly created?: string;
54
+ readonly change?: HeadChange;
55
+ };
56
+ export type RoomMove = {
57
+ readonly source: {
58
+ readonly room: string;
59
+ readonly baseRoomVersion: string;
60
+ };
61
+ readonly destination: {
62
+ readonly room: string;
63
+ readonly baseRoomVersion: string;
64
+ readonly handle: string;
65
+ };
66
+ readonly moves: readonly {
67
+ readonly path: string;
68
+ readonly to: string;
69
+ }[];
43
70
  };
44
71
  export type Precondition = {
45
72
  readonly kind: 'field';
@@ -81,8 +108,12 @@ export type ChangeBatch = {
81
108
  readonly changes: readonly Change[];
82
109
  readonly preconditions: readonly Precondition[];
83
110
  readonly writtenBy?: WrittenBy;
111
+ readonly between?: RoomMove;
84
112
  };
85
113
  export declare function immutable(batch: ChangeBatch): ChangeBatch;
114
+ export declare function partnerOf(batch: ChangeBatch, locator: string): string | null;
115
+ export declare function leaving(batch: ChangeBatch, locator: string): boolean;
86
116
  export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
87
117
  export declare function departure(changes: readonly Change[], index: number): string;
88
118
  export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
119
+ export {};
@@ -1,16 +1,26 @@
1
- import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
2
- import type { Member, ServiceMode } from './adapter.js';
3
- import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.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';
7
+ import type { ListedAgent, Member, ServiceMode } from './adapter.js';
8
+ import type { UnsentWork } from './durability.js';
9
+ import type { ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
4
10
  import { type Observation } from './observation.js';
5
- import type { BinaryReference } from './binary.js';
6
- import type { BinaryAnswer, BinaryLinkAnswer, 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, QueueEntry, Resolution } from './outcome.js';
12
+ import type { FiguresResult } from './figures.js';
13
+ import type { Holdings } from './holdings.js';
14
+ import type { DocumentResult, GroupResult, PendingResult } from './query.js';
8
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
9
16
  import type { SearchRequest, SearchResult } from './search.js';
10
17
  import type { Readiness } from './readiness.js';
18
+ import type { ObservedRead } from './reads.js';
11
19
  import type { SyncStatus } from './status.js';
12
20
  import { type RuntimePort } from './wire.js';
21
+ export type BuildFile = (name: string) => Promise<Blob | null>;
13
22
  export type MdRuntimeClient = {
23
+ buildFile(name: string): Promise<Blob | null>;
14
24
  rooms(): Promise<readonly AppRoom[]>;
15
25
  query: {
16
26
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
@@ -21,7 +31,7 @@ export type MdRuntimeClient = {
21
31
  roomDraft: {
22
32
  list(): Promise<readonly RoomDraft[]>;
23
33
  read(room: string, path: string): Promise<RoomDraft | null>;
24
- write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
34
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
25
35
  discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
36
  };
27
37
  save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
@@ -31,33 +41,26 @@ export type MdRuntimeClient = {
31
41
  write(value: unknown): Promise<void>;
32
42
  edit(members: Readonly<Record<string, unknown>>): Promise<void>;
33
43
  };
34
- conversation: {
35
- list(): Promise<readonly ConversationEntry[]>;
36
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
37
- create(input: unknown): Promise<CallResult>;
38
- send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
39
- answer(conversation: string, answer: unknown): Promise<CallResult>;
40
- interrupt(conversation: string): Promise<CallResult>;
41
- kill(conversation: string): Promise<CallResult>;
42
- cancel(conversation: string, turn: string): Promise<CallResult>;
43
- delete(conversation: string): Promise<CallResult>;
44
- };
45
- chatDraft: {
46
- write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
47
- prepend(conversation: string, draft: ChatDraft): Promise<void>;
48
- discard(conversation: string): Promise<void>;
44
+ conversation: ConversationSurface & {
45
+ pageMetadata(app: string, address: string): Promise<string>;
49
46
  };
47
+ chatDraft: ChatDraftSurface;
50
48
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
49
+ resolve(room: string, path: string, destination: string): Promise<Resolution>;
51
50
  binaryFile: {
52
51
  read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
53
- link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
54
- readReference(reference: BinaryReference): Promise<BinaryAnswer>;
52
+ attach(room: string, file: File): Promise<AttachAnswer>;
53
+ download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
55
54
  };
56
55
  call(name: string, input: unknown): Promise<CallResult>;
56
+ answered(operation: string): Promise<boolean>;
57
57
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
58
- log(): Promise<string>;
59
58
  persistence(): Promise<boolean>;
60
59
  retry(): Promise<void>;
60
+ cleanUp(): Promise<number>;
61
+ unsent(): Promise<readonly UnsentWork[]>;
62
+ reset(): Promise<void>;
63
+ readAgain(): Promise<void>;
61
64
  observe: {
62
65
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
63
66
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -67,6 +70,7 @@ export type MdRuntimeClient = {
67
70
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
68
71
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
69
72
  (topic: 'member'): Promise<Observation<Member | null>>;
73
+ (topic: 'authority-changes'): Promise<Observation<number>>;
70
74
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
71
75
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
72
76
  (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
@@ -75,12 +79,19 @@ export type MdRuntimeClient = {
75
79
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
76
80
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
77
81
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
82
+ (topic: 'listed-agents'): Promise<Observation<readonly ListedAgent[]>>;
83
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
84
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
85
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
78
86
  };
79
87
  reauthorize(): Promise<void>;
80
88
  settled(): Promise<void>;
81
89
  };
82
- export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
90
+ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFile): MdRuntimeClient;
83
91
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
92
+ export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
93
+ export { roomDraftRevision } from './identity.js';
94
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
84
95
  export type { Observation } from './observation.js';
85
96
  export type { Open } from './open.js';
86
97
  export { unanswered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,9 +1,7 @@
1
- import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
2
- import { type ModelState } from './model.js';
1
+ import { type DefinitionOf, type Document, type TypedPath } from '../mdmodel/index.js';
2
+ import type { ModelState, TypesResult } from './model.js';
3
+ import type { AppTypedSelection } from './listing.js';
3
4
  import type { MdModelIdentity } from './adapter.js';
4
- import { type Paths } from './shared.js';
5
- import type { Refused } from './transfer.js';
6
- import { type Later } from './turn.js';
7
5
  export declare const MD_MODEL: MdModelIdentity;
8
6
  export type Collection = {
9
7
  text: Readonly<Record<string, string>>;
@@ -16,24 +14,33 @@ export type Composition = {
16
14
  roots: readonly string[];
17
15
  model: ModelState;
18
16
  } | null;
17
+ typedPaths: readonly TypedPath[];
19
18
  };
20
- export declare function governing(composition: Composition, path: string): ModelState;
21
- export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
22
- export declare function collecting(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Generator<number, Collection, void>;
23
- export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
24
- export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
25
- export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Generator<number, Refused | null, void>;
26
- export declare function validRoot(root: unknown): root is string;
27
- export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Generator<number, Validation, void>;
28
- type Held = {
29
- text: Paths<string>;
30
- binaries: Paths<unknown>;
19
+ export type Composed = {
20
+ readonly composition: Composition;
21
+ readonly fingerprint: string;
22
+ };
23
+ export declare function composedOf(composition: Composition): Composed;
24
+ type Selecting<M> = {
25
+ readonly model: M;
26
+ readonly selection: {
27
+ readonly roots: readonly string[];
28
+ readonly model: M;
29
+ } | null;
31
30
  };
32
- export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
33
- export declare function referencesIndexed(held: Held, composition: Composition): boolean;
34
- export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
31
+ export declare function selected(composition: {
32
+ readonly selection: {
33
+ readonly roots: readonly string[];
34
+ } | null;
35
+ }, path: string): boolean;
36
+ export declare function governing<M>(composition: Selecting<M>, path: string): M;
37
+ export declare function definitionsAt(composition: Composition, path: string): DefinitionOf;
38
+ export declare function definitionsIn(room: {
39
+ readonly model: TypesResult;
40
+ readonly typedSelection: AppTypedSelection | null;
41
+ }, path: string, typedPaths: readonly TypedPath[]): DefinitionOf;
42
+ export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
43
+ export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
44
+ export declare function validRoot(root: unknown): root is string;
35
45
  export declare function available(composition: Composition): boolean;
36
- export declare function changedCleanly(next: Held, previous: Held & {
37
- composition: Composition;
38
- }, composition: Composition): Generator<number, boolean, void>;
39
46
  export {};
@@ -0,0 +1,17 @@
1
+ import { sql } from '../mdmodel/index.js';
2
+ import { type Composition } from './collection.js';
3
+ import type { Plan, QueryRows } from './query.js';
4
+ import type { Connection } from './tables.js';
5
+ export type QueryRoom = {
6
+ readonly locator: string;
7
+ readonly key: number;
8
+ readonly composition?: Composition;
9
+ };
10
+ type Fragment = sql.Fragment;
11
+ export declare const VISIBLE: (alias: string) => string;
12
+ export declare function within(alias: string, path: string): Fragment;
13
+ export type QueryAnswer = QueryRows & {
14
+ readonly more?: string;
15
+ };
16
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
17
+ export {};
@@ -0,0 +1,146 @@
1
+ import type { SessionState } from '../session-content/index.js';
2
+ import type { AcceptedMessage, ConversationAction, ConversationHistoryRequest, ConversationStream, ListedAgent, ListedConversation, ProcessCommand, SessionOption } from './adapter.js';
3
+ import { type Cell } from './cell.js';
4
+ import type { ChangeSet } from './change-set.js';
5
+ import type { Asked, ConversationAgent, ConversationEntry, ConversationView, RunningTurn } from './conversation.js';
6
+ import type { CallResult } from './outcome.js';
7
+ import type { Recovery } from './recovery.js';
8
+ import type { Attempt, Retries } from './retried.js';
9
+ import type { ChatDraftRecord, RuntimeStore } from './store.js';
10
+ export type ConversationDependencies = {
11
+ call(name: ConversationAction, input: unknown, attempt?: Attempt): Promise<CallResult>;
12
+ history(request: ConversationHistoryRequest): Promise<CallResult>;
13
+ durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
14
+ local(): Promise<RuntimeStore>;
15
+ again(): void;
16
+ settled(): void;
17
+ stream(): ConversationStream | undefined;
18
+ publish(set: ChangeSet): void;
19
+ online(): boolean;
20
+ full(): boolean;
21
+ closed(): boolean;
22
+ unanswered(): void;
23
+ heard(operation: string, lost: boolean): void;
24
+ readonly recovery: Recovery;
25
+ readonly retries: Retries;
26
+ };
27
+ export type Live = {
28
+ turn: RunningTurn | null;
29
+ questions: readonly unknown[];
30
+ process: {
31
+ running: boolean;
32
+ } | null;
33
+ commands: readonly ProcessCommand[];
34
+ options: readonly SessionOption[];
35
+ starting: string | null;
36
+ state: SessionState | null;
37
+ link: {
38
+ connected: boolean;
39
+ } | null;
40
+ deliveryWaiting: readonly string[];
41
+ deliveryUnknown: readonly string[];
42
+ };
43
+ export declare const QUIET: Live;
44
+ export type Fact = Exclude<keyof Live, 'turn'>;
45
+ export declare const FACTS: readonly Fact[];
46
+ type Watcher = {
47
+ readonly notify: (view: ConversationView) => void;
48
+ };
49
+ type HeldWindow = {
50
+ readonly window: readonly AcceptedMessage[] | null;
51
+ readonly draft: ChatDraftRecord | null;
52
+ readonly ended: string | null;
53
+ readonly dismissed: string | null;
54
+ readonly more: boolean;
55
+ readonly total: number | null;
56
+ };
57
+ export type SharedView = {
58
+ readonly conversation: string;
59
+ readonly asked: Asked;
60
+ readonly held: Cell<HeldWindow>;
61
+ ready(): readonly Watcher[];
62
+ join(watcher: Watcher): void;
63
+ admit(watcher: Watcher): boolean;
64
+ leave(watcher: Watcher): boolean;
65
+ empty(): boolean;
66
+ };
67
+ type Listing<T> = (value: T) => void;
68
+ export type Audience<T> = {
69
+ waiting(): boolean;
70
+ told(): boolean;
71
+ join(watcher: Listing<T>): void;
72
+ leave(watcher: Listing<T>): void;
73
+ tell(value: T): void;
74
+ welcome(value: T): void;
75
+ clear(): void;
76
+ };
77
+ type HeldFacts = {
78
+ readonly listKnown: boolean;
79
+ readonly openingRead: boolean;
80
+ readonly openingListed: boolean;
81
+ readonly listOwed: boolean;
82
+ readonly listTelling: boolean;
83
+ readonly agentsShown: string | null;
84
+ readonly listedShown: string | null;
85
+ readonly replicated: ReadonlySet<string>;
86
+ readonly handedReplicated: string | undefined;
87
+ };
88
+ export type Dispatch = Cell<{
89
+ readonly answered: boolean;
90
+ }>;
91
+ export type Relisted = {
92
+ readonly conversations: ReadonlyMap<string, ListedConversation>;
93
+ readonly agents: ReadonlyMap<string, ListedAgent>;
94
+ };
95
+ export type LiveConversations = {
96
+ readonly deps: ConversationDependencies;
97
+ readonly held: Cell<HeldFacts>;
98
+ readonly closing: AbortSignal;
99
+ readonly listeners: Audience<readonly ConversationEntry[]>;
100
+ readonly agentListeners: Audience<readonly ConversationAgent[]>;
101
+ readonly listedListeners: Audience<readonly ListedAgent[]>;
102
+ views(): Iterable<SharedView>;
103
+ viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
104
+ readonly view: SharedView;
105
+ readonly watcher: Watcher;
106
+ };
107
+ viewLeft(key: string, view: SharedView, watcher: Watcher): void;
108
+ liveOf(conversation: string): Live;
109
+ liveHeld(conversation: string): Live | undefined;
110
+ holdLive(conversation: string, next: Live | null): void;
111
+ factsOwed(conversation: string): void;
112
+ factsHeard(conversation: string, facts: readonly Fact[]): void;
113
+ factsTaken(): readonly (readonly [string, ReadonlySet<Fact>])[];
114
+ behind(conversation: string): boolean;
115
+ behindAll(): readonly string[];
116
+ fellBehind(conversation: string): void;
117
+ caughtUpTo(conversation: string): void;
118
+ gapOpened(conversation: string): void;
119
+ generation(conversation: string): number;
120
+ heardAt(conversation: string, change: string): void;
121
+ newestHeard(conversation: string): string | undefined;
122
+ catching(conversation: string): Promise<void> | undefined;
123
+ catchingUntil(conversation: string, ended: Promise<void>): void;
124
+ creating(conversation: string): void;
125
+ created(conversation: string): void;
126
+ isCreating(conversation: string): boolean;
127
+ relisting(): boolean;
128
+ relistBegun(): void;
129
+ relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
130
+ relistDropped(conversation: string): void;
131
+ relistTaken(): Relisted | null;
132
+ sendingBegan(operation: string): Dispatch;
133
+ sendingEnded(operation: string, dispatch: Dispatch): void;
134
+ sending(operation: string): boolean;
135
+ rowSoon(tell: () => void): void;
136
+ inOrder(work: () => Promise<void>): void;
137
+ forget(conversation: string): void;
138
+ current(): boolean;
139
+ known(): boolean;
140
+ listed(): boolean;
141
+ reopened(): void;
142
+ lost(): void;
143
+ close(): void;
144
+ };
145
+ export declare function createLiveConversations(deps: ConversationDependencies): LiveConversations;
146
+ 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,45 +1,55 @@
1
- import type { ConversationAction, ConversationAgents, ConversationEvent, ConversationMessage, ConversationStream, ProcessCommand, SessionOption, TurnContext } from './adapter.js';
1
+ import { type Part, type SessionState } from '../session-content/index.js';
2
+ import type { AgentEnvironment, ConversationEvent, ConversationMessage, ListedAgent, ProcessCommand, SessionOption } from './adapter.js';
2
3
  import { type ChangeSet } from './change-set.js';
3
- import { type ChatDraftFile } from './file.js';
4
+ import { type LiveConversations } from './conversation-live.js';
5
+ import { type ConversationHeld } from './conversation-row.js';
4
6
  import type { Open } from './open.js';
5
7
  import { type CallResult, type Offline } from './outcome.js';
6
- import type { DocumentResult, PendingResult } from './query.js';
8
+ import type { ChatRequest } from './source.js';
7
9
  import type { CycleProgress } from './status.js';
8
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
10
+ import type { RuntimeStore } from './store.js';
9
11
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
10
- export type ConversationEntry = {
12
+ export type ConversationEntry = ConversationHeld & {
11
13
  conversation: string;
12
14
  agent: {
13
15
  identity: string;
14
- name: string | null;
16
+ name: string;
17
+ retired: boolean;
15
18
  };
16
19
  name: string;
17
20
  created: string;
18
21
  finished: string | null;
19
22
  outcome: string | null;
20
23
  waiting: boolean;
24
+ subject: string | null;
21
25
  state: ConversationState;
22
26
  started: string | null;
27
+ line: string | null;
28
+ question: string | null;
29
+ asked: string | null;
23
30
  };
24
31
  export type ConversationAgent = {
25
32
  identity: string;
26
33
  name: string;
34
+ cli: string;
35
+ environment: AgentEnvironment;
27
36
  };
28
37
  export type RunningTurn = {
29
38
  turn: string;
30
39
  started: string | null;
31
- parts: readonly unknown[];
32
- context: TurnContext | null;
40
+ parts: readonly Part[];
33
41
  };
34
42
  export type ChatDraft = {
35
43
  text: string;
36
- files: readonly ChatDraftFile[];
37
44
  };
38
45
  export type ConversationOptions = {
39
46
  limit?: number;
40
47
  after?: string;
41
48
  total?: true;
42
49
  };
50
+ export type ConversationRead = ConversationOptions & {
51
+ text?: string;
52
+ };
43
53
  export type ConversationView = {
44
54
  conversation: string;
45
55
  messages: readonly ConversationMessage[];
@@ -50,67 +60,76 @@ export type ConversationView = {
50
60
  process: {
51
61
  running: boolean;
52
62
  } | null;
63
+ processEnded: string | null;
53
64
  commands: readonly ProcessCommand[];
54
65
  options: readonly SessionOption[];
55
66
  starting: string | null;
67
+ state: SessionState | null;
56
68
  link: {
57
69
  connected: boolean;
58
70
  } | null;
71
+ deliveryWaiting: readonly string[];
59
72
  deliveryUnknown: readonly string[];
60
73
  chatDraft: (ChatDraft & {
61
74
  readonly revision: string;
62
75
  }) | null;
76
+ dismissedSuggestion: string | null;
63
77
  };
78
+ export type RequestDecision = 'approve' | 'decline';
64
79
  export type ConversationSurface = {
65
80
  list(): Promise<readonly ConversationEntry[]>;
66
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
81
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
67
82
  create(input: unknown): Promise<CallResult>;
68
83
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
69
- answer(conversation: string, answer: unknown): Promise<CallResult>;
70
- interrupt(conversation: string): Promise<CallResult>;
71
- kill(conversation: string): Promise<CallResult>;
72
- cancel(conversation: string, turn: string): Promise<CallResult>;
73
- delete(conversation: string): Promise<CallResult>;
84
+ answer(conversation: string, answer: ConversationAnswer, operation: string): Promise<CallResult>;
85
+ interrupt(conversation: string, operation: string): Promise<CallResult>;
86
+ kill(conversation: string, operation: string): Promise<CallResult>;
87
+ delete(conversation: string, operation: string): Promise<CallResult>;
88
+ takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
89
+ decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
90
+ rename(conversation: string, name: string, operation: string): Promise<CallResult>;
91
+ option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
92
+ retry(conversation: string, message: string, operation: string): Promise<CallResult>;
93
+ pins(): Promise<readonly string[]>;
94
+ pin(figures: readonly string[]): Promise<void>;
95
+ openedTurns(): Promise<Readonly<Record<string, string>>>;
96
+ openTurn(conversation: string, turn: string): Promise<void>;
97
+ dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
98
+ };
99
+ export type ConversationAnswer = {
100
+ interaction_id: string;
101
+ response: unknown;
74
102
  };
75
103
  export type ChatDraftSurface = {
76
104
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
77
105
  prepend(conversation: string, draft: ChatDraft): Promise<void>;
106
+ append(conversation: string, draft: ChatDraft): Promise<void>;
78
107
  discard(conversation: string): Promise<void>;
79
108
  };
80
- export type ConversationDependencies = {
81
- agents(): ConversationAgents | undefined;
82
- documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
83
- call(name: ConversationAction, input: unknown): Promise<CallResult>;
84
- durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
85
- stream(): ConversationStream | undefined;
86
- publish(set: ChangeSet): void;
87
- online(): boolean;
88
- closed(): boolean;
89
- unanswered(): void;
90
- expired(operation: string): boolean;
91
- };
92
- export type ConversationStore = {
93
- surface: ConversationSurface;
94
- chatDraft: ChatDraftSurface;
95
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
96
- reconcile(): Promise<void>;
97
- catchUp(progress: CycleProgress): Promise<void>;
98
- resend(progress: CycleProgress): Promise<void>;
99
- current(): boolean;
100
- known(): boolean;
101
- reconnected(): void;
102
- reopened(): void;
103
- lost(): void;
104
- watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
105
- watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
106
- watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
107
- changed(set: ChangeSet): void;
108
- receive(event: ConversationEvent): boolean;
109
- searchable(): readonly string[];
110
- acquired(conversation: string): boolean;
111
- close(): void;
112
- };
113
109
  export declare function unheldView(conversation: string): ConversationView;
114
110
  export declare const SESSION_STARTED = "Session started";
111
+ export declare const CATCHING_UP = "catching-up";
112
+ export declare const HISTORY_CONVERSATIONS = 64;
115
113
  export declare function newChat(agent: string): string;
116
- export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
114
+ export type Asked = {
115
+ limit: number;
116
+ after: string | undefined;
117
+ before: readonly [string, string] | null;
118
+ total: boolean;
119
+ };
120
+ export declare function joinedDraft(first: string, second: string): string;
121
+ export declare function conversationsLearned(alive: LiveConversations): void;
122
+ export declare function conversationSurface(alive: LiveConversations): ConversationSurface;
123
+ export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
124
+ export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
125
+ export declare function reconcileOpening(alive: LiveConversations): Promise<void>;
126
+ export declare function reconcileConversations(alive: LiveConversations): Promise<void>;
127
+ export declare function catchUpConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
128
+ export declare function holdsSubmission(alive: LiveConversations, operation: string): Promise<boolean>;
129
+ export declare function resendConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
130
+ export declare function watchConversation(alive: LiveConversations, conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
131
+ export declare function watchConversationList(alive: LiveConversations, deliver: (entries: readonly ConversationEntry[]) => void): () => void;
132
+ export declare function watchConversationAgents(alive: LiveConversations, deliver: (agents: readonly ConversationAgent[]) => void): () => void;
133
+ export declare function watchListedAgents(alive: LiveConversations, deliver: (agents: readonly ListedAgent[]) => void): () => void;
134
+ export declare function conversationsChanged(alive: LiveConversations, set: ChangeSet): void;
135
+ export declare function receiveConversationEvent(alive: LiveConversations, event: ConversationEvent): void;