@agentshouse/app-bridge 0.1.0-c58a055eeaa71 → 0.1.0-c59dd0a694516
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 +620 -14
- package/dist/mdmodel/body.d.ts +84 -0
- package/dist/mdmodel/built-in.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 +21 -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 +865 -0
- package/dist/mdmodel/house-references/crockford.d.ts +3 -0
- package/dist/mdmodel/house-references/patterns.d.ts +8 -0
- package/dist/mdmodel/index.d.ts +43 -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/not-ready.d.ts +1 -0
- package/dist/mdmodel/paths.d.ts +39 -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 +172 -0
- package/dist/mdmodel/validate.d.ts +37 -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 +575 -0
- package/dist/mdruntime/attached-model.d.ts +6 -0
- package/dist/mdruntime/authored.d.ts +87 -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 +123 -0
- package/dist/mdruntime/client.d.ts +98 -0
- package/dist/mdruntime/collection.d.ts +49 -0
- package/dist/mdruntime/compile.d.ts +17 -0
- package/dist/mdruntime/conversation-live.d.ts +149 -0
- package/dist/mdruntime/conversation-row.d.ts +39 -0
- package/dist/mdruntime/conversation.d.ts +136 -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/install.d.ts +59 -0
- package/dist/mdruntime/listing.d.ts +51 -0
- package/dist/mdruntime/live.d.ts +24 -0
- package/dist/mdruntime/media.d.ts +12 -0
- package/dist/mdruntime/messages.d.ts +57 -0
- package/dist/mdruntime/model.d.ts +54 -0
- package/dist/mdruntime/observation.d.ts +59 -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 +40 -0
- package/dist/mdruntime/presence.d.ts +57 -0
- package/dist/mdruntime/query.d.ts +87 -0
- package/dist/mdruntime/reach.d.ts +54 -0
- package/dist/mdruntime/readiness.d.ts +54 -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 +197 -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 +58 -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 +10 -0
- package/dist/mdruntime/store/records.d.ts +222 -0
- package/dist/mdruntime/store/room-held.d.ts +7 -0
- package/dist/mdruntime/store/rooms-shown.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 +125 -0
- package/dist/mdruntime/stored.d.ts +166 -0
- package/dist/mdruntime/surface.d.ts +89 -0
- package/dist/mdruntime/tables.d.ts +375 -0
- package/dist/mdruntime/tallies.d.ts +17 -0
- package/dist/mdruntime/transfer.d.ts +4 -0
- package/dist/mdruntime/wire.d.ts +288 -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 +15 -5
- package/dist/test-host.js +74 -23
- package/docs/families.md +93 -22
- package/package.json +8 -6
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { type ApplyResult, type Definition, type DefinitionOf, type Document } from '../mdmodel/index.js';
|
|
2
|
+
import type { HeadChange, ProviderRefusal } from './adapter.js';
|
|
3
|
+
import type { Open } from './open.js';
|
|
4
|
+
import type { Change, PartChange, Precondition } from './change.js';
|
|
5
|
+
import type { VisibleLayer } from './replica.js';
|
|
6
|
+
export type FieldValue = {
|
|
7
|
+
readonly value: unknown;
|
|
8
|
+
} | null;
|
|
9
|
+
export type RoomDraftCreation = {
|
|
10
|
+
readonly type: string;
|
|
11
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
12
|
+
readonly sections: Readonly<Record<string, string>>;
|
|
13
|
+
} | {
|
|
14
|
+
readonly markdown: string;
|
|
15
|
+
};
|
|
16
|
+
export type RoomDraftParts = {
|
|
17
|
+
readonly fields?: Readonly<Record<string, {
|
|
18
|
+
readonly value: unknown;
|
|
19
|
+
readonly base?: FieldValue;
|
|
20
|
+
}>>;
|
|
21
|
+
readonly sections?: Readonly<Record<string, {
|
|
22
|
+
readonly value: string;
|
|
23
|
+
readonly base?: string;
|
|
24
|
+
}>>;
|
|
25
|
+
readonly preamble?: {
|
|
26
|
+
readonly value: string;
|
|
27
|
+
readonly base?: string;
|
|
28
|
+
};
|
|
29
|
+
readonly markdown?: {
|
|
30
|
+
readonly value: string;
|
|
31
|
+
readonly base?: string;
|
|
32
|
+
};
|
|
33
|
+
readonly creation?: RoomDraftCreation;
|
|
34
|
+
readonly move?: {
|
|
35
|
+
readonly to: string;
|
|
36
|
+
readonly room?: string;
|
|
37
|
+
readonly base?: string | null;
|
|
38
|
+
};
|
|
39
|
+
readonly removal?: {
|
|
40
|
+
readonly base?: string | null;
|
|
41
|
+
};
|
|
42
|
+
readonly file?: {
|
|
43
|
+
readonly blob: Blob;
|
|
44
|
+
readonly base?: string | null;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type HeldFile = {
|
|
48
|
+
readonly localId: string;
|
|
49
|
+
readonly name?: string;
|
|
50
|
+
readonly byteLength: number;
|
|
51
|
+
readonly mediaType: string;
|
|
52
|
+
readonly sha256: string;
|
|
53
|
+
readonly base: string | null;
|
|
54
|
+
};
|
|
55
|
+
type HeldParts = {
|
|
56
|
+
readonly fields?: Readonly<Record<string, {
|
|
57
|
+
readonly value: unknown;
|
|
58
|
+
readonly base: FieldValue;
|
|
59
|
+
}>>;
|
|
60
|
+
readonly sections?: Readonly<Record<string, {
|
|
61
|
+
readonly value: string;
|
|
62
|
+
readonly base: string;
|
|
63
|
+
}>>;
|
|
64
|
+
readonly preamble?: {
|
|
65
|
+
readonly value: string;
|
|
66
|
+
readonly base: string;
|
|
67
|
+
};
|
|
68
|
+
readonly markdown?: {
|
|
69
|
+
readonly value: string;
|
|
70
|
+
readonly base: string;
|
|
71
|
+
};
|
|
72
|
+
readonly creation?: RoomDraftCreation;
|
|
73
|
+
readonly move?: {
|
|
74
|
+
readonly to: string;
|
|
75
|
+
readonly room?: string;
|
|
76
|
+
readonly base: string | null;
|
|
77
|
+
};
|
|
78
|
+
readonly removal?: {
|
|
79
|
+
readonly base: string | null;
|
|
80
|
+
};
|
|
81
|
+
readonly file?: HeldFile;
|
|
82
|
+
};
|
|
83
|
+
type ChangedUnderneath = {
|
|
84
|
+
readonly fields?: Readonly<Record<string, FieldValue>>;
|
|
85
|
+
readonly sections?: Readonly<Record<string, string | null>>;
|
|
86
|
+
readonly preamble?: string | null;
|
|
87
|
+
readonly markdown?: string | null;
|
|
88
|
+
readonly creation?: string;
|
|
89
|
+
readonly move?: string | null;
|
|
90
|
+
readonly removal?: string | null;
|
|
91
|
+
readonly file?: string | null;
|
|
92
|
+
};
|
|
93
|
+
export type ReturnReason = ProviderRefusal & {
|
|
94
|
+
readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
|
|
95
|
+
};
|
|
96
|
+
export declare function returnedBy(): ReturnReason;
|
|
97
|
+
type Mark = {
|
|
98
|
+
readonly change: HeadChange | null;
|
|
99
|
+
};
|
|
100
|
+
export type Marks = {
|
|
101
|
+
readonly fields?: Readonly<Record<string, Mark & {
|
|
102
|
+
readonly current: FieldValue;
|
|
103
|
+
}>>;
|
|
104
|
+
readonly sections?: Readonly<Record<string, Mark>>;
|
|
105
|
+
readonly preamble?: Mark;
|
|
106
|
+
readonly markdown?: Mark;
|
|
107
|
+
readonly file?: Mark & {
|
|
108
|
+
readonly current: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type RoomDraft = {
|
|
112
|
+
readonly room: string;
|
|
113
|
+
readonly path: string;
|
|
114
|
+
readonly revision: string;
|
|
115
|
+
readonly parts: HeldParts;
|
|
116
|
+
readonly changedUnderneath: ChangedUnderneath;
|
|
117
|
+
readonly marks: Marks;
|
|
118
|
+
readonly returned: ReturnReason | null;
|
|
119
|
+
};
|
|
120
|
+
export type RoomDraftWrite = {
|
|
121
|
+
readonly outcome: 'written';
|
|
122
|
+
readonly roomDraft: RoomDraft | null;
|
|
123
|
+
} | {
|
|
124
|
+
readonly outcome: 'stale';
|
|
125
|
+
readonly current: RoomDraft | null;
|
|
126
|
+
};
|
|
127
|
+
export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
|
|
128
|
+
export type ChangedPart = {
|
|
129
|
+
readonly path: string;
|
|
130
|
+
readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
|
|
131
|
+
readonly name?: string;
|
|
132
|
+
};
|
|
133
|
+
export type RoomDraftRecord = {
|
|
134
|
+
readonly locator: string;
|
|
135
|
+
readonly path: string;
|
|
136
|
+
readonly revision: string;
|
|
137
|
+
readonly parts: HeldParts;
|
|
138
|
+
readonly marks: Marks;
|
|
139
|
+
readonly returned: ReturnReason | null;
|
|
140
|
+
};
|
|
141
|
+
export type SavedDraft = {
|
|
142
|
+
readonly path: string;
|
|
143
|
+
readonly parts: HeldParts;
|
|
144
|
+
};
|
|
145
|
+
export declare function readParts(value: unknown, path: string): RoomDraftParts;
|
|
146
|
+
export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
|
|
147
|
+
export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
|
|
148
|
+
export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
|
|
149
|
+
export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
|
|
150
|
+
export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
|
|
151
|
+
export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
|
|
152
|
+
export declare function marksOver(kept: Marks, under: Marks): Marks;
|
|
153
|
+
export declare function heldMarks(marks: Marks, parts: HeldParts): Marks;
|
|
154
|
+
export declare function partsBetween(path: string, before: Document, after: Document): PartChange[];
|
|
155
|
+
export declare function applyParts(document: Document, changes: readonly Change[], definition: Definition | undefined): ApplyResult;
|
|
156
|
+
type Joined = {
|
|
157
|
+
readonly parts: HeldParts;
|
|
158
|
+
readonly marks: Marks;
|
|
159
|
+
};
|
|
160
|
+
export declare function joinedOver(parts: HeldParts, marks: Marks, path: string, visible: VisibleLayer): Joined | null;
|
|
161
|
+
export declare function lineEnded(text: string): string;
|
|
162
|
+
export type TextParts = {
|
|
163
|
+
readonly fields?: Readonly<Record<string, {
|
|
164
|
+
readonly value: unknown;
|
|
165
|
+
}>>;
|
|
166
|
+
readonly sections?: Readonly<Record<string, {
|
|
167
|
+
readonly value: string;
|
|
168
|
+
}>>;
|
|
169
|
+
readonly preamble?: {
|
|
170
|
+
readonly value: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export declare function partsAfter(markdown: string, parts: TextParts, definitions?: DefinitionOf): string | null;
|
|
174
|
+
export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts, definitions?: DefinitionOf): HeldParts | null;
|
|
175
|
+
export declare function moveTarget(move: {
|
|
176
|
+
readonly to: string;
|
|
177
|
+
}): string;
|
|
178
|
+
export declare function readSavedParts(named: readonly {
|
|
179
|
+
readonly path: string;
|
|
180
|
+
readonly parts: unknown;
|
|
181
|
+
}[]): readonly {
|
|
182
|
+
readonly path: string;
|
|
183
|
+
readonly parts: RoomDraftParts;
|
|
184
|
+
}[];
|
|
185
|
+
export declare function partsChanges(named: readonly {
|
|
186
|
+
readonly path: string;
|
|
187
|
+
readonly parts: unknown;
|
|
188
|
+
}[]): {
|
|
189
|
+
readonly changes: readonly Change[];
|
|
190
|
+
readonly preconditions: readonly Precondition[];
|
|
191
|
+
};
|
|
192
|
+
export declare function changesOf(path: string, parts: HeldParts): {
|
|
193
|
+
changes: readonly Change[];
|
|
194
|
+
bases: readonly Precondition[];
|
|
195
|
+
};
|
|
196
|
+
export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
|
|
197
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ChangeSet } from './change-set.js';
|
|
2
|
+
import { type VisibleLayer } from './replica.js';
|
|
3
|
+
import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { Store } from './store.js';
|
|
6
|
+
export type RoomDraftSurface = {
|
|
7
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
8
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
9
|
+
write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
|
|
10
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
11
|
+
};
|
|
12
|
+
export type PresentationSurface = {
|
|
13
|
+
read(app: string): Promise<unknown>;
|
|
14
|
+
write(app: string, value: unknown): Promise<void>;
|
|
15
|
+
edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
16
|
+
};
|
|
17
|
+
export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
|
|
18
|
+
export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
|
|
19
|
+
export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
|
|
20
|
+
export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
|
|
21
|
+
export declare function presentationSurface(runtime: Runtime): PresentationSurface;
|
|
22
|
+
export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
|
|
23
|
+
export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RoomDeclaration, TypedPath } from './adapter.js';
|
|
2
|
+
import type { RuntimeShell } from './durability.js';
|
|
3
|
+
import type { LiveConversations } from './conversation-live.js';
|
|
4
|
+
import type { WriteRule } from './declaration.js';
|
|
5
|
+
import type { FiguresRead } from './figures.js';
|
|
6
|
+
import type { LiveQueries } from './live.js';
|
|
7
|
+
import type { ModelState } from './model.js';
|
|
8
|
+
import type { Presence } from './presence.js';
|
|
9
|
+
import type { ReadAnswers } from './reads.js';
|
|
10
|
+
import type { Recovery } from './recovery.js';
|
|
11
|
+
import type { Retries } from './retried.js';
|
|
12
|
+
import type { RuntimeSocket } from './socket.js';
|
|
13
|
+
import type { HeldCover, Store } from './store.js';
|
|
14
|
+
import type { schemaTypes } from './attached-model.js';
|
|
15
|
+
export type Runtime = {
|
|
16
|
+
readonly store: Store;
|
|
17
|
+
readonly socket: RuntimeSocket;
|
|
18
|
+
readonly presence: Presence;
|
|
19
|
+
readonly recovery: Recovery;
|
|
20
|
+
readonly retries: Retries;
|
|
21
|
+
readonly shell: RuntimeShell;
|
|
22
|
+
readonly localSaves: boolean;
|
|
23
|
+
readonly roomTypes: Parameters<typeof schemaTypes>[1];
|
|
24
|
+
readonly builtIn: ModelState;
|
|
25
|
+
readonly typedPaths: readonly TypedPath[];
|
|
26
|
+
readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
|
|
27
|
+
readonly usableWhenHeld: readonly string[];
|
|
28
|
+
readonly build: string;
|
|
29
|
+
readonly conversations: LiveConversations;
|
|
30
|
+
readonly liveQueries: LiveQueries<HeldCover>;
|
|
31
|
+
readonly figures: FiguresRead;
|
|
32
|
+
readonly lastAnswers: ReadAnswers;
|
|
33
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type Validation } from '../mdmodel/index.js';
|
|
2
|
+
import type { ProviderLimit } from './adapter.js';
|
|
3
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
4
|
+
import { type Composition } from './collection.js';
|
|
5
|
+
import type { WriteRule } from './declaration.js';
|
|
6
|
+
import { type Layer } from './overlay.js';
|
|
7
|
+
import type { ReplicaRecord, VisibleLayer } from './replica.js';
|
|
8
|
+
import { type ChangedPart, type RoomDraftRecord, type SavedDraft } from './room-draft.js';
|
|
9
|
+
export type SaveRefusal = {
|
|
10
|
+
code: string;
|
|
11
|
+
retryable: boolean;
|
|
12
|
+
file?: string;
|
|
13
|
+
location?: string;
|
|
14
|
+
line?: number;
|
|
15
|
+
referrers?: readonly string[];
|
|
16
|
+
parts?: readonly ChangedPart[];
|
|
17
|
+
};
|
|
18
|
+
export type SaveAsk = {
|
|
19
|
+
readonly saved: readonly SavedDraft[];
|
|
20
|
+
readonly consumed: ReadonlySet<string>;
|
|
21
|
+
readonly writtenBy?: WrittenBy;
|
|
22
|
+
readonly local: boolean;
|
|
23
|
+
readonly providerLimits: readonly ProviderLimit[];
|
|
24
|
+
};
|
|
25
|
+
export type SavingRoom = {
|
|
26
|
+
readonly record: ReplicaRecord;
|
|
27
|
+
readonly rule: WriteRule;
|
|
28
|
+
readonly composition: Composition;
|
|
29
|
+
readonly queue: readonly ChangeBatch[];
|
|
30
|
+
readonly changeable: ReadonlySet<string>;
|
|
31
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
32
|
+
readonly replay: (queue: readonly ChangeBatch[]) => Generator<number, VisibleLayer, void>;
|
|
33
|
+
readonly folders: ReadonlySet<string>;
|
|
34
|
+
readonly modelled: boolean;
|
|
35
|
+
readonly drafts: ReadonlyMap<string, RoomDraftRecord>;
|
|
36
|
+
readonly validate: Validator;
|
|
37
|
+
};
|
|
38
|
+
export type PlannedRoom = {
|
|
39
|
+
readonly locator: string;
|
|
40
|
+
readonly queue: readonly ChangeBatch[];
|
|
41
|
+
readonly saved: ReadonlyMap<string, readonly SavedDraft[]>;
|
|
42
|
+
readonly consumed: readonly string[];
|
|
43
|
+
readonly carried: readonly RoomDraftRecord[];
|
|
44
|
+
};
|
|
45
|
+
export type SavePlan = {
|
|
46
|
+
readonly kind: 'refused';
|
|
47
|
+
readonly refusal: SaveRefusal;
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'planned';
|
|
50
|
+
readonly identifier: string;
|
|
51
|
+
readonly rooms: readonly PlannedRoom[];
|
|
52
|
+
};
|
|
53
|
+
export type Validator = (resulting: Layer, touched: readonly string[]) => Promise<Validation>;
|
|
54
|
+
export declare function providerRewritten(batch: ChangeBatch, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
55
|
+
export declare function rewriting(batch: ChangeBatch, locator: string): boolean;
|
|
56
|
+
export declare function effectiveIn(batch: ChangeBatch, locator: string, visible: VisibleLayer): Generator<number, ChangeBatch, void>;
|
|
57
|
+
export declare function destination(locator: string, saved: readonly SavedDraft[]): string | null;
|
|
58
|
+
export declare function planSave(ask: SaveAsk, room: SavingRoom, into?: SavingRoom): Promise<SavePlan>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ChangeBatch, type WrittenBy } from './change.js';
|
|
2
|
+
import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
|
|
3
|
+
import { type RoomDraftParts } from './room-draft.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import { type SaveRefusal } from './save.js';
|
|
6
|
+
import type { Store } from './store.js';
|
|
7
|
+
export type SaveResult = {
|
|
8
|
+
outcome: 'saved';
|
|
9
|
+
identifier: string;
|
|
10
|
+
} | ({
|
|
11
|
+
outcome: 'refused';
|
|
12
|
+
} & SaveRefusal);
|
|
13
|
+
export type SavedRoomDraft = {
|
|
14
|
+
readonly path: string;
|
|
15
|
+
readonly revision: string;
|
|
16
|
+
};
|
|
17
|
+
export type SavedParts = {
|
|
18
|
+
readonly path: string;
|
|
19
|
+
readonly parts: RoomDraftParts;
|
|
20
|
+
};
|
|
21
|
+
export type BinaryFileSurface = {
|
|
22
|
+
read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
|
|
23
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
24
|
+
show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
|
|
25
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
26
|
+
part(file: string, part: number): Promise<Uint8Array | null>;
|
|
27
|
+
};
|
|
28
|
+
export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
29
|
+
export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
|
|
30
|
+
export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
|
|
31
|
+
export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
3
|
+
export type SearchRequest = {
|
|
4
|
+
text: string;
|
|
5
|
+
rooms?: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type { SearchHit } from './adapter.js';
|
|
8
|
+
export type SearchFound = {
|
|
9
|
+
kind: 'found';
|
|
10
|
+
documents: readonly SearchHit[];
|
|
11
|
+
};
|
|
12
|
+
export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
|
|
13
|
+
kind: 'rejected';
|
|
14
|
+
}) | (ProviderRefusal & {
|
|
15
|
+
kind: 'undeclared';
|
|
16
|
+
}) | Failure;
|
|
17
|
+
export type SearchPlan = {
|
|
18
|
+
text: string;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
20
|
+
};
|
|
21
|
+
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Cover } from './live.js';
|
|
2
|
+
import { type KeyedResult } from './observation.js';
|
|
3
|
+
import type { Plan, QueryRows } from './query.js';
|
|
4
|
+
import type { Deliver } from './reach.js';
|
|
5
|
+
import type { Runtime } from './runtime.js';
|
|
6
|
+
import type { HeldCover, Store } from './store.js';
|
|
7
|
+
export type EntrySeed = {
|
|
8
|
+
readonly at: Readonly<Record<string, string>>;
|
|
9
|
+
readonly queries: readonly {
|
|
10
|
+
readonly query: unknown;
|
|
11
|
+
readonly rows: QueryRows;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
export type Seeded = {
|
|
15
|
+
readonly rows: QueryRows;
|
|
16
|
+
readonly at: Readonly<Record<string, string>>;
|
|
17
|
+
};
|
|
18
|
+
type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
|
|
19
|
+
export declare function entrySeedOf(value: unknown): EntrySeed | null;
|
|
20
|
+
export declare function seededResult(seed: Seeded): KeyedResult;
|
|
21
|
+
export declare function seedApplies(runtime: Runtime, plan: Plan, held: HeldCover): Seeded | null;
|
|
22
|
+
export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
|
|
23
|
+
export declare function watchSeeded(runtime: Runtime, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,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,58 @@
|
|
|
1
|
+
export type RequestAnswer = 'at_once' | 'ask_me' | 'off';
|
|
2
|
+
export type HouseSource = {
|
|
3
|
+
readonly kind: 'request';
|
|
4
|
+
readonly request: string;
|
|
5
|
+
readonly agentFunction: RequestAgentFunction | null;
|
|
6
|
+
readonly requester: {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly room: boolean;
|
|
9
|
+
};
|
|
10
|
+
readonly room: {
|
|
11
|
+
readonly ref: string;
|
|
12
|
+
readonly handle: string;
|
|
13
|
+
readonly name: string;
|
|
14
|
+
};
|
|
15
|
+
readonly sent: string;
|
|
16
|
+
readonly instruction: string | null;
|
|
17
|
+
readonly answer: RequestAnswer | null;
|
|
18
|
+
readonly approved: string | null;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'mail';
|
|
21
|
+
readonly request: string;
|
|
22
|
+
readonly room: string;
|
|
23
|
+
readonly report: boolean;
|
|
24
|
+
readonly agent: string;
|
|
25
|
+
readonly owner: string;
|
|
26
|
+
readonly approved: string | null;
|
|
27
|
+
readonly declined: string | null;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'trigger';
|
|
30
|
+
readonly customer: boolean;
|
|
31
|
+
readonly trigger: string;
|
|
32
|
+
readonly room: {
|
|
33
|
+
readonly ref: string;
|
|
34
|
+
readonly name: string;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'conversation';
|
|
38
|
+
readonly conversation: {
|
|
39
|
+
readonly id: string;
|
|
40
|
+
readonly name: string;
|
|
41
|
+
};
|
|
42
|
+
readonly agent: string;
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'declined';
|
|
45
|
+
readonly agent: string;
|
|
46
|
+
readonly owner: string;
|
|
47
|
+
};
|
|
48
|
+
export type ChatRequest = {
|
|
49
|
+
readonly request: string;
|
|
50
|
+
readonly room: string;
|
|
51
|
+
readonly message?: string;
|
|
52
|
+
};
|
|
53
|
+
type RequestAgentFunction = {
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly version: number;
|
|
56
|
+
};
|
|
57
|
+
export declare function sourceOf(value: unknown, sender: string | null): HouseSource | null;
|
|
58
|
+
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(among: readonly string[] | null): ReadonlySet<string>;
|
|
25
|
+
transferring(): readonly string[];
|
|
26
|
+
arrivalsDue(locator: string, now: number, everyMs: number): readonly string[];
|
|
27
|
+
};
|
|
28
|
+
export declare function createInstalls(): Installs;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ReadinessQueue<W, S> = {
|
|
2
|
+
add(watch: W): () => void;
|
|
3
|
+
held(watch: W): boolean;
|
|
4
|
+
kept(watch: W): S | undefined;
|
|
5
|
+
keep(watch: W, shown: S): void;
|
|
6
|
+
owe(watches: readonly W[]): void;
|
|
7
|
+
queue(rooms?: readonly string[]): void;
|
|
8
|
+
close(): void;
|
|
9
|
+
};
|
|
10
|
+
export declare function createReadinessQueue<W, S>(deliver: (owed: readonly W[], rooms: ReadonlySet<string> | null) => Promise<void>, unpublished: (error: unknown) => void): ReadinessQueue<W, S>;
|