@agentshouse/app-bridge 0.1.0-c895bda3a3f6a → 0.1.0-c8a196c36dc76

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 (119) hide show
  1. package/README.md +6 -6
  2. package/dist/index.d.ts +247 -407
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/definition.d.ts +24 -11
  6. package/dist/mdmodel/document.d.ts +14 -9
  7. package/dist/mdmodel/event.d.ts +76 -0
  8. package/dist/mdmodel/facts.d.ts +14 -0
  9. package/dist/mdmodel/fields.d.ts +1 -1
  10. package/dist/mdmodel/house-model.d.ts +869 -0
  11. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  12. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  13. package/dist/mdmodel/index.d.ts +44 -15
  14. package/dist/mdmodel/indexed.d.ts +8 -0
  15. package/dist/mdmodel/kinds.d.ts +20 -0
  16. package/dist/mdmodel/markdown.d.ts +74 -0
  17. package/dist/mdmodel/media-type.d.ts +71 -0
  18. package/dist/mdmodel/moment.d.ts +6 -0
  19. package/dist/mdmodel/not-ready.d.ts +1 -0
  20. package/dist/mdmodel/paths.d.ts +15 -1
  21. package/dist/mdmodel/pattern.d.ts +9 -0
  22. package/dist/mdmodel/query/language.d.ts +254 -0
  23. package/dist/mdmodel/query/match.d.ts +13 -0
  24. package/dist/mdmodel/query/rows.d.ts +31 -0
  25. package/dist/mdmodel/query/sql.d.ts +42 -0
  26. package/dist/mdmodel/query/walk.d.ts +62 -0
  27. package/dist/mdmodel/references.d.ts +2 -2
  28. package/dist/mdmodel/reserved.d.ts +5 -0
  29. package/dist/mdmodel/room-types.d.ts +6 -0
  30. package/dist/mdmodel/types.d.ts +22 -22
  31. package/dist/mdmodel/validate.d.ts +12 -6
  32. package/dist/mdmodel/yaml.d.ts +4 -4
  33. package/dist/mdruntime/actions.d.ts +25 -0
  34. package/dist/mdruntime/adapter.d.ts +161 -81
  35. package/dist/mdruntime/attached-model.d.ts +6 -0
  36. package/dist/mdruntime/authored.d.ts +87 -0
  37. package/dist/mdruntime/bootstrap.d.ts +43 -0
  38. package/dist/mdruntime/cell.d.ts +5 -0
  39. package/dist/mdruntime/chain.d.ts +2 -1
  40. package/dist/mdruntime/change-set.d.ts +4 -0
  41. package/dist/mdruntime/change.d.ts +5 -0
  42. package/dist/mdruntime/client.d.ts +36 -23
  43. package/dist/mdruntime/collection.d.ts +27 -4
  44. package/dist/mdruntime/compile.d.ts +9 -7
  45. package/dist/mdruntime/conversation-live.d.ts +151 -0
  46. package/dist/mdruntime/conversation-row.d.ts +39 -0
  47. package/dist/mdruntime/conversation.d.ts +67 -46
  48. package/dist/mdruntime/declaration.d.ts +9 -0
  49. package/dist/mdruntime/durability.d.ts +20 -0
  50. package/dist/mdruntime/failure.d.ts +3 -0
  51. package/dist/mdruntime/figures.d.ts +48 -0
  52. package/dist/mdruntime/holdings.d.ts +28 -0
  53. package/dist/mdruntime/house-query.d.ts +14 -0
  54. package/dist/mdruntime/identity.d.ts +0 -1
  55. package/dist/mdruntime/install.d.ts +59 -0
  56. package/dist/mdruntime/listing.d.ts +59 -0
  57. package/dist/mdruntime/live.d.ts +24 -0
  58. package/dist/mdruntime/media.d.ts +19 -2
  59. package/dist/mdruntime/messages.d.ts +35 -5
  60. package/dist/mdruntime/modal.d.ts +1 -0
  61. package/dist/mdruntime/model.d.ts +6 -12
  62. package/dist/mdruntime/observation.d.ts +30 -13
  63. package/dist/mdruntime/opened.d.ts +1 -1
  64. package/dist/mdruntime/outcome.d.ts +17 -2
  65. package/dist/mdruntime/overlay.d.ts +7 -2
  66. package/dist/mdruntime/preparation.d.ts +45 -0
  67. package/dist/mdruntime/presence.d.ts +57 -0
  68. package/dist/mdruntime/query.d.ts +13 -211
  69. package/dist/mdruntime/reach.d.ts +25 -14
  70. package/dist/mdruntime/readiness.d.ts +20 -7
  71. package/dist/mdruntime/reads.d.ts +38 -0
  72. package/dist/mdruntime/recovery.d.ts +4 -1
  73. package/dist/mdruntime/refresh.d.ts +26 -0
  74. package/dist/mdruntime/replica.d.ts +11 -16
  75. package/dist/mdruntime/retried.d.ts +29 -0
  76. package/dist/mdruntime/room-draft.d.ts +33 -9
  77. package/dist/mdruntime/room-drafts.d.ts +23 -0
  78. package/dist/mdruntime/runtime.d.ts +34 -0
  79. package/dist/mdruntime/save.d.ts +42 -86
  80. package/dist/mdruntime/saves.d.ts +33 -0
  81. package/dist/mdruntime/search.d.ts +12 -63
  82. package/dist/mdruntime/seed.d.ts +11 -2
  83. package/dist/mdruntime/socket/admission.d.ts +6 -0
  84. package/dist/mdruntime/socket/answers.d.ts +5 -0
  85. package/dist/mdruntime/socket/lanes.d.ts +27 -0
  86. package/dist/mdruntime/socket/session.d.ts +40 -0
  87. package/dist/mdruntime/socket.d.ts +67 -0
  88. package/dist/mdruntime/source.d.ts +58 -0
  89. package/dist/mdruntime/status.d.ts +0 -2
  90. package/dist/mdruntime/store/installs.d.ts +29 -0
  91. package/dist/mdruntime/store/readiness.d.ts +10 -0
  92. package/dist/mdruntime/store/records.d.ts +226 -0
  93. package/dist/mdruntime/store/room-held.d.ts +7 -0
  94. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  95. package/dist/mdruntime/store/space.d.ts +10 -0
  96. package/dist/mdruntime/store/watchers.d.ts +16 -0
  97. package/dist/mdruntime/store/writes.d.ts +23 -0
  98. package/dist/mdruntime/store.d.ts +116 -154
  99. package/dist/mdruntime/stored.d.ts +80 -69
  100. package/dist/mdruntime/surface.d.ts +93 -0
  101. package/dist/mdruntime/tables.d.ts +118 -93
  102. package/dist/mdruntime/tallies.d.ts +17 -0
  103. package/dist/mdruntime/transfer.d.ts +4 -0
  104. package/dist/mdruntime/wire.d.ts +81 -7
  105. package/dist/session-content/check.d.ts +17 -0
  106. package/dist/session-content/index.d.ts +6 -0
  107. package/dist/session-content/parts.d.ts +30 -0
  108. package/dist/session-content/state.d.ts +59 -0
  109. package/dist/session-content/turn.d.ts +137 -0
  110. package/dist/test-host.d.ts +8 -1
  111. package/dist/test-host.js +45 -2
  112. package/docs/families.md +78 -39
  113. package/package.json +2 -2
  114. package/dist/mdmodel/blocks.d.ts +0 -10
  115. package/dist/mdmodel/condition.d.ts +0 -180
  116. package/dist/mdmodel/links.d.ts +0 -28
  117. package/dist/mdmodel/profile.d.ts +0 -5
  118. package/dist/mdruntime/connection.d.ts +0 -153
  119. package/dist/mdruntime/fulltext.d.ts +0 -26
@@ -1,21 +1,34 @@
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, ConversationAnswer, 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, RoomList, 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 { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
6
- import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
11
+ import { type AttachAnswer, type BinaryAnswer, type CallResult, type DownloadAnswer, type HistoryAnswer, type QueueEntry, type 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';
7
15
  import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
8
16
  import type { SearchRequest, SearchResult } from './search.js';
17
+ import type { HouseQuery, HouseQueryResult } from './house-query.js';
9
18
  import type { Readiness } from './readiness.js';
19
+ import type { ObservedRead } from './reads.js';
10
20
  import type { SyncStatus } from './status.js';
11
21
  import { type RuntimePort } from './wire.js';
22
+ export type BuildFile = (name: string) => Promise<Blob | null>;
12
23
  export type MdRuntimeClient = {
24
+ buildFile(name: string): Promise<Blob | null>;
13
25
  rooms(): Promise<readonly AppRoom[]>;
14
26
  query: {
15
27
  (query: DocumentQuery): Promise<DocumentResult | PendingResult>;
16
28
  (query: GroupQuery): Promise<GroupResult | PendingResult>;
17
29
  };
18
30
  search(request: SearchRequest): Promise<SearchResult>;
31
+ queryHouse(query: HouseQuery): Promise<HouseQueryResult>;
19
32
  types(locator: string): Promise<RoomSchemas>;
20
33
  roomDraft: {
21
34
  list(): Promise<readonly RoomDraft[]>;
@@ -30,21 +43,10 @@ export type MdRuntimeClient = {
30
43
  write(value: unknown): Promise<void>;
31
44
  edit(members: Readonly<Record<string, unknown>>): Promise<void>;
32
45
  };
33
- conversation: {
34
- list(): Promise<readonly ConversationEntry[]>;
35
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
36
- create(input: unknown): Promise<CallResult>;
37
- send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
38
- answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
39
- interrupt(conversation: string): Promise<CallResult>;
40
- kill(conversation: string): Promise<CallResult>;
41
- delete(conversation: string): Promise<CallResult>;
42
- };
43
- chatDraft: {
44
- write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
45
- prepend(conversation: string, draft: ChatDraft): Promise<void>;
46
- discard(conversation: string): Promise<void>;
46
+ conversation: ConversationSurface & {
47
+ pageMetadata(app: string, address: string): Promise<string>;
47
48
  };
49
+ chatDraft: ChatDraftSurface;
48
50
  history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
49
51
  resolve(room: string, path: string, destination: string): Promise<Resolution>;
50
52
  binaryFile: {
@@ -53,11 +55,15 @@ export type MdRuntimeClient = {
53
55
  download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
54
56
  };
55
57
  call(name: string, input: unknown): Promise<CallResult>;
58
+ answered(operation: string): Promise<boolean>;
56
59
  reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
57
- log(): Promise<string>;
58
60
  persistence(): Promise<boolean>;
59
61
  retry(): Promise<void>;
60
62
  cleanUp(): Promise<number>;
63
+ unsent(): Promise<readonly UnsentWork[]>;
64
+ sent(): Promise<void>;
65
+ reset(): Promise<void>;
66
+ readAgain(): Promise<void>;
61
67
  observe: {
62
68
  (topic: 'deployment-facts'): Promise<Observation<unknown>>;
63
69
  (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
@@ -67,6 +73,7 @@ export type MdRuntimeClient = {
67
73
  (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
68
74
  (topic: 'service-mode'): Promise<Observation<ServiceMode>>;
69
75
  (topic: 'member'): Promise<Observation<Member | null>>;
76
+ (topic: 'time-zone'): Promise<Observation<string | null>>;
70
77
  (topic: 'authority-changes'): Promise<Observation<number>>;
71
78
  (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
72
79
  (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
@@ -76,15 +83,21 @@ export type MdRuntimeClient = {
76
83
  (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
77
84
  (topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
78
85
  (topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
86
+ (topic: 'listed-agents'): Promise<Observation<readonly ListedAgent[]>>;
87
+ (topic: 'room-list'): Promise<Observation<RoomList | null>>;
88
+ (topic: 'figures'): Promise<Observation<FiguresResult>>;
89
+ (topic: 'holdings'): Promise<Observation<Holdings>>;
90
+ (topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
79
91
  };
80
92
  reauthorize(): Promise<void>;
81
93
  settled(): Promise<void>;
82
94
  };
83
- export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
95
+ export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFile): MdRuntimeClient;
84
96
  export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
85
97
  export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
86
98
  export { roomDraftRevision } from './identity.js';
87
- export { defineRoomMedia, ROOM_MEDIA } from './media.js';
99
+ export { defineRoomMedia, ROOM_MEDIA, viewFile } from './media.js';
100
+ export { shownModal } from './modal.js';
88
101
  export type { Observation } from './observation.js';
89
102
  export type { Open } from './open.js';
90
- export { unanswered, type RuntimePort, type WireMember } from './wire.js';
103
+ export { unanswered, undelivered, type RuntimePort, type WireMember } from './wire.js';
@@ -1,5 +1,6 @@
1
- import { type Document } from '../mdmodel/index.js';
2
- import type { ModelState } from './model.js';
1
+ import { type DefinitionOf, type Document, type ParseResult, type TypedPath, type VerifiedModel } 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
5
  export declare const MD_MODEL: MdModelIdentity;
5
6
  export type Collection = {
@@ -13,15 +14,37 @@ export type Composition = {
13
14
  roots: readonly string[];
14
15
  model: ModelState;
15
16
  } | null;
17
+ typedPaths: readonly TypedPath[];
16
18
  };
17
19
  export type Composed = {
18
20
  readonly composition: Composition;
19
21
  readonly fingerprint: string;
20
22
  };
23
+ export declare function typesPrint(types: VerifiedModel['types']): string;
21
24
  export declare function composedOf(composition: Composition): Composed;
22
- export declare function selected(composition: Composition, path: string): boolean;
23
- export declare function governing(composition: Composition, path: string): ModelState;
25
+ type Selecting<M> = {
26
+ readonly model: M;
27
+ readonly selection: {
28
+ readonly roots: readonly string[];
29
+ readonly model: M;
30
+ } | null;
31
+ };
32
+ export declare function selected(composition: {
33
+ readonly selection: {
34
+ readonly roots: readonly string[];
35
+ } | null;
36
+ }, path: string): boolean;
37
+ export declare function governing<M>(composition: Selecting<M>, path: string): M;
38
+ export declare function definitionsAt(composition: Composition, path: string): DefinitionOf;
39
+ export declare function definitionsIn(room: {
40
+ readonly model: TypesResult;
41
+ readonly typedSelection: AppTypedSelection | null;
42
+ }, path: string, typedPaths: readonly TypedPath[]): DefinitionOf;
24
43
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
25
44
  export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
26
45
  export declare function validRoot(root: unknown): root is string;
46
+ export declare const UNTYPED = "any";
47
+ export declare function textType(read: ParseResult): string | undefined;
48
+ export declare function typedText(read: ParseResult): boolean;
27
49
  export declare function available(composition: Composition): boolean;
50
+ export {};
@@ -1,15 +1,17 @@
1
- import { type Plan, type QueryRows } from './query.js';
2
- import type { Connection, Value } from './tables.js';
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';
3
5
  export type QueryRoom = {
4
6
  readonly locator: string;
5
7
  readonly key: number;
8
+ readonly composition?: Composition;
6
9
  };
7
- export type Fragment = {
8
- readonly sql: string;
9
- readonly bind: readonly Value[];
10
- };
10
+ type Fragment = sql.Fragment;
11
+ export declare const VISIBLE: (alias: string) => string;
12
+ export declare function within(alias: string, path: string): Fragment;
11
13
  export type QueryAnswer = QueryRows & {
12
14
  readonly more?: string;
13
15
  };
14
- export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
16
  export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
17
+ export {};
@@ -0,0 +1,151 @@
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
+ export type Kept = {
50
+ readonly draft: ChatDraftRecord | null;
51
+ readonly ended: string | null;
52
+ readonly dismissed: string | null;
53
+ readonly pins: readonly string[];
54
+ };
55
+ type HeldWindow = Kept & {
56
+ readonly window: readonly AcceptedMessage[] | null;
57
+ readonly more: boolean;
58
+ readonly total: number | null;
59
+ };
60
+ export type SharedView = {
61
+ readonly conversation: string;
62
+ readonly asked: Asked;
63
+ readonly held: Cell<HeldWindow>;
64
+ ready(): readonly Watcher[];
65
+ join(watcher: Watcher): void;
66
+ admit(watcher: Watcher): boolean;
67
+ leave(watcher: Watcher): boolean;
68
+ empty(): boolean;
69
+ };
70
+ type Listing<T> = (value: T) => void;
71
+ export type Audience<T> = {
72
+ waiting(): boolean;
73
+ told(): boolean;
74
+ join(watcher: Listing<T>): void;
75
+ leave(watcher: Listing<T>): void;
76
+ tell(value: T): void;
77
+ welcome(value: T): void;
78
+ clear(): void;
79
+ };
80
+ type HeldFacts = {
81
+ readonly listKnown: boolean;
82
+ readonly listHeld: boolean;
83
+ readonly openingRead: boolean;
84
+ readonly openingListed: boolean;
85
+ readonly listOwed: boolean;
86
+ readonly listTelling: boolean;
87
+ readonly agentsShown: string | null;
88
+ readonly listedShown: string | null;
89
+ readonly replicated: ReadonlySet<string>;
90
+ readonly handedReplicated: string | undefined;
91
+ };
92
+ export type Dispatch = Cell<{
93
+ readonly answered: boolean;
94
+ }>;
95
+ export type Relisted = {
96
+ readonly conversations: ReadonlyMap<string, ListedConversation>;
97
+ readonly agents: ReadonlyMap<string, ListedAgent>;
98
+ };
99
+ export type LiveConversations = {
100
+ readonly deps: ConversationDependencies;
101
+ readonly held: Cell<HeldFacts>;
102
+ readonly closing: AbortSignal;
103
+ readonly listeners: Audience<readonly ConversationEntry[]>;
104
+ readonly agentListeners: Audience<readonly ConversationAgent[]>;
105
+ readonly listedListeners: Audience<readonly ListedAgent[]>;
106
+ views(): Iterable<SharedView>;
107
+ viewJoined(key: string, conversation: string, asked: Asked, notify: (view: ConversationView) => void): {
108
+ readonly view: SharedView;
109
+ readonly watcher: Watcher;
110
+ };
111
+ viewLeft(key: string, view: SharedView, watcher: Watcher): void;
112
+ liveOf(conversation: string): Live;
113
+ liveHeld(conversation: string): Live | undefined;
114
+ holdLive(conversation: string, next: Live | null): void;
115
+ factsOwed(conversation: string): void;
116
+ factsHeard(conversation: string, facts: readonly Fact[]): void;
117
+ factsTaken(): readonly (readonly [string, ReadonlySet<Fact>])[];
118
+ behind(conversation: string): boolean;
119
+ behindAll(): readonly string[];
120
+ fellBehind(conversation: string): void;
121
+ caughtUpTo(conversation: string): void;
122
+ gapOpened(conversation: string): void;
123
+ generation(conversation: string): number;
124
+ heardAt(conversation: string, change: string): void;
125
+ newestHeard(conversation: string): string | undefined;
126
+ catching(conversation: string): Promise<void> | undefined;
127
+ catchingUntil(conversation: string, ended: Promise<void>): void;
128
+ creating(conversation: string): void;
129
+ created(conversation: string): void;
130
+ isCreating(conversation: string): boolean;
131
+ relisting(): boolean;
132
+ relistBegun(): void;
133
+ relistHeard(entries: readonly ListedConversation[], agents: readonly ListedAgent[]): void;
134
+ relistDropped(conversation: string): void;
135
+ relistTaken(): Relisted | null;
136
+ sendingBegan(operation: string): Dispatch;
137
+ sendingEnded(operation: string, dispatch: Dispatch): void;
138
+ sending(operation: string): boolean;
139
+ rowSoon(tell: () => void): void;
140
+ inOrder(work: () => Promise<void>): void;
141
+ forget(conversation: string): void;
142
+ current(): boolean;
143
+ known(): boolean;
144
+ listHeld(): boolean;
145
+ listed(): boolean;
146
+ reopened(): void;
147
+ lost(): void;
148
+ close(): void;
149
+ };
150
+ export declare function createLiveConversations(deps: ConversationDependencies): LiveConversations;
151
+ export {};
@@ -0,0 +1,39 @@
1
+ import type { HeldRow } from './messages.js';
2
+ import { type HouseSource, type RequestAnswer } 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 fromRoom: boolean;
14
+ readonly agent: string | null;
15
+ readonly room: {
16
+ readonly ref: string;
17
+ readonly handle: string;
18
+ readonly name: string;
19
+ };
20
+ readonly prompt: string;
21
+ readonly agentFunction: string | null;
22
+ readonly answer: RequestAnswer | null;
23
+ readonly instruction: string | null;
24
+ readonly at: string;
25
+ readonly request: string;
26
+ readonly message?: string;
27
+ };
28
+ export type ConversationHeld = {
29
+ readonly last: ConversationLast | null;
30
+ readonly answered: string | null;
31
+ readonly opened: string | null;
32
+ readonly failure: string | null;
33
+ readonly startedBy: ConversationStart | null;
34
+ readonly asks: ConversationAsk | null;
35
+ };
36
+ export declare function heldFacts(held: HeldRow | undefined, listed: {
37
+ readonly outcome: string | null;
38
+ readonly waiting: boolean;
39
+ }): ConversationHeld;
@@ -1,33 +1,45 @@
1
- import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, 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';
4
+ import { type LiveConversations } from './conversation-live.js';
5
+ import { type ConversationHeld } from './conversation-row.js';
3
6
  import type { Open } from './open.js';
4
- import { type CallResult, type Offline } from './outcome.js';
7
+ import { type BinaryLinkAnswer, type CallResult, type ConversationAttachAnswer, type Offline } from './outcome.js';
8
+ import type { ChatRequest } from './source.js';
5
9
  import type { CycleProgress } from './status.js';
6
- import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
10
+ import type { RuntimeStore } from './store.js';
7
11
  export type ConversationState = Open<'working' | 'asking' | 'idle'>;
8
- export type ConversationEntry = {
12
+ export type ConversationEntry = ConversationHeld & {
9
13
  conversation: string;
10
14
  agent: {
11
15
  identity: string;
12
16
  name: string;
17
+ retired: boolean;
13
18
  };
14
19
  name: string;
15
20
  created: string;
16
21
  finished: string | null;
17
22
  outcome: string | null;
18
23
  waiting: boolean;
24
+ subject: string | null;
19
25
  state: ConversationState;
20
26
  started: string | null;
27
+ line: string | null;
28
+ question: string | null;
29
+ asked: string | null;
21
30
  };
22
31
  export type ConversationAgent = {
23
32
  identity: string;
24
33
  name: string;
34
+ cli: string;
35
+ model: string | null;
36
+ effort: string | null;
37
+ environment: AgentEnvironment;
25
38
  };
26
39
  export type RunningTurn = {
27
40
  turn: string;
28
41
  started: string | null;
29
- parts: readonly unknown[];
30
- context: TurnContext | null;
42
+ parts: readonly Part[];
31
43
  };
32
44
  export type ChatDraft = {
33
45
  text: string;
@@ -37,6 +49,9 @@ export type ConversationOptions = {
37
49
  after?: string;
38
50
  total?: true;
39
51
  };
52
+ export type ConversationRead = ConversationOptions & {
53
+ text?: string;
54
+ };
40
55
  export type ConversationView = {
41
56
  conversation: string;
42
57
  messages: readonly ConversationMessage[];
@@ -47,28 +62,44 @@ export type ConversationView = {
47
62
  process: {
48
63
  running: boolean;
49
64
  } | null;
65
+ processEnded: string | null;
50
66
  commands: readonly ProcessCommand[];
51
67
  options: readonly SessionOption[];
52
68
  starting: string | null;
53
- subagents: readonly RunningSubagent[];
69
+ state: SessionState | null;
54
70
  link: {
55
71
  connected: boolean;
56
72
  } | null;
73
+ deliveryWaiting: readonly string[];
57
74
  deliveryUnknown: readonly string[];
58
75
  chatDraft: (ChatDraft & {
59
76
  readonly revision: string;
60
77
  }) | null;
78
+ dismissedSuggestion: string | null;
79
+ pins: readonly string[];
61
80
  };
81
+ export type RequestDecision = 'approve' | 'decline';
62
82
  export type ConversationSurface = {
63
83
  list(): Promise<readonly ConversationEntry[]>;
64
- read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
84
+ read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
65
85
  create(input: unknown): Promise<CallResult>;
66
86
  send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
67
- answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
68
- interrupt(conversation: string): Promise<CallResult>;
69
- kill(conversation: string): Promise<CallResult>;
70
- delete(conversation: string): Promise<CallResult>;
87
+ answer(conversation: string, answer: ConversationAnswer, operation: string): Promise<CallResult>;
88
+ interrupt(conversation: string, operation: string): Promise<CallResult>;
89
+ kill(conversation: string, operation: string): Promise<CallResult>;
90
+ delete(conversation: string, operation: string): Promise<CallResult>;
91
+ takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
92
+ decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
93
+ rename(conversation: string, name: string, operation: string): Promise<CallResult>;
94
+ option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
95
+ retry(conversation: string, message: string, operation: string): Promise<CallResult>;
96
+ pin(figures: readonly string[]): Promise<void>;
97
+ openTurn(conversation: string, turn: string): Promise<void>;
98
+ dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
99
+ attach(file: File): Promise<ConversationAttachAnswer>;
100
+ attachment(link: string): Promise<BinaryLinkAnswer>;
71
101
  };
102
+ export type ConversationFiles = Pick<ConversationSurface, 'attach' | 'attachment'>;
72
103
  export type ConversationAnswer = {
73
104
  interaction_id: string;
74
105
  response: unknown;
@@ -76,43 +107,33 @@ export type ConversationAnswer = {
76
107
  export type ChatDraftSurface = {
77
108
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
78
109
  prepend(conversation: string, draft: ChatDraft): Promise<void>;
110
+ append(conversation: string, draft: ChatDraft): Promise<void>;
79
111
  discard(conversation: string): Promise<void>;
80
112
  };
81
- export type ConversationDependencies = {
82
- call(name: ConversationAction, input: unknown): Promise<CallResult>;
83
- history(request: ConversationHistoryRequest): 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
- full(): boolean;
89
- closed(): boolean;
90
- unanswered(): void;
91
- expired(operation: string): boolean;
92
- };
93
- export type ConversationStore = {
94
- surface: ConversationSurface;
95
- chatDraft: ChatDraftSurface;
96
- hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
97
- reconcile(): Promise<void>;
98
- catchUp(progress: CycleProgress): Promise<void>;
99
- resend(progress: CycleProgress): Promise<void>;
100
- current(): boolean;
101
- known(): boolean;
102
- learned(): void;
103
- reopened(): void;
104
- lost(): void;
105
- watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
106
- watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
107
- watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
108
- changed(set: ChangeSet): void;
109
- receive(event: ConversationEvent): boolean;
110
- searchable(): readonly string[];
111
- acquired(conversation: string): boolean;
112
- close(): void;
113
- };
114
113
  export declare function unheldView(conversation: string): ConversationView;
115
114
  export declare const SESSION_STARTED = "Session started";
115
+ export declare const CATCHING_UP = "catching-up";
116
116
  export declare const HISTORY_CONVERSATIONS = 64;
117
117
  export declare function newChat(agent: string): string;
118
- export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
118
+ export type Asked = {
119
+ limit: number;
120
+ after: string | undefined;
121
+ before: readonly [string, string] | null;
122
+ total: boolean;
123
+ };
124
+ export declare function joinedDraft(first: string, second: string): string;
125
+ export declare function conversationsLearned(alive: LiveConversations): void;
126
+ export declare function conversationSurface(alive: LiveConversations, files: ConversationFiles): ConversationSurface;
127
+ export declare function chatDraftSurface(alive: LiveConversations): ChatDraftSurface;
128
+ export declare function conversationsOpened(alive: LiveConversations, local: RuntimeStore): Promise<void>;
129
+ export declare function reconcileOpening(alive: LiveConversations): Promise<void>;
130
+ export declare function reconcileConversations(alive: LiveConversations): Promise<void>;
131
+ export declare function catchUpConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
132
+ export declare function holdsSubmission(alive: LiveConversations, operation: string): Promise<boolean>;
133
+ export declare function resendConversations(alive: LiveConversations, progress: CycleProgress): Promise<void>;
134
+ export declare function watchConversation(alive: LiveConversations, conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
135
+ export declare function watchConversationList(alive: LiveConversations, deliver: (entries: readonly ConversationEntry[]) => void): () => void;
136
+ export declare function watchConversationAgents(alive: LiveConversations, deliver: (agents: readonly ConversationAgent[]) => void): () => void;
137
+ export declare function watchListedAgents(alive: LiveConversations, deliver: (agents: readonly ListedAgent[]) => void): () => void;
138
+ export declare function conversationsChanged(alive: LiveConversations, set: ChangeSet): void;
139
+ export declare function receiveConversationEvent(alive: LiveConversations, event: ConversationEvent): void;
@@ -0,0 +1,9 @@
1
+ import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
2
+ export type WriteRefusal = {
3
+ readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
4
+ readonly path: string;
5
+ };
6
+ export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
7
+ export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
8
+ export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
9
+ export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
@@ -1,11 +1,31 @@
1
1
  import type { Persistence } from './readiness.js';
2
+ import type { RetriedFailure, Step } from './retried.js';
3
+ export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
4
+ export type UnsentWork = {
5
+ readonly kind: UnsentKind;
6
+ readonly count: number;
7
+ };
8
+ export declare function leftToSend(unsent: readonly UnsentWork[]): boolean;
9
+ export type AppCode = {
10
+ readonly running: number;
11
+ readonly older: number;
12
+ };
13
+ export type HeldCode = {
14
+ readonly house: number | null;
15
+ readonly apps: readonly string[];
16
+ };
2
17
  export type RuntimeShell = {
3
18
  persistence: Persistence;
4
19
  generation: string | null;
5
20
  keepGeneration(value: string): void | Promise<void>;
6
21
  dropGeneration(): void | Promise<void>;
7
22
  cleanUp?(): Promise<number>;
23
+ measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
24
+ reset(): Promise<void>;
25
+ retried?(failure: RetriedFailure): void;
26
+ succeeded?(step: Step): void;
8
27
  };
9
28
  export declare function refusedForSpace(error: unknown): boolean;
10
29
  export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
30
+ export declare function lossStated(persistence: Persistence, loss: string | null): string | null;
11
31
  export declare function nextGeneration(stored: string | null, reported: string | null): string;
@@ -1,3 +1,4 @@
1
+ import type { ProviderRefusal } from './adapter.js';
1
2
  export type RuntimeError = Error & {
2
3
  readonly code: string;
3
4
  readonly retryable: boolean;
@@ -8,5 +9,7 @@ export type Described = {
8
9
  retryable: boolean;
9
10
  };
10
11
  export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
12
+ export declare function refusalError(refusal: ProviderRefusal): RuntimeError;
11
13
  export declare function failed(error: unknown): RuntimeError;
14
+ export declare function uncaught(error: unknown): void;
12
15
  export declare function described(error: unknown): Described;
@@ -0,0 +1,48 @@
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 declare const FIGURES_DAY_MS = 86400000;
15
+ export type DayFigures = {
16
+ readonly created: number;
17
+ readonly changed: number;
18
+ readonly chats: number;
19
+ readonly messages: number;
20
+ };
21
+ export type RoomFigures = {
22
+ readonly room: string;
23
+ readonly day: DayFigures;
24
+ readonly total: {
25
+ readonly documents: GroupTotal;
26
+ readonly files: GroupTotal;
27
+ };
28
+ };
29
+ export type Figures = {
30
+ readonly rooms: readonly RoomFigures[];
31
+ readonly agentMessages: number;
32
+ };
33
+ export type FiguresResult = Figures | PendingResult;
34
+ export type FiguresCover = PendingResult | {
35
+ readonly rooms: readonly QueryRoom[];
36
+ };
37
+ export type FiguresSources = {
38
+ cover(): Promise<FiguresCover>;
39
+ rooms(rooms: readonly QueryRoom[], since: string): Promise<readonly RoomTally[]>;
40
+ conversations(conversations: readonly string[] | null, since: string): Promise<readonly ConversationTally[]>;
41
+ };
42
+ export type FiguresRead = {
43
+ watch(deliver: Deliver, fail: Fail): () => void;
44
+ touched(set: ChangeSet): void;
45
+ recover(): void;
46
+ close(): void;
47
+ };
48
+ export declare function createFigures(sources: FiguresSources): FiguresRead;