@agentshouse/app-bridge 0.1.0-c8d97d63f2350 → 0.1.0-c8dd3de04bf64
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 +6 -6
- package/dist/index.d.ts +196 -132
- package/dist/mdmodel/definition.d.ts +1 -1
- package/dist/mdmodel/document.d.ts +2 -1
- package/dist/mdmodel/event.d.ts +77 -0
- package/dist/mdmodel/facts.d.ts +14 -0
- package/dist/mdmodel/index.d.ts +19 -7
- package/dist/mdmodel/kinds.d.ts +17 -0
- package/dist/mdmodel/pattern.d.ts +9 -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/reserved.d.ts +5 -0
- package/dist/mdmodel/types.d.ts +11 -0
- package/dist/mdmodel/validate.d.ts +7 -5
- package/dist/mdruntime/actions.d.ts +19 -0
- package/dist/mdruntime/adapter.d.ts +45 -25
- package/dist/mdruntime/attached-model.d.ts +7 -0
- package/dist/mdruntime/bootstrap.d.ts +43 -0
- package/dist/mdruntime/cell.d.ts +5 -0
- package/dist/mdruntime/chain.d.ts +2 -1
- package/dist/mdruntime/change.d.ts +1 -0
- package/dist/mdruntime/client.d.ts +23 -5
- package/dist/mdruntime/collection.d.ts +2 -1
- package/dist/mdruntime/compile.d.ts +6 -6
- package/dist/mdruntime/conversation-live.d.ts +135 -0
- package/dist/mdruntime/conversation-row.d.ts +32 -0
- package/dist/mdruntime/conversation.d.ts +34 -38
- package/dist/mdruntime/durability.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 +0 -1
- package/dist/mdruntime/install.d.ts +55 -0
- package/dist/mdruntime/job.d.ts +32 -0
- package/dist/mdruntime/listing.d.ts +52 -0
- package/dist/mdruntime/live.d.ts +22 -0
- package/dist/mdruntime/log.d.ts +5 -0
- package/dist/mdruntime/media.d.ts +1 -1
- package/dist/mdruntime/messages.d.ts +27 -3
- package/dist/mdruntime/model.d.ts +2 -9
- package/dist/mdruntime/observation.d.ts +2 -2
- package/dist/mdruntime/outcome.d.ts +4 -1
- package/dist/mdruntime/overlay.d.ts +1 -0
- package/dist/mdruntime/preparation.d.ts +19 -0
- package/dist/mdruntime/query.d.ts +13 -209
- package/dist/mdruntime/reach.d.ts +14 -12
- package/dist/mdruntime/readiness.d.ts +0 -3
- package/dist/mdruntime/reads.d.ts +36 -0
- package/dist/mdruntime/refresh.d.ts +26 -0
- package/dist/mdruntime/replica.d.ts +9 -8
- package/dist/mdruntime/room-draft.d.ts +4 -5
- package/dist/mdruntime/room-drafts.d.ts +23 -0
- package/dist/mdruntime/runtime.d.ts +42 -0
- package/dist/mdruntime/save.d.ts +5 -1
- package/dist/mdruntime/saves.d.ts +69 -0
- package/dist/mdruntime/search.d.ts +12 -63
- package/dist/mdruntime/seed.d.ts +11 -2
- 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 +19 -0
- package/dist/mdruntime/socket/rooms.d.ts +43 -0
- package/dist/mdruntime/socket/session.d.ts +37 -0
- package/dist/mdruntime/socket.d.ts +69 -0
- package/dist/mdruntime/source.d.ts +60 -0
- package/dist/mdruntime/status.d.ts +0 -2
- package/dist/mdruntime/store/fences.d.ts +15 -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 +211 -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 +107 -145
- package/dist/mdruntime/stored.d.ts +59 -33
- package/dist/mdruntime/surface.d.ts +87 -0
- package/dist/mdruntime/tables.d.ts +120 -29
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/turn.d.ts +8 -0
- package/dist/mdruntime/wire.d.ts +17 -1
- package/dist/test-host.js +1 -1
- package/docs/families.md +20 -8
- package/package.json +1 -1
- package/dist/mdmodel/condition.d.ts +0 -167
- package/dist/mdmodel/profile.d.ts +0 -5
- package/dist/mdruntime/connection.d.ts +0 -152
- package/dist/mdruntime/fulltext.d.ts +0 -26
|
@@ -1,72 +1,21 @@
|
|
|
1
|
-
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
-
import
|
|
3
|
-
import type { Open } from './open.js';
|
|
4
|
-
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
5
3
|
export type SearchRequest = {
|
|
6
4
|
text: string;
|
|
7
|
-
|
|
8
|
-
collection?: true;
|
|
9
|
-
conversations?: readonly string[];
|
|
10
|
-
limit?: number;
|
|
11
|
-
after?: string;
|
|
12
|
-
total?: true;
|
|
5
|
+
rooms?: readonly string[];
|
|
13
6
|
};
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
at: readonly [number, number];
|
|
19
|
-
};
|
|
20
|
-
export type DocumentHit = {
|
|
21
|
-
room: string;
|
|
22
|
-
path: string;
|
|
23
|
-
type: string;
|
|
24
|
-
score: number;
|
|
25
|
-
matches: Readonly<Record<string, readonly DocumentPart[]>>;
|
|
26
|
-
snippet?: Snippet<DocumentPart>;
|
|
27
|
-
};
|
|
28
|
-
export type MessageHit = {
|
|
29
|
-
conversation: string;
|
|
30
|
-
identity: string;
|
|
31
|
-
score: number;
|
|
32
|
-
matches: Readonly<Record<string, readonly MessagePart[]>>;
|
|
33
|
-
snippet?: Snippet<MessagePart>;
|
|
34
|
-
};
|
|
35
|
-
export type SearchCoverage = {
|
|
36
|
-
rooms: readonly CoveredRoom[];
|
|
37
|
-
conversations: readonly string[];
|
|
38
|
-
overlay: readonly string[];
|
|
7
|
+
export type { SearchHit } from './adapter.js';
|
|
8
|
+
export type SearchFound = {
|
|
9
|
+
kind: 'found';
|
|
10
|
+
documents: readonly SearchHit[];
|
|
39
11
|
};
|
|
40
|
-
export type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export type SearchWindow = SearchHits & {
|
|
45
|
-
next?: string;
|
|
46
|
-
total?: {
|
|
47
|
-
documents: number;
|
|
48
|
-
messages: number;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export type SearchPending = SearchHits & {
|
|
52
|
-
pending: readonly PendingRoom[];
|
|
53
|
-
coverage: SearchCoverage;
|
|
54
|
-
};
|
|
55
|
-
export type SearchUndeclared = ProviderRefusal & {
|
|
12
|
+
export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
|
|
13
|
+
kind: 'rejected';
|
|
14
|
+
}) | (ProviderRefusal & {
|
|
56
15
|
kind: 'undeclared';
|
|
57
|
-
};
|
|
58
|
-
export type SearchResult = (SearchWindow & {
|
|
59
|
-
coverage: SearchCoverage;
|
|
60
|
-
}) | SearchPending | SearchUndeclared;
|
|
61
|
-
export declare function undeclaredSearch(): SearchUndeclared;
|
|
62
|
-
export type HitCursor = readonly [number, string, string] | readonly [] | null;
|
|
16
|
+
}) | Failure;
|
|
63
17
|
export type SearchPlan = {
|
|
64
18
|
text: string;
|
|
65
|
-
|
|
66
|
-
collection: boolean;
|
|
67
|
-
conversations: readonly string[] | null;
|
|
68
|
-
limit: number | null;
|
|
69
|
-
after: readonly [HitCursor, HitCursor] | null;
|
|
70
|
-
total: boolean;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
71
20
|
};
|
|
72
21
|
export declare function searchPlanOf(input: unknown): SearchPlan;
|
package/dist/mdruntime/seed.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type
|
|
1
|
+
import type { Cover } from './live.js';
|
|
2
|
+
import { type KeyedResult } from './observation.js';
|
|
3
|
+
import type { Plan, QueryRows } from './query.js';
|
|
4
|
+
import type { Deliver } from './reach.js';
|
|
5
|
+
import type { Runtime } from './runtime.js';
|
|
6
|
+
import type { HeldCover, Store } from './store.js';
|
|
3
7
|
export type EntrySeed = {
|
|
4
8
|
readonly at: Readonly<Record<string, string>>;
|
|
5
9
|
readonly queries: readonly {
|
|
@@ -11,5 +15,10 @@ export type Seeded = {
|
|
|
11
15
|
readonly rows: QueryRows;
|
|
12
16
|
readonly at: Readonly<Record<string, string>>;
|
|
13
17
|
};
|
|
18
|
+
type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
|
|
14
19
|
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
15
20
|
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
21
|
+
export declare function seedApplies(runtime: Runtime, plan: Plan, held: HeldCover): Seeded | null;
|
|
22
|
+
export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
|
|
23
|
+
export declare function watchSeeded(runtime: Runtime, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Live = () => boolean;
|
|
2
|
+
type LaneRules = {
|
|
3
|
+
generation(): number;
|
|
4
|
+
continuing(): boolean;
|
|
5
|
+
stopping(): boolean;
|
|
6
|
+
};
|
|
7
|
+
export type Lanes = {
|
|
8
|
+
task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
9
|
+
inRoom<T>(locator: string, work: (live: Live) => Promise<T>): Promise<T>;
|
|
10
|
+
roomTask(locator: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
11
|
+
roomWork(): number;
|
|
12
|
+
current(): Promise<unknown>;
|
|
13
|
+
finished(): Promise<unknown>;
|
|
14
|
+
calling(operation: string): boolean;
|
|
15
|
+
call(operation: string): void;
|
|
16
|
+
called(operation: string): void;
|
|
17
|
+
};
|
|
18
|
+
export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DiscoveredRoom, ProviderRefusal, TypedSelection } from '../adapter.js';
|
|
2
|
+
import type { ModelState } from '../model.js';
|
|
3
|
+
export type RoomDeclaration = Omit<DiscoveredRoom, 'roomVersion' | 'typedSelection'> & {
|
|
4
|
+
typedSelection?: TypedSelection | null;
|
|
5
|
+
};
|
|
6
|
+
export type Declared = {
|
|
7
|
+
readonly room: RoomDeclaration | null;
|
|
8
|
+
readonly available: boolean;
|
|
9
|
+
};
|
|
10
|
+
type RoomStanding = {
|
|
11
|
+
readonly unreadable: boolean;
|
|
12
|
+
readonly refusal: ProviderRefusal | null;
|
|
13
|
+
readonly unheldModel: ModelState | null;
|
|
14
|
+
readonly stale: boolean;
|
|
15
|
+
readonly repairable: {
|
|
16
|
+
readonly reset: string | undefined;
|
|
17
|
+
} | null;
|
|
18
|
+
readonly repairing: boolean;
|
|
19
|
+
readonly reloadDue: boolean;
|
|
20
|
+
readonly confirmed: boolean;
|
|
21
|
+
readonly unpreparable: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type Rooms = {
|
|
24
|
+
declare(locator: string, declared: Declared): void;
|
|
25
|
+
declared(locator: string): Declared | undefined;
|
|
26
|
+
declarations(): ReadonlyMap<string, Declared>;
|
|
27
|
+
discover(room: DiscoveredRoom): void;
|
|
28
|
+
discovered(locator: string): DiscoveredRoom | undefined;
|
|
29
|
+
discoveredRooms(): readonly DiscoveredRoom[];
|
|
30
|
+
undiscoverAll(): void;
|
|
31
|
+
standing(locator: string): RoomStanding;
|
|
32
|
+
stand(locator: string, change: Partial<RoomStanding>): void;
|
|
33
|
+
standingWhere(held: (room: RoomStanding) => boolean): readonly string[];
|
|
34
|
+
standAll(change: Partial<RoomStanding>): void;
|
|
35
|
+
forget(locator: string): void;
|
|
36
|
+
askAgain(locator: string, ask: () => void): void;
|
|
37
|
+
readied(locator: string): void;
|
|
38
|
+
unreadied(): void;
|
|
39
|
+
connectionLost(lapsed: () => void): void;
|
|
40
|
+
connectionLive(): void;
|
|
41
|
+
};
|
|
42
|
+
export declare function createRooms(): Rooms;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
|
|
2
|
+
import { type Cell } from '../cell.js';
|
|
3
|
+
import type { Open } from '../open.js';
|
|
4
|
+
import type { CycleProgress, SyncStatus } from '../status.js';
|
|
5
|
+
export type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
|
|
6
|
+
export type ConnectionRefusalCode = Open<RefusalReason>;
|
|
7
|
+
export type ConnectionRefusal = {
|
|
8
|
+
code: ConnectionRefusalCode;
|
|
9
|
+
reauthorizationOffered: boolean;
|
|
10
|
+
refusal: ProviderRefusal | null;
|
|
11
|
+
};
|
|
12
|
+
export type Moving = {
|
|
13
|
+
readonly state: SyncStatus['state'];
|
|
14
|
+
readonly providerUnreachable: boolean;
|
|
15
|
+
readonly resting: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type Session = {
|
|
18
|
+
readonly closed: boolean;
|
|
19
|
+
readonly stopping: boolean;
|
|
20
|
+
readonly paused: boolean;
|
|
21
|
+
readonly authorization: Authorization | undefined;
|
|
22
|
+
readonly refusal: ConnectionRefusal | null;
|
|
23
|
+
readonly discoveries: number;
|
|
24
|
+
readonly roomsNamed: boolean;
|
|
25
|
+
readonly roomsListed: boolean;
|
|
26
|
+
readonly serviceMode: ServiceMode;
|
|
27
|
+
readonly haltedRefusal: boolean;
|
|
28
|
+
readonly openSignals: number;
|
|
29
|
+
readonly authorityChanges: number;
|
|
30
|
+
readonly currencyQueued: number | null;
|
|
31
|
+
readonly moving: Moving;
|
|
32
|
+
readonly complete: boolean;
|
|
33
|
+
readonly recorded: boolean;
|
|
34
|
+
readonly underway: CycleProgress | null;
|
|
35
|
+
readonly streamed: CycleProgress | null;
|
|
36
|
+
};
|
|
37
|
+
export declare function createSession(authorization: Authorization | undefined): Cell<Session>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, ServiceMode } from './adapter.js';
|
|
2
|
+
import type { Reads } from './bootstrap.js';
|
|
3
|
+
import type { Cell } from './cell.js';
|
|
4
|
+
import type { Log } from './log.js';
|
|
5
|
+
import { type Admission } from './socket/admission.js';
|
|
6
|
+
import { type Answers } from './socket/answers.js';
|
|
7
|
+
import { type Lanes } from './socket/lanes.js';
|
|
8
|
+
import { type Rooms } from './socket/rooms.js';
|
|
9
|
+
import { type Session } from './socket/session.js';
|
|
10
|
+
export type { Live } from './socket/lanes.js';
|
|
11
|
+
export type { RoomDeclaration } from './socket/rooms.js';
|
|
12
|
+
export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
|
|
13
|
+
type SocketEvent = {
|
|
14
|
+
readonly kind: 'opened';
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'discovered';
|
|
17
|
+
readonly discovery: Discovery;
|
|
18
|
+
readonly missed: boolean;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'closed';
|
|
21
|
+
readonly revoked: boolean;
|
|
22
|
+
readonly lost: boolean;
|
|
23
|
+
readonly opened: boolean;
|
|
24
|
+
} | Exclude<RoomStreamEvent, {
|
|
25
|
+
kind: 'opened' | 'discovered' | 'closed';
|
|
26
|
+
}>;
|
|
27
|
+
export type RuntimeSocket = Admission & Answers & {
|
|
28
|
+
readonly reads: Reads;
|
|
29
|
+
readonly streamed: boolean;
|
|
30
|
+
readonly session: Cell<Session>;
|
|
31
|
+
readonly rooms: Rooms;
|
|
32
|
+
readonly lanes: Lanes;
|
|
33
|
+
readonly ready: Promise<void>;
|
|
34
|
+
readonly firstDiscovery: Promise<void>;
|
|
35
|
+
conversations(): Adapter['conversations'];
|
|
36
|
+
search(): Adapter['search'];
|
|
37
|
+
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
38
|
+
follows: Adapter['follows'];
|
|
39
|
+
mutate: Adapter['mutate'];
|
|
40
|
+
binary: Adapter['binary'];
|
|
41
|
+
link: Adapter['link'];
|
|
42
|
+
attach: Adapter['attach'];
|
|
43
|
+
history: Adapter['history'];
|
|
44
|
+
action: Adapter['action'];
|
|
45
|
+
authorize(): Promise<void>;
|
|
46
|
+
observe(listen: (event: SocketEvent) => void): void;
|
|
47
|
+
observeConversations(listen: (event: ConversationEvent) => void): void;
|
|
48
|
+
observeServiceMode(listen: (mode: ServiceMode) => void): void;
|
|
49
|
+
close(): void;
|
|
50
|
+
readyFromStore(): void;
|
|
51
|
+
notifyReady(): void;
|
|
52
|
+
closed(): boolean;
|
|
53
|
+
stopping(): boolean;
|
|
54
|
+
continuing(): boolean;
|
|
55
|
+
reached(): boolean;
|
|
56
|
+
writesHeld(): boolean;
|
|
57
|
+
haltedSince(opens: number): boolean;
|
|
58
|
+
isOpen(): boolean;
|
|
59
|
+
isAnnounced(): boolean;
|
|
60
|
+
isHanded(): boolean;
|
|
61
|
+
generation(): number;
|
|
62
|
+
naming(): boolean;
|
|
63
|
+
hand(rooms: readonly HeldRoom[]): void;
|
|
64
|
+
name(room: HeldRoom): void;
|
|
65
|
+
named(): void;
|
|
66
|
+
abortReads(): void;
|
|
67
|
+
stopReads(): void;
|
|
68
|
+
};
|
|
69
|
+
export declare function createSocket(adapter: Adapter, journal: Log, authorization: Authorization | undefined): RuntimeSocket;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type HouseSource = {
|
|
2
|
+
readonly kind: 'request';
|
|
3
|
+
readonly request: string;
|
|
4
|
+
readonly agentFunction: RequestAgentFunction | null;
|
|
5
|
+
readonly requester: {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly room: boolean;
|
|
8
|
+
};
|
|
9
|
+
readonly room: {
|
|
10
|
+
readonly ref: string;
|
|
11
|
+
readonly name: string;
|
|
12
|
+
};
|
|
13
|
+
readonly approved: string | null;
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'mail';
|
|
16
|
+
readonly request: string;
|
|
17
|
+
readonly room: string;
|
|
18
|
+
readonly report: boolean;
|
|
19
|
+
readonly agent: string;
|
|
20
|
+
readonly owner: string;
|
|
21
|
+
readonly approved: string | null;
|
|
22
|
+
readonly declined: string | null;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'trigger';
|
|
25
|
+
readonly customer: boolean;
|
|
26
|
+
readonly trigger: string;
|
|
27
|
+
readonly room: {
|
|
28
|
+
readonly ref: string;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
readonly kind: 'conversation';
|
|
33
|
+
readonly conversation: {
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
};
|
|
37
|
+
readonly agent: string;
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'declined';
|
|
40
|
+
readonly agent: string;
|
|
41
|
+
readonly owner: string;
|
|
42
|
+
};
|
|
43
|
+
export type ChatRequest = {
|
|
44
|
+
readonly request: string;
|
|
45
|
+
readonly room: string;
|
|
46
|
+
readonly message?: string;
|
|
47
|
+
};
|
|
48
|
+
export type ChatRoomRequest = {
|
|
49
|
+
readonly request: string;
|
|
50
|
+
readonly room: {
|
|
51
|
+
readonly ref: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type RequestAgentFunction = {
|
|
56
|
+
readonly name: string;
|
|
57
|
+
readonly version: number;
|
|
58
|
+
};
|
|
59
|
+
export declare function sourceOf(value: unknown, sender: string | null): HouseSource | null;
|
|
60
|
+
export {};
|
|
@@ -22,6 +22,4 @@ export type CycleProgress = {
|
|
|
22
22
|
reachable: boolean;
|
|
23
23
|
};
|
|
24
24
|
export declare const STARTING: SyncStatus;
|
|
25
|
-
export declare function transferring(status: SyncStatus): SyncStatus;
|
|
26
|
-
export declare function saving(status: SyncStatus): SyncStatus;
|
|
27
25
|
export declare function same(one: SyncStatus, other: SyncStatus): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Fence = {
|
|
2
|
+
readonly at: number;
|
|
3
|
+
readonly written: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type Fences = {
|
|
6
|
+
has(locator: string): boolean;
|
|
7
|
+
of(locator: string): Fence | undefined;
|
|
8
|
+
raise(locator: string, at: number): boolean;
|
|
9
|
+
mark(locator: string, written: boolean): void;
|
|
10
|
+
lift(locator: string): void;
|
|
11
|
+
count(): number;
|
|
12
|
+
since(locator: string, count: number): boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function createFences(): Fences;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { InstallationAmount } from '../readiness.js';
|
|
2
|
+
import type { TransferRecord } from './records.js';
|
|
3
|
+
type OwedIndex = {
|
|
4
|
+
readonly bytes: number;
|
|
5
|
+
readonly text: number;
|
|
6
|
+
};
|
|
7
|
+
export type RoomInstall = {
|
|
8
|
+
readonly transfer: TransferRecord | null;
|
|
9
|
+
readonly arrived: number | null;
|
|
10
|
+
readonly streaming: boolean;
|
|
11
|
+
readonly underived: number;
|
|
12
|
+
readonly unindexed: readonly OwedIndex[];
|
|
13
|
+
readonly startedOver: InstallationAmount | null;
|
|
14
|
+
readonly installing: boolean;
|
|
15
|
+
readonly catching: boolean;
|
|
16
|
+
readonly highest: string | null;
|
|
17
|
+
readonly beyondHorizon: boolean;
|
|
18
|
+
readonly confirmations: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const NO_INSTALL: RoomInstall;
|
|
21
|
+
export type Installs = {
|
|
22
|
+
of(locator: string): RoomInstall;
|
|
23
|
+
change(locator: string, next: (held: RoomInstall) => RoomInstall): void;
|
|
24
|
+
underway(): ReadonlySet<string>;
|
|
25
|
+
transferring(): readonly string[];
|
|
26
|
+
arrivalDue(now: number, everyMs: number): boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function createInstalls(): Installs;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type ReadinessQueue<W> = {
|
|
2
|
+
add(watch: W): () => void;
|
|
3
|
+
held(watch: W): boolean;
|
|
4
|
+
changed(watch: W, reading: string): boolean;
|
|
5
|
+
owe(watches: readonly W[]): void;
|
|
6
|
+
queue(): void;
|
|
7
|
+
close(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function createReadinessQueue<W>(deliver: (owed: readonly W[]) => Promise<void>, unpublished: (error: unknown) => void): ReadinessQueue<W>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from '../adapter.js';
|
|
2
|
+
import type { ChangeBatch } from '../change.js';
|
|
3
|
+
import { type Composition } from '../collection.js';
|
|
4
|
+
import type { Plan } from '../query.js';
|
|
5
|
+
import type { ReplicaRecord } from '../replica.js';
|
|
6
|
+
import type { Submission } from '../outcome.js';
|
|
7
|
+
import type { RoomDraftRecord, SavedDraft } from '../room-draft.js';
|
|
8
|
+
import type { ModelState, StoredModel } from '../model.js';
|
|
9
|
+
import type { CommittedWrite, ConversationWrite, HeldConversation, HeldRow, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, ReplicaOpened, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from '../tables.js';
|
|
10
|
+
import type { JobMarker } from '../job.js';
|
|
11
|
+
export type { ConversationWrite, HeldConversation, MessageWindow } from '../tables.js';
|
|
12
|
+
export type TransferRecord = {
|
|
13
|
+
readonly locator: string;
|
|
14
|
+
readonly transfer: string;
|
|
15
|
+
readonly selection: string;
|
|
16
|
+
readonly from: string;
|
|
17
|
+
readonly last: string;
|
|
18
|
+
readonly done: BootstrapInventory;
|
|
19
|
+
readonly models: {
|
|
20
|
+
readonly collection: ModelState;
|
|
21
|
+
};
|
|
22
|
+
readonly key: number | null;
|
|
23
|
+
};
|
|
24
|
+
export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
|
|
25
|
+
readonly model: StoredModel;
|
|
26
|
+
};
|
|
27
|
+
export type PendingState = {
|
|
28
|
+
readonly drafts: readonly SavedDraft[];
|
|
29
|
+
readonly submission: Submission;
|
|
30
|
+
readonly lost: boolean;
|
|
31
|
+
readonly upload?: unknown;
|
|
32
|
+
};
|
|
33
|
+
export type TargetRecord = {
|
|
34
|
+
established: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type PresentationRecord = {
|
|
37
|
+
app: string;
|
|
38
|
+
value: unknown;
|
|
39
|
+
};
|
|
40
|
+
export type ChatSubmission = {
|
|
41
|
+
readonly operation: string;
|
|
42
|
+
readonly text: string;
|
|
43
|
+
readonly turn: string | null;
|
|
44
|
+
};
|
|
45
|
+
export type ChatDraftRecord = {
|
|
46
|
+
conversation: string;
|
|
47
|
+
text: string;
|
|
48
|
+
revision: string;
|
|
49
|
+
submitted?: readonly ChatSubmission[];
|
|
50
|
+
moves?: readonly string[];
|
|
51
|
+
};
|
|
52
|
+
export type CallRecord = {
|
|
53
|
+
readonly operation: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly input: unknown;
|
|
56
|
+
};
|
|
57
|
+
export type AuthoredWrite = {
|
|
58
|
+
locator: string;
|
|
59
|
+
queue?: readonly ChangeBatch[];
|
|
60
|
+
stored?: readonly ChangeBatch[];
|
|
61
|
+
founded?: readonly ChangeBatch[];
|
|
62
|
+
saved?: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
63
|
+
roomDrafts?: readonly RoomDraftRecord[];
|
|
64
|
+
consumedRoomDrafts?: readonly string[];
|
|
65
|
+
};
|
|
66
|
+
export type StagedPage = {
|
|
67
|
+
readonly entries: readonly StoredEntry[];
|
|
68
|
+
readonly folders: readonly string[];
|
|
69
|
+
readonly part?: string;
|
|
70
|
+
};
|
|
71
|
+
export type ResumedTransfer = {
|
|
72
|
+
readonly key: number | null;
|
|
73
|
+
readonly transfer: string;
|
|
74
|
+
readonly staged: readonly string[];
|
|
75
|
+
};
|
|
76
|
+
export type RefreshedPage = StagedPage & {
|
|
77
|
+
readonly removals: readonly string[];
|
|
78
|
+
readonly folderRemovals: readonly string[];
|
|
79
|
+
};
|
|
80
|
+
export type HeldRoom = {
|
|
81
|
+
readonly record: StoredReplica;
|
|
82
|
+
readonly indexed: boolean;
|
|
83
|
+
readonly documents: number;
|
|
84
|
+
};
|
|
85
|
+
export type QueuedChange = {
|
|
86
|
+
readonly batch: ChangeBatch;
|
|
87
|
+
readonly state: PendingState;
|
|
88
|
+
};
|
|
89
|
+
export type HeldWork = {
|
|
90
|
+
readonly room: (HeldRoom & {
|
|
91
|
+
readonly overlaid: ReadonlySet<string>;
|
|
92
|
+
}) | null;
|
|
93
|
+
readonly queue: readonly QueuedChange[];
|
|
94
|
+
};
|
|
95
|
+
export type CoveredRoom = {
|
|
96
|
+
readonly key: number;
|
|
97
|
+
readonly transfer: string;
|
|
98
|
+
readonly roomVersion: string;
|
|
99
|
+
readonly indexed: boolean;
|
|
100
|
+
readonly documents: number;
|
|
101
|
+
readonly bytes: number;
|
|
102
|
+
readonly offline: string;
|
|
103
|
+
};
|
|
104
|
+
export type HeldCover = {
|
|
105
|
+
readonly rooms: ReadonlyMap<string, CoveredRoom>;
|
|
106
|
+
readonly queues: ReadonlyMap<string, readonly string[]>;
|
|
107
|
+
};
|
|
108
|
+
export type HeldStatus = {
|
|
109
|
+
readonly queued: readonly string[];
|
|
110
|
+
readonly lastCompleted: string | null;
|
|
111
|
+
readonly unsent: readonly {
|
|
112
|
+
readonly room: string;
|
|
113
|
+
readonly path: string;
|
|
114
|
+
}[];
|
|
115
|
+
readonly resets: readonly {
|
|
116
|
+
readonly locator: string;
|
|
117
|
+
readonly reset: string;
|
|
118
|
+
}[];
|
|
119
|
+
readonly returned: readonly RoomDraftRecord[];
|
|
120
|
+
};
|
|
121
|
+
export type Facts = {
|
|
122
|
+
readonly lastCompleted: string | null;
|
|
123
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
124
|
+
readonly capabilities: readonly Capability[];
|
|
125
|
+
readonly member: Member | null;
|
|
126
|
+
readonly targets: Readonly<Record<string, TargetRecord>>;
|
|
127
|
+
readonly conversationList: readonly ListedConversation[] | null;
|
|
128
|
+
readonly conversationCursor: string | null;
|
|
129
|
+
};
|
|
130
|
+
export type Commit = {
|
|
131
|
+
readonly rooms: readonly RoomCommit[];
|
|
132
|
+
readonly writes?: readonly AuthoredWrite[];
|
|
133
|
+
readonly files?: readonly StoredFile[];
|
|
134
|
+
readonly whole?: boolean;
|
|
135
|
+
};
|
|
136
|
+
export type RuntimeStore = {
|
|
137
|
+
opened(): Promise<ReplicaOpened>;
|
|
138
|
+
rooms(locators?: readonly string[]): Promise<readonly HeldRoom[]>;
|
|
139
|
+
room(locator: string): Promise<HeldWork>;
|
|
140
|
+
covering(): Promise<HeldCover>;
|
|
141
|
+
offline(locator: string): Promise<string | null>;
|
|
142
|
+
held(): Promise<{
|
|
143
|
+
readonly held: ReadonlySet<string>;
|
|
144
|
+
readonly staged: ReadonlySet<string>;
|
|
145
|
+
}>;
|
|
146
|
+
status(): Promise<HeldStatus>;
|
|
147
|
+
batch(locator: string, id: string): Promise<ChangeBatch | null>;
|
|
148
|
+
order(locator: string): Promise<readonly string[]>;
|
|
149
|
+
queued(): Promise<readonly string[]>;
|
|
150
|
+
moving(): Promise<{
|
|
151
|
+
readonly queued: ReadonlyMap<string, readonly string[]>;
|
|
152
|
+
readonly moving: readonly (QueuedChange & {
|
|
153
|
+
readonly locator: string;
|
|
154
|
+
})[];
|
|
155
|
+
}>;
|
|
156
|
+
pending(locator: string, id: string): Promise<{
|
|
157
|
+
readonly state: PendingState | undefined;
|
|
158
|
+
readonly room: boolean;
|
|
159
|
+
}>;
|
|
160
|
+
facts(): Promise<Facts>;
|
|
161
|
+
presentation(app: string): Promise<unknown>;
|
|
162
|
+
demote(): Promise<void>;
|
|
163
|
+
query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
|
|
164
|
+
changes(keys: readonly number[]): number;
|
|
165
|
+
entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
|
|
166
|
+
typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
|
|
167
|
+
referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
|
|
168
|
+
folders(key: number, paths: readonly string[]): Promise<readonly string[]>;
|
|
169
|
+
typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
|
|
170
|
+
stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
|
|
171
|
+
resume(record: TransferRecord, composition: Composition, parts: readonly string[], published: number | null): Promise<ResumedTransfer | null>;
|
|
172
|
+
refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
|
|
173
|
+
unrefresh(key: number): Promise<void>;
|
|
174
|
+
commit(commit: Commit): Promise<CommittedWrite>;
|
|
175
|
+
fence(locators: readonly string[]): Promise<void>;
|
|
176
|
+
erase(locator: string | null, limit: number): Promise<boolean>;
|
|
177
|
+
abandon(locator: string): Promise<void>;
|
|
178
|
+
unfence(locators: readonly string[]): Promise<ReadonlySet<string>>;
|
|
179
|
+
release(key: number): Promise<void>;
|
|
180
|
+
rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
|
|
181
|
+
readonly done: boolean;
|
|
182
|
+
readonly text: number;
|
|
183
|
+
}>;
|
|
184
|
+
fact(name: string, value: unknown): Promise<void>;
|
|
185
|
+
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
186
|
+
keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
|
|
187
|
+
roomDrafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
|
|
188
|
+
present(record: PresentationRecord): Promise<void>;
|
|
189
|
+
conversations(conversations?: readonly string[]): Promise<readonly HeldConversation[]>;
|
|
190
|
+
keepMessages(write: ConversationWrite): Promise<void>;
|
|
191
|
+
messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
|
|
192
|
+
messageCount(conversation: string, phrase?: string | null): Promise<number>;
|
|
193
|
+
turnArrived(conversation: string, turn: string): Promise<boolean>;
|
|
194
|
+
conversationRows(conversations: readonly string[]): Promise<readonly HeldRow[]>;
|
|
195
|
+
jobMarkers(conversation: string): Promise<readonly JobMarker[]>;
|
|
196
|
+
dropConversations(conversations: readonly string[]): Promise<void>;
|
|
197
|
+
chatDrafts(): Promise<readonly ChatDraftRecord[]>;
|
|
198
|
+
chatDraft(conversation: string): Promise<ChatDraftRecord | null>;
|
|
199
|
+
keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
|
|
200
|
+
dropChatDraft(conversation: string): Promise<void>;
|
|
201
|
+
calls(): Promise<readonly CallRecord[]>;
|
|
202
|
+
keepCall(record: CallRecord): Promise<void>;
|
|
203
|
+
dropCall(operation: string): Promise<void>;
|
|
204
|
+
keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
|
|
205
|
+
discardRoomDraft(locator: string, path: string): Promise<void>;
|
|
206
|
+
fences(): Promise<readonly string[]>;
|
|
207
|
+
generation(): Promise<string | null>;
|
|
208
|
+
rememberGeneration(value: string): Promise<void>;
|
|
209
|
+
file(key: string, type: string): Promise<Blob>;
|
|
210
|
+
};
|
|
211
|
+
export declare function openRuntimeStore(database: RuntimeDatabase): RuntimeStore;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RoomHeld<T> = {
|
|
2
|
+
of(locator: string, key: string): T | undefined;
|
|
3
|
+
hold(locator: string, key: string, value: T): void;
|
|
4
|
+
drop(locator: string, key: string): void;
|
|
5
|
+
forget(locator: string): void;
|
|
6
|
+
};
|
|
7
|
+
export declare function createRoomHeld<T>(): RoomHeld<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RuntimeDatabase } from '../tables.js';
|
|
2
|
+
export type Space = {
|
|
3
|
+
full(): boolean;
|
|
4
|
+
fill(): boolean;
|
|
5
|
+
probing(): boolean;
|
|
6
|
+
probeEachMinute(): void;
|
|
7
|
+
probe(): Promise<void>;
|
|
8
|
+
stop(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createSpace(database: RuntimeDatabase, freed: () => void): Space;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Watcher = {
|
|
2
|
+
held(): boolean;
|
|
3
|
+
stop(): void;
|
|
4
|
+
answer(value: unknown): void;
|
|
5
|
+
};
|
|
6
|
+
export type Watching = 'all' | 'waiting' | 'ready';
|
|
7
|
+
type Watchers = {
|
|
8
|
+
publication(work: () => Promise<void>): Promise<void>;
|
|
9
|
+
owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
|
|
10
|
+
watch(topic: string, notify: (value: unknown) => void): Watcher;
|
|
11
|
+
watching(topic: string, which?: Watching): readonly Watcher[];
|
|
12
|
+
tell(topic: string, value: unknown): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
};
|
|
15
|
+
export declare function createWatchers(unpublished: (error: unknown) => void): Watchers;
|
|
16
|
+
export {};
|