@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,10 +1,25 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
3
|
+
export type UnsentWork = {
|
|
4
|
+
readonly kind: UnsentKind;
|
|
5
|
+
readonly count: number;
|
|
6
|
+
};
|
|
7
|
+
export type AppCode = {
|
|
8
|
+
readonly running: number;
|
|
9
|
+
readonly older: number;
|
|
10
|
+
};
|
|
11
|
+
export type HeldCode = {
|
|
12
|
+
readonly house: number | null;
|
|
13
|
+
readonly apps: readonly string[];
|
|
14
|
+
};
|
|
2
15
|
export type RuntimeShell = {
|
|
3
16
|
persistence: Persistence;
|
|
4
17
|
generation: string | null;
|
|
5
18
|
keepGeneration(value: string): void | Promise<void>;
|
|
6
19
|
dropGeneration(): void | Promise<void>;
|
|
7
20
|
cleanUp?(): Promise<number>;
|
|
21
|
+
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
22
|
+
reset(): Promise<void>;
|
|
8
23
|
};
|
|
9
24
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
10
25
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
@@ -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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
-
export declare function identityTime(identity: string): number;
|
|
3
2
|
export declare function roomDraftRevision(): string;
|
|
4
3
|
export declare function chatDraftRevision(): string;
|
|
5
4
|
export declare function transferIdentity(): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AdapterFailure, Authorization, DiscoveredRoom, NotReady, RetryableRefusal } from './adapter.js';
|
|
2
|
+
import { type Reads } from './bootstrap.js';
|
|
3
|
+
import type { Installation, RoomCoverage } from './readiness.js';
|
|
4
|
+
import { advancement, type Refresher } from './refresh.js';
|
|
5
|
+
import type { ReplicaRecord } from './replica.js';
|
|
6
|
+
import type { Runtime } from './runtime.js';
|
|
7
|
+
import type { Live } from './socket.js';
|
|
8
|
+
import { type CoveredRoom, type InstallHold, type RuntimeStore, type Store } from './store.js';
|
|
9
|
+
import { type Unconfirmed } from './transfer.js';
|
|
10
|
+
type Standing = {
|
|
11
|
+
readonly key: number | null;
|
|
12
|
+
readonly confirmed: number;
|
|
13
|
+
};
|
|
14
|
+
export type Unheld = {
|
|
15
|
+
readonly staged: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type Withheld = AdapterFailure | RetryableRefusal | NotReady | Unconfirmed;
|
|
18
|
+
type Landing = {
|
|
19
|
+
readonly kind: 'refreshed';
|
|
20
|
+
readonly from: Standing;
|
|
21
|
+
readonly remodelled: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: 'bootstrapped';
|
|
24
|
+
readonly refreshed: boolean;
|
|
25
|
+
readonly from: Standing;
|
|
26
|
+
};
|
|
27
|
+
type Refreshed = {
|
|
28
|
+
kind: 'advanced';
|
|
29
|
+
record: ReplicaRecord;
|
|
30
|
+
from: Standing;
|
|
31
|
+
remodelled: boolean;
|
|
32
|
+
} | Exclude<Awaited<ReturnType<typeof advancement>>, {
|
|
33
|
+
kind: 'advanced';
|
|
34
|
+
}>;
|
|
35
|
+
export declare const ERASE_BATCH = 512;
|
|
36
|
+
export declare function installationOf(store: Store, coverage: readonly RoomCoverage[], held: ReadonlyMap<string, CoveredRoom>): Installation;
|
|
37
|
+
export declare function roomInFlight(store: Store, locator: string): boolean;
|
|
38
|
+
export declare function sweep({ store, socket, journal }: Runtime): void;
|
|
39
|
+
export declare function forgetInstall(store: Store, locator: string): void;
|
|
40
|
+
export declare function caughtUpTo(runtime: Runtime, locator: string): void;
|
|
41
|
+
export declare function catching(store: Store, locator: string): void;
|
|
42
|
+
export declare function confirmedAgain(store: Store, locator: string): void;
|
|
43
|
+
export declare function standingAt(store: Store, locator: string, held: Pick<ReplicaRecord, 'key'> | undefined): Standing;
|
|
44
|
+
export declare function showing(system: Runtime, locator: string, roomVersion: string, held: string | undefined): void;
|
|
45
|
+
export declare function olderThan(system: Runtime, locator: string, roomVersion: string, held: string | undefined): boolean;
|
|
46
|
+
export declare function replaced(store: Store, locators: readonly string[]): void;
|
|
47
|
+
export declare function reachedBy({ store, socket }: Runtime, locator: string, roomVersion: string): Promise<boolean>;
|
|
48
|
+
export declare function behind({ store, socket }: Runtime, room: DiscoveredRoom): Promise<boolean>;
|
|
49
|
+
export declare function writtenAfter({ store, socket }: Runtime, locator: string, roomVersion: string, path: string): Promise<boolean>;
|
|
50
|
+
export declare function pullRefresh(runtime: Runtime, authorized: Authorization, record: ReplicaRecord, liveness: Live, hold: InstallHold, refresh: Refresher): Promise<Refreshed>;
|
|
51
|
+
export declare function pullBootstrap(runtime: Runtime, authorized: Authorization, room: DiscoveredRoom, local: RuntimeStore, liveness: Live, prior: ReplicaRecord | undefined, from?: Reads, unheld?: Unheld): Promise<import("./bootstrap.js").Bootstrapped | NotReady | import("./adapter.js").RevokedAuthorization | import("./adapter.js").RoomNotReadable | Unconfirmed | {
|
|
52
|
+
readonly kind: 'transport-uncertainty';
|
|
53
|
+
} | RetryableRefusal | import("./adapter.js").ScopedRefusal>;
|
|
54
|
+
export declare function publish(runtime: Runtime, local: RuntimeStore, room: DiscoveredRoom, reached: ReplicaRecord, landing: Landing, live: Live): Promise<boolean>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type Job = {
|
|
2
|
+
readonly label: string;
|
|
3
|
+
readonly kind: 'started' | 'scheduled' | 'ended';
|
|
4
|
+
readonly state: string;
|
|
5
|
+
readonly next: string | null;
|
|
6
|
+
};
|
|
7
|
+
export type RunningJob = {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly running_since: string;
|
|
10
|
+
};
|
|
11
|
+
export type JobMarker = {
|
|
12
|
+
readonly said: string;
|
|
13
|
+
readonly at: string;
|
|
14
|
+
};
|
|
15
|
+
export type OpenJob<At = string | null> = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly started: At;
|
|
18
|
+
};
|
|
19
|
+
export declare function jobOf(said: string): Job;
|
|
20
|
+
export declare function closeLast(open: {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
}[], key: string): void;
|
|
23
|
+
export declare function markerMoved<Kept extends {
|
|
24
|
+
readonly key: string;
|
|
25
|
+
}>(open: Kept[], said: string, opened: (job: Job, key: string) => Kept | null): void;
|
|
26
|
+
export declare function openJobs<At>(markers: readonly {
|
|
27
|
+
readonly said: string;
|
|
28
|
+
readonly at: At;
|
|
29
|
+
}[]): readonly OpenJob<At>[];
|
|
30
|
+
export declare function jobsRunning(jobs: readonly RunningJob[], now: number): string[];
|
|
31
|
+
export declare function sessionEnded(jobs: readonly RunningJob[], now: number): string;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HeldRooms } from '../mdmodel/index.js';
|
|
2
|
+
import type { DiscoveredRoom, HeldRoom, OperationScopes, ProviderRefusal, ReplicaAdmission } 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 { RoomDeclaration } from './socket.js';
|
|
9
|
+
import type { Stored } from './store.js';
|
|
10
|
+
export type AppTypedSelection = {
|
|
11
|
+
roots: readonly string[];
|
|
12
|
+
model: TypesResult;
|
|
13
|
+
};
|
|
14
|
+
export type AppRoom = {
|
|
15
|
+
name: string;
|
|
16
|
+
locator: string;
|
|
17
|
+
handle: string;
|
|
18
|
+
operations: OperationScopes;
|
|
19
|
+
replica: ReplicaAdmission;
|
|
20
|
+
model: TypesResult;
|
|
21
|
+
typedSelection: AppTypedSelection | null;
|
|
22
|
+
providerOwnedPaths: 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 }: Runtime, locator: string, stored: Stored | undefined): ModelState;
|
|
35
|
+
export declare function compositionFor(runtime: Runtime, record: ReplicaRecord): Composition;
|
|
36
|
+
export declare function declarationOf({ socket }: Runtime, locator: string, stored: Stored | undefined): {
|
|
37
|
+
readonly room: RoomDeclaration;
|
|
38
|
+
readonly available: boolean;
|
|
39
|
+
} | undefined;
|
|
40
|
+
export declare function listedLocators({ store, socket }: 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(runtime: Runtime, listing: Listing): readonly AppRoom[];
|
|
44
|
+
export declare function roomFacts(runtime: Runtime, reach?: PortReach | null): Promise<HeldRooms>;
|
|
45
|
+
export declare function list({ store, socket }: Runtime, room: RoomDeclaration, synchronizationAvailable: boolean): void;
|
|
46
|
+
export declare function listHeld({ store, socket }: Runtime, locator: string): void;
|
|
47
|
+
export declare function admitted({ socket }: Runtime, room: RoomDeclaration): boolean;
|
|
48
|
+
export declare function readable(runtime: Runtime, room: DiscoveredRoom): void;
|
|
49
|
+
export declare function usable(runtime: Runtime, room: DiscoveredRoom): void;
|
|
50
|
+
export declare function heldRooms({ store }: Runtime, listed: readonly DiscoveredRoom[]): Promise<HeldRoom[]>;
|
|
51
|
+
export declare function name(runtime: Runtime, locator: string): Promise<void>;
|
|
52
|
+
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 {};
|
|
@@ -3,5 +3,5 @@ import { type ShownAnswer } from './outcome.js';
|
|
|
3
3
|
export declare const ROOM_MEDIA = "room-media";
|
|
4
4
|
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
5
|
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
-
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
|
|
7
7
|
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { JobMarker } from './job.js';
|
|
2
3
|
import type { Connection } from './tables.js';
|
|
3
4
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
5
|
+
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";
|
|
6
|
+
export declare const JOB_MARKERS = "SELECT json_extract(part.value, '$.text') AS said,\n json_extract(message, '$.accepted_at') AS at\n FROM conversation_messages, json_each(message, '$.parts') AS part\n WHERE conversation = ? AND instr(message, '\"marker\":\"job\"') > 0\n AND json_extract(part.value, '$.type') = 'marker'\n AND json_extract(part.value, '$.marker') = 'job'\n ORDER BY position, identity, part.key";
|
|
4
7
|
export type HeldConversation = {
|
|
5
8
|
readonly conversation: string;
|
|
6
9
|
readonly read: string | null | undefined;
|
|
@@ -10,6 +13,25 @@ export type MessageWindow = {
|
|
|
10
13
|
readonly messages: AcceptedMessage[];
|
|
11
14
|
readonly more: boolean;
|
|
12
15
|
};
|
|
16
|
+
export type HeldSource = {
|
|
17
|
+
readonly source: unknown;
|
|
18
|
+
readonly sender: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type HeldRow = {
|
|
21
|
+
readonly conversation: string;
|
|
22
|
+
readonly said: {
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly role: string | null;
|
|
25
|
+
readonly at: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
readonly failure: string | null;
|
|
28
|
+
readonly opened: HeldSource | null;
|
|
29
|
+
readonly asking: (HeldSource & {
|
|
30
|
+
readonly identity: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly at: string | null;
|
|
33
|
+
}) | null;
|
|
34
|
+
};
|
|
13
35
|
export type ConversationWrite = {
|
|
14
36
|
readonly conversation: string;
|
|
15
37
|
readonly messages: readonly AcceptedMessage[];
|
|
@@ -18,10 +40,12 @@ export type ConversationWrite = {
|
|
|
18
40
|
readonly partial: boolean;
|
|
19
41
|
};
|
|
20
42
|
};
|
|
21
|
-
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
43
|
+
export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
|
|
22
44
|
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
|
-
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null): MessageWindow;
|
|
24
|
-
export declare function messageCount(connection: Connection, conversation: string): number;
|
|
45
|
+
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
46
|
+
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
47
|
+
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
48
|
+
export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
|
|
25
49
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
50
|
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
51
|
export declare function forgottenMessages(connection: Connection): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Definition,
|
|
1
|
+
import type { Definition, VerifiedModel } from '../mdmodel/index.js';
|
|
2
2
|
import type { Open } from './open.js';
|
|
3
3
|
export type ModelIdentity = {
|
|
4
4
|
identity: string;
|
|
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
8
8
|
schema: string | null;
|
|
9
9
|
revision: string | null;
|
|
10
10
|
};
|
|
11
|
-
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
|
|
12
12
|
export type ModelResult = {
|
|
13
13
|
kind: 'model';
|
|
14
14
|
snapshot: ModelSnapshot;
|
|
@@ -20,8 +20,6 @@ export type MdType = Definition;
|
|
|
20
20
|
export type ModelState = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
|
-
schema?: string | null;
|
|
24
|
-
revision?: string | null;
|
|
25
23
|
} | {
|
|
26
24
|
status: 'current' | 'cached';
|
|
27
25
|
snapshot: ModelSnapshot;
|
|
@@ -37,8 +35,6 @@ export type TypesResult = {
|
|
|
37
35
|
status: Open<'unavailable'>;
|
|
38
36
|
reason: ModelUnavailableReason;
|
|
39
37
|
types: null;
|
|
40
|
-
schema?: string | null;
|
|
41
|
-
revision?: string | null;
|
|
42
38
|
} | {
|
|
43
39
|
status: Open<'current' | 'cached'>;
|
|
44
40
|
identity: string;
|
|
@@ -57,6 +53,3 @@ export declare const NO_MODEL: ModelState;
|
|
|
57
53
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
58
54
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
55
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
|
-
export declare function cached(state: ModelState): ModelState;
|
|
61
|
-
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
|
-
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
@@ -27,8 +27,8 @@ export declare function rowsOf(result: QueryResult): readonly (QueryDocument | Q
|
|
|
27
27
|
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
28
28
|
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
29
29
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
30
|
-
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
-
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
30
|
+
export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
31
|
+
export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
|
|
32
32
|
export type Digest = {
|
|
33
33
|
readonly pending: string;
|
|
34
34
|
} | {
|
|
@@ -13,7 +13,9 @@ export type CallResult = {
|
|
|
13
13
|
kind: 'action';
|
|
14
14
|
result: unknown;
|
|
15
15
|
at?: RoomVersionAt;
|
|
16
|
-
} | Refused<'rejected'>
|
|
16
|
+
} | (Refused<'rejected'> & {
|
|
17
|
+
reset?: string;
|
|
18
|
+
}) | Refused<'undeclared'> | Failure;
|
|
17
19
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
18
20
|
kind: Failure['kind'];
|
|
19
21
|
}> | Failure;
|
|
@@ -65,6 +67,7 @@ export type Offline = {
|
|
|
65
67
|
readonly kind: 'offline';
|
|
66
68
|
};
|
|
67
69
|
export declare const OFFLINE: Offline;
|
|
70
|
+
export declare function answeredResult(value: unknown): boolean;
|
|
68
71
|
export declare const UNCERTAIN: Failure;
|
|
69
72
|
export declare function undeclared(name: string): CallResult;
|
|
70
73
|
export declare function failure(result: AdapterFailure): Failure;
|
|
@@ -3,6 +3,7 @@ import type { ChangeBatch } from './change.js';
|
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
5
|
fileIds: Readonly<Record<string, string>>;
|
|
6
|
+
created: Readonly<Record<string, string>>;
|
|
6
7
|
changes: Readonly<Record<string, HeadChange>>;
|
|
7
8
|
};
|
|
8
9
|
export type HeldBinary = ({
|
|
@@ -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;
|