@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,27 @@
|
|
|
1
|
+
import type { CallResult } from '../outcome.js';
|
|
2
|
+
export type Live = () => boolean;
|
|
3
|
+
export type KeptSender = {
|
|
4
|
+
next(): Promise<CallResult>;
|
|
5
|
+
};
|
|
6
|
+
type LaneRules = {
|
|
7
|
+
generation(): number;
|
|
8
|
+
continuing(): boolean;
|
|
9
|
+
stopping(): boolean;
|
|
10
|
+
failed(locator: string, error: unknown): void;
|
|
11
|
+
};
|
|
12
|
+
export type Lanes = {
|
|
13
|
+
task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
14
|
+
inRoom<T>(locator: string, work: (live: Live) => Promise<T>): Promise<T>;
|
|
15
|
+
roomTask(locator: string, work: (live: Live) => Promise<void>): Promise<void>;
|
|
16
|
+
roomWork(): number;
|
|
17
|
+
current(): Promise<unknown>;
|
|
18
|
+
finished(): Promise<unknown>;
|
|
19
|
+
sender(operation: string): KeptSender | undefined;
|
|
20
|
+
sending(operation: string, sender: KeptSender): void;
|
|
21
|
+
sent(operation: string, sender: KeptSender): void;
|
|
22
|
+
settled(operation: string): Promise<void>;
|
|
23
|
+
settle(operation: string, lost: boolean): void;
|
|
24
|
+
unclaimed(operation: string): boolean;
|
|
25
|
+
};
|
|
26
|
+
export declare function createLanes({ generation, continuing, stopping, failed }: LaneRules): Lanes;
|
|
27
|
+
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,66 @@
|
|
|
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 { Retries } from './retried.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 Session } from './socket/session.js';
|
|
9
|
+
export type { KeptSender, Live } from './socket/lanes.js';
|
|
10
|
+
export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
|
|
11
|
+
type SocketEvent = {
|
|
12
|
+
readonly kind: 'opened';
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: 'discovered';
|
|
15
|
+
readonly discovery: Discovery;
|
|
16
|
+
readonly missed: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'closed';
|
|
19
|
+
readonly revoked: boolean;
|
|
20
|
+
readonly lost: boolean;
|
|
21
|
+
readonly opened: boolean;
|
|
22
|
+
} | Exclude<RoomStreamEvent, {
|
|
23
|
+
kind: 'opened' | 'discovered' | 'closed';
|
|
24
|
+
}>;
|
|
25
|
+
export type RuntimeSocket = Admission & Answers & {
|
|
26
|
+
readonly reads: Reads;
|
|
27
|
+
readonly streamed: boolean;
|
|
28
|
+
readonly session: Cell<Session>;
|
|
29
|
+
readonly lanes: Lanes;
|
|
30
|
+
readonly ready: Promise<void>;
|
|
31
|
+
readonly firstDiscovery: Promise<void>;
|
|
32
|
+
conversations(): Adapter['conversations'];
|
|
33
|
+
search(): Adapter['search'];
|
|
34
|
+
discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
|
|
35
|
+
follows: Adapter['follows'];
|
|
36
|
+
mutate: Adapter['mutate'];
|
|
37
|
+
binary: Adapter['binary'];
|
|
38
|
+
link: Adapter['link'];
|
|
39
|
+
attach: Adapter['attach'];
|
|
40
|
+
history: Adapter['history'];
|
|
41
|
+
action: Adapter['action'];
|
|
42
|
+
authorize(): Promise<void>;
|
|
43
|
+
observe(listen: (event: SocketEvent) => void): void;
|
|
44
|
+
observeConversations(listen: (event: ConversationEvent) => void): void;
|
|
45
|
+
observeServiceMode(listen: (mode: ServiceMode) => void): void;
|
|
46
|
+
close(): void;
|
|
47
|
+
readyFromStore(): void;
|
|
48
|
+
notifyReady(): void;
|
|
49
|
+
closed(): boolean;
|
|
50
|
+
stopping(): boolean;
|
|
51
|
+
continuing(): boolean;
|
|
52
|
+
reached(): boolean;
|
|
53
|
+
writesHeld(): boolean;
|
|
54
|
+
haltedSince(opens: number): boolean;
|
|
55
|
+
isOpen(): boolean;
|
|
56
|
+
isAnnounced(): boolean;
|
|
57
|
+
isHanded(): boolean;
|
|
58
|
+
generation(): number;
|
|
59
|
+
naming(): boolean;
|
|
60
|
+
hand(rooms: readonly HeldRoom[]): void;
|
|
61
|
+
name(room: HeldRoom): void;
|
|
62
|
+
named(): void;
|
|
63
|
+
abortReads(): void;
|
|
64
|
+
stopReads(): void;
|
|
65
|
+
};
|
|
66
|
+
export declare function createSocket(adapter: Adapter, retries: Retries, authorization: Authorization | undefined): RuntimeSocket;
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
type RequestAgentFunction = {
|
|
49
|
+
readonly name: string;
|
|
50
|
+
readonly version: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function sourceOf(value: unknown, sender: string | null): HouseSource | null;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
import type { ReturnReason } from './room-draft.js';
|
|
3
|
+
export type AttentionEntry = {
|
|
4
|
+
room: string;
|
|
5
|
+
path: string;
|
|
6
|
+
returned: ReturnReason;
|
|
7
|
+
};
|
|
8
|
+
export type UnsentChange = {
|
|
9
|
+
room: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
export type SyncStatus = {
|
|
13
|
+
state: Open<'pending' | 'syncing' | 'synced'>;
|
|
14
|
+
lastCompleted: string | null;
|
|
15
|
+
providerUnreachable: boolean;
|
|
16
|
+
attentionRequired: readonly AttentionEntry[];
|
|
17
|
+
unsent: readonly UnsentChange[];
|
|
18
|
+
reset: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type CycleProgress = {
|
|
21
|
+
complete: boolean;
|
|
22
|
+
reachable: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const STARTING: SyncStatus;
|
|
25
|
+
export declare function same(one: SyncStatus, other: SyncStatus): boolean;
|
|
@@ -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,214 @@
|
|
|
1
|
+
import type { BootstrapInventory, Capability, ListedAgent, 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, HeldFact, HeldRow, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, ReplicaOpened, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from '../tables.js';
|
|
10
|
+
export type { ConversationFact, ConversationWrite, HeldConversation, MessageWindow, } from '../tables.js';
|
|
11
|
+
export type TransferRecord = {
|
|
12
|
+
readonly locator: string;
|
|
13
|
+
readonly transfer: string;
|
|
14
|
+
readonly selection: string;
|
|
15
|
+
readonly from: string;
|
|
16
|
+
readonly last: string;
|
|
17
|
+
readonly done: BootstrapInventory;
|
|
18
|
+
readonly models: {
|
|
19
|
+
readonly collection: ModelState;
|
|
20
|
+
};
|
|
21
|
+
readonly key: number | null;
|
|
22
|
+
};
|
|
23
|
+
export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
|
|
24
|
+
readonly model: StoredModel;
|
|
25
|
+
};
|
|
26
|
+
export type PendingState = {
|
|
27
|
+
readonly drafts: readonly SavedDraft[];
|
|
28
|
+
readonly submission: Submission;
|
|
29
|
+
readonly lost: boolean;
|
|
30
|
+
readonly upload?: unknown;
|
|
31
|
+
};
|
|
32
|
+
export type TargetRecord = {
|
|
33
|
+
established: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type PresentationRecord = {
|
|
36
|
+
app: string;
|
|
37
|
+
value: unknown;
|
|
38
|
+
};
|
|
39
|
+
export type ChatSubmission = {
|
|
40
|
+
readonly operation: string;
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly turn: string | null;
|
|
43
|
+
};
|
|
44
|
+
export type ChatDraftRecord = {
|
|
45
|
+
conversation: string;
|
|
46
|
+
text: string;
|
|
47
|
+
revision: string;
|
|
48
|
+
submitted?: readonly ChatSubmission[];
|
|
49
|
+
moves?: readonly string[];
|
|
50
|
+
};
|
|
51
|
+
export type CallRecord = {
|
|
52
|
+
readonly operation: string;
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly input: unknown;
|
|
55
|
+
};
|
|
56
|
+
export type AuthoredWrite = {
|
|
57
|
+
locator: string;
|
|
58
|
+
queue?: readonly ChangeBatch[];
|
|
59
|
+
stored?: readonly ChangeBatch[];
|
|
60
|
+
founded?: readonly ChangeBatch[];
|
|
61
|
+
saved?: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
62
|
+
roomDrafts?: readonly RoomDraftRecord[];
|
|
63
|
+
consumedRoomDrafts?: readonly string[];
|
|
64
|
+
};
|
|
65
|
+
export type StagedPage = {
|
|
66
|
+
readonly entries: readonly StoredEntry[];
|
|
67
|
+
readonly folders: readonly string[];
|
|
68
|
+
readonly part?: string;
|
|
69
|
+
};
|
|
70
|
+
export type ResumedTransfer = {
|
|
71
|
+
readonly key: number | null;
|
|
72
|
+
readonly transfer: string;
|
|
73
|
+
readonly staged: readonly string[];
|
|
74
|
+
};
|
|
75
|
+
export type RefreshedPage = StagedPage & {
|
|
76
|
+
readonly removals: readonly string[];
|
|
77
|
+
readonly folderRemovals: readonly string[];
|
|
78
|
+
};
|
|
79
|
+
export type HeldRoom = {
|
|
80
|
+
readonly record: StoredReplica;
|
|
81
|
+
readonly indexed: boolean;
|
|
82
|
+
readonly documents: number;
|
|
83
|
+
};
|
|
84
|
+
export type QueuedChange = {
|
|
85
|
+
readonly batch: ChangeBatch;
|
|
86
|
+
readonly state: PendingState;
|
|
87
|
+
};
|
|
88
|
+
export type HeldWork = {
|
|
89
|
+
readonly room: (HeldRoom & {
|
|
90
|
+
readonly overlaid: ReadonlySet<string>;
|
|
91
|
+
}) | null;
|
|
92
|
+
readonly queue: readonly QueuedChange[];
|
|
93
|
+
};
|
|
94
|
+
export type CoveredRoom = {
|
|
95
|
+
readonly key: number;
|
|
96
|
+
readonly transfer: string;
|
|
97
|
+
readonly roomVersion: string;
|
|
98
|
+
readonly indexed: boolean;
|
|
99
|
+
readonly documents: number;
|
|
100
|
+
readonly bytes: number;
|
|
101
|
+
readonly offline: string;
|
|
102
|
+
};
|
|
103
|
+
export type HeldCover = {
|
|
104
|
+
readonly rooms: ReadonlyMap<string, CoveredRoom>;
|
|
105
|
+
readonly queues: ReadonlyMap<string, readonly string[]>;
|
|
106
|
+
};
|
|
107
|
+
export type HeldStatus = {
|
|
108
|
+
readonly queued: readonly string[];
|
|
109
|
+
readonly lastCompleted: string | null;
|
|
110
|
+
readonly unsent: readonly {
|
|
111
|
+
readonly room: string;
|
|
112
|
+
readonly path: string;
|
|
113
|
+
}[];
|
|
114
|
+
readonly resets: readonly {
|
|
115
|
+
readonly locator: string;
|
|
116
|
+
readonly reset: string;
|
|
117
|
+
}[];
|
|
118
|
+
readonly returned: readonly RoomDraftRecord[];
|
|
119
|
+
};
|
|
120
|
+
export type Facts = {
|
|
121
|
+
readonly lastCompleted: string | null;
|
|
122
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
123
|
+
readonly capabilities: readonly Capability[];
|
|
124
|
+
readonly member: Member | null;
|
|
125
|
+
readonly targets: Readonly<Record<string, TargetRecord>>;
|
|
126
|
+
readonly conversationList: readonly ListedConversation[] | null;
|
|
127
|
+
readonly agentList: readonly ListedAgent[] | null;
|
|
128
|
+
readonly conversationCursor: string | null;
|
|
129
|
+
readonly chatPins: readonly string[];
|
|
130
|
+
};
|
|
131
|
+
export type Commit = {
|
|
132
|
+
readonly rooms: readonly RoomCommit[];
|
|
133
|
+
readonly writes?: readonly AuthoredWrite[];
|
|
134
|
+
readonly files?: readonly StoredFile[];
|
|
135
|
+
readonly whole?: boolean;
|
|
136
|
+
};
|
|
137
|
+
export type RuntimeStore = {
|
|
138
|
+
opened(): Promise<ReplicaOpened>;
|
|
139
|
+
rooms(locators?: readonly string[]): Promise<readonly HeldRoom[]>;
|
|
140
|
+
room(locator: string): Promise<HeldWork>;
|
|
141
|
+
covering(): Promise<HeldCover>;
|
|
142
|
+
offline(locator: string): Promise<string | null>;
|
|
143
|
+
held(): Promise<{
|
|
144
|
+
readonly held: ReadonlySet<string>;
|
|
145
|
+
readonly staged: ReadonlySet<string>;
|
|
146
|
+
}>;
|
|
147
|
+
status(): Promise<HeldStatus>;
|
|
148
|
+
batch(locator: string, id: string): Promise<ChangeBatch | null>;
|
|
149
|
+
order(locator: string): Promise<readonly string[]>;
|
|
150
|
+
queued(): Promise<readonly string[]>;
|
|
151
|
+
moving(): Promise<{
|
|
152
|
+
readonly queued: ReadonlyMap<string, readonly string[]>;
|
|
153
|
+
readonly moving: readonly (QueuedChange & {
|
|
154
|
+
readonly locator: string;
|
|
155
|
+
})[];
|
|
156
|
+
}>;
|
|
157
|
+
pending(locator: string, id: string): Promise<{
|
|
158
|
+
readonly state: PendingState | undefined;
|
|
159
|
+
readonly room: boolean;
|
|
160
|
+
}>;
|
|
161
|
+
facts(): Promise<Facts>;
|
|
162
|
+
presentation(app: string): Promise<unknown>;
|
|
163
|
+
demote(): Promise<void>;
|
|
164
|
+
query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
|
|
165
|
+
changes(keys: readonly number[]): number;
|
|
166
|
+
entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
|
|
167
|
+
typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
|
|
168
|
+
referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
|
|
169
|
+
folders(key: number, paths: readonly string[]): Promise<readonly string[]>;
|
|
170
|
+
typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
|
|
171
|
+
stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
|
|
172
|
+
resume(record: TransferRecord, composition: Composition, parts: readonly string[], published: number | null): Promise<ResumedTransfer | null>;
|
|
173
|
+
refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
|
|
174
|
+
unrefresh(key: number): Promise<void>;
|
|
175
|
+
commit(commit: Commit): Promise<CommittedWrite>;
|
|
176
|
+
fence(locators: readonly string[]): Promise<void>;
|
|
177
|
+
erase(locator: string | null, limit: number): Promise<boolean>;
|
|
178
|
+
abandon(locator: string): Promise<void>;
|
|
179
|
+
unfence(locators: readonly string[]): Promise<ReadonlySet<string>>;
|
|
180
|
+
release(key: number): Promise<void>;
|
|
181
|
+
rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
|
|
182
|
+
readonly done: boolean;
|
|
183
|
+
readonly text: number;
|
|
184
|
+
}>;
|
|
185
|
+
fact(name: string, value: unknown): Promise<void>;
|
|
186
|
+
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
187
|
+
keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
|
|
188
|
+
roomDrafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
|
|
189
|
+
present(record: PresentationRecord): Promise<void>;
|
|
190
|
+
conversations(conversations?: readonly string[]): Promise<readonly HeldConversation[]>;
|
|
191
|
+
keepMessages(write: ConversationWrite): Promise<void>;
|
|
192
|
+
messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
|
|
193
|
+
messageCount(conversation: string, phrase?: string | null): Promise<number>;
|
|
194
|
+
turnArrived(conversation: string, turn: string): Promise<boolean>;
|
|
195
|
+
conversationRows(conversations: readonly string[]): Promise<readonly HeldRow[]>;
|
|
196
|
+
conversationFacts(): Promise<readonly HeldFact[]>;
|
|
197
|
+
keepConversationFact(fact: HeldFact): Promise<void>;
|
|
198
|
+
storedConversations(): Promise<readonly string[]>;
|
|
199
|
+
dropConversations(conversations: readonly string[]): Promise<readonly string[]>;
|
|
200
|
+
chatDrafts(): Promise<readonly ChatDraftRecord[]>;
|
|
201
|
+
chatDraft(conversation: string): Promise<ChatDraftRecord | null>;
|
|
202
|
+
keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
|
|
203
|
+
dropChatDraft(conversation: string): Promise<void>;
|
|
204
|
+
calls(): Promise<readonly CallRecord[]>;
|
|
205
|
+
keepCall(record: CallRecord): Promise<void>;
|
|
206
|
+
dropCall(operation: string): Promise<void>;
|
|
207
|
+
keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
|
|
208
|
+
discardRoomDraft(locator: string, path: string): Promise<void>;
|
|
209
|
+
fences(): Promise<readonly string[]>;
|
|
210
|
+
generation(): Promise<string | null>;
|
|
211
|
+
rememberGeneration(value: string): Promise<void>;
|
|
212
|
+
file(key: string, type: string): Promise<Blob>;
|
|
213
|
+
};
|
|
214
|
+
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 {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Composition } from '../collection.js';
|
|
2
|
+
import type { RefreshedPage, RuntimeStore } from './records.js';
|
|
3
|
+
export type InstallHold = {
|
|
4
|
+
take(): void;
|
|
5
|
+
release(): void;
|
|
6
|
+
};
|
|
7
|
+
type Writes = {
|
|
8
|
+
exclusive<T>(work: () => Promise<T>): Promise<T>;
|
|
9
|
+
gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
|
|
10
|
+
written(): Promise<unknown>;
|
|
11
|
+
startingWrite<T>(work: () => Promise<T>): Promise<T>;
|
|
12
|
+
finishingWrite<T>(work: () => Promise<T>): Promise<T>;
|
|
13
|
+
ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
|
|
14
|
+
rederive(local: RuntimeStore, key: number, composition: Composition): Promise<{
|
|
15
|
+
readonly done: boolean;
|
|
16
|
+
readonly text: number;
|
|
17
|
+
}>;
|
|
18
|
+
refreshPage(local: RuntimeStore, key: number, composition: Composition, page: RefreshedPage): Promise<void>;
|
|
19
|
+
stageBytes(): number;
|
|
20
|
+
deriveBytes(): number;
|
|
21
|
+
};
|
|
22
|
+
export declare function createWrites(): Writes;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { TypedPath } from './adapter.js';
|
|
2
|
+
import { schemaTypes } from './attached-model.js';
|
|
3
|
+
import { type Cell } from './cell.js';
|
|
4
|
+
import type { ChangeBatch } from './change.js';
|
|
5
|
+
import type { ChangeSet } from './change-set.js';
|
|
6
|
+
import type { Composition } from './collection.js';
|
|
7
|
+
import type { ReadinessWatch } from './preparation.js';
|
|
8
|
+
import type { Persistence } from './readiness.js';
|
|
9
|
+
import type { Retries } from './retried.js';
|
|
10
|
+
import type { Listing } from './listing.js';
|
|
11
|
+
import type { Seeded } from './seed.js';
|
|
12
|
+
import type { ModelState } from './model.js';
|
|
13
|
+
import { type OpenedFiles } from './opened.js';
|
|
14
|
+
import { type HeldReplica, type ReplicaRecord } from './replica.js';
|
|
15
|
+
import type { RoomDraftRecord } from './room-draft.js';
|
|
16
|
+
import { type SyncStatus } from './status.js';
|
|
17
|
+
import type { RuntimeDatabase } from './tables.js';
|
|
18
|
+
import { type Installs } from './store/installs.js';
|
|
19
|
+
import { type HeldCover, type HeldStatus, type PendingState, type RuntimeStore } from './store/records.js';
|
|
20
|
+
import { type ReadinessQueue } from './store/readiness.js';
|
|
21
|
+
import { type RoomHeld } from './store/room-held.js';
|
|
22
|
+
import { type Space } from './store/space.js';
|
|
23
|
+
import { type Watcher, type Watching } from './store/watchers.js';
|
|
24
|
+
import { createWrites, type InstallHold } from './store/writes.js';
|
|
25
|
+
export type { RoomInstall } from './store/installs.js';
|
|
26
|
+
export type { AuthoredWrite, ChatDraftRecord, ChatSubmission, ConversationFact, CoveredRoom, Facts, HeldConversation, HeldCover, PendingState, RefreshedPage, RuntimeStore, StagedPage, TransferRecord, } from './store/records.js';
|
|
27
|
+
export type { InstallHold } from './store/writes.js';
|
|
28
|
+
export type { CommittedWrite, QueryRoom, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, View, } from './tables.js';
|
|
29
|
+
export type Stored = {
|
|
30
|
+
readonly record: ReplicaRecord;
|
|
31
|
+
readonly indexed: boolean;
|
|
32
|
+
readonly documents: number;
|
|
33
|
+
};
|
|
34
|
+
export type Held = HeldReplica & {
|
|
35
|
+
readonly states: ReadonlyMap<string, PendingState>;
|
|
36
|
+
};
|
|
37
|
+
export type Work = {
|
|
38
|
+
readonly replica: Held | undefined;
|
|
39
|
+
readonly queue: readonly ChangeBatch[];
|
|
40
|
+
readonly states: ReadonlyMap<string, PendingState>;
|
|
41
|
+
};
|
|
42
|
+
type LandedAhead = Readonly<Record<string, string | undefined>>;
|
|
43
|
+
type AttachedFile = {
|
|
44
|
+
readonly revision: string;
|
|
45
|
+
readonly mediaType: string;
|
|
46
|
+
};
|
|
47
|
+
type Seeds = {
|
|
48
|
+
of(key: string): Seeded | undefined;
|
|
49
|
+
keep(key: string, seed: Seeded): void;
|
|
50
|
+
drop(key: string): void;
|
|
51
|
+
};
|
|
52
|
+
type Device = {
|
|
53
|
+
readonly persistence: Persistence;
|
|
54
|
+
readonly storageLoss: string | null;
|
|
55
|
+
readonly heldWhenOpened: boolean;
|
|
56
|
+
readonly preparing: boolean;
|
|
57
|
+
readonly sweeping: boolean;
|
|
58
|
+
readonly unpreparedDemand: ReadonlySet<string>;
|
|
59
|
+
readonly unpreparable: ReadonlySet<string>;
|
|
60
|
+
readonly establishing: ReadonlySet<string>;
|
|
61
|
+
readonly status: SyncStatus;
|
|
62
|
+
readonly roomsShown: Listing | null;
|
|
63
|
+
};
|
|
64
|
+
type StoreOptions = {
|
|
65
|
+
readonly database: RuntimeDatabase;
|
|
66
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
67
|
+
readonly builtIn: ModelState;
|
|
68
|
+
readonly typedPaths: readonly TypedPath[];
|
|
69
|
+
readonly persistence: Persistence;
|
|
70
|
+
readonly retries: Retries;
|
|
71
|
+
lost(locator: string): boolean;
|
|
72
|
+
opening(records: RuntimeStore): Promise<RuntimeStore>;
|
|
73
|
+
unpublished(error: unknown): void;
|
|
74
|
+
changed(set: ChangeSet): Promise<void>;
|
|
75
|
+
deliverReadiness(owed: readonly ReadinessWatch[]): Promise<void>;
|
|
76
|
+
spaceFreed(): void;
|
|
77
|
+
};
|
|
78
|
+
export type Store = {
|
|
79
|
+
readonly device: Cell<Device>;
|
|
80
|
+
readonly space: Space;
|
|
81
|
+
readonly readiness: ReadinessQueue<ReadinessWatch>;
|
|
82
|
+
ask: RuntimeDatabase['ask'];
|
|
83
|
+
changed(set: ChangeSet): Promise<void>;
|
|
84
|
+
open(): Promise<RuntimeStore>;
|
|
85
|
+
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
86
|
+
exclusive<T>(work: () => Promise<T>): Promise<T>;
|
|
87
|
+
gathered<I, T>(key: string, input: I, merge: (earlier: I, later: I) => I | null, work: (input: I) => Promise<T>): Promise<T>;
|
|
88
|
+
written(): Promise<unknown>;
|
|
89
|
+
startingWrite<T>(work: () => Promise<T>): Promise<T>;
|
|
90
|
+
finishingWrite<T>(work: () => Promise<T>): Promise<T>;
|
|
91
|
+
ahead<T>(work: (hold: InstallHold) => Promise<T>): Promise<T>;
|
|
92
|
+
rederive: ReturnType<typeof createWrites>['rederive'];
|
|
93
|
+
refreshPage: ReturnType<typeof createWrites>['refreshPage'];
|
|
94
|
+
stageBytes(): number;
|
|
95
|
+
deriveBytes(): number;
|
|
96
|
+
rooms(locators?: readonly string[]): Promise<ReadonlyMap<string, Stored>>;
|
|
97
|
+
record(locator: string): Promise<ReplicaRecord | undefined>;
|
|
98
|
+
work(locator: string): Promise<Work>;
|
|
99
|
+
replica(locator: string): Promise<Held | undefined>;
|
|
100
|
+
covering(): Promise<HeldCover>;
|
|
101
|
+
status(): Promise<HeldStatus>;
|
|
102
|
+
queued(): Promise<readonly string[]>;
|
|
103
|
+
drafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
|
|
104
|
+
draft(locator: string, path: string): Promise<RoomDraftRecord | undefined>;
|
|
105
|
+
composed(record: Pick<ReplicaRecord, 'model' | 'declaration'>): Composition;
|
|
106
|
+
publication(work: () => Promise<void>): Promise<void>;
|
|
107
|
+
owing<T>(topic: string, add: (owed: T | undefined) => T, work: (owed: T) => Promise<void>): Promise<void>;
|
|
108
|
+
watch(topic: string, notify: (value: unknown) => void): Watcher;
|
|
109
|
+
watching(topic: string, which?: Watching): readonly Watcher[];
|
|
110
|
+
tell(topic: string, value: unknown): void;
|
|
111
|
+
readonly installs: Installs;
|
|
112
|
+
readonly seeds: Seeds;
|
|
113
|
+
readonly landed: RoomHeld<LandedAhead>;
|
|
114
|
+
readonly attached: RoomHeld<AttachedFile>;
|
|
115
|
+
readonly opened: OpenedFiles;
|
|
116
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
117
|
+
prepareAgain(locator?: string): void;
|
|
118
|
+
forget(locator: string): void;
|
|
119
|
+
close(): void;
|
|
120
|
+
};
|
|
121
|
+
export declare function createStore(options: StoreOptions): Store;
|