@agentshouse/app-bridge 0.1.0-ccf413b4e709d → 0.1.0-ccf6bf7d473e2
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 +11 -9
- package/dist/index.d.ts +588 -7
- package/dist/mdmodel/body.d.ts +84 -0
- package/dist/mdmodel/built-in.d.ts +3 -0
- package/dist/mdmodel/crockford.d.ts +3 -0
- package/dist/mdmodel/definition.d.ts +90 -0
- package/dist/mdmodel/divide.d.ts +2 -0
- package/dist/mdmodel/document.d.ts +22 -0
- package/dist/mdmodel/event.d.ts +76 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/fields.d.ts +5 -0
- package/dist/mdmodel/house-model.d.ts +826 -0
- package/dist/mdmodel/house-references.d.ts +3 -0
- package/dist/mdmodel/index.d.ts +42 -0
- package/dist/mdmodel/kinds.d.ts +17 -0
- package/dist/mdmodel/markdown.d.ts +74 -0
- package/dist/mdmodel/media-type.d.ts +71 -0
- package/dist/mdmodel/paths.d.ts +34 -0
- package/dist/mdmodel/pattern.d.ts +9 -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 +5 -0
- package/dist/mdmodel/room-types.d.ts +6 -0
- package/dist/mdmodel/types.d.ts +181 -0
- package/dist/mdmodel/validate.d.ts +35 -0
- package/dist/mdmodel/version.d.ts +1 -0
- package/dist/mdmodel/yaml.d.ts +55 -0
- package/dist/mdruntime/actions.d.ts +25 -0
- package/dist/mdruntime/adapter.d.ts +540 -0
- package/dist/mdruntime/attached-model.d.ts +6 -0
- package/dist/mdruntime/binary.d.ts +17 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/cell.d.ts +5 -0
- package/dist/mdruntime/chain.d.ts +11 -0
- package/dist/mdruntime/change-set.d.ts +31 -0
- package/dist/mdruntime/change.d.ts +119 -0
- package/dist/mdruntime/client.d.ts +97 -0
- package/dist/mdruntime/collection.d.ts +46 -0
- package/dist/mdruntime/compile.d.ts +17 -0
- package/dist/mdruntime/conversation-live.d.ts +146 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +135 -0
- package/dist/mdruntime/declaration.d.ts +9 -0
- package/dist/mdruntime/durability.d.ts +30 -0
- package/dist/mdruntime/failure.d.ts +15 -0
- package/dist/mdruntime/figures.d.ts +48 -0
- package/dist/mdruntime/holdings.d.ts +28 -0
- package/dist/mdruntime/identity.d.ts +5 -0
- package/dist/mdruntime/listing.d.ts +47 -0
- package/dist/mdruntime/live.d.ts +22 -0
- package/dist/mdruntime/media.d.ts +7 -0
- package/dist/mdruntime/messages.d.ts +55 -0
- package/dist/mdruntime/model.d.ts +54 -0
- package/dist/mdruntime/observation.d.ts +45 -0
- package/dist/mdruntime/open.d.ts +1 -0
- package/dist/mdruntime/opened.d.ts +21 -0
- package/dist/mdruntime/outcome.d.ts +94 -0
- package/dist/mdruntime/overlay.d.ts +29 -0
- package/dist/mdruntime/preparation.d.ts +19 -0
- package/dist/mdruntime/presence.d.ts +51 -0
- package/dist/mdruntime/query.d.ts +87 -0
- package/dist/mdruntime/reach.d.ts +55 -0
- package/dist/mdruntime/readiness.d.ts +48 -0
- package/dist/mdruntime/reads.d.ts +38 -0
- package/dist/mdruntime/recovery.d.ts +27 -0
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +62 -0
- package/dist/mdruntime/retried.d.ts +29 -0
- package/dist/mdruntime/room-draft.d.ts +172 -0
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +33 -0
- package/dist/mdruntime/save.d.ts +58 -0
- package/dist/mdruntime/saves.d.ts +31 -0
- package/dist/mdruntime/search.d.ts +21 -0
- package/dist/mdruntime/seed.d.ts +24 -0
- package/dist/mdruntime/socket/admission.d.ts +6 -0
- package/dist/mdruntime/socket/answers.d.ts +5 -0
- package/dist/mdruntime/socket/lanes.d.ts +27 -0
- package/dist/mdruntime/socket/session.d.ts +37 -0
- package/dist/mdruntime/socket.d.ts +66 -0
- package/dist/mdruntime/source.d.ts +53 -0
- package/dist/mdruntime/status.d.ts +25 -0
- package/dist/mdruntime/store/installs.d.ts +29 -0
- package/dist/mdruntime/store/readiness.d.ts +9 -0
- package/dist/mdruntime/store/records.d.ts +214 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/space.d.ts +10 -0
- package/dist/mdruntime/store/watchers.d.ts +16 -0
- package/dist/mdruntime/store/writes.d.ts +23 -0
- package/dist/mdruntime/store.d.ts +121 -0
- package/dist/mdruntime/stored.d.ts +156 -0
- package/dist/mdruntime/surface.d.ts +88 -0
- package/dist/mdruntime/tables.d.ts +414 -0
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/wire.d.ts +295 -0
- package/dist/session-content/bounds.d.ts +7 -0
- package/dist/session-content/check.d.ts +18 -0
- package/dist/session-content/index.d.ts +7 -0
- package/dist/session-content/parts.d.ts +103 -0
- package/dist/session-content/state.d.ts +61 -0
- package/dist/session-content/turn.d.ts +328 -0
- package/dist/test-host.d.ts +8 -2
- package/dist/test-host.js +48 -12
- package/docs/families.md +70 -20
- package/package.json +8 -6
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import type { GroupTotal, PendingResult } from './query.js';
|
|
3
|
+
import type { Deliver, Fail } from './reach.js';
|
|
4
|
+
import type { ConversationTally, RoomTally } from './tallies.js';
|
|
5
|
+
import type { QueryRoom } from './tables.js';
|
|
6
|
+
export declare const HOUSE_DIRECTORY = "house";
|
|
7
|
+
export declare const ROOM_TOTALS: {
|
|
8
|
+
readonly outside: readonly ["house"];
|
|
9
|
+
readonly groupBy: readonly ["room"];
|
|
10
|
+
readonly select: {
|
|
11
|
+
readonly size: true;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const FIGURES_DAY_MS = 86400000;
|
|
15
|
+
export type DayFigures = {
|
|
16
|
+
readonly created: number;
|
|
17
|
+
readonly changed: number;
|
|
18
|
+
readonly chats: number;
|
|
19
|
+
readonly messages: number;
|
|
20
|
+
};
|
|
21
|
+
export type RoomFigures = {
|
|
22
|
+
readonly room: string;
|
|
23
|
+
readonly day: DayFigures;
|
|
24
|
+
readonly total: {
|
|
25
|
+
readonly documents: GroupTotal;
|
|
26
|
+
readonly files: GroupTotal;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type Figures = {
|
|
30
|
+
readonly rooms: readonly RoomFigures[];
|
|
31
|
+
readonly agentMessages: number;
|
|
32
|
+
};
|
|
33
|
+
export type FiguresResult = Figures | PendingResult;
|
|
34
|
+
export type FiguresCover = PendingResult | {
|
|
35
|
+
readonly rooms: readonly QueryRoom[];
|
|
36
|
+
};
|
|
37
|
+
export type FiguresSources = {
|
|
38
|
+
cover(): Promise<FiguresCover>;
|
|
39
|
+
rooms(rooms: readonly QueryRoom[], since: string): Promise<readonly RoomTally[]>;
|
|
40
|
+
conversations(conversations: readonly string[] | null, since: string): Promise<readonly ConversationTally[]>;
|
|
41
|
+
};
|
|
42
|
+
export type FiguresRead = {
|
|
43
|
+
watch(deliver: Deliver, fail: Fail): () => void;
|
|
44
|
+
touched(set: ChangeSet): void;
|
|
45
|
+
recover(): void;
|
|
46
|
+
close(): void;
|
|
47
|
+
};
|
|
48
|
+
export declare function createFigures(sources: FiguresSources): FiguresRead;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AppCode } from './durability.js';
|
|
2
|
+
import type { GroupTotal, PendingResult } from './query.js';
|
|
3
|
+
import type { Deliver, Fail } from './reach.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { OpenedRoom } from './tables.js';
|
|
6
|
+
export type RoomDocuments = {
|
|
7
|
+
readonly room: string;
|
|
8
|
+
readonly documents: GroupTotal;
|
|
9
|
+
};
|
|
10
|
+
export type HeldApp = ({
|
|
11
|
+
readonly app: string;
|
|
12
|
+
readonly state: 'measured';
|
|
13
|
+
} & AppCode) | {
|
|
14
|
+
readonly app: string;
|
|
15
|
+
readonly state: 'asking' | 'unknown';
|
|
16
|
+
};
|
|
17
|
+
export type Holdings = {
|
|
18
|
+
readonly rooms: readonly RoomDocuments[] | PendingResult;
|
|
19
|
+
readonly opened: GroupTotal & {
|
|
20
|
+
readonly rooms: readonly OpenedRoom[];
|
|
21
|
+
};
|
|
22
|
+
readonly apps: readonly HeldApp[];
|
|
23
|
+
readonly house: number | null;
|
|
24
|
+
readonly total: number | null;
|
|
25
|
+
readonly cleanUp: number | null;
|
|
26
|
+
};
|
|
27
|
+
export declare const CLEANED_TOPIC = "cleaned";
|
|
28
|
+
export declare function watchHoldings({ store, figures, shell }: Runtime, deliver: Deliver, fail: Fail): () => void;
|
|
@@ -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,47 @@
|
|
|
1
|
+
import type { HeldRooms } from '../mdmodel/index.js';
|
|
2
|
+
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission, RoomDeclaration } from './adapter.js';
|
|
3
|
+
import type { Composition } from './collection.js';
|
|
4
|
+
import { type ModelState, type TypesResult } from './model.js';
|
|
5
|
+
import { type PortReach } from './reach.js';
|
|
6
|
+
import type { ReplicaRecord } from './replica.js';
|
|
7
|
+
import type { Runtime } from './runtime.js';
|
|
8
|
+
import type { Stored } from './store.js';
|
|
9
|
+
export type AppTypedSelection = {
|
|
10
|
+
roots: readonly string[];
|
|
11
|
+
model: TypesResult;
|
|
12
|
+
};
|
|
13
|
+
export type AppRoom = {
|
|
14
|
+
name: string;
|
|
15
|
+
locator: string;
|
|
16
|
+
handle: string;
|
|
17
|
+
operations: OperationScopes;
|
|
18
|
+
replica: ReplicaAdmission;
|
|
19
|
+
model: TypesResult;
|
|
20
|
+
typedSelection: AppTypedSelection | null;
|
|
21
|
+
providerOwnedPaths: readonly string[];
|
|
22
|
+
authoredPaths: readonly string[];
|
|
23
|
+
roomVersion: string | null;
|
|
24
|
+
documents: number;
|
|
25
|
+
synchronizationAvailable: boolean;
|
|
26
|
+
refusal: ProviderRefusal | null;
|
|
27
|
+
locked: boolean;
|
|
28
|
+
};
|
|
29
|
+
type ListedRoom = Omit<AppRoom, 'documents' | 'locked'>;
|
|
30
|
+
type ListedEntry = ListedRoom & {
|
|
31
|
+
readonly documents: number;
|
|
32
|
+
};
|
|
33
|
+
export type Listing = ReadonlyMap<string, ListedEntry>;
|
|
34
|
+
export declare function modelIn({ socket, presence }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
|
+
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
|
+
export declare function declarationOf({ presence }: Runtime, locator: string, stored: Stored | undefined): {
|
|
37
|
+
readonly room: RoomDeclaration;
|
|
38
|
+
readonly available: boolean;
|
|
39
|
+
} | undefined;
|
|
40
|
+
export declare function listedLocators({ presence }: Runtime, held: ReadonlyMap<string, unknown>): string[];
|
|
41
|
+
export declare function patchedListing(runtime: Runtime, changed: ReadonlySet<string>): Promise<Listing | null>;
|
|
42
|
+
export declare function listingNow(runtime: Runtime): Promise<Listing>;
|
|
43
|
+
export declare function shownRooms({ presence }: Runtime, listing: Listing): readonly AppRoom[];
|
|
44
|
+
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
|
+
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
46
|
+
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
4
|
+
import type { Fail } from './reach.js';
|
|
5
|
+
import type { QueryRoom } from './tables.js';
|
|
6
|
+
export type Cover = {
|
|
7
|
+
coverage: QueryCoverage;
|
|
8
|
+
rooms: readonly QueryRoom[];
|
|
9
|
+
} | PendingResult;
|
|
10
|
+
export type Ran = KeyedResult & {
|
|
11
|
+
readonly current: () => boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
|
|
14
|
+
type Listener = (message: QueryMessage) => void;
|
|
15
|
+
export type LiveQueries<H> = {
|
|
16
|
+
touched(set: ChangeSet): void;
|
|
17
|
+
recover(): void;
|
|
18
|
+
watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
|
|
19
|
+
close(): void;
|
|
20
|
+
};
|
|
21
|
+
export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
|
|
22
|
+
export {};
|
|
@@ -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): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
|
+
export declare const MESSAGE_TABLES: readonly string[];
|
|
4
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
5
|
+
export type HeldConversation = {
|
|
6
|
+
readonly conversation: string;
|
|
7
|
+
readonly read: string | null | undefined;
|
|
8
|
+
readonly partial: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type MessageWindow = {
|
|
11
|
+
readonly messages: AcceptedMessage[];
|
|
12
|
+
readonly more: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type HeldSource = {
|
|
15
|
+
readonly source: unknown;
|
|
16
|
+
readonly sender: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type HeldRow = {
|
|
19
|
+
readonly conversation: string;
|
|
20
|
+
readonly said: {
|
|
21
|
+
readonly text: string;
|
|
22
|
+
readonly role: string | null;
|
|
23
|
+
readonly at: string | null;
|
|
24
|
+
} | null;
|
|
25
|
+
readonly failure: string | null;
|
|
26
|
+
readonly opened: HeldSource | null;
|
|
27
|
+
readonly asking: (HeldSource & {
|
|
28
|
+
readonly identity: string;
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly at: string | null;
|
|
31
|
+
}) | null;
|
|
32
|
+
};
|
|
33
|
+
export type ConversationFact = 'openedTurn' | 'dismissedSuggestion';
|
|
34
|
+
export type HeldFact = {
|
|
35
|
+
readonly conversation: string;
|
|
36
|
+
readonly name: ConversationFact;
|
|
37
|
+
readonly value: string;
|
|
38
|
+
};
|
|
39
|
+
export type ConversationWrite = {
|
|
40
|
+
readonly conversation: string;
|
|
41
|
+
readonly messages: readonly AcceptedMessage[];
|
|
42
|
+
readonly read?: {
|
|
43
|
+
readonly at: string | null;
|
|
44
|
+
readonly partial: boolean;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
|
|
48
|
+
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
49
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
50
|
+
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
51
|
+
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
52
|
+
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
53
|
+
export declare function conversationFacts(connection: Connection): HeldFact[];
|
|
54
|
+
export declare function keptFact(connection: Connection, { conversation, name, value }: HeldFact): null;
|
|
55
|
+
export declare function forgottenConversations(connection: Connection): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Definition, 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'>;
|
|
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
|
+
} | {
|
|
24
|
+
status: 'current' | 'cached';
|
|
25
|
+
snapshot: ModelSnapshot;
|
|
26
|
+
verifiedWith: ModelIdentity;
|
|
27
|
+
types: VerifiedModel['types'];
|
|
28
|
+
};
|
|
29
|
+
export type StoredModel = Extract<ModelState, {
|
|
30
|
+
status: 'unavailable';
|
|
31
|
+
}> | Omit<Extract<ModelState, {
|
|
32
|
+
status: 'current' | 'cached';
|
|
33
|
+
}>, 'types'>;
|
|
34
|
+
export type TypesResult = {
|
|
35
|
+
status: Open<'unavailable'>;
|
|
36
|
+
reason: ModelUnavailableReason;
|
|
37
|
+
types: null;
|
|
38
|
+
} | {
|
|
39
|
+
status: Open<'current' | 'cached'>;
|
|
40
|
+
identity: string;
|
|
41
|
+
version: string;
|
|
42
|
+
verifiedWith: ModelIdentity;
|
|
43
|
+
types: readonly MdType[];
|
|
44
|
+
schema: string | null;
|
|
45
|
+
revision: string | null;
|
|
46
|
+
};
|
|
47
|
+
export type ValidationReceipt = {
|
|
48
|
+
identity: string;
|
|
49
|
+
version: string;
|
|
50
|
+
source: Open<'current' | 'cached'>;
|
|
51
|
+
};
|
|
52
|
+
export declare const NO_MODEL: ModelState;
|
|
53
|
+
export declare function modelTypes(state: ModelState): TypesResult;
|
|
54
|
+
export declare function storedModel(state: ModelState): StoredModel;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 replaces(topic: string, message: unknown): boolean;
|
|
29
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
30
|
+
export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
|
|
31
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
|
|
32
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
33
|
+
export type Digest = {
|
|
34
|
+
readonly pending: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly keys: readonly RowKey[];
|
|
37
|
+
readonly rows: ReadonlyMap<RowKey, number>;
|
|
38
|
+
readonly coverage: string;
|
|
39
|
+
readonly next: string | undefined;
|
|
40
|
+
readonly total: number | undefined;
|
|
41
|
+
};
|
|
42
|
+
export declare function hashed(text: string): number;
|
|
43
|
+
export declare function digestOf({ result, keys }: KeyedResult): Digest;
|
|
44
|
+
export declare function digestApplied(digest: Digest, message: QueryMessage): Digest;
|
|
45
|
+
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, lost: (locator: string) => boolean): OpenedFiles;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { Attempt, Retries } from './retried.js';
|
|
4
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
5
|
+
type Refused<Kind extends string> = ProviderRefusal & {
|
|
6
|
+
kind: Kind;
|
|
7
|
+
};
|
|
8
|
+
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
9
|
+
locator: string;
|
|
10
|
+
}) | (Refused<'room-locked'> & {
|
|
11
|
+
locator: string;
|
|
12
|
+
}) | ScopedRefusal;
|
|
13
|
+
export type CallResult = {
|
|
14
|
+
kind: 'action';
|
|
15
|
+
result: unknown;
|
|
16
|
+
at?: RoomVersionAt;
|
|
17
|
+
} | (Refused<'rejected'> & {
|
|
18
|
+
reset?: string;
|
|
19
|
+
}) | Refused<'undeclared'> | Failure;
|
|
20
|
+
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
21
|
+
kind: Failure['kind'];
|
|
22
|
+
}> | Failure;
|
|
23
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
24
|
+
export type BinaryAnswer = {
|
|
25
|
+
kind: 'binary';
|
|
26
|
+
stream: ReadableStream<Uint8Array>;
|
|
27
|
+
byteLength: number;
|
|
28
|
+
mediaType: string;
|
|
29
|
+
} | BinaryRefusal;
|
|
30
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
31
|
+
export type BinaryLinkAnswer = {
|
|
32
|
+
kind: 'link';
|
|
33
|
+
url: string;
|
|
34
|
+
name: string;
|
|
35
|
+
mediaType: string;
|
|
36
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
37
|
+
export type HeldShownAnswer = KeptBinary | BinaryLinkAnswer;
|
|
38
|
+
export type ShownAnswer = BinaryAnswer | BinaryLinkAnswer;
|
|
39
|
+
export type AttachAnswer = {
|
|
40
|
+
kind: 'attached';
|
|
41
|
+
path: string;
|
|
42
|
+
} | Offline | Refused<'rejected'> | Failure;
|
|
43
|
+
export type DownloadAnswer = {
|
|
44
|
+
kind: 'started';
|
|
45
|
+
} | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
|
|
46
|
+
export type Resolution = {
|
|
47
|
+
readonly kind: 'document';
|
|
48
|
+
readonly room: string;
|
|
49
|
+
readonly path: string;
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: 'deleted';
|
|
52
|
+
readonly room: string;
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly revision: HistoryRevision;
|
|
55
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
56
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
57
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
58
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
59
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
60
|
+
export declare function declaredType(blob: Blob): string;
|
|
61
|
+
export declare function blobOf(binary: Extract<BinaryAnswer, {
|
|
62
|
+
kind: 'binary';
|
|
63
|
+
}>): Promise<Blob>;
|
|
64
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
65
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
|
|
66
|
+
export declare function attachAnswer(result: AttachResult): AttachAnswer;
|
|
67
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
68
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
69
|
+
locator: string;
|
|
70
|
+
};
|
|
71
|
+
export type Offline = {
|
|
72
|
+
readonly kind: 'offline';
|
|
73
|
+
};
|
|
74
|
+
export declare const OFFLINE: Offline;
|
|
75
|
+
export declare function answeredResult(value: unknown): boolean;
|
|
76
|
+
export declare const UNCERTAIN: Failure;
|
|
77
|
+
export declare function undeclared(name: string): CallResult;
|
|
78
|
+
export declare function failure(result: AdapterFailure): Failure;
|
|
79
|
+
export declare function calledResult(result: ActionResult): CallResult;
|
|
80
|
+
export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
|
|
81
|
+
export type Submission = {
|
|
82
|
+
readonly state: 'waiting' | 'submitted';
|
|
83
|
+
} | {
|
|
84
|
+
readonly state: 'reset';
|
|
85
|
+
readonly reset: string;
|
|
86
|
+
};
|
|
87
|
+
export type QueueEntry = {
|
|
88
|
+
readonly batch: ChangeBatch;
|
|
89
|
+
} & (Submission | {
|
|
90
|
+
readonly state: 'local';
|
|
91
|
+
});
|
|
92
|
+
export declare const UNANSWERED: ActionResult;
|
|
93
|
+
export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ApplyResult } from '../mdmodel/index.js';
|
|
2
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
3
|
+
import { type Composition } from './collection.js';
|
|
4
|
+
import type { ChangeBatch } from './change.js';
|
|
5
|
+
export type Heads = {
|
|
6
|
+
revisions: Readonly<Record<string, string>>;
|
|
7
|
+
fileIds: Readonly<Record<string, string>>;
|
|
8
|
+
created: Readonly<Record<string, string>>;
|
|
9
|
+
changes: Readonly<Record<string, HeadChange>>;
|
|
10
|
+
};
|
|
11
|
+
export type HeldBinary = ({
|
|
12
|
+
readonly state: 'accepted';
|
|
13
|
+
} & BinaryFile) | {
|
|
14
|
+
readonly state: 'pending';
|
|
15
|
+
readonly localId: string;
|
|
16
|
+
readonly byteLength: number;
|
|
17
|
+
readonly mediaType: string;
|
|
18
|
+
readonly sha256: string;
|
|
19
|
+
};
|
|
20
|
+
export type Layer = Heads & {
|
|
21
|
+
documents: Readonly<Record<string, string>>;
|
|
22
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
23
|
+
};
|
|
24
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
25
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
26
|
+
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
27
|
+
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
+
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
29
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PlanReach } from './query.js';
|
|
2
|
+
import { type PortReach } from './reach.js';
|
|
3
|
+
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
export type ReadinessPort = {
|
|
6
|
+
readonly target: string;
|
|
7
|
+
readonly code: CodeAvailability;
|
|
8
|
+
};
|
|
9
|
+
export type ReadinessWatch = {
|
|
10
|
+
readonly port: ReadinessPort;
|
|
11
|
+
readonly reach: PortReach | null;
|
|
12
|
+
readonly deliver: (readiness: Readiness) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
+
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
|
+
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
19
|
+
export declare function filled(runtime: Runtime): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { DiscoveredRoom, ProviderRefusal, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import type { ModelState } from './model.js';
|
|
3
|
+
type Repairable = {
|
|
4
|
+
readonly reset: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
type Standing = {
|
|
7
|
+
readonly stale: boolean;
|
|
8
|
+
readonly repairable: Repairable | null;
|
|
9
|
+
readonly repairing: boolean;
|
|
10
|
+
readonly reloadDue: boolean;
|
|
11
|
+
};
|
|
12
|
+
type Listing = {
|
|
13
|
+
readonly whole: boolean;
|
|
14
|
+
readonly live: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type Presence = {
|
|
17
|
+
list(found: readonly DiscoveredRoom[], how: Listing): readonly DiscoveredRoom[];
|
|
18
|
+
room(locator: string): DiscoveredRoom | undefined;
|
|
19
|
+
rooms(): readonly DiscoveredRoom[];
|
|
20
|
+
available(locator: string, selection?: string): boolean;
|
|
21
|
+
refusal(locator: string): ProviderRefusal | null;
|
|
22
|
+
unheldModel(locator: string): ModelState | null;
|
|
23
|
+
refused(locator: string, refusal: ScopedRefusal | null): void;
|
|
24
|
+
readable(locator: string): boolean;
|
|
25
|
+
modelled(locator: string, model: ModelState | null): void;
|
|
26
|
+
installed(locator: string, bootstrapped: boolean): void;
|
|
27
|
+
locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
|
|
28
|
+
lockedAmong(stored: ReadonlyMap<string, string>): readonly string[];
|
|
29
|
+
connectionLost(lapsed: () => void): void;
|
|
30
|
+
connectionLive(): void;
|
|
31
|
+
lapse(): void;
|
|
32
|
+
stood(locator: string, stale: boolean, repairable?: Repairable | null): void;
|
|
33
|
+
repairing(locator: string, running: boolean): void;
|
|
34
|
+
reload(locator: string, due: boolean): void;
|
|
35
|
+
standing(locator: string): Standing;
|
|
36
|
+
settled(): boolean;
|
|
37
|
+
repairsOwed(): readonly string[];
|
|
38
|
+
askAgain(locator: string, ask: () => void): void;
|
|
39
|
+
stopAsking(locator?: string): void;
|
|
40
|
+
lose(locator: string, during: number): boolean;
|
|
41
|
+
writing(locator: string): boolean;
|
|
42
|
+
unwritten(locator: string): void;
|
|
43
|
+
lost(locator: string): boolean;
|
|
44
|
+
losses(): number;
|
|
45
|
+
lostSince(locator: string, losses: number): boolean;
|
|
46
|
+
liftable(locator: string, discovery: number): boolean;
|
|
47
|
+
lift(locator: string, discovery: number, unfenced: boolean): void;
|
|
48
|
+
close(): void;
|
|
49
|
+
};
|
|
50
|
+
export declare function createPresence(): Presence;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type HeldRooms, type QueryPlan } from '../mdmodel/index.js';
|
|
2
|
+
import type { HeadChange } from './adapter.js';
|
|
3
|
+
import type { BinaryFileRecord } from './binary.js';
|
|
4
|
+
import type { Open } from './open.js';
|
|
5
|
+
export type Backlink = {
|
|
6
|
+
path: string;
|
|
7
|
+
type: string;
|
|
8
|
+
field: string;
|
|
9
|
+
};
|
|
10
|
+
export type QueryDocument = {
|
|
11
|
+
room: string;
|
|
12
|
+
path: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
fields?: Readonly<Record<string, unknown>>;
|
|
15
|
+
sections?: Readonly<Record<string, string>>;
|
|
16
|
+
preamble?: string;
|
|
17
|
+
markdown?: string;
|
|
18
|
+
backlinks?: readonly Backlink[];
|
|
19
|
+
change?: HeadChange | null;
|
|
20
|
+
fileId?: string | null;
|
|
21
|
+
revision?: string | null;
|
|
22
|
+
binaryFile?: BinaryFileRecord;
|
|
23
|
+
size?: number | null;
|
|
24
|
+
created?: string | null;
|
|
25
|
+
};
|
|
26
|
+
export type GroupTotal = {
|
|
27
|
+
count: number;
|
|
28
|
+
size: number;
|
|
29
|
+
};
|
|
30
|
+
export type QueryGroup = {
|
|
31
|
+
key: readonly unknown[];
|
|
32
|
+
count: number;
|
|
33
|
+
documents?: GroupTotal;
|
|
34
|
+
files?: GroupTotal;
|
|
35
|
+
updated?: string | null;
|
|
36
|
+
greatest?: unknown;
|
|
37
|
+
};
|
|
38
|
+
export type CoveredRoom = {
|
|
39
|
+
room: string;
|
|
40
|
+
generation: string;
|
|
41
|
+
current: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type QueryCoverage = {
|
|
44
|
+
rooms: readonly CoveredRoom[];
|
|
45
|
+
overlay: readonly string[];
|
|
46
|
+
};
|
|
47
|
+
export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
|
|
48
|
+
export type PendingRoom = {
|
|
49
|
+
room: string;
|
|
50
|
+
awaits: Awaits;
|
|
51
|
+
};
|
|
52
|
+
export type PendingResult = {
|
|
53
|
+
pending: readonly PendingRoom[];
|
|
54
|
+
};
|
|
55
|
+
export type DocumentRows = {
|
|
56
|
+
documents: readonly QueryDocument[];
|
|
57
|
+
next?: string;
|
|
58
|
+
total?: number;
|
|
59
|
+
};
|
|
60
|
+
export type GroupRows = {
|
|
61
|
+
groups: readonly QueryGroup[];
|
|
62
|
+
next?: string;
|
|
63
|
+
total?: number;
|
|
64
|
+
};
|
|
65
|
+
export type QueryRows = DocumentRows | GroupRows;
|
|
66
|
+
export type DocumentResult = DocumentRows & {
|
|
67
|
+
coverage: QueryCoverage;
|
|
68
|
+
};
|
|
69
|
+
export type GroupResult = GroupRows & {
|
|
70
|
+
coverage: QueryCoverage;
|
|
71
|
+
};
|
|
72
|
+
export type QueryResult = DocumentResult | GroupResult | PendingResult;
|
|
73
|
+
export type PlanArea = {
|
|
74
|
+
room: string;
|
|
75
|
+
path: string;
|
|
76
|
+
open: readonly string[];
|
|
77
|
+
};
|
|
78
|
+
export type PlanReach = {
|
|
79
|
+
rooms: readonly string[];
|
|
80
|
+
documents: readonly string[];
|
|
81
|
+
areas: readonly PlanArea[];
|
|
82
|
+
};
|
|
83
|
+
export type Plan = QueryPlan & {
|
|
84
|
+
reach: PlanReach | null;
|
|
85
|
+
locked: readonly string[];
|
|
86
|
+
};
|
|
87
|
+
export declare function planWithin(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|