@agentshouse/app-bridge 0.1.0-cf8a685b77ec0 → 0.1.0-cfb5ca35059bb
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 +19 -16
- package/dist/index.d.ts +974 -0
- package/dist/index.js +1 -0
- package/dist/mdmodel/blocks.d.ts +10 -0
- package/dist/mdmodel/condition.d.ts +179 -0
- package/dist/mdmodel/definition.d.ts +81 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +15 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/index.d.ts +20 -0
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +25 -0
- package/dist/mdmodel/profile.d.ts +5 -0
- package/dist/mdmodel/project.d.ts +21 -0
- package/dist/mdmodel/references.d.ts +3 -0
- package/dist/mdmodel/types.d.ts +167 -0
- package/dist/mdmodel/validate.d.ts +31 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/adapter.d.ts +530 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/chain.d.ts +10 -0
- package/dist/mdruntime/change-set.d.ts +27 -0
- package/dist/mdruntime/change.d.ts +118 -0
- package/dist/mdruntime/client.d.ts +89 -0
- package/dist/mdruntime/collection.d.ts +27 -0
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +152 -0
- package/dist/mdruntime/conversation.d.ts +118 -0
- package/dist/mdruntime/durability.d.ts +11 -0
- package/dist/mdruntime/failure.d.ts +12 -0
- package/dist/mdruntime/fulltext.d.ts +26 -0
- package/dist/mdruntime/identity.d.ts +6 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +27 -0
- package/dist/mdruntime/model.d.ts +62 -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 +84 -0
- package/dist/mdruntime/overlay.d.ts +24 -0
- package/dist/mdruntime/query.d.ts +283 -0
- package/dist/mdruntime/reach.d.ts +53 -0
- package/dist/mdruntime/readiness.d.ts +51 -0
- package/dist/mdruntime/recovery.d.ts +25 -0
- package/dist/mdruntime/replica.d.ts +67 -0
- package/dist/mdruntime/room-draft.d.ts +173 -0
- package/dist/mdruntime/save.d.ts +102 -0
- package/dist/mdruntime/search.d.ts +72 -0
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/status.d.ts +27 -0
- package/dist/mdruntime/store.d.ts +154 -0
- package/dist/mdruntime/stored.d.ts +129 -0
- package/dist/mdruntime/tables.d.ts +324 -0
- package/dist/mdruntime/wire.d.ts +234 -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 +86 -42
- 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,89 @@
|
|
|
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';
|
|
4
|
+
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';
|
|
7
|
+
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
8
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
9
|
+
import type { Readiness } from './readiness.js';
|
|
10
|
+
import type { SyncStatus } from './status.js';
|
|
11
|
+
import { type RuntimePort } from './wire.js';
|
|
12
|
+
export type MdRuntimeClient = {
|
|
13
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
14
|
+
query: {
|
|
15
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
16
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
17
|
+
};
|
|
18
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
19
|
+
types(locator: string): Promise<RoomSchemas>;
|
|
20
|
+
roomDraft: {
|
|
21
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
22
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
23
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
|
|
24
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
25
|
+
};
|
|
26
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
27
|
+
saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
|
|
28
|
+
presentation: {
|
|
29
|
+
read(): Promise<unknown>;
|
|
30
|
+
write(value: unknown): Promise<void>;
|
|
31
|
+
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
32
|
+
};
|
|
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>;
|
|
47
|
+
};
|
|
48
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
49
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
50
|
+
binaryFile: {
|
|
51
|
+
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
52
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
53
|
+
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
54
|
+
};
|
|
55
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
56
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
57
|
+
log(): Promise<string>;
|
|
58
|
+
persistence(): Promise<boolean>;
|
|
59
|
+
retry(): Promise<void>;
|
|
60
|
+
cleanUp(): Promise<number>;
|
|
61
|
+
observe: {
|
|
62
|
+
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
63
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
64
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
65
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
66
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
67
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
68
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
69
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
70
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
71
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
72
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
73
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
74
|
+
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
75
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
76
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
77
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
78
|
+
};
|
|
79
|
+
reauthorize(): Promise<void>;
|
|
80
|
+
settled(): Promise<void>;
|
|
81
|
+
};
|
|
82
|
+
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
83
|
+
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
84
|
+
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
85
|
+
export { roomDraftRevision } from './identity.js';
|
|
86
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
87
|
+
export type { Observation } from './observation.js';
|
|
88
|
+
export type { Open } from './open.js';
|
|
89
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Document } 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
|
+
};
|
|
17
|
+
export type Composed = {
|
|
18
|
+
readonly composition: Composition;
|
|
19
|
+
readonly fingerprint: string;
|
|
20
|
+
};
|
|
21
|
+
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;
|
|
24
|
+
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
25
|
+
export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
|
|
26
|
+
export declare function validRoot(root: unknown): root is string;
|
|
27
|
+
export declare function available(composition: Composition): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Plan, QueryRows } from './query.js';
|
|
2
|
+
import type { Connection, Value } from './tables.js';
|
|
3
|
+
export type QueryRoom = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly key: number;
|
|
6
|
+
};
|
|
7
|
+
export type Fragment = {
|
|
8
|
+
readonly sql: string;
|
|
9
|
+
readonly bind: readonly Value[];
|
|
10
|
+
};
|
|
11
|
+
export type QueryAnswer = QueryRows & {
|
|
12
|
+
readonly more?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
|
|
15
|
+
export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type TypesResult } from './model.js';
|
|
2
|
+
import { type Observation } from './observation.js';
|
|
3
|
+
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
|
|
4
|
+
import { type EntrySeed } from './seed.js';
|
|
5
|
+
import { type SearchRequest, type SearchResult } from './search.js';
|
|
6
|
+
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
7
|
+
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
8
|
+
import { type WrittenBy } from './change.js';
|
|
9
|
+
import type { Open } from './open.js';
|
|
10
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
|
|
11
|
+
import { type Recovery } from './recovery.js';
|
|
12
|
+
import { type SaveRefusal } from './save.js';
|
|
13
|
+
import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
|
|
14
|
+
import { type SyncStatus } from './status.js';
|
|
15
|
+
import { type RuntimeShell } from './durability.js';
|
|
16
|
+
import { type CodeAvailability, type Persistence, type Readiness, type SearchObligation, type Space } from './readiness.js';
|
|
17
|
+
import type { RuntimeDatabase } from './tables.js';
|
|
18
|
+
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
19
|
+
export type AppTypedSelection = {
|
|
20
|
+
roots: readonly string[];
|
|
21
|
+
model: TypesResult;
|
|
22
|
+
};
|
|
23
|
+
export type AppRoom = {
|
|
24
|
+
name: string;
|
|
25
|
+
locator: string;
|
|
26
|
+
handle: string;
|
|
27
|
+
operations: import('./adapter.js').OperationScopes;
|
|
28
|
+
replica: import('./adapter.js').ReplicaAdmission;
|
|
29
|
+
model: TypesResult;
|
|
30
|
+
typedSelection: AppTypedSelection | null;
|
|
31
|
+
providerOwnedPaths: readonly string[];
|
|
32
|
+
roomVersion: string | null;
|
|
33
|
+
documents: number;
|
|
34
|
+
synchronizationAvailable: boolean;
|
|
35
|
+
refusal: ProviderRefusal | null;
|
|
36
|
+
locked: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type RoomSchemas = {
|
|
39
|
+
collection: TypesResult;
|
|
40
|
+
typedSelection: TypesResult | null;
|
|
41
|
+
};
|
|
42
|
+
type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
43
|
+
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
44
|
+
export type ConnectionRefusal = {
|
|
45
|
+
code: ConnectionRefusalCode;
|
|
46
|
+
retryable: boolean;
|
|
47
|
+
reauthorizationOffered: boolean;
|
|
48
|
+
refusal: ProviderRefusal | null;
|
|
49
|
+
};
|
|
50
|
+
export type MdRuntimeOptions = {
|
|
51
|
+
adapter: Adapter;
|
|
52
|
+
shell: RuntimeShell;
|
|
53
|
+
database: RuntimeDatabase;
|
|
54
|
+
authorization?: Authorization;
|
|
55
|
+
signal?: AbortSignal;
|
|
56
|
+
recovery?: Recovery;
|
|
57
|
+
usableWhenHeld?: readonly string[];
|
|
58
|
+
};
|
|
59
|
+
export type SaveResult = {
|
|
60
|
+
outcome: 'saved';
|
|
61
|
+
identifier: string;
|
|
62
|
+
} | ({
|
|
63
|
+
outcome: 'refused';
|
|
64
|
+
} & SaveRefusal);
|
|
65
|
+
export type SavedRoomDraft = {
|
|
66
|
+
readonly path: string;
|
|
67
|
+
readonly revision: string;
|
|
68
|
+
};
|
|
69
|
+
export type SavedParts = {
|
|
70
|
+
readonly path: string;
|
|
71
|
+
readonly parts: RoomDraftParts;
|
|
72
|
+
};
|
|
73
|
+
export type RoomDraftSurface = {
|
|
74
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
75
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
76
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
77
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
78
|
+
};
|
|
79
|
+
export type PresentationSurface = {
|
|
80
|
+
read(app: string): Promise<unknown>;
|
|
81
|
+
write(app: string, value: unknown): Promise<void>;
|
|
82
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
83
|
+
};
|
|
84
|
+
export type BinaryFileSurface = {
|
|
85
|
+
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
86
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
87
|
+
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
88
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
89
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
90
|
+
};
|
|
91
|
+
export type HistoryQuery = {
|
|
92
|
+
revision?: string;
|
|
93
|
+
pageToken?: string;
|
|
94
|
+
};
|
|
95
|
+
export type MdRuntime = {
|
|
96
|
+
loaded(): Promise<void>;
|
|
97
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
98
|
+
query: {
|
|
99
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
100
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
101
|
+
};
|
|
102
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
103
|
+
types(locator: string): RoomSchemas;
|
|
104
|
+
roomDraft: RoomDraftSurface;
|
|
105
|
+
conversation: ConversationSurface;
|
|
106
|
+
chatDraft: ChatDraftSurface;
|
|
107
|
+
presentation: PresentationSurface;
|
|
108
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
109
|
+
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
110
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
111
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
112
|
+
binaryFile: BinaryFileSurface;
|
|
113
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
114
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
115
|
+
log(): string;
|
|
116
|
+
persistence(): boolean;
|
|
117
|
+
retry(): Promise<void>;
|
|
118
|
+
cleanUp(): Promise<number>;
|
|
119
|
+
observe: {
|
|
120
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
121
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
122
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
123
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
124
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
125
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
126
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
127
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
128
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
129
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
130
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
131
|
+
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
132
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
133
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
134
|
+
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
135
|
+
};
|
|
136
|
+
reauthorize(): Promise<void>;
|
|
137
|
+
};
|
|
138
|
+
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
139
|
+
export type ReadinessPort = {
|
|
140
|
+
readonly target: string;
|
|
141
|
+
readonly code: CodeAvailability;
|
|
142
|
+
readonly space: Space | null;
|
|
143
|
+
readonly search: SearchObligation;
|
|
144
|
+
};
|
|
145
|
+
export type ComposedRuntime = RuntimeView & {
|
|
146
|
+
seed(entry: EntrySeed): void;
|
|
147
|
+
stop(): Promise<void>;
|
|
148
|
+
persisted(answer: Persistence): void;
|
|
149
|
+
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
150
|
+
};
|
|
151
|
+
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
|
|
2
|
+
import { type ChangeSet } from './change-set.js';
|
|
3
|
+
import type { Open } from './open.js';
|
|
4
|
+
import { type CallResult, type Offline } from './outcome.js';
|
|
5
|
+
import type { CycleProgress } from './status.js';
|
|
6
|
+
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
7
|
+
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
8
|
+
export type ConversationEntry = {
|
|
9
|
+
conversation: string;
|
|
10
|
+
agent: {
|
|
11
|
+
identity: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
name: string;
|
|
15
|
+
created: string;
|
|
16
|
+
finished: string | null;
|
|
17
|
+
outcome: string | null;
|
|
18
|
+
waiting: boolean;
|
|
19
|
+
state: ConversationState;
|
|
20
|
+
started: string | null;
|
|
21
|
+
};
|
|
22
|
+
export type ConversationAgent = {
|
|
23
|
+
identity: string;
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
export type RunningTurn = {
|
|
27
|
+
turn: string;
|
|
28
|
+
started: string | null;
|
|
29
|
+
parts: readonly unknown[];
|
|
30
|
+
context: TurnContext | null;
|
|
31
|
+
};
|
|
32
|
+
export type ChatDraft = {
|
|
33
|
+
text: string;
|
|
34
|
+
};
|
|
35
|
+
export type ConversationOptions = {
|
|
36
|
+
limit?: number;
|
|
37
|
+
after?: string;
|
|
38
|
+
total?: true;
|
|
39
|
+
};
|
|
40
|
+
export type ConversationView = {
|
|
41
|
+
conversation: string;
|
|
42
|
+
messages: readonly ConversationMessage[];
|
|
43
|
+
next?: string;
|
|
44
|
+
total?: number;
|
|
45
|
+
turn: RunningTurn | null;
|
|
46
|
+
questions: readonly unknown[];
|
|
47
|
+
process: {
|
|
48
|
+
running: boolean;
|
|
49
|
+
} | null;
|
|
50
|
+
commands: readonly ProcessCommand[];
|
|
51
|
+
options: readonly SessionOption[];
|
|
52
|
+
starting: string | null;
|
|
53
|
+
subagents: readonly RunningSubagent[];
|
|
54
|
+
link: {
|
|
55
|
+
connected: boolean;
|
|
56
|
+
} | null;
|
|
57
|
+
deliveryUnknown: readonly string[];
|
|
58
|
+
chatDraft: (ChatDraft & {
|
|
59
|
+
readonly revision: string;
|
|
60
|
+
}) | null;
|
|
61
|
+
};
|
|
62
|
+
export type ConversationSurface = {
|
|
63
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
64
|
+
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
65
|
+
create(input: unknown): Promise<CallResult>;
|
|
66
|
+
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>;
|
|
71
|
+
};
|
|
72
|
+
export type ConversationAnswer = {
|
|
73
|
+
interaction_id: string;
|
|
74
|
+
response: unknown;
|
|
75
|
+
};
|
|
76
|
+
export type ChatDraftSurface = {
|
|
77
|
+
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
78
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
79
|
+
discard(conversation: string): Promise<void>;
|
|
80
|
+
};
|
|
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
|
+
export declare function unheldView(conversation: string): ConversationView;
|
|
115
|
+
export declare const SESSION_STARTED = "Session started";
|
|
116
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
117
|
+
export declare function newChat(agent: string): string;
|
|
118
|
+
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type RuntimeShell = {
|
|
3
|
+
persistence: Persistence;
|
|
4
|
+
generation: string | null;
|
|
5
|
+
keepGeneration(value: string): void | Promise<void>;
|
|
6
|
+
dropGeneration(): void | Promise<void>;
|
|
7
|
+
cleanUp?(): Promise<number>;
|
|
8
|
+
};
|
|
9
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
10
|
+
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
11
|
+
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,26 @@
|
|
|
1
|
+
import { type QueryRoom } from './compile.js';
|
|
2
|
+
import type { Plan } from './query.js';
|
|
3
|
+
import type { HitCursor, SearchWindow } from './search.js';
|
|
4
|
+
import type { Connection } from './tables.js';
|
|
5
|
+
export declare const SEARCH_TABLES: readonly string[];
|
|
6
|
+
export type SearchAsk = {
|
|
7
|
+
readonly text: string;
|
|
8
|
+
readonly limit: number;
|
|
9
|
+
readonly after: readonly [HitCursor, HitCursor] | null;
|
|
10
|
+
readonly total: boolean;
|
|
11
|
+
readonly documents: {
|
|
12
|
+
readonly plan: Plan;
|
|
13
|
+
readonly rooms: readonly QueryRoom[];
|
|
14
|
+
readonly beneath: readonly {
|
|
15
|
+
readonly key: number;
|
|
16
|
+
readonly roots: readonly string[];
|
|
17
|
+
}[];
|
|
18
|
+
} | null;
|
|
19
|
+
readonly conversations: readonly string[];
|
|
20
|
+
};
|
|
21
|
+
export declare function indexDocument(connection: Connection, id: number, path: string, content: string): void;
|
|
22
|
+
export declare function indexMessage(connection: Connection, id: number, text: string): void;
|
|
23
|
+
export declare function unindexDocuments(connection: Connection, ids: Iterable<number>): void;
|
|
24
|
+
export declare function unindexMessages(connection: Connection, ids: Iterable<number>): void;
|
|
25
|
+
export declare function unindexAll(connection: Connection): void;
|
|
26
|
+
export declare function searched(connection: Connection, ask: SearchAsk): SearchWindow;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
+
export declare function identityTime(identity: string): number;
|
|
3
|
+
export declare function roomDraftRevision(): string;
|
|
4
|
+
export declare function chatDraftRevision(): string;
|
|
5
|
+
export declare function transferIdentity(): string;
|
|
6
|
+
export declare function binaryLocalId(): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import { type ShownAnswer } from './outcome.js';
|
|
3
|
+
export declare const ROOM_MEDIA = "room-media";
|
|
4
|
+
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
|
+
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export type HeldConversation = {
|
|
5
|
+
readonly conversation: string;
|
|
6
|
+
readonly read: string | null | undefined;
|
|
7
|
+
readonly partial: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type MessageWindow = {
|
|
10
|
+
readonly messages: AcceptedMessage[];
|
|
11
|
+
readonly more: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ConversationWrite = {
|
|
14
|
+
readonly conversation: string;
|
|
15
|
+
readonly messages: readonly AcceptedMessage[];
|
|
16
|
+
readonly read?: {
|
|
17
|
+
readonly at: string | null;
|
|
18
|
+
readonly partial: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
22
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
+
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
25
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
|
+
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
|
+
export declare function forgottenMessages(connection: Connection): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Definition, ValueFacts, VerifiedModel } from '../mdmodel/index.js';
|
|
2
|
+
import type { Open } from './open.js';
|
|
3
|
+
export type ModelIdentity = {
|
|
4
|
+
identity: string;
|
|
5
|
+
version: string;
|
|
6
|
+
};
|
|
7
|
+
export type ModelSnapshot = ModelIdentity & {
|
|
8
|
+
schema: string | null;
|
|
9
|
+
revision: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired' | 'invalid'>;
|
|
12
|
+
export type ModelResult = {
|
|
13
|
+
kind: 'model';
|
|
14
|
+
snapshot: ModelSnapshot;
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'model-unavailable';
|
|
17
|
+
reason: ModelUnavailableReason;
|
|
18
|
+
};
|
|
19
|
+
export type MdType = Definition;
|
|
20
|
+
export type ModelState = {
|
|
21
|
+
status: 'unavailable';
|
|
22
|
+
reason: ModelUnavailableReason;
|
|
23
|
+
schema?: string | null;
|
|
24
|
+
revision?: string | null;
|
|
25
|
+
} | {
|
|
26
|
+
status: 'current' | 'cached';
|
|
27
|
+
snapshot: ModelSnapshot;
|
|
28
|
+
verifiedWith: ModelIdentity;
|
|
29
|
+
types: VerifiedModel['types'];
|
|
30
|
+
};
|
|
31
|
+
export type StoredModel = Extract<ModelState, {
|
|
32
|
+
status: 'unavailable';
|
|
33
|
+
}> | Omit<Extract<ModelState, {
|
|
34
|
+
status: 'current' | 'cached';
|
|
35
|
+
}>, 'types'>;
|
|
36
|
+
export type TypesResult = {
|
|
37
|
+
status: Open<'unavailable'>;
|
|
38
|
+
reason: ModelUnavailableReason;
|
|
39
|
+
types: null;
|
|
40
|
+
schema?: string | null;
|
|
41
|
+
revision?: string | null;
|
|
42
|
+
} | {
|
|
43
|
+
status: Open<'current' | 'cached'>;
|
|
44
|
+
identity: string;
|
|
45
|
+
version: string;
|
|
46
|
+
verifiedWith: ModelIdentity;
|
|
47
|
+
types: readonly MdType[];
|
|
48
|
+
schema: string | null;
|
|
49
|
+
revision: string | null;
|
|
50
|
+
};
|
|
51
|
+
export type ValidationReceipt = {
|
|
52
|
+
identity: string;
|
|
53
|
+
version: string;
|
|
54
|
+
source: Open<'current' | 'cached'>;
|
|
55
|
+
};
|
|
56
|
+
export declare const NO_MODEL: ModelState;
|
|
57
|
+
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
58
|
+
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
|
+
export declare function cached(state: ModelState): ModelState;
|
|
61
|
+
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
+
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
|
+
export type Observation<T> = {
|
|
3
|
+
current(): T;
|
|
4
|
+
subscribe(listener: (value: T) => void): () => void;
|
|
5
|
+
close(): void;
|
|
6
|
+
};
|
|
7
|
+
export type RowKey = string | number;
|
|
8
|
+
export type KeyedResult = {
|
|
9
|
+
result: QueryResult;
|
|
10
|
+
keys: readonly RowKey[];
|
|
11
|
+
};
|
|
12
|
+
export type QueryChange = {
|
|
13
|
+
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
|
+
removed: readonly RowKey[];
|
|
15
|
+
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
19
|
+
};
|
|
20
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
21
|
+
export type Observed = {
|
|
22
|
+
observation: Observation<unknown>;
|
|
23
|
+
receive(message: unknown): void;
|
|
24
|
+
end(): void;
|
|
25
|
+
};
|
|
26
|
+
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
27
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
29
|
+
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
30
|
+
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
|
+
export type Digest = {
|
|
33
|
+
readonly pending: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly keys: readonly RowKey[];
|
|
36
|
+
readonly rows: ReadonlyMap<RowKey, number>;
|
|
37
|
+
readonly coverage: string;
|
|
38
|
+
readonly next: string | undefined;
|
|
39
|
+
readonly total: number | undefined;
|
|
40
|
+
};
|
|
41
|
+
export declare function hashed(text: string): number;
|
|
42
|
+
export declare function digestOf({ result, keys }: KeyedResult): Digest;
|
|
43
|
+
export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
|
|
44
|
+
export declare function changeOf(previous: Digest, next: KeyedResult): QueryMessage | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Open<Value extends string> = Value | (string & {});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { BinaryResult } from './adapter.js';
|
|
2
|
+
import { type RuntimeDatabase } from './tables.js';
|
|
3
|
+
export type OpenedName = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly revision: string;
|
|
7
|
+
};
|
|
8
|
+
export type KeptBinary = {
|
|
9
|
+
readonly kind: 'binary';
|
|
10
|
+
readonly file: string;
|
|
11
|
+
readonly byteLength: number;
|
|
12
|
+
readonly mediaType: string;
|
|
13
|
+
};
|
|
14
|
+
export type KeptResult = KeptBinary | Exclude<BinaryResult, {
|
|
15
|
+
kind: 'binary';
|
|
16
|
+
}>;
|
|
17
|
+
export type OpenedFiles = {
|
|
18
|
+
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
|
+
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
|
+
};
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
|