@agentshouse/app-bridge 0.1.0-c1bc683ed8f4e → 0.1.0-c1ccced28150f
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 +9 -9
- package/dist/index.d.ts +826 -18
- package/dist/mdmodel/condition.d.ts +41 -11
- package/dist/mdmodel/definition.d.ts +17 -1
- package/dist/mdmodel/document.d.ts +5 -5
- package/dist/mdmodel/index.d.ts +11 -9
- package/dist/mdmodel/links.d.ts +28 -0
- package/dist/mdmodel/paths.d.ts +9 -1
- package/dist/mdmodel/project.d.ts +1 -0
- package/dist/mdmodel/types.d.ts +28 -4
- package/dist/mdmodel/validate.d.ts +27 -3
- package/dist/mdruntime/adapter.d.ts +121 -66
- package/dist/mdruntime/binary.d.ts +0 -5
- package/dist/mdruntime/chain.d.ts +10 -0
- package/dist/mdruntime/change-set.d.ts +9 -16
- package/dist/mdruntime/change.d.ts +31 -1
- package/dist/mdruntime/client.d.ts +15 -8
- package/dist/mdruntime/collection.d.ts +10 -21
- package/dist/mdruntime/compile.d.ts +15 -0
- package/dist/mdruntime/connection.d.ts +28 -14
- package/dist/mdruntime/conversation.d.ts +26 -11
- package/dist/mdruntime/durability.d.ts +2 -5
- 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 +6 -1
- package/dist/mdruntime/observation.d.ts +15 -0
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +45 -7
- package/dist/mdruntime/overlay.d.ts +3 -5
- package/dist/mdruntime/query.d.ts +38 -2
- package/dist/mdruntime/reach.d.ts +14 -6
- package/dist/mdruntime/readiness.d.ts +14 -15
- package/dist/mdruntime/recovery.d.ts +3 -2
- package/dist/mdruntime/replica.d.ts +55 -33
- package/dist/mdruntime/room-draft.d.ts +33 -3
- package/dist/mdruntime/save.d.ts +53 -14
- package/dist/mdruntime/search.d.ts +32 -43
- package/dist/mdruntime/seed.d.ts +15 -0
- package/dist/mdruntime/status.d.ts +4 -3
- package/dist/mdruntime/store.d.ts +93 -98
- package/dist/mdruntime/stored.d.ts +129 -0
- package/dist/mdruntime/tables.d.ts +324 -0
- package/dist/mdruntime/wire.d.ts +33 -5
- package/dist/test-host.d.ts +7 -4
- package/dist/test-host.js +18 -28
- package/docs/families.md +52 -47
- package/package.json +8 -3
- package/dist/calls.d.ts +0 -117
- package/dist/calls.js +0 -1
- package/dist/mdruntime/acquisition.d.ts +0 -13
- package/dist/mdruntime/file.d.ts +0 -19
- package/dist/mdruntime/rows.d.ts +0 -36
- package/dist/mdruntime/shared.d.ts +0 -10
- package/dist/mdruntime/transfer.d.ts +0 -9
- package/dist/mdruntime/turn.d.ts +0 -6
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { type TypesResult } from './model.js';
|
|
2
2
|
import { type Observation } from './observation.js';
|
|
3
3
|
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
|
|
4
|
+
import { type EntrySeed } from './seed.js';
|
|
4
5
|
import { type SearchRequest, type SearchResult } from './search.js';
|
|
5
6
|
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
6
7
|
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
7
8
|
import { type WrittenBy } from './change.js';
|
|
8
9
|
import type { Open } from './open.js';
|
|
9
|
-
import { type
|
|
10
|
-
import { type BinaryAnswer, type CallResult, type HistoryAnswer, type QueueEntry } from './outcome.js';
|
|
10
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type CallResult, type HeldBinaryAnswer, type HeldShownAnswer, type HistoryAnswer, type QueueEntry, type Resolution } from './outcome.js';
|
|
11
11
|
import { type Recovery } from './recovery.js';
|
|
12
12
|
import { type SaveRefusal } from './save.js';
|
|
13
|
-
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
13
|
+
import { type RoomDraft, type RoomDraftParts, type RoomDraftWrite } from './room-draft.js';
|
|
14
14
|
import { type SyncStatus } from './status.js';
|
|
15
15
|
import { type RuntimeShell } from './durability.js';
|
|
16
|
-
import { type
|
|
17
|
-
import
|
|
16
|
+
import { type CodeAvailability, type Persistence, type Readiness, type SearchObligation, type Space } from './readiness.js';
|
|
17
|
+
import type { RuntimeDatabase } from './tables.js';
|
|
18
18
|
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
19
19
|
export type AppTypedSelection = {
|
|
20
20
|
roots: readonly string[];
|
|
@@ -33,6 +33,7 @@ export type AppRoom = {
|
|
|
33
33
|
documents: number;
|
|
34
34
|
synchronizationAvailable: boolean;
|
|
35
35
|
refusal: ProviderRefusal | null;
|
|
36
|
+
locked: boolean;
|
|
36
37
|
};
|
|
37
38
|
export type RoomSchemas = {
|
|
38
39
|
collection: TypesResult;
|
|
@@ -49,9 +50,11 @@ export type ConnectionRefusal = {
|
|
|
49
50
|
export type MdRuntimeOptions = {
|
|
50
51
|
adapter: Adapter;
|
|
51
52
|
shell: RuntimeShell;
|
|
53
|
+
database: RuntimeDatabase;
|
|
52
54
|
authorization?: Authorization;
|
|
53
55
|
signal?: AbortSignal;
|
|
54
56
|
recovery?: Recovery;
|
|
57
|
+
usableWhenHeld?: readonly string[];
|
|
55
58
|
};
|
|
56
59
|
export type SaveResult = {
|
|
57
60
|
outcome: 'saved';
|
|
@@ -63,19 +66,27 @@ export type SavedRoomDraft = {
|
|
|
63
66
|
readonly path: string;
|
|
64
67
|
readonly revision: string;
|
|
65
68
|
};
|
|
69
|
+
export type SavedParts = {
|
|
70
|
+
readonly path: string;
|
|
71
|
+
readonly parts: RoomDraftParts;
|
|
72
|
+
};
|
|
66
73
|
export type RoomDraftSurface = {
|
|
67
74
|
list(): Promise<readonly RoomDraft[]>;
|
|
68
|
-
read(room: string, path: string): RoomDraft | null
|
|
69
|
-
write(room: string, path: string, revision: string | null, parts: unknown): Promise<RoomDraftWrite>;
|
|
75
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
76
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
70
77
|
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
71
78
|
};
|
|
72
79
|
export type PresentationSurface = {
|
|
73
80
|
read(app: string): Promise<unknown>;
|
|
74
81
|
write(app: string, value: unknown): Promise<void>;
|
|
82
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
75
83
|
};
|
|
76
84
|
export type BinaryFileSurface = {
|
|
77
|
-
read(room: string, path: string, revision?: string): Promise<
|
|
78
|
-
|
|
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>;
|
|
79
90
|
};
|
|
80
91
|
export type HistoryQuery = {
|
|
81
92
|
revision?: string;
|
|
@@ -83,7 +94,7 @@ export type HistoryQuery = {
|
|
|
83
94
|
};
|
|
84
95
|
export type MdRuntime = {
|
|
85
96
|
loaded(): Promise<void>;
|
|
86
|
-
rooms(): readonly AppRoom[]
|
|
97
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
87
98
|
query: {
|
|
88
99
|
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
89
100
|
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
@@ -95,13 +106,16 @@ export type MdRuntime = {
|
|
|
95
106
|
chatDraft: ChatDraftSurface;
|
|
96
107
|
presentation: PresentationSurface;
|
|
97
108
|
save(room: string, roomDrafts: readonly SavedRoomDraft[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
109
|
+
saveParts(room: string, parts: readonly SavedParts[], writtenBy?: WrittenBy): Promise<SaveResult>;
|
|
98
110
|
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
111
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
99
112
|
binaryFile: BinaryFileSurface;
|
|
100
113
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
101
|
-
reached(locator: string, roomVersion: string, path?: string): boolean
|
|
114
|
+
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
102
115
|
log(): string;
|
|
103
116
|
persistence(): boolean;
|
|
104
117
|
retry(): Promise<void>;
|
|
118
|
+
cleanUp(): Promise<number>;
|
|
105
119
|
observe: {
|
|
106
120
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
107
121
|
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
@@ -125,12 +139,12 @@ export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'stora
|
|
|
125
139
|
export type ReadinessPort = {
|
|
126
140
|
readonly target: string;
|
|
127
141
|
readonly code: CodeAvailability;
|
|
128
|
-
readonly
|
|
142
|
+
readonly space: Space | null;
|
|
143
|
+
readonly search: SearchObligation;
|
|
129
144
|
};
|
|
130
145
|
export type ComposedRuntime = RuntimeView & {
|
|
146
|
+
seed(entry: EntrySeed): void;
|
|
131
147
|
stop(): Promise<void>;
|
|
132
|
-
lose(locators: readonly string[]): Promise<void>;
|
|
133
|
-
acquire(demand: RuntimeDemand): void;
|
|
134
148
|
persisted(answer: Persistence): void;
|
|
135
149
|
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
136
150
|
};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { ConversationAction,
|
|
1
|
+
import type { ConversationAction, ConversationEvent, ConversationHistoryRequest, ConversationMessage, ConversationStream, ListedConversation, ProcessCommand, RunningSubagent, SessionOption, TurnContext } from './adapter.js';
|
|
2
2
|
import { type ChangeSet } from './change-set.js';
|
|
3
|
-
import { type ChatDraftFile } from './file.js';
|
|
4
3
|
import type { Open } from './open.js';
|
|
5
4
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
|
-
import type { DocumentResult, PendingResult } from './query.js';
|
|
7
5
|
import type { CycleProgress } from './status.js';
|
|
8
6
|
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
9
7
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
@@ -11,12 +9,13 @@ export type ConversationEntry = {
|
|
|
11
9
|
conversation: string;
|
|
12
10
|
agent: {
|
|
13
11
|
identity: string;
|
|
14
|
-
name: string
|
|
12
|
+
name: string;
|
|
15
13
|
};
|
|
16
14
|
name: string;
|
|
17
15
|
created: string;
|
|
18
16
|
finished: string | null;
|
|
19
17
|
outcome: string | null;
|
|
18
|
+
waiting: boolean;
|
|
20
19
|
state: ConversationState;
|
|
21
20
|
started: string | null;
|
|
22
21
|
};
|
|
@@ -32,14 +31,17 @@ export type RunningTurn = {
|
|
|
32
31
|
};
|
|
33
32
|
export type ChatDraft = {
|
|
34
33
|
text: string;
|
|
35
|
-
files: readonly ChatDraftFile[];
|
|
36
34
|
};
|
|
37
35
|
export type ConversationOptions = {
|
|
38
36
|
limit?: number;
|
|
37
|
+
after?: string;
|
|
38
|
+
total?: true;
|
|
39
39
|
};
|
|
40
40
|
export type ConversationView = {
|
|
41
41
|
conversation: string;
|
|
42
42
|
messages: readonly ConversationMessage[];
|
|
43
|
+
next?: string;
|
|
44
|
+
total?: number;
|
|
43
45
|
turn: RunningTurn | null;
|
|
44
46
|
questions: readonly unknown[];
|
|
45
47
|
process: {
|
|
@@ -47,6 +49,12 @@ export type ConversationView = {
|
|
|
47
49
|
} | null;
|
|
48
50
|
commands: readonly ProcessCommand[];
|
|
49
51
|
options: readonly SessionOption[];
|
|
52
|
+
starting: string | null;
|
|
53
|
+
subagents: readonly RunningSubagent[];
|
|
54
|
+
link: {
|
|
55
|
+
connected: boolean;
|
|
56
|
+
} | null;
|
|
57
|
+
deliveryUnknown: readonly string[];
|
|
50
58
|
chatDraft: (ChatDraft & {
|
|
51
59
|
readonly revision: string;
|
|
52
60
|
}) | null;
|
|
@@ -56,24 +64,28 @@ export type ConversationSurface = {
|
|
|
56
64
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
57
65
|
create(input: unknown): Promise<CallResult>;
|
|
58
66
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
59
|
-
answer(conversation: string, answer:
|
|
67
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
60
68
|
interrupt(conversation: string): Promise<CallResult>;
|
|
61
69
|
kill(conversation: string): Promise<CallResult>;
|
|
62
|
-
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
63
70
|
delete(conversation: string): Promise<CallResult>;
|
|
64
71
|
};
|
|
72
|
+
export type ConversationAnswer = {
|
|
73
|
+
interaction_id: string;
|
|
74
|
+
response: unknown;
|
|
75
|
+
};
|
|
65
76
|
export type ChatDraftSurface = {
|
|
66
77
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
78
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
67
79
|
discard(conversation: string): Promise<void>;
|
|
68
80
|
};
|
|
69
81
|
export type ConversationDependencies = {
|
|
70
|
-
agents(): ConversationAgents | undefined;
|
|
71
|
-
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
72
82
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
83
|
+
history(request: ConversationHistoryRequest): Promise<CallResult>;
|
|
73
84
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
74
85
|
stream(): ConversationStream | undefined;
|
|
75
86
|
publish(set: ChangeSet): void;
|
|
76
87
|
online(): boolean;
|
|
88
|
+
full(): boolean;
|
|
77
89
|
closed(): boolean;
|
|
78
90
|
unanswered(): void;
|
|
79
91
|
expired(operation: string): boolean;
|
|
@@ -81,14 +93,15 @@ export type ConversationDependencies = {
|
|
|
81
93
|
export type ConversationStore = {
|
|
82
94
|
surface: ConversationSurface;
|
|
83
95
|
chatDraft: ChatDraftSurface;
|
|
84
|
-
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[]): void;
|
|
96
|
+
hydrate(held: readonly HeldConversation[], drafts: readonly ChatDraftRecord[], list: readonly ListedConversation[] | null, cursor: string | null): void;
|
|
85
97
|
reconcile(): Promise<void>;
|
|
86
98
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
87
99
|
resend(progress: CycleProgress): Promise<void>;
|
|
88
100
|
current(): boolean;
|
|
89
101
|
known(): boolean;
|
|
90
|
-
|
|
102
|
+
learned(): void;
|
|
91
103
|
reopened(): void;
|
|
104
|
+
lost(): void;
|
|
92
105
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
93
106
|
watchList(deliver: (entries: readonly ConversationEntry[]) => void): () => void;
|
|
94
107
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
@@ -100,4 +113,6 @@ export type ConversationStore = {
|
|
|
100
113
|
};
|
|
101
114
|
export declare function unheldView(conversation: string): ConversationView;
|
|
102
115
|
export declare const SESSION_STARTED = "Session started";
|
|
116
|
+
export declare const HISTORY_CONVERSATIONS = 64;
|
|
117
|
+
export declare function newChat(agent: string): string;
|
|
103
118
|
export declare function createConversationStore(deps: ConversationDependencies): ConversationStore;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
-
export type StorageEstimate = {
|
|
3
|
-
readonly usage: number;
|
|
4
|
-
readonly quota: number;
|
|
5
|
-
};
|
|
6
2
|
export type RuntimeShell = {
|
|
7
3
|
persistence: Persistence;
|
|
8
4
|
generation: string | null;
|
|
9
5
|
keepGeneration(value: string): void | Promise<void>;
|
|
10
6
|
dropGeneration(): void | Promise<void>;
|
|
11
|
-
|
|
7
|
+
cleanUp?(): Promise<number>;
|
|
12
8
|
};
|
|
9
|
+
export declare function refusedForSpace(error: unknown): boolean;
|
|
13
10
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
14
11
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
@@ -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;
|
|
@@ -28,6 +28,11 @@ export type ModelState = {
|
|
|
28
28
|
verifiedWith: ModelIdentity;
|
|
29
29
|
types: VerifiedModel['types'];
|
|
30
30
|
};
|
|
31
|
+
export type StoredModel = Extract<ModelState, {
|
|
32
|
+
status: 'unavailable';
|
|
33
|
+
}> | Omit<Extract<ModelState, {
|
|
34
|
+
status: 'current' | 'cached';
|
|
35
|
+
}>, 'types'>;
|
|
31
36
|
export type TypesResult = {
|
|
32
37
|
status: Open<'unavailable'>;
|
|
33
38
|
reason: ModelUnavailableReason;
|
|
@@ -51,7 +56,7 @@ export type ValidationReceipt = {
|
|
|
51
56
|
export declare const NO_MODEL: ModelState;
|
|
52
57
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
53
58
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
54
60
|
export declare function cached(state: ModelState): ModelState;
|
|
55
61
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
56
|
-
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
57
62
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
@@ -14,6 +14,8 @@ export type QueryChange = {
|
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
16
|
coverage?: QueryCoverage;
|
|
17
|
+
next?: string | null;
|
|
18
|
+
total?: number;
|
|
17
19
|
};
|
|
18
20
|
export type QueryMessage = KeyedResult | QueryChange;
|
|
19
21
|
export type Observed = {
|
|
@@ -27,3 +29,16 @@ export declare function applied(keyed: KeyedResult, message: QueryMessage): Keye
|
|
|
27
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
28
30
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
29
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,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;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure,
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
3
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
5
|
kind: Kind;
|
|
5
6
|
};
|
|
6
7
|
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
8
|
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
8
11
|
}) | ScopedRefusal;
|
|
9
12
|
export type CallResult = {
|
|
10
13
|
kind: 'action';
|
|
@@ -14,12 +17,50 @@ export type CallResult = {
|
|
|
14
17
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
18
|
kind: Failure['kind'];
|
|
16
19
|
}> | Failure;
|
|
20
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
17
21
|
export type BinaryAnswer = {
|
|
18
22
|
kind: 'binary';
|
|
19
|
-
|
|
23
|
+
stream: ReadableStream<Uint8Array>;
|
|
24
|
+
byteLength: number;
|
|
25
|
+
mediaType: string;
|
|
26
|
+
} | BinaryRefusal;
|
|
27
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
28
|
+
export type BinaryLinkAnswer = {
|
|
29
|
+
kind: 'link';
|
|
30
|
+
url: string;
|
|
31
|
+
name: string;
|
|
32
|
+
mediaType: string;
|
|
20
33
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
-
export
|
|
22
|
-
export
|
|
34
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
35
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
36
|
+
export type AttachAnswer = {
|
|
37
|
+
kind: 'attached';
|
|
38
|
+
path: string;
|
|
39
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
40
|
+
export type DownloadAnswer = {
|
|
41
|
+
kind: 'started';
|
|
42
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
43
|
+
export type Resolution = {
|
|
44
|
+
readonly kind: 'document';
|
|
45
|
+
readonly room: string;
|
|
46
|
+
readonly path: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: 'deleted';
|
|
49
|
+
readonly room: string;
|
|
50
|
+
readonly path: string;
|
|
51
|
+
readonly revision: HistoryRevision;
|
|
52
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
53
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
54
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
55
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
56
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
57
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
58
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
59
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
60
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
61
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
62
|
+
locator: string;
|
|
63
|
+
};
|
|
23
64
|
export type Offline = {
|
|
24
65
|
readonly kind: 'offline';
|
|
25
66
|
};
|
|
@@ -39,8 +80,5 @@ export type QueueEntry = {
|
|
|
39
80
|
readonly batch: ChangeBatch;
|
|
40
81
|
} & (Submission | {
|
|
41
82
|
readonly state: 'local';
|
|
42
|
-
} | {
|
|
43
|
-
readonly state: 'accepted';
|
|
44
|
-
readonly roomVersion: string;
|
|
45
83
|
});
|
|
46
84
|
export {};
|
|
@@ -2,6 +2,7 @@ import type { BinaryFile, HeadChange } from './adapter.js';
|
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
|
+
fileIds: Readonly<Record<string, string>>;
|
|
5
6
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
7
|
};
|
|
7
8
|
export type HeldBinary = ({
|
|
@@ -17,10 +18,7 @@ export type Layer = Heads & {
|
|
|
17
18
|
documents: Readonly<Record<string, string>>;
|
|
18
19
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
19
20
|
};
|
|
20
|
-
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>):
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
21
22
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
22
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
-
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
26
|
-
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
24
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
@@ -38,6 +38,8 @@ export type Filter = {
|
|
|
38
38
|
types?: readonly string[];
|
|
39
39
|
where?: Where;
|
|
40
40
|
pathPrefix?: string;
|
|
41
|
+
folder?: string;
|
|
42
|
+
paths?: readonly string[];
|
|
41
43
|
hop?: Related & {
|
|
42
44
|
field: string;
|
|
43
45
|
};
|
|
@@ -45,7 +47,7 @@ export type Filter = {
|
|
|
45
47
|
field?: string;
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
|
-
export type Key = 'room' | 'path' | 'type' | {
|
|
50
|
+
export type Key = 'room' | 'path' | 'type' | 'folder' | {
|
|
49
51
|
field: string;
|
|
50
52
|
};
|
|
51
53
|
export type Select = 'all' | {
|
|
@@ -55,6 +57,8 @@ export type Select = 'all' | {
|
|
|
55
57
|
markdown?: true;
|
|
56
58
|
backlinks?: true;
|
|
57
59
|
change?: true;
|
|
60
|
+
fileId?: true;
|
|
61
|
+
revision?: true;
|
|
58
62
|
};
|
|
59
63
|
export type OrderOptions = {
|
|
60
64
|
nulls?: 'first' | 'last';
|
|
@@ -70,6 +74,8 @@ export type DocumentQuery = Filter & {
|
|
|
70
74
|
direction?: Direction;
|
|
71
75
|
} & OrderOptions)[];
|
|
72
76
|
limit?: number;
|
|
77
|
+
after?: string;
|
|
78
|
+
total?: true;
|
|
73
79
|
};
|
|
74
80
|
export type GroupQuery = Filter & {
|
|
75
81
|
groupBy: readonly Exclude<Key, 'path'>[];
|
|
@@ -78,6 +84,8 @@ export type GroupQuery = Filter & {
|
|
|
78
84
|
direction?: Direction;
|
|
79
85
|
}[];
|
|
80
86
|
limit?: number;
|
|
87
|
+
after?: string;
|
|
88
|
+
total?: true;
|
|
81
89
|
};
|
|
82
90
|
export type LocalQuery = DocumentQuery | GroupQuery;
|
|
83
91
|
export type Backlink = {
|
|
@@ -95,6 +103,8 @@ export type QueryDocument = {
|
|
|
95
103
|
markdown?: string;
|
|
96
104
|
backlinks?: readonly Backlink[];
|
|
97
105
|
change?: HeadChange | null;
|
|
106
|
+
fileId?: string | null;
|
|
107
|
+
revision?: string | null;
|
|
98
108
|
binaryFile?: BinaryFileRecord;
|
|
99
109
|
};
|
|
100
110
|
export type QueryGroup = {
|
|
@@ -111,7 +121,7 @@ export type QueryCoverage = {
|
|
|
111
121
|
indexes: readonly string[];
|
|
112
122
|
overlay: readonly string[];
|
|
113
123
|
};
|
|
114
|
-
export type Awaits = Open<'acquisition' | 'preparation' | '
|
|
124
|
+
export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
|
|
115
125
|
export type PendingRoom = {
|
|
116
126
|
room: string;
|
|
117
127
|
awaits: Awaits;
|
|
@@ -121,9 +131,13 @@ export type PendingResult = {
|
|
|
121
131
|
};
|
|
122
132
|
export type DocumentRows = {
|
|
123
133
|
documents: readonly QueryDocument[];
|
|
134
|
+
next?: string;
|
|
135
|
+
total?: number;
|
|
124
136
|
};
|
|
125
137
|
export type GroupRows = {
|
|
126
138
|
groups: readonly QueryGroup[];
|
|
139
|
+
next?: string;
|
|
140
|
+
total?: number;
|
|
127
141
|
};
|
|
128
142
|
export type QueryRows = DocumentRows | GroupRows;
|
|
129
143
|
export type DocumentResult = DocumentRows & {
|
|
@@ -187,6 +201,8 @@ export type KeyPlan = {
|
|
|
187
201
|
of: 'path';
|
|
188
202
|
} | {
|
|
189
203
|
of: 'type';
|
|
204
|
+
} | {
|
|
205
|
+
of: 'folder';
|
|
190
206
|
} | {
|
|
191
207
|
of: 'field';
|
|
192
208
|
field: string;
|
|
@@ -199,6 +215,8 @@ export type DocumentShape = {
|
|
|
199
215
|
markdown: boolean;
|
|
200
216
|
backlinks: boolean;
|
|
201
217
|
change: boolean;
|
|
218
|
+
fileId: boolean;
|
|
219
|
+
revision: boolean;
|
|
202
220
|
orderBy: readonly {
|
|
203
221
|
key: KeyPlan;
|
|
204
222
|
options: OrderOptions & {
|
|
@@ -214,14 +232,28 @@ export type GroupShape = {
|
|
|
214
232
|
direction: Direction;
|
|
215
233
|
}[];
|
|
216
234
|
};
|
|
235
|
+
export type PlanArea = {
|
|
236
|
+
room: string;
|
|
237
|
+
path: string;
|
|
238
|
+
open: readonly string[];
|
|
239
|
+
};
|
|
217
240
|
export type PlanReach = {
|
|
218
241
|
rooms: readonly string[];
|
|
219
242
|
documents: readonly string[];
|
|
243
|
+
areas: readonly PlanArea[];
|
|
244
|
+
};
|
|
245
|
+
export type Continuation = {
|
|
246
|
+
text: string;
|
|
247
|
+
values: readonly unknown[] | null;
|
|
220
248
|
};
|
|
221
249
|
export type Plan = {
|
|
250
|
+
key: string;
|
|
222
251
|
rooms: readonly string[] | null;
|
|
223
252
|
reach: PlanReach | null;
|
|
253
|
+
locked: readonly string[];
|
|
224
254
|
root: Scope;
|
|
255
|
+
folder: string | null;
|
|
256
|
+
paths: readonly string[] | null;
|
|
225
257
|
hop: (Scope & {
|
|
226
258
|
field: string;
|
|
227
259
|
}) | null;
|
|
@@ -230,6 +262,8 @@ export type Plan = {
|
|
|
230
262
|
}) | null;
|
|
231
263
|
shape: DocumentShape | GroupShape;
|
|
232
264
|
limit: number | null;
|
|
265
|
+
after: Continuation | null;
|
|
266
|
+
total: boolean;
|
|
233
267
|
};
|
|
234
268
|
export declare class QueryError extends Error {
|
|
235
269
|
readonly code: QueryErrorCode;
|
|
@@ -240,8 +274,10 @@ type Entries = Readonly<Record<string, unknown>>;
|
|
|
240
274
|
export declare function invalid(at: string, problem: string): never;
|
|
241
275
|
export declare function plain(value: unknown): value is Entries;
|
|
242
276
|
export declare function known(value: Entries, allowed: readonly string[], at: string): void;
|
|
277
|
+
export declare function flag(input: unknown, at: string): boolean;
|
|
243
278
|
export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
244
279
|
export declare function limitOf(input: unknown): number | null;
|
|
245
280
|
export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
281
|
+
export declare function queryKey(query: unknown): string;
|
|
246
282
|
export declare function identityOf(plan: Plan): string;
|
|
247
283
|
export {};
|