@agentshouse/app-bridge 0.1.0-cd8e22905148b → 0.1.0-cdb88c540d78b
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/dist/index.d.ts +15 -0
- package/dist/mdmodel/document.d.ts +2 -1
- package/dist/mdmodel/index.d.ts +3 -3
- package/dist/mdmodel/references.d.ts +2 -2
- package/dist/mdmodel/types.d.ts +22 -1
- package/dist/mdmodel/validate.d.ts +5 -1
- package/dist/mdruntime/acquisition.d.ts +13 -0
- package/dist/mdruntime/adapter.d.ts +5 -1
- package/dist/mdruntime/change-set.d.ts +2 -0
- package/dist/mdruntime/client.d.ts +9 -6
- package/dist/mdruntime/collection.d.ts +17 -3
- package/dist/mdruntime/connection.d.ts +18 -7
- package/dist/mdruntime/conversation.d.ts +5 -5
- package/dist/mdruntime/durability.d.ts +7 -1
- package/dist/mdruntime/model.d.ts +1 -0
- package/dist/mdruntime/observation.d.ts +5 -2
- package/dist/mdruntime/overlay.d.ts +1 -0
- package/dist/mdruntime/query.d.ts +28 -3
- package/dist/mdruntime/reach.d.ts +6 -2
- package/dist/mdruntime/readiness.d.ts +52 -0
- package/dist/mdruntime/replica.d.ts +1 -1
- package/dist/mdruntime/rows.d.ts +4 -13
- package/dist/mdruntime/save.d.ts +5 -0
- package/dist/mdruntime/search.d.ts +28 -6
- package/dist/mdruntime/shared.d.ts +10 -0
- package/dist/mdruntime/status.d.ts +4 -0
- package/dist/mdruntime/store.d.ts +17 -3
- package/dist/mdruntime/turn.d.ts +6 -0
- package/dist/mdruntime/wire.d.ts +136 -32
- package/dist/test-host.d.ts +4 -1
- package/dist/test-host.js +27 -0
- package/docs/families.md +37 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -110,6 +110,20 @@ export interface HouseBrowserRefused extends Error {
|
|
|
110
110
|
readonly code: string;
|
|
111
111
|
readonly retryable: boolean;
|
|
112
112
|
}
|
|
113
|
+
export interface HouseTrialWithheld {
|
|
114
|
+
readonly code: Open<'house_trial_withheld'>;
|
|
115
|
+
readonly retryable: true;
|
|
116
|
+
}
|
|
117
|
+
export type HouseTask = unknown;
|
|
118
|
+
export type HouseActivation = Open<'committed' | 'abandoned'>;
|
|
119
|
+
export interface HouseCooperation {
|
|
120
|
+
checkpoint(): Promise<void> | void;
|
|
121
|
+
persist(): Promise<void> | void;
|
|
122
|
+
capture(): Promise<HouseTask> | HouseTask;
|
|
123
|
+
restore(task: HouseTask | null): Promise<void> | void;
|
|
124
|
+
ready(): Promise<boolean> | boolean;
|
|
125
|
+
settle(activation: HouseActivation): void;
|
|
126
|
+
}
|
|
113
127
|
export interface HouseBridge {
|
|
114
128
|
readonly runtime: Promise<HouseRuntime>;
|
|
115
129
|
address(): string | null;
|
|
@@ -130,6 +144,7 @@ export interface HouseBridge {
|
|
|
130
144
|
onStatus(listener: (status: HouseStatus) => void): () => void;
|
|
131
145
|
messages(listener: (message: HouseAppMessage) => void): () => void;
|
|
132
146
|
analyticsConsent(choice: HouseAnalyticsChoice): void;
|
|
147
|
+
cooperate(cooperation: HouseCooperation): () => void;
|
|
133
148
|
}
|
|
134
149
|
export interface HouseHeld {
|
|
135
150
|
readonly houseBridge: HouseBridge;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import type { ApplyResult, BodyResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
|
|
2
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
|
|
3
3
|
import { type YamlMap } from './yaml.js';
|
|
4
|
+
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
4
5
|
export declare function parse(content: string, file?: string): ParseResult;
|
|
5
6
|
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
|
|
6
7
|
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
package/dist/mdmodel/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, C
|
|
|
3
3
|
export { headingLines } from './blocks.js';
|
|
4
4
|
export type { HeadingLine } from './blocks.js';
|
|
5
5
|
export { divide } from './divide.js';
|
|
6
|
-
export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
6
|
+
export { apply, bodyLinks, fieldStart, linkOccurrences, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
7
7
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
8
8
|
export { relative, retarget, target } from './paths.js';
|
|
9
9
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
@@ -11,8 +11,8 @@ export { project } from './project.js';
|
|
|
11
11
|
export { references } from './references.js';
|
|
12
12
|
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
13
13
|
export type { Definition, JsonType, PatternFacts, PointerFacts, SectionSpec, Shape, ValueFacts, } from './definition.js';
|
|
14
|
-
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
|
|
15
|
-
export { validate, verify } from './validate.js';
|
|
14
|
+
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, LinkOccurrence, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, Span, Validation, ValidationContext, VerifiedModel, } from './types.js';
|
|
15
|
+
export { checkDocument, resolves, sectionReferences, validate, verify } from './validate.js';
|
|
16
16
|
export { VERSION } from './version.js';
|
|
17
17
|
export { equalValue, frontmatterValue } from './yaml.js';
|
|
18
18
|
export type { FrontmatterValue } from './yaml.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function references(document:
|
|
2
|
+
import type { Frontmatter, Reference } from './types.js';
|
|
3
|
+
export declare function references(document: Pick<Frontmatter, 'fields'>, definition: Definition): readonly Reference[];
|
package/dist/mdmodel/types.d.ts
CHANGED
|
@@ -28,10 +28,12 @@ export type Extent = {
|
|
|
28
28
|
export type Span = Extent & {
|
|
29
29
|
readonly text: string;
|
|
30
30
|
};
|
|
31
|
-
export type
|
|
31
|
+
export type Frontmatter = {
|
|
32
32
|
readonly content: string;
|
|
33
33
|
readonly type: string | undefined;
|
|
34
34
|
readonly fields: Readonly<Record<string, unknown>>;
|
|
35
|
+
};
|
|
36
|
+
export type Document = Frontmatter & {
|
|
35
37
|
readonly preamble: string;
|
|
36
38
|
readonly sections: Readonly<Record<string, string>>;
|
|
37
39
|
};
|
|
@@ -41,6 +43,18 @@ export type Refusal = {
|
|
|
41
43
|
readonly location?: string;
|
|
42
44
|
readonly referrers?: readonly string[];
|
|
43
45
|
};
|
|
46
|
+
export type Reached = {
|
|
47
|
+
readonly target: string | null;
|
|
48
|
+
readonly to: readonly string[];
|
|
49
|
+
};
|
|
50
|
+
export type DocumentCheck = {
|
|
51
|
+
readonly ok: false;
|
|
52
|
+
} | {
|
|
53
|
+
readonly ok: true;
|
|
54
|
+
readonly type: string;
|
|
55
|
+
readonly typed: boolean;
|
|
56
|
+
readonly references: readonly Reached[];
|
|
57
|
+
};
|
|
44
58
|
export type Validation = {
|
|
45
59
|
readonly verdict: 'accept';
|
|
46
60
|
} | ({
|
|
@@ -60,6 +74,13 @@ export type Division = {
|
|
|
60
74
|
readonly ok: false;
|
|
61
75
|
readonly refusal: Refusal;
|
|
62
76
|
};
|
|
77
|
+
export type FrontmatterResult = {
|
|
78
|
+
readonly ok: true;
|
|
79
|
+
readonly frontmatter: Frontmatter;
|
|
80
|
+
} | {
|
|
81
|
+
readonly ok: false;
|
|
82
|
+
readonly refusal: Refusal;
|
|
83
|
+
};
|
|
63
84
|
export type ParseResult = {
|
|
64
85
|
readonly ok: true;
|
|
65
86
|
readonly document: Document;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import type { DocumentCheck, Library, ModelVerification, Reached, Validation, ValidationContext, VerifiedModel } from './types.js';
|
|
3
|
+
export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
|
|
2
4
|
export declare function verify(schema: string): ModelVerification;
|
|
5
|
+
export declare function checkDocument(file: string, content: string, model: VerifiedModel): DocumentCheck;
|
|
6
|
+
export declare function sectionReferences(file: string, content: string, definition: Definition): readonly Reached[];
|
|
3
7
|
export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RuntimeDemand = {
|
|
2
|
+
readonly whole: boolean;
|
|
3
|
+
readonly rooms: readonly string[];
|
|
4
|
+
readonly handles: readonly string[];
|
|
5
|
+
readonly conversations: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const WHOLE_DEMAND: RuntimeDemand;
|
|
8
|
+
export declare function demanded(demand: RuntimeDemand, room: {
|
|
9
|
+
readonly locator: string;
|
|
10
|
+
readonly handle: string;
|
|
11
|
+
}): boolean;
|
|
12
|
+
export declare function wider(next: RuntimeDemand, current: RuntimeDemand): boolean;
|
|
13
|
+
export declare function narrower(next: RuntimeDemand, current: RuntimeDemand): boolean;
|
|
@@ -446,8 +446,12 @@ export type StreamReceipts = {
|
|
|
446
446
|
}): Promise<void>;
|
|
447
447
|
drop(keys: readonly string[]): Promise<void>;
|
|
448
448
|
};
|
|
449
|
+
export type AcquiredDemand = {
|
|
450
|
+
rooms: readonly string[];
|
|
451
|
+
conversations: boolean;
|
|
452
|
+
};
|
|
449
453
|
export type RoomStream = {
|
|
450
|
-
hold(rooms: readonly HeldRoom[]): void;
|
|
454
|
+
hold(rooms: readonly HeldRoom[], demand: AcquiredDemand | null): void;
|
|
451
455
|
reopen(): void;
|
|
452
456
|
published(locator: string, roomVersion: string): void;
|
|
453
457
|
observe(notify: (event: RoomStreamEvent) => void, receipts: StreamReceipts): () => void;
|
|
@@ -9,6 +9,7 @@ export type DocumentChange = {
|
|
|
9
9
|
export type MessageChange = {
|
|
10
10
|
conversation: string;
|
|
11
11
|
identity: string;
|
|
12
|
+
text: string | null;
|
|
12
13
|
};
|
|
13
14
|
export type ChangeSet = {
|
|
14
15
|
documents: readonly DocumentChange[];
|
|
@@ -28,5 +29,6 @@ export declare function changeSet(locator: string, before: Replica | null, after
|
|
|
28
29
|
queue?: boolean;
|
|
29
30
|
presentation?: string;
|
|
30
31
|
}): ChangeSet;
|
|
32
|
+
export declare function entering(locator: string, replica: Replica, paths: readonly string[]): ChangeSet;
|
|
31
33
|
export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
|
|
32
34
|
export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
|
|
@@ -4,16 +4,17 @@ import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptio
|
|
|
4
4
|
import { type Observation } from './observation.js';
|
|
5
5
|
import type { BinaryReference } from './binary.js';
|
|
6
6
|
import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
|
|
7
|
-
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
7
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
8
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
9
9
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
10
|
+
import type { Readiness } from './readiness.js';
|
|
10
11
|
import type { SyncStatus } from './status.js';
|
|
11
12
|
import { type RuntimePort } from './wire.js';
|
|
12
13
|
export type MdRuntimeClient = {
|
|
13
14
|
rooms(): Promise<readonly AppRoom[]>;
|
|
14
15
|
query: {
|
|
15
|
-
(query: DocumentQuery): Promise<DocumentResult>;
|
|
16
|
-
(query: GroupQuery): Promise<GroupResult>;
|
|
16
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
17
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
17
18
|
};
|
|
18
19
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
19
20
|
types(locator: string): Promise<RoomSchemas>;
|
|
@@ -52,16 +53,18 @@ export type MdRuntimeClient = {
|
|
|
52
53
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
53
54
|
log(): Promise<string>;
|
|
54
55
|
persistence(): Promise<boolean>;
|
|
56
|
+
retry(): Promise<void>;
|
|
55
57
|
observe: {
|
|
56
58
|
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
57
59
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
60
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
58
61
|
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
59
62
|
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
60
63
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
61
64
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
62
65
|
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
63
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
64
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
66
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
67
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
65
68
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
66
69
|
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
67
70
|
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
@@ -75,4 +78,4 @@ export type MdRuntimeClient = {
|
|
|
75
78
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
76
79
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
77
80
|
export type { Observation } from './observation.js';
|
|
78
|
-
export type
|
|
81
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type Document, type Validation } from '../mdmodel/index.js';
|
|
2
|
-
import type
|
|
1
|
+
import { type Document, type Frontmatter, type Validation } from '../mdmodel/index.js';
|
|
2
|
+
import { type ModelState } from './model.js';
|
|
3
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
+
import { type Paths } from './shared.js';
|
|
4
5
|
import type { Refused } from './transfer.js';
|
|
6
|
+
import { type Later } from './turn.js';
|
|
5
7
|
export declare const MD_MODEL: MdModelIdentity;
|
|
6
8
|
export type Collection = {
|
|
7
9
|
text: Readonly<Record<string, string>>;
|
|
@@ -17,8 +19,20 @@ export type Composition = {
|
|
|
17
19
|
};
|
|
18
20
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
19
21
|
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
|
|
20
|
-
export declare function
|
|
22
|
+
export declare function passingFrontmatter(collection: Collection, path: string): Frontmatter | undefined;
|
|
21
23
|
export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
|
|
22
24
|
export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
|
|
23
25
|
export declare function validRoot(root: unknown): root is string;
|
|
24
26
|
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
|
|
27
|
+
type Held = {
|
|
28
|
+
text: Paths<string>;
|
|
29
|
+
binaries: Paths<unknown>;
|
|
30
|
+
};
|
|
31
|
+
export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
|
|
32
|
+
export declare function referencesIndexed(held: Held, composition: Composition): boolean;
|
|
33
|
+
export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
|
|
34
|
+
export declare function available(composition: Composition): boolean;
|
|
35
|
+
export declare function changedCleanly(next: Held, previous: Held & {
|
|
36
|
+
composition: Composition;
|
|
37
|
+
}, composition: Composition): boolean;
|
|
38
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TypesResult } from './model.js';
|
|
2
2
|
import { type Observation } from './observation.js';
|
|
3
|
-
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult } from './query.js';
|
|
3
|
+
import { type DocumentQuery, type DocumentResult, type GroupQuery, type GroupResult, type PendingResult } from './query.js';
|
|
4
4
|
import { type SearchRequest, type SearchResult } from './search.js';
|
|
5
5
|
import { type Adapter, type Authorization, type Member, type ProviderRefusal, type ServiceMode } from './adapter.js';
|
|
6
6
|
import { type ChatDraftSurface, type ConversationAgent, type ConversationEntry, type ConversationOptions, type ConversationSurface, type ConversationView } from './conversation.js';
|
|
@@ -13,6 +13,8 @@ import { type SaveRefusal } from './save.js';
|
|
|
13
13
|
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
14
14
|
import { type SyncStatus } from './status.js';
|
|
15
15
|
import { type RuntimeShell } from './durability.js';
|
|
16
|
+
import { type RuntimeDemand } from './acquisition.js';
|
|
17
|
+
import { type CapacityCause, type CodeAvailability, type Persistence, type Readiness } from './readiness.js';
|
|
16
18
|
import { type NarrowedView, type PortReach, type RuntimeView } from './reach.js';
|
|
17
19
|
export type AppTypedSelection = {
|
|
18
20
|
roots: readonly string[];
|
|
@@ -83,8 +85,8 @@ export type MdRuntime = {
|
|
|
83
85
|
loaded(): Promise<void>;
|
|
84
86
|
rooms(): readonly AppRoom[];
|
|
85
87
|
query: {
|
|
86
|
-
(query: DocumentQuery): Promise<DocumentResult>;
|
|
87
|
-
(query: GroupQuery): Promise<GroupResult>;
|
|
88
|
+
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
89
|
+
(query: GroupQuery): Promise<GroupResult | PendingResult>;
|
|
88
90
|
};
|
|
89
91
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
90
92
|
types(locator: string): RoomSchemas;
|
|
@@ -99,15 +101,17 @@ export type MdRuntime = {
|
|
|
99
101
|
reached(locator: string, roomVersion: string, path?: string): boolean;
|
|
100
102
|
log(): string;
|
|
101
103
|
persistence(): boolean;
|
|
104
|
+
retry(): Promise<void>;
|
|
102
105
|
observe: {
|
|
103
106
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
107
|
+
(topic: 'readiness'): Promise<Observation<Readiness>>;
|
|
104
108
|
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
105
109
|
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
106
110
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
107
111
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
108
112
|
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
109
|
-
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
110
|
-
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
113
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
114
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
111
115
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
112
116
|
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
113
117
|
(topic: 'presentation', app: string): Promise<Observation<unknown>>;
|
|
@@ -117,11 +121,18 @@ export type MdRuntime = {
|
|
|
117
121
|
};
|
|
118
122
|
reauthorize(): Promise<void>;
|
|
119
123
|
};
|
|
120
|
-
export type RuntimeTopic = 'rooms' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
124
|
+
export type RuntimeTopic = 'rooms' | 'readiness' | 'connection-refusal' | 'storage-loss' | 'sync-status' | 'service-mode' | 'member' | 'query' | 'queue' | 'room-drafts' | 'presentation' | 'conversation' | 'conversations' | 'agents';
|
|
125
|
+
export type ReadinessPort = {
|
|
126
|
+
readonly target: string;
|
|
127
|
+
readonly code: CodeAvailability;
|
|
128
|
+
readonly capacity: CapacityCause | null;
|
|
129
|
+
};
|
|
121
130
|
export type ComposedRuntime = RuntimeView & {
|
|
122
131
|
stop(): Promise<void>;
|
|
123
132
|
lose(locators: readonly string[]): Promise<void>;
|
|
124
|
-
|
|
133
|
+
acquire(demand: RuntimeDemand): void;
|
|
134
|
+
persisted(answer: Persistence): void;
|
|
135
|
+
within(reach: PortReach | null, port: ReadinessPort): NarrowedView;
|
|
125
136
|
};
|
|
126
137
|
export declare function composeRuntime(options: MdRuntimeOptions): ComposedRuntime;
|
|
127
138
|
export {};
|
|
@@ -3,8 +3,7 @@ import { type ChangeSet } from './change-set.js';
|
|
|
3
3
|
import { type ChatDraftFile } from './file.js';
|
|
4
4
|
import type { Open } from './open.js';
|
|
5
5
|
import { type CallResult, type Offline } from './outcome.js';
|
|
6
|
-
import type { DocumentResult } from './query.js';
|
|
7
|
-
import type { SearchedMessage } from './search.js';
|
|
6
|
+
import type { DocumentResult, PendingResult } from './query.js';
|
|
8
7
|
import type { CycleProgress } from './status.js';
|
|
9
8
|
import type { ChatDraftRecord, HeldConversation, RuntimeStore } from './store.js';
|
|
10
9
|
export type ConversationState = Open<'working' | 'asking' | 'idle'>;
|
|
@@ -69,7 +68,7 @@ export type ChatDraftSurface = {
|
|
|
69
68
|
};
|
|
70
69
|
export type ConversationDependencies = {
|
|
71
70
|
agents(): ConversationAgents | undefined;
|
|
72
|
-
documents(
|
|
71
|
+
documents(agents: ConversationAgents): Promise<DocumentResult | PendingResult>;
|
|
73
72
|
call(name: ConversationAction, input: unknown): Promise<CallResult>;
|
|
74
73
|
durably<T>(work: (local: RuntimeStore) => Promise<T>): Promise<T>;
|
|
75
74
|
stream(): ConversationStream | undefined;
|
|
@@ -87,6 +86,7 @@ export type ConversationStore = {
|
|
|
87
86
|
catchUp(progress: CycleProgress): Promise<void>;
|
|
88
87
|
resend(progress: CycleProgress): Promise<void>;
|
|
89
88
|
current(): boolean;
|
|
89
|
+
known(): boolean;
|
|
90
90
|
reconnected(): void;
|
|
91
91
|
reopened(): void;
|
|
92
92
|
watch(conversation: string, options: ConversationOptions, deliver: (view: ConversationView) => void): () => void;
|
|
@@ -94,8 +94,8 @@ export type ConversationStore = {
|
|
|
94
94
|
watchAgents(deliver: (agents: readonly ConversationAgent[]) => void): () => void;
|
|
95
95
|
changed(set: ChangeSet): void;
|
|
96
96
|
receive(event: ConversationEvent): boolean;
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
searchable(): readonly string[];
|
|
98
|
+
acquired(conversation: string): boolean;
|
|
99
99
|
close(): void;
|
|
100
100
|
};
|
|
101
101
|
export declare function unheldView(conversation: string): ConversationView;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { Persistence } from './readiness.js';
|
|
2
|
+
export type StorageEstimate = {
|
|
3
|
+
readonly usage: number;
|
|
4
|
+
readonly quota: number;
|
|
5
|
+
};
|
|
1
6
|
export type RuntimeShell = {
|
|
2
|
-
|
|
7
|
+
persistence: Persistence;
|
|
3
8
|
generation: string | null;
|
|
4
9
|
keepGeneration(value: string): void | Promise<void>;
|
|
5
10
|
dropGeneration(): void | Promise<void>;
|
|
11
|
+
estimate?(): Promise<StorageEstimate | null>;
|
|
6
12
|
};
|
|
7
13
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
|
8
14
|
export declare function nextGeneration(stored: string | null, reported: string | null): string;
|
|
@@ -52,4 +52,5 @@ export declare function definitionOf(state: ModelState, type: string | undefined
|
|
|
52
52
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
53
53
|
export declare function cached(state: ModelState): ModelState;
|
|
54
54
|
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
55
|
+
export declare function sameTyping(left: ModelState, right: ModelState): boolean;
|
|
55
56
|
export declare function referenceField(facts: ValueFacts | undefined): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
1
|
+
import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
|
|
2
2
|
export type Observation<T> = {
|
|
3
3
|
current(): T;
|
|
4
4
|
subscribe(listener: (value: T) => void): () => void;
|
|
@@ -13,14 +13,17 @@ export type QueryChange = {
|
|
|
13
13
|
changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
|
|
14
14
|
removed: readonly RowKey[];
|
|
15
15
|
order: readonly RowKey[] | null;
|
|
16
|
+
coverage?: QueryCoverage;
|
|
16
17
|
};
|
|
18
|
+
export type QueryMessage = KeyedResult | QueryChange;
|
|
17
19
|
export type Observed = {
|
|
18
20
|
observation: Observation<unknown>;
|
|
19
21
|
receive(message: unknown): void;
|
|
20
22
|
end(): void;
|
|
21
23
|
};
|
|
22
24
|
export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function whole(message: QueryMessage): message is KeyedResult;
|
|
26
|
+
export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
|
|
24
27
|
export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
|
|
25
28
|
export declare function opened(watch: (deliver: (message: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
|
|
26
29
|
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>>;
|
|
@@ -22,4 +22,5 @@ export declare function sameBinary(left: HeldBinary | undefined, right: HeldBina
|
|
|
22
22
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
23
23
|
export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
|
|
24
24
|
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
25
|
+
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
25
26
|
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
@@ -100,13 +100,38 @@ export type QueryGroup = {
|
|
|
100
100
|
key: readonly unknown[];
|
|
101
101
|
count: number;
|
|
102
102
|
};
|
|
103
|
-
export type
|
|
103
|
+
export type CoveredRoom = {
|
|
104
|
+
room: string;
|
|
105
|
+
generation: string;
|
|
106
|
+
current: boolean;
|
|
107
|
+
};
|
|
108
|
+
export type QueryCoverage = {
|
|
109
|
+
rooms: readonly CoveredRoom[];
|
|
110
|
+
indexes: readonly string[];
|
|
111
|
+
overlay: readonly string[];
|
|
112
|
+
};
|
|
113
|
+
export type Awaits = 'acquisition' | 'preparation' | 'index';
|
|
114
|
+
export type PendingRoom = {
|
|
115
|
+
room: string;
|
|
116
|
+
awaits: Awaits;
|
|
117
|
+
};
|
|
118
|
+
export type PendingResult = {
|
|
119
|
+
pending: readonly PendingRoom[];
|
|
120
|
+
};
|
|
121
|
+
export type DocumentRows = {
|
|
104
122
|
documents: readonly QueryDocument[];
|
|
105
123
|
};
|
|
106
|
-
export type
|
|
124
|
+
export type GroupRows = {
|
|
107
125
|
groups: readonly QueryGroup[];
|
|
108
126
|
};
|
|
109
|
-
export type
|
|
127
|
+
export type QueryRows = DocumentRows | GroupRows;
|
|
128
|
+
export type DocumentResult = DocumentRows & {
|
|
129
|
+
coverage: QueryCoverage;
|
|
130
|
+
};
|
|
131
|
+
export type GroupResult = GroupRows & {
|
|
132
|
+
coverage: QueryCoverage;
|
|
133
|
+
};
|
|
134
|
+
export type QueryResult = DocumentResult | GroupResult | PendingResult;
|
|
110
135
|
export type QueryErrorCode = 'invalid-query' | 'unknown-type' | 'unknown-field' | 'wrong-kind';
|
|
111
136
|
export type RoomFacts = {
|
|
112
137
|
locator: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReferrerScope } from './adapter.js';
|
|
2
|
-
import type { MdRuntime, RuntimeTopic } from './connection.js';
|
|
2
|
+
import type { MdRuntime, ReadinessPort, RuntimeTopic } from './connection.js';
|
|
3
3
|
import type { Plan, PlanReach, QueryResult } from './query.js';
|
|
4
|
+
import type { Readiness } from './readiness.js';
|
|
4
5
|
import type { SearchResult } from './search.js';
|
|
5
6
|
export type ReachedDocument = {
|
|
6
7
|
readonly room: string;
|
|
@@ -19,12 +20,15 @@ export type RuntimeView = {
|
|
|
19
20
|
};
|
|
20
21
|
export type NarrowedView = RuntimeView & {
|
|
21
22
|
narrow(reach: PortReach | null): void;
|
|
23
|
+
facts(port: ReadinessPort): void;
|
|
22
24
|
};
|
|
23
25
|
export type Reachable = RuntimeView & {
|
|
24
26
|
plan(input: unknown, reach: PortReach | null): Plan;
|
|
25
27
|
query(plan: Plan): Promise<QueryResult>;
|
|
26
28
|
watchPlan(plan: Plan, deliver: (message: unknown) => void): () => void;
|
|
27
29
|
search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
|
30
|
+
searching(target: string): void;
|
|
31
|
+
watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
|
|
28
32
|
referrerScope(referrer: unknown): ReferrerScope | null;
|
|
29
33
|
};
|
|
30
34
|
export declare function holds(reach: PortReach | null, room: string): boolean;
|
|
@@ -38,4 +42,4 @@ export declare function governs(reach: PortReach | null, room: {
|
|
|
38
42
|
readonly selection: boolean;
|
|
39
43
|
};
|
|
40
44
|
export declare function planReach(reach: PortReach | null): PlanReach | null;
|
|
41
|
-
export declare function narrowed(runtime: Reachable, given: PortReach | null): NarrowedView;
|
|
45
|
+
export declare function narrowed(runtime: Reachable, given: PortReach | null, told: ReadinessPort): NarrowedView;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
export type CodeAvailability = Open<'stored' | 'absent'>;
|
|
3
|
+
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'indexing' | 'refused' | 'unadmitted'>;
|
|
4
|
+
export type RoomCoverage = {
|
|
5
|
+
readonly room: string;
|
|
6
|
+
readonly state: RoomPreparation;
|
|
7
|
+
};
|
|
8
|
+
export type ConversationCoverage = Open<'complete' | 'acquiring' | 'indexing' | 'undeclared'>;
|
|
9
|
+
export type SearchObligation = Open<'required' | 'unused'>;
|
|
10
|
+
export type TargetCoverage = {
|
|
11
|
+
readonly complete: boolean;
|
|
12
|
+
readonly listed: boolean;
|
|
13
|
+
readonly rooms: readonly RoomCoverage[];
|
|
14
|
+
readonly conversations: ConversationCoverage;
|
|
15
|
+
readonly search: SearchObligation;
|
|
16
|
+
};
|
|
17
|
+
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
18
|
+
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
19
|
+
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
20
|
+
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
21
|
+
export type CapacityCause = {
|
|
22
|
+
readonly cause: Open<'insufficient-space' | 'quota-exceeded'>;
|
|
23
|
+
readonly needed: number | null;
|
|
24
|
+
readonly available: number | null;
|
|
25
|
+
};
|
|
26
|
+
export type RefusedRoom = {
|
|
27
|
+
readonly room: string;
|
|
28
|
+
readonly file: string;
|
|
29
|
+
readonly rule: string;
|
|
30
|
+
readonly location: string | null;
|
|
31
|
+
};
|
|
32
|
+
export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
|
|
33
|
+
export type Readiness = {
|
|
34
|
+
readonly status: ReadinessStatus;
|
|
35
|
+
readonly ready: boolean;
|
|
36
|
+
readonly usable: boolean;
|
|
37
|
+
readonly code: CodeAvailability;
|
|
38
|
+
readonly coverage: TargetCoverage;
|
|
39
|
+
readonly durability: Durability;
|
|
40
|
+
readonly persistence: Persistence;
|
|
41
|
+
readonly connection: ConnectionAvailability;
|
|
42
|
+
readonly house: HouseOutcome;
|
|
43
|
+
readonly capacity: CapacityCause | null;
|
|
44
|
+
readonly refused: readonly RefusedRoom[];
|
|
45
|
+
readonly lost: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
|
48
|
+
readonly coverage: Omit<TargetCoverage, 'complete'>;
|
|
49
|
+
readonly established: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare const SETTLED_ROOMS: ReadonlySet<string>;
|
|
52
|
+
export declare function readinessOf(facts: ReadinessFacts): Readiness;
|
|
@@ -31,7 +31,7 @@ type ReplayStep = {
|
|
|
31
31
|
export declare function compositionOf(record: ReplicaRecord): Composition;
|
|
32
32
|
export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
|
|
33
33
|
export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
|
|
34
|
-
export declare function readStaged(
|
|
34
|
+
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged;
|
|
35
35
|
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
|
|
36
36
|
kind: 'deferred';
|
|
37
37
|
};
|
package/dist/mdruntime/rows.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Frontmatter } from '../mdmodel/index.js';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
3
|
import type { BinaryFileRecord } from './binary.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
@@ -13,19 +13,10 @@ export type DocumentRow = {
|
|
|
13
13
|
values: Fields;
|
|
14
14
|
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
15
15
|
directories: readonly string[];
|
|
16
|
-
|
|
16
|
+
text: string | null;
|
|
17
17
|
change: HeadChange | null;
|
|
18
18
|
binary: BinaryFileRecord | null;
|
|
19
19
|
};
|
|
20
|
-
export type BodyRow = {
|
|
21
|
-
key: string;
|
|
22
|
-
kind: 'body';
|
|
23
|
-
room: string;
|
|
24
|
-
path: string;
|
|
25
|
-
preamble: string;
|
|
26
|
-
sections: Readonly<Record<string, string>>;
|
|
27
|
-
markdown: string;
|
|
28
|
-
};
|
|
29
20
|
export type ReferenceRow = {
|
|
30
21
|
key: string;
|
|
31
22
|
kind: 'reference';
|
|
@@ -37,9 +28,9 @@ export type ReferenceRow = {
|
|
|
37
28
|
path: string;
|
|
38
29
|
type: string;
|
|
39
30
|
};
|
|
40
|
-
export type Row = DocumentRow |
|
|
31
|
+
export type Row = DocumentRow | ReferenceRow;
|
|
41
32
|
export declare function documentKey(room: string, path: string): string;
|
|
42
33
|
export declare function roomOfKey(key: string): string;
|
|
43
34
|
export declare function markdownPath(path: string): boolean;
|
|
44
|
-
export declare function rowsOf(room: string, path: string, document:
|
|
35
|
+
export declare function rowsOf(room: string, path: string, document: Frontmatter | null, composition: Composition, change: HeadChange | null, binary: BinaryFileRecord | null): readonly Row[];
|
|
45
36
|
export {};
|
package/dist/mdruntime/save.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export type SaveInput = {
|
|
|
24
24
|
bases: readonly Precondition[];
|
|
25
25
|
queued?: ReadonlySet<string>;
|
|
26
26
|
writtenBy?: WrittenBy;
|
|
27
|
+
clean?: {
|
|
28
|
+
text: Readonly<Record<string, string>>;
|
|
29
|
+
binaries: Readonly<Record<string, unknown>>;
|
|
30
|
+
composition: Composition;
|
|
31
|
+
};
|
|
27
32
|
};
|
|
28
33
|
export type BatchResult = {
|
|
29
34
|
kind: 'batch';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChangeSet } from './change-set.js';
|
|
2
|
-
import { type Filter } from './query.js';
|
|
2
|
+
import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
|
|
3
3
|
import type { Open } from './open.js';
|
|
4
4
|
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
5
5
|
export type SearchRequest = {
|
|
@@ -21,10 +21,26 @@ export type MessageHit = {
|
|
|
21
21
|
score: number;
|
|
22
22
|
matches: Readonly<Record<string, readonly Open<'text'>[]>>;
|
|
23
23
|
};
|
|
24
|
-
export type
|
|
24
|
+
export type SearchCoverage = {
|
|
25
|
+
rooms: readonly CoveredRoom[];
|
|
26
|
+
conversations: readonly string[];
|
|
27
|
+
index: string;
|
|
28
|
+
overlay: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
export type PendingConversation = {
|
|
31
|
+
conversation: string;
|
|
32
|
+
awaits: 'index';
|
|
33
|
+
};
|
|
34
|
+
export type SearchPending = {
|
|
35
|
+
pending: readonly (PendingRoom | PendingConversation)[];
|
|
36
|
+
};
|
|
37
|
+
export type SearchHits = {
|
|
25
38
|
documents: readonly DocumentHit[];
|
|
26
39
|
messages: readonly MessageHit[];
|
|
27
40
|
};
|
|
41
|
+
export type SearchResult = (SearchHits & {
|
|
42
|
+
coverage: SearchCoverage;
|
|
43
|
+
}) | SearchPending;
|
|
28
44
|
export type SearchedDocument = {
|
|
29
45
|
room: string;
|
|
30
46
|
path: string;
|
|
@@ -39,10 +55,8 @@ export type SearchedMessage = {
|
|
|
39
55
|
text: string;
|
|
40
56
|
};
|
|
41
57
|
export type SearchSource = {
|
|
42
|
-
|
|
58
|
+
room(room: string): readonly string[];
|
|
43
59
|
document(room: string, path: string): SearchedDocument | null;
|
|
44
|
-
messages(): readonly SearchedMessage[];
|
|
45
|
-
message(conversation: string, identity: string): SearchedMessage | null;
|
|
46
60
|
};
|
|
47
61
|
export type SearchPlan = {
|
|
48
62
|
text: string;
|
|
@@ -51,11 +65,19 @@ export type SearchPlan = {
|
|
|
51
65
|
limit: number | null;
|
|
52
66
|
};
|
|
53
67
|
export type SearchIndex = {
|
|
68
|
+
generation(): string;
|
|
69
|
+
rooms(): ReadonlySet<string>;
|
|
70
|
+
conversations(): ReadonlySet<string>;
|
|
71
|
+
indexRoom(room: string): Promise<void>;
|
|
72
|
+
indexMessages(conversation: string, messages: readonly SearchedMessage[], whole: boolean): void;
|
|
73
|
+
forget(rooms: readonly string[]): void;
|
|
54
74
|
changed(set: ChangeSet): void;
|
|
75
|
+
changes(): number;
|
|
76
|
+
caughtUp(): Promise<void>;
|
|
55
77
|
search(plan: SearchPlan, documents: readonly {
|
|
56
78
|
room: string;
|
|
57
79
|
path: string;
|
|
58
|
-
}[] | null):
|
|
80
|
+
}[] | null, conversations: readonly string[]): SearchHits;
|
|
59
81
|
};
|
|
60
82
|
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
61
83
|
export declare function createSearchIndex(source: SearchSource): SearchIndex;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type Paths<V> = Readonly<Record<string, V>>;
|
|
2
|
+
type Weigh<V> = (key: string, value: V) => number;
|
|
3
|
+
export declare function shared<V>(map: Paths<V>): Paths<V>;
|
|
4
|
+
export declare function patched<V>(base: Paths<V>, set: Iterable<readonly [string, V]>, removed?: Iterable<string>): Paths<V>;
|
|
5
|
+
export declare function tally<V>(map: Paths<V>, weigh: Weigh<V>): number;
|
|
6
|
+
export declare function sizeOf<V>(map: Paths<V>): number;
|
|
7
|
+
export declare function differing<V>(left: Paths<V>, right: Paths<V>, same?: (left: V, right: V) => boolean): ReadonlySet<string>;
|
|
8
|
+
export declare function drafted<V>(base: Paths<V>): Record<string, V>;
|
|
9
|
+
export declare function settled<V>(draft: Record<string, V>): Paths<V>;
|
|
10
|
+
export {};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
2
3
|
import type { ReturnReason } from './room-draft.js';
|
|
3
4
|
export type AttentionEntry = {
|
|
4
5
|
room: string;
|
|
5
6
|
path: string;
|
|
6
7
|
returned: ReturnReason;
|
|
8
|
+
} | {
|
|
9
|
+
room: string;
|
|
10
|
+
refusal: ProviderRefusal;
|
|
7
11
|
};
|
|
8
12
|
export type SyncStatus = {
|
|
9
13
|
state: Open<'pending' | 'syncing' | 'synced'>;
|
|
@@ -6,7 +6,7 @@ import { type HeldBinary } from './overlay.js';
|
|
|
6
6
|
import type { ChatDraftFile } from './file.js';
|
|
7
7
|
import type { Submission } from './outcome.js';
|
|
8
8
|
import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
9
|
-
export declare const STORE_SCHEMA =
|
|
9
|
+
export declare const STORE_SCHEMA = 25;
|
|
10
10
|
export declare const AUTHORED_SCHEMA = 2;
|
|
11
11
|
export type ReplicaRecord = {
|
|
12
12
|
locator: string;
|
|
@@ -46,6 +46,10 @@ export type PendingState = {
|
|
|
46
46
|
readonly upload?: unknown;
|
|
47
47
|
readonly accepted?: string;
|
|
48
48
|
};
|
|
49
|
+
export type TargetRecord = {
|
|
50
|
+
established: boolean;
|
|
51
|
+
search: boolean;
|
|
52
|
+
};
|
|
49
53
|
export type QueueRecord = {
|
|
50
54
|
locator: string;
|
|
51
55
|
pending: readonly {
|
|
@@ -60,12 +64,15 @@ export type PresentationRecord = {
|
|
|
60
64
|
export type HeldConversation = {
|
|
61
65
|
conversation: string;
|
|
62
66
|
read: string | null | undefined;
|
|
63
|
-
|
|
67
|
+
partial: boolean;
|
|
64
68
|
};
|
|
65
69
|
export type ConversationWrite = {
|
|
66
70
|
conversation: string;
|
|
67
71
|
messages: readonly AcceptedMessage[];
|
|
68
|
-
read?:
|
|
72
|
+
read?: {
|
|
73
|
+
at: string | null;
|
|
74
|
+
partial: boolean;
|
|
75
|
+
};
|
|
69
76
|
};
|
|
70
77
|
export type ChatSubmission = {
|
|
71
78
|
readonly operation: string;
|
|
@@ -104,6 +111,8 @@ export type RuntimeStore = {
|
|
|
104
111
|
declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
|
|
105
112
|
member(): Promise<Member | null>;
|
|
106
113
|
keepMember(member: Member | null): Promise<void>;
|
|
114
|
+
targets(): Promise<Readonly<Record<string, TargetRecord>>>;
|
|
115
|
+
keepTargets(targets: Readonly<Record<string, TargetRecord>>): Promise<void>;
|
|
107
116
|
queues(): Promise<readonly QueueRecord[]>;
|
|
108
117
|
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
109
118
|
accept(locator: string, id: string, roomVersion: string): Promise<void>;
|
|
@@ -113,6 +122,10 @@ export type RuntimeStore = {
|
|
|
113
122
|
present(record: PresentationRecord): Promise<void>;
|
|
114
123
|
conversations(): Promise<readonly HeldConversation[]>;
|
|
115
124
|
keepMessages(write: ConversationWrite): Promise<void>;
|
|
125
|
+
messageWindow(conversation: string, limit: number | undefined): Promise<AcceptedMessage[]>;
|
|
126
|
+
messagesAfter(conversation: string, identity: string | null): Promise<AcceptedMessage[]>;
|
|
127
|
+
messageIdentities(conversation: string): Promise<readonly string[]>;
|
|
128
|
+
turnArrived(conversation: string, turn: string): Promise<boolean>;
|
|
116
129
|
dropConversations(conversations: readonly string[]): Promise<void>;
|
|
117
130
|
chatDrafts(): Promise<readonly ChatDraftRecord[]>;
|
|
118
131
|
keepChatDraft(record: ChatDraftRecord): Promise<void>;
|
|
@@ -142,4 +155,5 @@ export declare function authoredBy(holder: string): Promise<boolean>;
|
|
|
142
155
|
export declare function authoredBinding(): Promise<string | null>;
|
|
143
156
|
export declare function bindAuthored(binding: string): Promise<void>;
|
|
144
157
|
export declare function removeRuntimeStore(holder?: string): Promise<boolean>;
|
|
158
|
+
export declare function openDatabase(name: string, version: number, upgrade: (opening: IDBOpenDBRequest, oldVersion: number) => void): Promise<IDBDatabase>;
|
|
145
159
|
export declare function openRuntimeStore(fenced: (locator: string) => boolean): Promise<RuntimeStore>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function yielded(): Promise<void>;
|
|
2
|
+
export declare const ROW_WEIGHT = 256;
|
|
3
|
+
export type Later<T> = T | Promise<T>;
|
|
4
|
+
export declare function after<T, R>(value: Later<T>, next: (value: T) => R): Later<R>;
|
|
5
|
+
export declare function inUnits<T>(items: Iterable<T>, each: (item: T) => number): Later<void>;
|
|
6
|
+
export declare function inChunks<T>(items: readonly T[], weigh: (item: T) => number, each: (chunk: readonly T[]) => void): Promise<void>;
|
package/dist/mdruntime/wire.d.ts
CHANGED
|
@@ -8,40 +8,140 @@ export type RuntimePort = {
|
|
|
8
8
|
start(): void;
|
|
9
9
|
};
|
|
10
10
|
export type WireReach = 'within' | 'app' | 'runtime' | 'actions' | 'whole';
|
|
11
|
+
export type WireEffect = 'read' | 'write' | 'action';
|
|
12
|
+
export type WireCall = {
|
|
13
|
+
readonly reach: WireReach;
|
|
14
|
+
readonly effect: WireEffect;
|
|
15
|
+
};
|
|
11
16
|
declare const MEMBERS: {
|
|
12
|
-
readonly rooms:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
readonly
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
readonly
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
readonly
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
readonly '
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
readonly '
|
|
41
|
-
|
|
17
|
+
readonly rooms: {
|
|
18
|
+
readonly reach: 'within';
|
|
19
|
+
readonly effect: 'read';
|
|
20
|
+
};
|
|
21
|
+
readonly query: {
|
|
22
|
+
readonly reach: 'within';
|
|
23
|
+
readonly effect: 'read';
|
|
24
|
+
};
|
|
25
|
+
readonly search: {
|
|
26
|
+
readonly reach: 'within';
|
|
27
|
+
readonly effect: 'read';
|
|
28
|
+
};
|
|
29
|
+
readonly types: {
|
|
30
|
+
readonly reach: 'within';
|
|
31
|
+
readonly effect: 'read';
|
|
32
|
+
};
|
|
33
|
+
readonly save: {
|
|
34
|
+
readonly reach: 'within';
|
|
35
|
+
readonly effect: 'write';
|
|
36
|
+
};
|
|
37
|
+
readonly history: {
|
|
38
|
+
readonly reach: 'within';
|
|
39
|
+
readonly effect: 'read';
|
|
40
|
+
};
|
|
41
|
+
readonly 'binaryFile.read': {
|
|
42
|
+
readonly reach: 'within';
|
|
43
|
+
readonly effect: 'read';
|
|
44
|
+
};
|
|
45
|
+
readonly 'binaryFile.readReference': {
|
|
46
|
+
readonly reach: 'within';
|
|
47
|
+
readonly effect: 'read';
|
|
48
|
+
};
|
|
49
|
+
readonly call: {
|
|
50
|
+
readonly reach: 'actions';
|
|
51
|
+
readonly effect: 'action';
|
|
52
|
+
};
|
|
53
|
+
readonly reached: {
|
|
54
|
+
readonly reach: 'within';
|
|
55
|
+
readonly effect: 'read';
|
|
56
|
+
};
|
|
57
|
+
readonly log: {
|
|
58
|
+
readonly reach: 'whole';
|
|
59
|
+
readonly effect: 'read';
|
|
60
|
+
};
|
|
61
|
+
readonly persistence: {
|
|
62
|
+
readonly reach: 'runtime';
|
|
63
|
+
readonly effect: 'read';
|
|
64
|
+
};
|
|
65
|
+
readonly retry: {
|
|
66
|
+
readonly reach: 'runtime';
|
|
67
|
+
readonly effect: 'write';
|
|
68
|
+
};
|
|
69
|
+
readonly reauthorize: {
|
|
70
|
+
readonly reach: 'runtime';
|
|
71
|
+
readonly effect: 'write';
|
|
72
|
+
};
|
|
73
|
+
readonly 'roomDraft.list': {
|
|
74
|
+
readonly reach: 'within';
|
|
75
|
+
readonly effect: 'read';
|
|
76
|
+
};
|
|
77
|
+
readonly 'roomDraft.read': {
|
|
78
|
+
readonly reach: 'within';
|
|
79
|
+
readonly effect: 'read';
|
|
80
|
+
};
|
|
81
|
+
readonly 'roomDraft.write': {
|
|
82
|
+
readonly reach: 'within';
|
|
83
|
+
readonly effect: 'write';
|
|
84
|
+
};
|
|
85
|
+
readonly 'roomDraft.discard': {
|
|
86
|
+
readonly reach: 'within';
|
|
87
|
+
readonly effect: 'write';
|
|
88
|
+
};
|
|
89
|
+
readonly 'presentation.read': {
|
|
90
|
+
readonly reach: 'app';
|
|
91
|
+
readonly effect: 'read';
|
|
92
|
+
};
|
|
93
|
+
readonly 'presentation.write': {
|
|
94
|
+
readonly reach: 'app';
|
|
95
|
+
readonly effect: 'write';
|
|
96
|
+
};
|
|
97
|
+
readonly 'conversation.list': {
|
|
98
|
+
readonly reach: 'within';
|
|
99
|
+
readonly effect: 'read';
|
|
100
|
+
};
|
|
101
|
+
readonly 'conversation.read': {
|
|
102
|
+
readonly reach: 'within';
|
|
103
|
+
readonly effect: 'read';
|
|
104
|
+
};
|
|
105
|
+
readonly 'conversation.create': {
|
|
106
|
+
readonly reach: 'within';
|
|
107
|
+
readonly effect: 'action';
|
|
108
|
+
};
|
|
109
|
+
readonly 'conversation.send': {
|
|
110
|
+
readonly reach: 'within';
|
|
111
|
+
readonly effect: 'action';
|
|
112
|
+
};
|
|
113
|
+
readonly 'conversation.answer': {
|
|
114
|
+
readonly reach: 'within';
|
|
115
|
+
readonly effect: 'action';
|
|
116
|
+
};
|
|
117
|
+
readonly 'conversation.interrupt': {
|
|
118
|
+
readonly reach: 'within';
|
|
119
|
+
readonly effect: 'action';
|
|
120
|
+
};
|
|
121
|
+
readonly 'conversation.kill': {
|
|
122
|
+
readonly reach: 'within';
|
|
123
|
+
readonly effect: 'action';
|
|
124
|
+
};
|
|
125
|
+
readonly 'conversation.cancel': {
|
|
126
|
+
readonly reach: 'within';
|
|
127
|
+
readonly effect: 'action';
|
|
128
|
+
};
|
|
129
|
+
readonly 'conversation.delete': {
|
|
130
|
+
readonly reach: 'within';
|
|
131
|
+
readonly effect: 'action';
|
|
132
|
+
};
|
|
133
|
+
readonly 'chatDraft.write': {
|
|
134
|
+
readonly reach: 'within';
|
|
135
|
+
readonly effect: 'write';
|
|
136
|
+
};
|
|
137
|
+
readonly 'chatDraft.discard': {
|
|
138
|
+
readonly reach: 'within';
|
|
139
|
+
readonly effect: 'write';
|
|
140
|
+
};
|
|
42
141
|
};
|
|
43
142
|
declare const TOPICS: {
|
|
44
143
|
readonly rooms: 'within';
|
|
144
|
+
readonly readiness: 'within';
|
|
45
145
|
readonly 'connection-refusal': 'runtime';
|
|
46
146
|
readonly 'storage-loss': 'runtime';
|
|
47
147
|
readonly 'deployment-facts': 'runtime';
|
|
@@ -56,8 +156,8 @@ declare const TOPICS: {
|
|
|
56
156
|
readonly conversations: 'within';
|
|
57
157
|
readonly agents: 'within';
|
|
58
158
|
};
|
|
59
|
-
export declare const
|
|
60
|
-
readonly members: Readonly<Record<string,
|
|
159
|
+
export declare const WIRE: {
|
|
160
|
+
readonly members: Readonly<Record<string, WireCall>>;
|
|
61
161
|
readonly topics: Readonly<Record<string, WireReach>>;
|
|
62
162
|
};
|
|
63
163
|
export type WireMember = keyof typeof MEMBERS;
|
|
@@ -95,6 +195,10 @@ export type WireAnswer = {
|
|
|
95
195
|
} | {
|
|
96
196
|
kind: 'ended';
|
|
97
197
|
};
|
|
198
|
+
export declare function unanswered(call: {
|
|
199
|
+
readonly id: number;
|
|
200
|
+
readonly member: WireMember;
|
|
201
|
+
}): WireAnswer | null;
|
|
98
202
|
export declare const AUTHORIZATION_ENDED = "the host authorization ended";
|
|
99
203
|
export declare const PORT_CLOSED = "the port closed";
|
|
100
204
|
export declare function request(message: unknown): WireRequest | null;
|
package/dist/test-host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from './mdruntime/client.js';
|
|
2
|
-
import type { HouseAnalyticsChoice, HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab } from './index.js';
|
|
2
|
+
import type { HouseActivation, HouseAnalyticsChoice, HouseAppMessage, HouseExternalAnswer, HouseExternalRequest, HouseNavigationMode, HouseRefusal, HouseSourceDownload, HouseSourceTop, HouseStatus, HouseTab, HouseTask } from './index.js';
|
|
3
3
|
export interface HouseBridgeNavigation {
|
|
4
4
|
readonly mode: HouseNavigationMode;
|
|
5
5
|
readonly address: string;
|
|
@@ -15,6 +15,9 @@ export interface HouseBridgeTestHost {
|
|
|
15
15
|
publish(status: HouseStatus): void;
|
|
16
16
|
message(message: HouseAppMessage): void;
|
|
17
17
|
attachRuntime(runtime: MdRuntimeClient): void;
|
|
18
|
+
checkpoint(): Promise<HouseTask>;
|
|
19
|
+
restore(task: HouseTask | null): Promise<boolean>;
|
|
20
|
+
settle(activation: HouseActivation): void;
|
|
18
21
|
}
|
|
19
22
|
export interface HouseBridgeTestHostOptions {
|
|
20
23
|
readonly address?: string;
|
package/dist/test-host.js
CHANGED
|
@@ -57,6 +57,7 @@ export function createHouseBridgeTestHost(options = {}) {
|
|
|
57
57
|
let published = options.status ?? null;
|
|
58
58
|
let shown = null;
|
|
59
59
|
let seen = null;
|
|
60
|
+
let cooperation = null;
|
|
60
61
|
let attached = () => { };
|
|
61
62
|
const runtime = new Promise((resolve) => {
|
|
62
63
|
attached = resolve;
|
|
@@ -144,7 +145,19 @@ export function createHouseBridgeTestHost(options = {}) {
|
|
|
144
145
|
consents.push(choice);
|
|
145
146
|
publish({ ...published, analytics: { measures: true, choice } });
|
|
146
147
|
},
|
|
148
|
+
cooperate(given) {
|
|
149
|
+
cooperation = given;
|
|
150
|
+
return () => {
|
|
151
|
+
if (cooperation === given)
|
|
152
|
+
cooperation = null;
|
|
153
|
+
};
|
|
154
|
+
},
|
|
147
155
|
};
|
|
156
|
+
function cooperating() {
|
|
157
|
+
if (cooperation === null)
|
|
158
|
+
throw new Error('the App registered no cooperation');
|
|
159
|
+
return cooperation;
|
|
160
|
+
}
|
|
148
161
|
Object.defineProperty(globalThis, 'houseBridge', { value: bridge, configurable: true });
|
|
149
162
|
if (published !== null)
|
|
150
163
|
publish(published);
|
|
@@ -169,5 +182,19 @@ export function createHouseBridgeTestHost(options = {}) {
|
|
|
169
182
|
attachRuntime(client) {
|
|
170
183
|
attached(client);
|
|
171
184
|
},
|
|
185
|
+
async checkpoint() {
|
|
186
|
+
const held = cooperating();
|
|
187
|
+
await held.checkpoint();
|
|
188
|
+
await held.persist();
|
|
189
|
+
return JSON.parse(JSON.stringify((await held.capture()) ?? null));
|
|
190
|
+
},
|
|
191
|
+
async restore(task) {
|
|
192
|
+
const held = cooperating();
|
|
193
|
+
await held.restore(task);
|
|
194
|
+
return (await held.ready()) === true;
|
|
195
|
+
},
|
|
196
|
+
settle(activation) {
|
|
197
|
+
cooperating().settle(activation);
|
|
198
|
+
},
|
|
172
199
|
};
|
|
173
200
|
}
|
package/docs/families.md
CHANGED
|
@@ -45,6 +45,15 @@
|
|
|
45
45
|
The App reports the visitor's choice with `analyticsConsent('accept')` or
|
|
46
46
|
`analyticsConsent('decline')`; the shell hands it to House's analytics loader, and
|
|
47
47
|
the choice never reaches House.
|
|
48
|
+
- **Handoff** - when House hands its runtime over to a newer build, the App keeps
|
|
49
|
+
running, its `runtime` client and observations included: a call it makes
|
|
50
|
+
meanwhile waits for the newer runtime, however long that takes, and is
|
|
51
|
+
answered once, by it; each observation goes on with the newer runtime's
|
|
52
|
+
values; and the status and the address arrive again. A runtime that ended
|
|
53
|
+
before answering has its reads answered by the next one; since it may have
|
|
54
|
+
applied any other call, an act on House is answered the outcome
|
|
55
|
+
`transport-uncertainty`, and every other call, a Save or a draft write among
|
|
56
|
+
them, fails with the retryable code `transport-uncertainty`.
|
|
48
57
|
- **Site image read** - given a Published Room and an original attachment
|
|
49
58
|
reference, it answers the web copy's path and metadata, or `null` when no
|
|
50
59
|
copy exists. The original bytes never cross this bridge at a Site.
|
|
@@ -84,6 +93,30 @@
|
|
|
84
93
|
after its latest release, as a JPEG `Blob`, or `null` when House holds none
|
|
85
94
|
or does not answer. A Site's own renderer reads none.
|
|
86
95
|
|
|
96
|
+
- **Cooperation** - `cooperate({ checkpoint, persist, capture, restore,
|
|
97
|
+
ready, settle })` lets House activate a newer release of the App while it
|
|
98
|
+
runs, keeping the User's task; the function it returns withdraws it.
|
|
99
|
+
Register it in the entry script, before the first draw, or House treats the
|
|
100
|
+
page as not cooperating and the newer release waits for the App's next
|
|
101
|
+
open. When a newer release is stored, House calls `checkpoint()`, which
|
|
102
|
+
resolves at the App's next safe checkpoint and may never resolve, then
|
|
103
|
+
`persist()`, which makes authored work durable, then `capture()`, which
|
|
104
|
+
answers the meaningful task the App owns, such as the selected record,
|
|
105
|
+
filters, cursor, selection and scroll position, as JSON of at most 65,536
|
|
106
|
+
characters; House keeps the address itself. In the newer release House
|
|
107
|
+
calls `restore(task)`, or `restore(null)` when it opens the release without
|
|
108
|
+
a task, then `ready()`, the App's own check that its local data and
|
|
109
|
+
capabilities work, and finally `settle('committed')` once the release is
|
|
110
|
+
active or `settle('abandoned')` when House returns to the release before
|
|
111
|
+
it, restoring the same task there. A release House opens already active is
|
|
112
|
+
settled `'committed'` at once, after `restore(task)` when House hands it a
|
|
113
|
+
task, and a cooperation registered after House settled is settled at its
|
|
114
|
+
registration. Until `settle('committed')` House fails the release's outside
|
|
115
|
+
calls at once, as offline, those of the workers it starts included, and
|
|
116
|
+
refuses its Saves, write acts and external calls with the retryable code
|
|
117
|
+
`house_trial_withheld`, so a start-up effect is not repeated; run start-up
|
|
118
|
+
effects after `settle('committed')`.
|
|
119
|
+
|
|
87
120
|
## The test host
|
|
88
121
|
|
|
89
122
|
`createHouseBridgeTestHost(options)` plays House in one page: it installs a
|
|
@@ -106,4 +139,7 @@ given by Site identifier, answers every `install()` `'manual'`, as a browser
|
|
|
106
139
|
with no install prompt does, answers every `notifications()` `'unavailable'`,
|
|
107
140
|
as a browser without push does, settles every `setBadge`, delivers each App
|
|
108
141
|
message `message({ from, body })` plays, and hands `bridge.runtime` the MD
|
|
109
|
-
Runtime client `attachRuntime(client)` gives it.
|
|
142
|
+
Runtime client `attachRuntime(client)` gives it. `checkpoint()` runs the
|
|
143
|
+
registered cooperation's checkpoint, persist and capture and answers the task,
|
|
144
|
+
`restore(task)` runs its restore and answers its readiness check, and
|
|
145
|
+
`settle(activation)` hands it the outcome.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/app-bridge",
|
|
3
|
-
"version": "0.1.0-
|
|
3
|
+
"version": "0.1.0-cdb88c540d78b",
|
|
4
4
|
"description": "Types of the agents.house App bridge House hands every App: navigation, the tab title and icon, ceremonies, installation, notifications and the icon badge, status, Site image reads, App release code, App and Site screenshot reads, and App messages, with an accessor and an in-page test host.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|