@agentshouse/app-bridge 0.1.0-cf2e2ca943fbc → 0.1.0-cf304386b60e3
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.
- package/README.md +21 -16
- package/dist/index.d.ts +1075 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/definition.d.ts +81 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +16 -0
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +33 -0
- package/dist/mdmodel/kinds.d.ts +18 -0
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +25 -0
- package/dist/mdmodel/pattern.d.ts +9 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +21 -0
- package/dist/mdmodel/query/language.d.ts +253 -0
- package/dist/mdmodel/query/match.d.ts +13 -0
- package/dist/mdmodel/query/rows.d.ts +31 -0
- package/dist/mdmodel/query/sql.d.ts +38 -0
- package/dist/mdmodel/references.d.ts +3 -0
- package/dist/mdmodel/reserved.d.ts +4 -0
- package/dist/mdmodel/types.d.ts +178 -0
- package/dist/mdmodel/validate.d.ts +33 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +546 -0
- package/dist/mdruntime/attached-model.d.ts +7 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/chain.d.ts +11 -0
- package/dist/mdruntime/change-set.d.ts +27 -0
- package/dist/mdruntime/change.d.ts +119 -0
- package/dist/mdruntime/client.d.ts +100 -0
- package/dist/mdruntime/collection.d.ts +28 -0
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +129 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +127 -0
- package/dist/mdruntime/durability.d.ts +17 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/figures.d.ts +47 -0
- package/dist/mdruntime/identity.d.ts +5 -0
- package/dist/mdruntime/job.d.ts +32 -0
- package/dist/mdruntime/live.d.ts +22 -0
- package/dist/mdruntime/log.d.ts +5 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +51 -0
- package/dist/mdruntime/model.d.ts +55 -0
- package/dist/mdruntime/observation.d.ts +44 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +85 -0
- package/dist/mdruntime/overlay.d.ts +25 -0
- package/dist/mdruntime/query.d.ts +88 -0
- package/dist/mdruntime/reach.d.ts +53 -0
- package/dist/mdruntime/readiness.d.ts +49 -0
- package/dist/mdruntime/reads.d.ts +35 -0
- package/dist/mdruntime/recovery.d.ts +25 -0
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +67 -0
- package/dist/mdruntime/room-draft.d.ts +174 -0
- package/dist/mdruntime/room-drafts.d.ts +28 -0
- package/dist/mdruntime/save.d.ts +102 -0
- package/dist/mdruntime/saves.d.ts +95 -0
- package/dist/mdruntime/search.d.ts +21 -0
- package/dist/mdruntime/seed.d.ts +29 -0
- package/dist/mdruntime/socket/admission.d.ts +6 -0
- package/dist/mdruntime/socket/answers.d.ts +5 -0
- package/dist/mdruntime/socket.d.ts +42 -0
- package/dist/mdruntime/source.d.ts +60 -0
- package/dist/mdruntime/status.d.ts +25 -0
- package/dist/mdruntime/store/fences.d.ts +15 -0
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/records.d.ts +211 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/watchers.d.ts +14 -0
- package/dist/mdruntime/store/writes.d.ts +23 -0
- package/dist/mdruntime/store.d.ts +86 -0
- package/dist/mdruntime/stored.d.ts +155 -0
- package/dist/mdruntime/tables.d.ts +406 -0
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/turn.d.ts +8 -0
- package/dist/mdruntime/wire.d.ts +249 -0
- package/dist/{client/src/test-host.d.ts → test-host.d.ts} +10 -8
- package/dist/test-host.js +190 -0
- package/docs/families.md +101 -45
- package/package.json +12 -10
- package/dist/client/src/bridge.d.ts +0 -38
- package/dist/client/src/bridge.js +0 -320
- package/dist/client/src/index.d.ts +0 -3
- package/dist/client/src/index.js +0 -2
- package/dist/client/src/test-host.js +0 -185
- package/dist/client/src/wire.d.ts +0 -215
- package/dist/client/src/wire.js +0 -1
- package/dist/src/apps/remainder.d.ts +0 -2
- package/dist/src/apps/remainder.js +0 -16
- package/dist/src/apps/tab.d.ts +0 -6
- package/dist/src/apps/tab.js +0 -27
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
|
+
export type Change = {
|
|
3
|
+
readonly kind: 'field';
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly value: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'section';
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly value: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'preamble';
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly value: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'create';
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
20
|
+
readonly sections: Readonly<Record<string, string>>;
|
|
21
|
+
} | {
|
|
22
|
+
readonly kind: 'create';
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly content: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'replace';
|
|
27
|
+
readonly path: string;
|
|
28
|
+
readonly content: string;
|
|
29
|
+
} | {
|
|
30
|
+
readonly kind: 'binary';
|
|
31
|
+
readonly path: string;
|
|
32
|
+
readonly localId: string;
|
|
33
|
+
readonly byteLength: number;
|
|
34
|
+
readonly mediaType: string;
|
|
35
|
+
readonly sha256: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'move';
|
|
38
|
+
readonly path: string;
|
|
39
|
+
readonly to: string;
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'remove';
|
|
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
|
+
}[];
|
|
70
|
+
};
|
|
71
|
+
export type Precondition = {
|
|
72
|
+
readonly kind: 'field';
|
|
73
|
+
readonly path: string;
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly value: unknown;
|
|
76
|
+
} | {
|
|
77
|
+
readonly kind: 'section';
|
|
78
|
+
readonly path: string;
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly value: string;
|
|
81
|
+
} | {
|
|
82
|
+
readonly kind: 'preamble';
|
|
83
|
+
readonly path: string;
|
|
84
|
+
readonly value: string;
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: 'revision';
|
|
87
|
+
readonly path: string;
|
|
88
|
+
readonly revision: string;
|
|
89
|
+
} | {
|
|
90
|
+
readonly kind: 'content';
|
|
91
|
+
readonly path: string;
|
|
92
|
+
readonly content: string;
|
|
93
|
+
} | {
|
|
94
|
+
readonly kind: 'present';
|
|
95
|
+
readonly path: string;
|
|
96
|
+
} | {
|
|
97
|
+
readonly kind: 'absent';
|
|
98
|
+
readonly path: string;
|
|
99
|
+
};
|
|
100
|
+
export type WrittenBy = {
|
|
101
|
+
readonly app: string;
|
|
102
|
+
readonly release: string;
|
|
103
|
+
};
|
|
104
|
+
export type ChangeBatch = {
|
|
105
|
+
validation?: import('./model.js').ValidationReceipt;
|
|
106
|
+
readonly id: string;
|
|
107
|
+
readonly baseRoomVersion: string;
|
|
108
|
+
readonly changes: readonly Change[];
|
|
109
|
+
readonly preconditions: readonly Precondition[];
|
|
110
|
+
readonly writtenBy?: WrittenBy;
|
|
111
|
+
readonly between?: RoomMove;
|
|
112
|
+
};
|
|
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;
|
|
116
|
+
export declare function landing(changes: readonly Change[], index: number, path: string): string | null;
|
|
117
|
+
export declare function departure(changes: readonly Change[], index: number): string;
|
|
118
|
+
export declare function queuedFile(batch: ChangeBatch, path: string, localId: string): number;
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '../mdmodel/index.js';
|
|
2
|
+
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas } from './connection.js';
|
|
3
|
+
import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
|
|
4
|
+
import type { Member, ServiceMode } from './adapter.js';
|
|
5
|
+
import type { UnsentWork } from './durability.js';
|
|
6
|
+
import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
|
|
7
|
+
import { type Observation } from './observation.js';
|
|
8
|
+
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
9
|
+
import type { FiguresResult } from './figures.js';
|
|
10
|
+
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
11
|
+
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
12
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
13
|
+
import type { Readiness } from './readiness.js';
|
|
14
|
+
import type { ObservedRead } from './reads.js';
|
|
15
|
+
import type { SyncStatus } from './status.js';
|
|
16
|
+
import { type RuntimePort } from './wire.js';
|
|
17
|
+
export type MdRuntimeClient = {
|
|
18
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
19
|
+
query: {
|
|
20
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
21
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
22
|
+
};
|
|
23
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
24
|
+
types(locator: string): Promise<RoomSchemas>;
|
|
25
|
+
roomDraft: {
|
|
26
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
27
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
28
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
|
|
29
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
30
|
+
};
|
|
31
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
32
|
+
saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
|
|
33
|
+
presentation: {
|
|
34
|
+
read(): Promise<unknown>;
|
|
35
|
+
write(value: unknown): Promise<void>;
|
|
36
|
+
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
conversation: {
|
|
39
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
40
|
+
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
41
|
+
create(input: unknown): Promise<CallResult>;
|
|
42
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
43
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
44
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
45
|
+
kill(conversation: string): Promise<CallResult>;
|
|
46
|
+
delete(conversation: string): Promise<CallResult>;
|
|
47
|
+
};
|
|
48
|
+
chatDraft: {
|
|
49
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
50
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
51
|
+
discard(conversation: string): Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
54
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
55
|
+
binaryFile: {
|
|
56
|
+
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
57
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
58
|
+
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
59
|
+
};
|
|
60
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
61
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
62
|
+
log(): Promise<string>;
|
|
63
|
+
persistence(): Promise<boolean>;
|
|
64
|
+
retry(): Promise<void>;
|
|
65
|
+
cleanUp(): Promise<number>;
|
|
66
|
+
unsent(): Promise<readonly UnsentWork[]>;
|
|
67
|
+
reset(): Promise<void>;
|
|
68
|
+
readAgain(): Promise<void>;
|
|
69
|
+
observe: {
|
|
70
|
+
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
71
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
72
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
73
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
74
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
75
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
76
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
77
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
78
|
+
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
79
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
80
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
81
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
82
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
83
|
+
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
84
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
85
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
86
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
87
|
+
(topic: 'figures'): Promise<Observation<FiguresResult>>;
|
|
88
|
+
(topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
|
|
89
|
+
};
|
|
90
|
+
reauthorize(): Promise<void>;
|
|
91
|
+
settled(): Promise<void>;
|
|
92
|
+
};
|
|
93
|
+
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
94
|
+
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
95
|
+
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
96
|
+
export { roomDraftRevision } from './identity.js';
|
|
97
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
98
|
+
export type { Observation } from './observation.js';
|
|
99
|
+
export type { Open } from './open.js';
|
|
100
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Document, type TypedPath } from '../mdmodel/index.js';
|
|
2
|
+
import type { ModelState } from './model.js';
|
|
3
|
+
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
+
export declare const MD_MODEL: MdModelIdentity;
|
|
5
|
+
export type Collection = {
|
|
6
|
+
text: Readonly<Record<string, string>>;
|
|
7
|
+
composition: Composition;
|
|
8
|
+
document(path: string): Document | undefined;
|
|
9
|
+
};
|
|
10
|
+
export type Composition = {
|
|
11
|
+
model: ModelState;
|
|
12
|
+
selection: {
|
|
13
|
+
roots: readonly string[];
|
|
14
|
+
model: ModelState;
|
|
15
|
+
} | null;
|
|
16
|
+
typedPaths: readonly TypedPath[];
|
|
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;
|
|
24
|
+
export declare function governing(composition: Composition, path: string): ModelState;
|
|
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>;
|
|
27
|
+
export declare function validRoot(root: unknown): root is string;
|
|
28
|
+
export declare function available(composition: Composition): boolean;
|
|
@@ -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,129 @@
|
|
|
1
|
+
import { type DocumentQuery, type GroupQuery } from '../mdmodel/index.js';
|
|
2
|
+
import { type TypesResult } from './model.js';
|
|
3
|
+
import { type Observation } from './observation.js';
|
|
4
|
+
import { type DocumentResult, type GroupResult, type PendingResult } from './query.js';
|
|
5
|
+
import { type FiguresResult } from './figures.js';
|
|
6
|
+
import { type EntrySeed } from './seed.js';
|
|
7
|
+
import { type SearchRequest, type SearchResult } from './search.js';
|
|
8
|
+
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
9
|
+
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
10
|
+
import { type WrittenBy } from './change.js';
|
|
11
|
+
import type { Open } from './open.js';
|
|
12
|
+
import { type CallResult, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
|
|
13
|
+
import { type ObservedRead } from './reads.js';
|
|
14
|
+
import { type Recovery } from './recovery.js';
|
|
15
|
+
import type { RoomDraft } from './room-draft.js';
|
|
16
|
+
import { type SyncStatus } from './status.js';
|
|
17
|
+
import { type RuntimeShell, type UnsentWork } from './durability.js';
|
|
18
|
+
import { type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
|
|
19
|
+
import { type RuntimeDatabase } from './store.js';
|
|
20
|
+
import { type PresentationSurface, type RoomDraftSurface } from './room-drafts.js';
|
|
21
|
+
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
22
|
+
import { type BinaryFileSurface, type SavedParts, type SavedRoomDraft, type SaveResult } from './saves.js';
|
|
23
|
+
export type AppTypedSelection = {
|
|
24
|
+
roots: readonly string[];
|
|
25
|
+
model: TypesResult;
|
|
26
|
+
};
|
|
27
|
+
export type AppRoom = {
|
|
28
|
+
name: string;
|
|
29
|
+
locator: string;
|
|
30
|
+
handle: string;
|
|
31
|
+
operations: import('./adapter.js').OperationScopes;
|
|
32
|
+
replica: import('./adapter.js').ReplicaAdmission;
|
|
33
|
+
model: TypesResult;
|
|
34
|
+
typedSelection: AppTypedSelection | null;
|
|
35
|
+
providerOwnedPaths: readonly string[];
|
|
36
|
+
roomVersion: string | null;
|
|
37
|
+
documents: number;
|
|
38
|
+
synchronizationAvailable: boolean;
|
|
39
|
+
refusal: ProviderRefusal | null;
|
|
40
|
+
locked: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type RoomSchemas = {
|
|
43
|
+
collection: TypesResult;
|
|
44
|
+
typedSelection: TypesResult | null;
|
|
45
|
+
};
|
|
46
|
+
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
47
|
+
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
48
|
+
export type ConnectionRefusal = {
|
|
49
|
+
code: ConnectionRefusalCode;
|
|
50
|
+
retryable: boolean;
|
|
51
|
+
reauthorizationOffered: boolean;
|
|
52
|
+
refusal: ProviderRefusal | null;
|
|
53
|
+
};
|
|
54
|
+
export type MdRuntimeOptions = {
|
|
55
|
+
adapter: Adapter;
|
|
56
|
+
shell: RuntimeShell;
|
|
57
|
+
database: RuntimeDatabase;
|
|
58
|
+
authorization?: Authorization;
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
recovery?: Recovery;
|
|
61
|
+
usableWhenHeld?: readonly string[];
|
|
62
|
+
build?: string;
|
|
63
|
+
};
|
|
64
|
+
export type HistoryQuery = {
|
|
65
|
+
revision?: string;
|
|
66
|
+
pageToken?: string;
|
|
67
|
+
};
|
|
68
|
+
export type MdRuntime = {
|
|
69
|
+
loaded(): Promise<void>;
|
|
70
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
71
|
+
query: {
|
|
72
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
73
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
74
|
+
};
|
|
75
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
76
|
+
types(locator: string): Promise<RoomSchemas>;
|
|
77
|
+
roomDraft: RoomDraftSurface;
|
|
78
|
+
conversation: ConversationSurface;
|
|
79
|
+
chatDraft: ChatDraftSurface;
|
|
80
|
+
presentation: PresentationSurface;
|
|
81
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
82
|
+
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
83
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
84
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
85
|
+
binaryFile: BinaryFileSurface;
|
|
86
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
87
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
88
|
+
log(): string;
|
|
89
|
+
persistence(): boolean;
|
|
90
|
+
retry(): Promise<void>;
|
|
91
|
+
cleanUp(): Promise<number>;
|
|
92
|
+
unsent(): Promise<readonly UnsentWork[]>;
|
|
93
|
+
reset(): Promise<void>;
|
|
94
|
+
readAgain(): Promise<void>;
|
|
95
|
+
observe: {
|
|
96
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
97
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
98
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
99
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
100
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
101
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
102
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
103
|
+
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
104
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
105
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
106
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
107
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
108
|
+
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
109
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
110
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
111
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
112
|
+
(topic: 'figures'): Promise<Observation<FiguresResult>>;
|
|
113
|
+
(topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
|
|
114
|
+
};
|
|
115
|
+
reauthorize(): Promise<void>;
|
|
116
|
+
};
|
|
117
|
+
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'authority-changes' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents' | 'figures' | 'read';
|
|
118
|
+
export type ReadinessPort = {
|
|
119
|
+
readonly target: string;
|
|
120
|
+
readonly code: CodeAvailability;
|
|
121
|
+
};
|
|
122
|
+
export type ComposedRuntime = RuntimeView & {
|
|
123
|
+
seed(entry: EntrySeed): void;
|
|
124
|
+
stop(): Promise<void>;
|
|
125
|
+
persisted(answer: Persistence): void;
|
|
126
|
+
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
127
|
+
};
|
|
128
|
+
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
129
|
+
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;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
|
|
2
|
+
import { type ChangeSet } from './change-set.js';
|
|
3
|
+
import { type ConversationHeld } from './conversation-row.js';
|
|
4
|
+
import type { OpenJob } from './job.js';
|
|
5
|
+
import type { Open } from './open.js';
|
|
6
|
+
import { type CallResult, type Offline } from './outcome.js';
|
|
7
|
+
import type { CycleProgress } from './status.js';
|
|
8
|
+
import type { RuntimeStore } from './store.js';
|
|
9
|
+
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
10
|
+
export type ConversationEntry = ConversationHeld & {
|
|
11
|
+
conversation: string;
|
|
12
|
+
agent: {
|
|
13
|
+
identity: string;
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
name: string;
|
|
17
|
+
created: string;
|
|
18
|
+
finished: string | null;
|
|
19
|
+
outcome: string | null;
|
|
20
|
+
waiting: boolean;
|
|
21
|
+
state: ConversationState;
|
|
22
|
+
started: string | null;
|
|
23
|
+
line: string | null;
|
|
24
|
+
question: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type ConversationAgent = {
|
|
27
|
+
identity: string;
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
export type RunningTurn = {
|
|
31
|
+
turn: string;
|
|
32
|
+
started: string | null;
|
|
33
|
+
parts: readonly unknown[];
|
|
34
|
+
context: TurnContext | null;
|
|
35
|
+
};
|
|
36
|
+
export type ChatDraft = {
|
|
37
|
+
text: string;
|
|
38
|
+
};
|
|
39
|
+
export type ConversationOptions = {
|
|
40
|
+
limit?: number;
|
|
41
|
+
after?: string;
|
|
42
|
+
total?: true;
|
|
43
|
+
};
|
|
44
|
+
export type ConversationRead = ConversationOptions & {
|
|
45
|
+
text?: string;
|
|
46
|
+
};
|
|
47
|
+
export type ConversationView = {
|
|
48
|
+
conversation: string;
|
|
49
|
+
messages: readonly ConversationMessage[];
|
|
50
|
+
next?: string;
|
|
51
|
+
total?: number;
|
|
52
|
+
turn: RunningTurn | null;
|
|
53
|
+
questions: readonly unknown[];
|
|
54
|
+
process: {
|
|
55
|
+
running: boolean;
|
|
56
|
+
} | null;
|
|
57
|
+
processEnded: string | null;
|
|
58
|
+
commands: readonly ProcessCommand[];
|
|
59
|
+
options: readonly SessionOption[];
|
|
60
|
+
starting: string | null;
|
|
61
|
+
subagents: readonly RunningSubagent[];
|
|
62
|
+
link: {
|
|
63
|
+
connected: boolean;
|
|
64
|
+
} | null;
|
|
65
|
+
deliveryUnknown: readonly string[];
|
|
66
|
+
chatDraft: (ChatDraft & {
|
|
67
|
+
readonly revision: string;
|
|
68
|
+
}) | null;
|
|
69
|
+
jobs: readonly OpenJob[];
|
|
70
|
+
};
|
|
71
|
+
export type ConversationSurface = {
|
|
72
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
73
|
+
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
74
|
+
create(input: unknown): Promise<CallResult>;
|
|
75
|
+
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
76
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
77
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
78
|
+
kill(conversation: string): Promise<CallResult>;
|
|
79
|
+
delete(conversation: string): Promise<CallResult>;
|
|
80
|
+
};
|
|
81
|
+
export type ConversationAnswer = {
|
|
82
|
+
interaction_id: string;
|
|
83
|
+
response: unknown;
|
|
84
|
+
};
|
|
85
|
+
export type ChatDraftSurface = {
|
|
86
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
87
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
88
|
+
discard(conversation: string): Promise<void>;
|
|
89
|
+
};
|
|
90
|
+
export type ConversationDependencies = {
|
|
91
|
+
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
92
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
93
|
+
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
94
|
+
local(): Promise<RuntimeStore>;
|
|
95
|
+
again(): void;
|
|
96
|
+
settled(): void;
|
|
97
|
+
stream(): ConversationStream | undefined;
|
|
98
|
+
publish(set: ChangeSet): void;
|
|
99
|
+
online(): boolean;
|
|
100
|
+
full(): boolean;
|
|
101
|
+
closed(): boolean;
|
|
102
|
+
unanswered(): void;
|
|
103
|
+
};
|
|
104
|
+
export type ConversationStore = {
|
|
105
|
+
surface: ConversationSurface;
|
|
106
|
+
chatDraft: ChatDraftSurface;
|
|
107
|
+
opened(local: RuntimeStore): Promise<void>;
|
|
108
|
+
reconcile(): Promise<void>;
|
|
109
|
+
catchUp(progress: CycleProgress): Promise<void>;
|
|
110
|
+
resend(progress: CycleProgress): Promise<void>;
|
|
111
|
+
current(): boolean;
|
|
112
|
+
known(): boolean;
|
|
113
|
+
learned(): void;
|
|
114
|
+
reopened(): void;
|
|
115
|
+
lost(): void;
|
|
116
|
+
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
117
|
+
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
118
|
+
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
119
|
+
changed(set: ChangeSet): void;
|
|
120
|
+
receive(event: ConversationEvent): void;
|
|
121
|
+
close(): void;
|
|
122
|
+
};
|
|
123
|
+
export declare function unheldView(conversation: string): ConversationView;
|
|
124
|
+
export declare const SESSION_STARTED = "Session started";
|
|
125
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
126
|
+
export declare function newChat(agent: string): string;
|
|
127
|
+
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
3
|
+
export type UnsentWork = {
|
|
4
|
+
readonly kind: UnsentKind;
|
|
5
|
+
readonly count: number;
|
|
6
|
+
};
|
|
7
|
+
export type RuntimeShell = {
|
|
8
|
+
persistence: Persistence;
|
|
9
|
+
generation: string | null;
|
|
10
|
+
keepGeneration(value: string): void | Promise<void>;
|
|
11
|
+
dropGeneration(): void | Promise<void>;
|
|
12
|
+
cleanUp?(): Promise<number>;
|
|
13
|
+
reset(): Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
16
|
+
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
17
|
+
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RuntimeError = Error & {
|
|
2
|
+
readonly code: string;
|
|
3
|
+
readonly retryable: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Described = {
|
|
6
|
+
message: string;
|
|
7
|
+
code: string;
|
|
8
|
+
retryable: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
11
|
+
export declare function failed(error: unknown): RuntimeError;
|
|
12
|
+
export declare function described(error: unknown): Described;
|
|
@@ -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,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,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 {};
|