@agentshouse/app-bridge 0.1.0-c8d8dc6285bbd → 0.1.0-c8dd3de04bf64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/README.md +7 -7
  2. package/dist/index.d.ts +910 -19
  3. package/dist/mdmodel/definition.d.ts +1 -1
  4. package/dist/mdmodel/document.d.ts +2 -1
  5. package/dist/mdmodel/event.d.ts +77 -0
  6. package/dist/mdmodel/facts.d.ts +14 -0
  7. package/dist/mdmodel/index.d.ts +19 -7
  8. package/dist/mdmodel/kinds.d.ts +17 -0
  9. package/dist/mdmodel/pattern.d.ts +9 -0
  10. package/dist/mdmodel/query/language.d.ts +253 -0
  11. package/dist/mdmodel/query/match.d.ts +13 -0
  12. package/dist/mdmodel/query/rows.d.ts +31 -0
  13. package/dist/mdmodel/query/sql.d.ts +38 -0
  14. package/dist/mdmodel/reserved.d.ts +5 -0
  15. package/dist/mdmodel/types.d.ts +11 -0
  16. package/dist/mdmodel/validate.d.ts +7 -5
  17. package/dist/mdruntime/actions.d.ts +19 -0
  18. package/dist/mdruntime/adapter.d.ts +107 -71
  19. package/dist/mdruntime/attached-model.d.ts +7 -0
  20. package/dist/mdruntime/bootstrap.d.ts +43 -0
  21. package/dist/mdruntime/cell.d.ts +5 -0
  22. package/dist/mdruntime/chain.d.ts +2 -1
  23. package/dist/mdruntime/change.d.ts +1 -0
  24. package/dist/mdruntime/client.d.ts +28 -11
  25. package/dist/mdruntime/collection.d.ts +7 -4
  26. package/dist/mdruntime/compile.d.ts +6 -6
  27. package/dist/mdruntime/conversation-live.d.ts +135 -0
  28. package/dist/mdruntime/conversation-row.d.ts +32 -0
  29. package/dist/mdruntime/conversation.d.ts +41 -45
  30. package/dist/mdruntime/durability.d.ts +15 -1
  31. package/dist/mdruntime/figures.d.ts +48 -0
  32. package/dist/mdruntime/holdings.d.ts +28 -0
  33. package/dist/mdruntime/identity.d.ts +0 -1
  34. package/dist/mdruntime/install.d.ts +55 -0
  35. package/dist/mdruntime/job.d.ts +32 -0
  36. package/dist/mdruntime/listing.d.ts +52 -0
  37. package/dist/mdruntime/live.d.ts +22 -0
  38. package/dist/mdruntime/log.d.ts +5 -0
  39. package/dist/mdruntime/media.d.ts +7 -0
  40. package/dist/mdruntime/messages.d.ts +27 -3
  41. package/dist/mdruntime/model.d.ts +8 -10
  42. package/dist/mdruntime/observation.d.ts +3 -2
  43. package/dist/mdruntime/outcome.d.ts +17 -6
  44. package/dist/mdruntime/overlay.d.ts +1 -0
  45. package/dist/mdruntime/preparation.d.ts +19 -0
  46. package/dist/mdruntime/query.d.ts +18 -208
  47. package/dist/mdruntime/reach.d.ts +20 -11
  48. package/dist/mdruntime/readiness.d.ts +3 -18
  49. package/dist/mdruntime/reads.d.ts +36 -0
  50. package/dist/mdruntime/recovery.d.ts +1 -0
  51. package/dist/mdruntime/refresh.d.ts +26 -0
  52. package/dist/mdruntime/replica.d.ts +11 -12
  53. package/dist/mdruntime/room-draft.d.ts +21 -7
  54. package/dist/mdruntime/room-drafts.d.ts +23 -0
  55. package/dist/mdruntime/runtime.d.ts +42 -0
  56. package/dist/mdruntime/save.d.ts +7 -1
  57. package/dist/mdruntime/saves.d.ts +69 -0
  58. package/dist/mdruntime/search.d.ts +12 -63
  59. package/dist/mdruntime/seed.d.ts +11 -2
  60. package/dist/mdruntime/socket/admission.d.ts +6 -0
  61. package/dist/mdruntime/socket/answers.d.ts +5 -0
  62. package/dist/mdruntime/socket/lanes.d.ts +19 -0
  63. package/dist/mdruntime/socket/rooms.d.ts +43 -0
  64. package/dist/mdruntime/socket/session.d.ts +37 -0
  65. package/dist/mdruntime/socket.d.ts +69 -0
  66. package/dist/mdruntime/source.d.ts +60 -0
  67. package/dist/mdruntime/status.d.ts +4 -5
  68. package/dist/mdruntime/store/fences.d.ts +15 -0
  69. package/dist/mdruntime/store/installs.d.ts +29 -0
  70. package/dist/mdruntime/store/readiness.d.ts +9 -0
  71. package/dist/mdruntime/store/records.d.ts +211 -0
  72. package/dist/mdruntime/store/room-held.d.ts +7 -0
  73. package/dist/mdruntime/store/space.d.ts +10 -0
  74. package/dist/mdruntime/store/watchers.d.ts +16 -0
  75. package/dist/mdruntime/store/writes.d.ts +23 -0
  76. package/dist/mdruntime/store.d.ts +105 -158
  77. package/dist/mdruntime/stored.d.ts +66 -55
  78. package/dist/mdruntime/surface.d.ts +87 -0
  79. package/dist/mdruntime/tables.d.ts +131 -69
  80. package/dist/mdruntime/tallies.d.ts +17 -0
  81. package/dist/mdruntime/transfer.d.ts +0 -5
  82. package/dist/mdruntime/turn.d.ts +8 -0
  83. package/dist/mdruntime/wire.d.ts +25 -9
  84. package/dist/test-host.d.ts +1 -4
  85. package/dist/test-host.js +2 -28
  86. package/docs/families.md +49 -53
  87. package/package.json +1 -1
  88. package/dist/calls.d.ts +0 -1007
  89. package/dist/calls.js +0 -1
  90. package/dist/mdmodel/condition.d.ts +0 -160
  91. package/dist/mdmodel/profile.d.ts +0 -5
  92. package/dist/mdruntime/connection.d.ts +0 -151
  93. package/dist/mdruntime/file.d.ts +0 -11
  94. package/dist/mdruntime/fulltext.d.ts +0 -26
  95. package/dist/mdruntime/shared.d.ts +0 -15
@@ -1,7 +1,8 @@
1
- import type { BootstrapInventory, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
1
+ import { type TypedPath } from '../mdmodel/index.js';
2
+ import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
2
3
  import { type ChangeBatch, type Precondition } from './change.js';
3
4
  import { type Collection, type Composition } from './collection.js';
4
- import type { ModelState } from './model.js';
5
+ import { type ModelState } from './model.js';
5
6
  import { type Layer } from './overlay.js';
6
7
  import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
7
8
  export type ReplicaRecord = {
@@ -12,35 +13,33 @@ export type ReplicaRecord = {
12
13
  readonly replica: ReplicaAdmission;
13
14
  readonly model: ModelState;
14
15
  readonly typedSelection: TypedSelection | null;
15
- readonly selectionModel: ModelState;
16
16
  readonly providerOwnedPaths: readonly string[];
17
+ readonly authoredPaths?: readonly string[];
17
18
  readonly roomVersion: string;
18
19
  readonly transfer: string;
19
- readonly inventory: BootstrapInventory | null;
20
+ readonly inventory: BootstrapInventory;
20
21
  readonly key: number;
21
22
  };
22
23
  export type HeldReplica = {
23
24
  readonly record: ReplicaRecord;
24
25
  readonly queue: readonly ChangeBatch[];
25
26
  readonly overlaid: ReadonlySet<string>;
26
- readonly count: number;
27
- readonly confirmed: number;
28
- readonly indexed: boolean;
29
27
  };
30
28
  export type VisibleLayer = Layer & {
31
29
  readonly collection: Collection;
32
30
  };
33
31
  export type Slice = Layer & {
34
32
  readonly written: Readonly<Record<string, string>>;
33
+ readonly facts: Readonly<Record<string, SavedFacts>>;
35
34
  readonly held: ReadonlySet<string>;
36
35
  };
37
- export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection' | 'selectionModel'>): Composition;
38
- export declare function sameMembership(record: Pick<ReplicaRecord, 'typedSelection'>, other: Pick<ReplicaRecord, 'typedSelection'>): boolean;
36
+ export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
39
37
  export declare function storedRecord(record: ReplicaRecord): string;
40
38
  export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
39
+ export type LayerEntry = Omit<StoredEntry, 'facts'>;
41
40
  export declare function entryAt(layer: Layer & {
42
41
  readonly written?: Readonly<Record<string, string>>;
43
- }, path: string): StoredEntry | null;
42
+ }, path: string): LayerEntry | null;
44
43
  export declare function slicingWith(slice: Slice, set: readonly StoredEntry[], removed: readonly string[]): Generator<number, Slice, void>;
45
44
  export declare function touchedBy(queue: readonly ChangeBatch[]): Set<string>;
46
45
  export declare function movedBy(queue: readonly ChangeBatch[], locator: string): Set<string>;
@@ -49,7 +48,7 @@ export type Replayed = {
49
48
  readonly touched: ReadonlySet<string>;
50
49
  };
51
50
  export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
52
- export declare function overlayOf(visible: Layer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
51
+ export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
53
52
  export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
54
53
  export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
55
54
  export type Standing = {
@@ -65,5 +64,5 @@ export type Returned = {
65
64
  readonly removed: readonly string[];
66
65
  };
67
66
  export declare function returnedPaths(submitted: ChangeBatch, accepted: Accepted): Set<string>;
68
- export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string): Generator<number, Returned, void>;
67
+ export declare function returning(confirmed: Slice, submitted: ChangeBatch, accepted: Accepted, writtenAt: string, composition: Composition): Generator<number, Returned, void>;
69
68
  export {};
@@ -40,6 +40,7 @@ export type RoomDraftParts = {
40
40
  };
41
41
  readonly file?: {
42
42
  readonly blob: Blob;
43
+ readonly base?: string | null;
43
44
  };
44
45
  };
45
46
  export type HeldFile = {
@@ -89,9 +90,9 @@ type ChangedUnderneath = {
89
90
  readonly file?: string | null;
90
91
  };
91
92
  export type ReturnReason = ProviderRefusal & {
92
- readonly kind: Open<'conflicted' | 'rejected' | 'expired' | 'withdrawn'>;
93
+ readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
93
94
  };
94
- export declare function returnedBy(kind: 'expired' | 'withdrawn'): ReturnReason;
95
+ export declare function returnedBy(): ReturnReason;
95
96
  export type RoomDraft = {
96
97
  readonly room: string;
97
98
  readonly path: string;
@@ -105,14 +106,12 @@ export type RoomDraftWrite = {
105
106
  readonly roomDraft: RoomDraft | null;
106
107
  } | {
107
108
  readonly outcome: 'stale';
108
- readonly code: string;
109
- readonly retryable: boolean;
110
109
  readonly current: RoomDraft | null;
111
110
  };
112
111
  export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
113
112
  export type ChangedPart = {
114
113
  readonly path: string;
115
- readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'creation' | 'move' | 'removal' | 'file'>;
114
+ readonly part: Open<'field' | 'section' | 'preamble' | 'markdown' | 'move' | 'removal' | 'file'>;
116
115
  readonly name?: string;
117
116
  };
118
117
  export type RoomDraftRecord = {
@@ -126,13 +125,14 @@ export type SavedDraft = {
126
125
  readonly path: string;
127
126
  readonly parts: HeldParts;
128
127
  };
129
- export declare function readParts(value: unknown): RoomDraftParts;
128
+ export declare function readParts(value: unknown, path: string): RoomDraftParts;
130
129
  export declare function gatheredParts(earlier: unknown, later: unknown): unknown;
131
130
  export declare function held(current: HeldParts | undefined, parts: RoomDraftParts, file?: HeldFile): HeldParts;
132
131
  export declare function underneath(parts: HeldParts, path: string, visible: VisibleLayer | undefined): ChangedUnderneath;
133
132
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
134
133
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
135
- export declare function changedParts(path: string, report: ChangedUnderneath): readonly ChangedPart[];
134
+ export declare function changedParts(path: string, parts: HeldParts, visible: VisibleLayer | undefined): readonly ChangedPart[];
135
+ export declare function lineEnded(text: string): string;
136
136
  export type TextParts = {
137
137
  readonly fields?: Readonly<Record<string, {
138
138
  readonly value: unknown;
@@ -149,6 +149,20 @@ export declare function returnedInto(existing: HeldParts | undefined, returned:
149
149
  export declare function moveTarget(move: {
150
150
  readonly to: string;
151
151
  }): string;
152
+ export declare function readSavedParts(named: readonly {
153
+ readonly path: string;
154
+ readonly parts: unknown;
155
+ }[]): readonly {
156
+ readonly path: string;
157
+ readonly parts: RoomDraftParts;
158
+ }[];
159
+ export declare function partsChanges(named: readonly {
160
+ readonly path: string;
161
+ readonly parts: unknown;
162
+ }[]): {
163
+ readonly changes: readonly Change[];
164
+ readonly preconditions: readonly Precondition[];
165
+ };
152
166
  export declare function changesOf(path: string, parts: HeldParts): {
153
167
  changes: readonly Change[];
154
168
  bases: readonly Precondition[];
@@ -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,42 @@
1
+ import type { Authorization, DiscoveredRoom, PathRule, ScopedRefusal, TypedPath } from './adapter.js';
2
+ import type { ChangeSet } from './change-set.js';
3
+ import type { ChangeBatch } from './change.js';
4
+ import type { RuntimeShell } from './durability.js';
5
+ import type { LiveConversations } from './conversation-live.js';
6
+ import type { FiguresRead } from './figures.js';
7
+ import type { Withheld } from './install.js';
8
+ import type { LiveQueries } from './live.js';
9
+ import type { Log } from './log.js';
10
+ import type { ModelState } from './model.js';
11
+ import type { ReadAnswers } from './reads.js';
12
+ import type { Recovery } from './recovery.js';
13
+ import type { ReplicaRecord } from './replica.js';
14
+ import type { RuntimeSocket, RoomDeclaration } from './socket.js';
15
+ import type { CycleProgress } from './status.js';
16
+ import type { Settling } from './saves.js';
17
+ import type { HeldCover, RuntimeStore, Store, Work } from './store.js';
18
+ import type { schemaTypes } from './attached-model.js';
19
+ export type Runtime = {
20
+ readonly store: Store;
21
+ readonly socket: RuntimeSocket;
22
+ readonly journal: Log;
23
+ readonly recovery: Recovery;
24
+ readonly shell: RuntimeShell;
25
+ readonly localSaves: boolean;
26
+ readonly roomTypes: Parameters<typeof schemaTypes>[1];
27
+ readonly builtIn: ModelState;
28
+ readonly typedPaths: readonly TypedPath[];
29
+ readonly pathRule: PathRule;
30
+ readonly usableWhenHeld: readonly string[];
31
+ readonly build: string;
32
+ readonly conversations: LiveConversations;
33
+ readonly liveQueries: LiveQueries<HeldCover>;
34
+ readonly figures: FiguresRead;
35
+ readonly lastAnswers: ReadAnswers;
36
+ settle(local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
37
+ scoped(result: ScopedRefusal, room: RoomDeclaration, local: RuntimeStore): Promise<void>;
38
+ submitLater(locator: string): void;
39
+ unpair(local: RuntimeStore): Promise<void>;
40
+ advanced(room: DiscoveredRoom, local: RuntimeStore, authorized: Authorization): Promise<Withheld | null>;
41
+ withhold(withheld: Withheld, room: DiscoveredRoom, local: RuntimeStore, progress: CycleProgress): Promise<void>;
42
+ };
@@ -1,5 +1,5 @@
1
1
  import { type Validation } from '../mdmodel/index.js';
2
- import type { OperationScopes, ProviderLimit } from './adapter.js';
2
+ import type { OperationScopes, PathRule, ProviderLimit } from './adapter.js';
3
3
  import { type Change, type ChangeBatch, type Precondition, type WrittenBy } from './change.js';
4
4
  import { type Composition } from './collection.js';
5
5
  import { type Layer } from './overlay.js';
@@ -19,8 +19,11 @@ export type SaveInput = {
19
19
  baseRoomVersion: string;
20
20
  operations: import('./adapter.js').OperationScopes;
21
21
  providerOwnedPaths: readonly string[];
22
+ authoredPaths?: readonly string[];
22
23
  providerLimits: readonly ProviderLimit[];
24
+ pathRule: PathRule;
23
25
  visible: VisibleLayer;
26
+ folders: ReadonlySet<string>;
24
27
  handle: string;
25
28
  changes: readonly Change[];
26
29
  bases: readonly Precondition[];
@@ -74,7 +77,9 @@ export type MoveSide = {
74
77
  composition: Composition;
75
78
  operations: OperationScopes;
76
79
  providerOwnedPaths: readonly string[];
80
+ authoredPaths?: readonly string[];
77
81
  visible: VisibleLayer;
82
+ folders: ReadonlySet<string>;
78
83
  queued: ReadonlySet<string>;
79
84
  unmodeled: boolean;
80
85
  validate: Validator;
@@ -87,6 +92,7 @@ export type MoveInput = {
87
92
  readonly to: string;
88
93
  }[];
89
94
  providerLimits: readonly ProviderLimit[];
95
+ pathRule: PathRule;
90
96
  local: boolean;
91
97
  writtenBy?: WrittenBy;
92
98
  };
@@ -0,0 +1,69 @@
1
+ import { type ChangeSet } from './change-set.js';
2
+ import { type ChangeBatch, type WrittenBy } from './change.js';
3
+ import { type AttachAnswer, type BinaryLinkAnswer, type HeldBinaryAnswer, type HeldShownAnswer } from './outcome.js';
4
+ import { type HeldReplica, type ReplicaRecord, type Slice, type VisibleLayer } from './replica.js';
5
+ import { type ReturnReason, type RoomDraftParts } from './room-draft.js';
6
+ import type { Runtime } from './runtime.js';
7
+ import { type SaveRefusal } from './save.js';
8
+ import type { AuthoredWrite, CommittedWrite, PendingState, RoomCommit, RuntimeStore, Store, StoredEntry, View, Work } from './store.js';
9
+ export type SaveResult = {
10
+ outcome: 'saved';
11
+ identifier: string;
12
+ } | ({
13
+ outcome: 'refused';
14
+ } & SaveRefusal);
15
+ export type SavedRoomDraft = {
16
+ readonly path: string;
17
+ readonly revision: string;
18
+ };
19
+ export type SavedParts = {
20
+ readonly path: string;
21
+ readonly parts: RoomDraftParts;
22
+ };
23
+ export type BinaryFileSurface = {
24
+ read(room: string, path: string, revision?: string): Promise<HeldBinaryAnswer>;
25
+ link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
26
+ show(room: string, path: string, revision?: string): Promise<HeldShownAnswer>;
27
+ attach(room: string, file: File): Promise<AttachAnswer>;
28
+ part(file: string, part: number): Promise<Uint8Array | null>;
29
+ };
30
+ export type Leaving = {
31
+ batch: ChangeBatch;
32
+ returned: ReturnReason | null;
33
+ };
34
+ export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
35
+ export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
36
+ export declare function landedWhole(store: Store, locator: string, batch: ChangeBatch, confirmedLayer: Slice, current?: Readonly<Record<string, string>>): Promise<boolean>;
37
+ export type Settling = {
38
+ leaving?: readonly Leaving[];
39
+ room?: boolean;
40
+ view?: View;
41
+ commit?: Pick<RoomCommit, 'published' | 'refreshed'>;
42
+ changes?: {
43
+ readonly set: readonly StoredEntry[];
44
+ readonly removed: readonly string[];
45
+ };
46
+ };
47
+ export declare function preparedAfter(runtime: Runtime, locator: string, answer: CommittedWrite): void;
48
+ export declare function replayed(store: Store, record: ReplicaRecord, confirmedLayer: Slice, queue: readonly ChangeBatch[]): import("./turn.js").Later<import("./replica.js").Replayed>;
49
+ export declare function overlayDiff(record: ReplicaRecord, before: HeldReplica | undefined, visible: VisibleLayer, touched: ReadonlySet<string>): Promise<{
50
+ overlay: NonNullable<RoomCommit['overlay']>;
51
+ touched: ReadonlySet<string>;
52
+ }>;
53
+ export type Settlement = {
54
+ readonly locator: string;
55
+ readonly left: readonly ChangeBatch[];
56
+ readonly commit: {
57
+ readonly rooms: readonly RoomCommit[];
58
+ readonly writes: readonly AuthoredWrite[];
59
+ };
60
+ apply(answer: CommittedWrite): ChangeSet;
61
+ };
62
+ export declare function settle(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<ChangeSet>;
63
+ export declare function together(runtime: Runtime, local: RuntimeStore, settlements: readonly Settlement[]): Promise<ChangeSet>;
64
+ export declare function settlement(runtime: Runtime, local: RuntimeStore, locator: string, work: Work, record: ReplicaRecord, queue: readonly ChangeBatch[], settling?: Settling): Promise<Settlement>;
65
+ export declare function unpairing(runtime: Runtime, local: RuntimeStore, locator: string, batches: readonly ChangeBatch[]): Promise<Settlement>;
66
+ export declare function saveRoomDrafts(runtime: Runtime, locator: string, named: readonly SavedRoomDraft[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
67
+ export declare function saveParts(runtime: Runtime, locator: string, named: readonly SavedParts[], writtenBy: WrittenBy | undefined): Promise<SaveResult>;
68
+ export declare function batchFile(store: Store, batch: ChangeBatch): (localId: string) => Promise<Blob>;
69
+ export declare function binaryFileSurface(runtime: Runtime): BinaryFileSurface;
@@ -1,72 +1,21 @@
1
- import type { ProviderRefusal } from './adapter.js';
2
- import { type CoveredRoom, type Filter, type PendingRoom } from './query.js';
3
- import type { Open } from './open.js';
4
- export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
1
+ import type { ProviderRefusal, SearchHit } from './adapter.js';
2
+ import type { Failure, Offline } from './outcome.js';
5
3
  export type SearchRequest = {
6
4
  text: string;
7
- documents?: Filter;
8
- collection?: true;
9
- conversations?: readonly string[];
10
- limit?: number;
11
- after?: string;
12
- total?: true;
5
+ rooms?: readonly string[];
13
6
  };
14
- export type MessagePart = Open<'text'>;
15
- export type Snippet<Part extends string> = {
16
- part: Part;
17
- text: string;
18
- at: readonly [number, number];
19
- };
20
- export type DocumentHit = {
21
- room: string;
22
- path: string;
23
- type: string;
24
- score: number;
25
- matches: Readonly<Record<string, readonly DocumentPart[]>>;
26
- snippet?: Snippet<DocumentPart>;
27
- };
28
- export type MessageHit = {
29
- conversation: string;
30
- identity: string;
31
- score: number;
32
- matches: Readonly<Record<string, readonly MessagePart[]>>;
33
- snippet?: Snippet<MessagePart>;
34
- };
35
- export type SearchCoverage = {
36
- rooms: readonly CoveredRoom[];
37
- conversations: readonly string[];
38
- overlay: readonly string[];
7
+ export type { SearchHit } from './adapter.js';
8
+ export type SearchFound = {
9
+ kind: 'found';
10
+ documents: readonly SearchHit[];
39
11
  };
40
- export type SearchHits = {
41
- documents: readonly DocumentHit[];
42
- messages: readonly MessageHit[];
43
- };
44
- export type SearchWindow = SearchHits & {
45
- next?: string;
46
- total?: {
47
- documents: number;
48
- messages: number;
49
- };
50
- };
51
- export type SearchPending = SearchHits & {
52
- pending: readonly PendingRoom[];
53
- coverage: SearchCoverage;
54
- };
55
- export type SearchUndeclared = ProviderRefusal & {
12
+ export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
13
+ kind: 'rejected';
14
+ }) | (ProviderRefusal & {
56
15
  kind: 'undeclared';
57
- };
58
- export type SearchResult = (SearchWindow & {
59
- coverage: SearchCoverage;
60
- }) | SearchPending | SearchUndeclared;
61
- export declare function undeclaredSearch(): SearchUndeclared;
62
- export type HitCursor = readonly [number, string, string] | readonly [] | null;
16
+ }) | Failure;
63
17
  export type SearchPlan = {
64
18
  text: string;
65
- documents: unknown;
66
- collection: boolean;
67
- conversations: readonly string[] | null;
68
- limit: number | null;
69
- after: readonly [HitCursor, HitCursor] | null;
70
- total: boolean;
19
+ rooms: readonly string[] | null;
71
20
  };
72
21
  export declare function searchPlanOf(input: unknown): SearchPlan;
@@ -1,5 +1,9 @@
1
- import type { KeyedResult } from './observation.js';
2
- import type { QueryRows } from './query.js';
1
+ import type { Cover } from './live.js';
2
+ import { type KeyedResult } from './observation.js';
3
+ import type { Plan, QueryRows } from './query.js';
4
+ import type { Deliver } from './reach.js';
5
+ import type { Runtime } from './runtime.js';
6
+ import type { HeldCover, Store } from './store.js';
3
7
  export type EntrySeed = {
4
8
  readonly at: Readonly<Record<string, string>>;
5
9
  readonly queries: readonly {
@@ -11,5 +15,10 @@ export type Seeded = {
11
15
  readonly rows: QueryRows;
12
16
  readonly at: Readonly<Record<string, string>>;
13
17
  };
18
+ type SeededWatch = (coverOf: (cover: Cover, held: HeldCover) => Cover, deliver: (message: unknown) => void) => () => void;
14
19
  export declare function entrySeedOf(value: unknown): EntrySeed | null;
15
20
  export declare function seededResult(seed: Seeded): KeyedResult;
21
+ export declare function seedApplies(runtime: Runtime, plan: Plan, held: HeldCover): Seeded | null;
22
+ export declare function keepEntrySeed(store: Store, entry: EntrySeed): void;
23
+ export declare function watchSeeded(runtime: Runtime, plan: Plan, deliver: Deliver, watch: SeededWatch): () => void;
24
+ export {};
@@ -0,0 +1,6 @@
1
+ export type Admission = {
2
+ heldStream(): Promise<() => void>;
3
+ unqueued(): Promise<void>;
4
+ queued(text: number): () => void;
5
+ };
6
+ export declare function createAdmission(): Admission;
@@ -0,0 +1,5 @@
1
+ export type Answers = {
2
+ awaitingAnswer(locator: string): () => void;
3
+ answered(locator: string): Promise<void> | undefined;
4
+ };
5
+ export declare function createAnswers(): Answers;
@@ -0,0 +1,19 @@
1
+ export type Live = () => boolean;
2
+ type LaneRules = {
3
+ generation(): number;
4
+ continuing(): boolean;
5
+ stopping(): boolean;
6
+ };
7
+ export type Lanes = {
8
+ task(lane: string, work: (live: Live) => Promise<void>): Promise<void>;
9
+ inRoom<T>(locator: string, work: (live: Live) => Promise<T>): Promise<T>;
10
+ roomTask(locator: string, work: (live: Live) => Promise<void>): Promise<void>;
11
+ roomWork(): number;
12
+ current(): Promise<unknown>;
13
+ finished(): Promise<unknown>;
14
+ calling(operation: string): boolean;
15
+ call(operation: string): void;
16
+ called(operation: string): void;
17
+ };
18
+ export declare function createLanes({ generation, continuing, stopping }: LaneRules): Lanes;
19
+ export {};
@@ -0,0 +1,43 @@
1
+ import type { DiscoveredRoom, ProviderRefusal, TypedSelection } from '../adapter.js';
2
+ import type { ModelState } from '../model.js';
3
+ export type RoomDeclaration = Omit<DiscoveredRoom, 'roomVersion' | 'typedSelection'> & {
4
+ typedSelection?: TypedSelection | null;
5
+ };
6
+ export type Declared = {
7
+ readonly room: RoomDeclaration | null;
8
+ readonly available: boolean;
9
+ };
10
+ type RoomStanding = {
11
+ readonly unreadable: boolean;
12
+ readonly refusal: ProviderRefusal | null;
13
+ readonly unheldModel: ModelState | null;
14
+ readonly stale: boolean;
15
+ readonly repairable: {
16
+ readonly reset: string | undefined;
17
+ } | null;
18
+ readonly repairing: boolean;
19
+ readonly reloadDue: boolean;
20
+ readonly confirmed: boolean;
21
+ readonly unpreparable: boolean;
22
+ };
23
+ export type Rooms = {
24
+ declare(locator: string, declared: Declared): void;
25
+ declared(locator: string): Declared | undefined;
26
+ declarations(): ReadonlyMap<string, Declared>;
27
+ discover(room: DiscoveredRoom): void;
28
+ discovered(locator: string): DiscoveredRoom | undefined;
29
+ discoveredRooms(): readonly DiscoveredRoom[];
30
+ undiscoverAll(): void;
31
+ standing(locator: string): RoomStanding;
32
+ stand(locator: string, change: Partial<RoomStanding>): void;
33
+ standingWhere(held: (room: RoomStanding) => boolean): readonly string[];
34
+ standAll(change: Partial<RoomStanding>): void;
35
+ forget(locator: string): void;
36
+ askAgain(locator: string, ask: () => void): void;
37
+ readied(locator: string): void;
38
+ unreadied(): void;
39
+ connectionLost(lapsed: () => void): void;
40
+ connectionLive(): void;
41
+ };
42
+ export declare function createRooms(): Rooms;
43
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { Authorization, ProviderRefusal, ServiceMode } from '../adapter.js';
2
+ import { type Cell } from '../cell.js';
3
+ import type { Open } from '../open.js';
4
+ import type { CycleProgress, SyncStatus } from '../status.js';
5
+ export type RefusalReason = 'missing-required-guarantee' | 'revoked-authorization';
6
+ export type ConnectionRefusalCode = Open<RefusalReason>;
7
+ export type ConnectionRefusal = {
8
+ code: ConnectionRefusalCode;
9
+ reauthorizationOffered: boolean;
10
+ refusal: ProviderRefusal | null;
11
+ };
12
+ export type Moving = {
13
+ readonly state: SyncStatus['state'];
14
+ readonly providerUnreachable: boolean;
15
+ readonly resting: boolean;
16
+ };
17
+ export type Session = {
18
+ readonly closed: boolean;
19
+ readonly stopping: boolean;
20
+ readonly paused: boolean;
21
+ readonly authorization: Authorization | undefined;
22
+ readonly refusal: ConnectionRefusal | null;
23
+ readonly discoveries: number;
24
+ readonly roomsNamed: boolean;
25
+ readonly roomsListed: boolean;
26
+ readonly serviceMode: ServiceMode;
27
+ readonly haltedRefusal: boolean;
28
+ readonly openSignals: number;
29
+ readonly authorityChanges: number;
30
+ readonly currencyQueued: number | null;
31
+ readonly moving: Moving;
32
+ readonly complete: boolean;
33
+ readonly recorded: boolean;
34
+ readonly underway: CycleProgress | null;
35
+ readonly streamed: CycleProgress | null;
36
+ };
37
+ export declare function createSession(authorization: Authorization | undefined): Cell<Session>;
@@ -0,0 +1,69 @@
1
+ import type { Adapter, Authorization, ConversationEvent, Discovery, HeldRoom, RoomStreamEvent, ServiceMode } from './adapter.js';
2
+ import type { Reads } from './bootstrap.js';
3
+ import type { Cell } from './cell.js';
4
+ import type { Log } from './log.js';
5
+ import { type Admission } from './socket/admission.js';
6
+ import { type Answers } from './socket/answers.js';
7
+ import { type Lanes } from './socket/lanes.js';
8
+ import { type Rooms } from './socket/rooms.js';
9
+ import { type Session } from './socket/session.js';
10
+ export type { Live } from './socket/lanes.js';
11
+ export type { RoomDeclaration } from './socket/rooms.js';
12
+ export type { ConnectionRefusal, ConnectionRefusalCode, Moving, RefusalReason, } from './socket/session.js';
13
+ type SocketEvent = {
14
+ readonly kind: 'opened';
15
+ } | {
16
+ readonly kind: 'discovered';
17
+ readonly discovery: Discovery;
18
+ readonly missed: boolean;
19
+ } | {
20
+ readonly kind: 'closed';
21
+ readonly revoked: boolean;
22
+ readonly lost: boolean;
23
+ readonly opened: boolean;
24
+ } | Exclude<RoomStreamEvent, {
25
+ kind: 'opened' | 'discovered' | 'closed';
26
+ }>;
27
+ export type RuntimeSocket = Admission & Answers & {
28
+ readonly reads: Reads;
29
+ readonly streamed: boolean;
30
+ readonly session: Cell<Session>;
31
+ readonly rooms: Rooms;
32
+ readonly lanes: Lanes;
33
+ readonly ready: Promise<void>;
34
+ readonly firstDiscovery: Promise<void>;
35
+ conversations(): Adapter['conversations'];
36
+ search(): Adapter['search'];
37
+ discover(authorized: Authorization): ReturnType<NonNullable<Adapter['discover']>> | undefined;
38
+ follows: Adapter['follows'];
39
+ mutate: Adapter['mutate'];
40
+ binary: Adapter['binary'];
41
+ link: Adapter['link'];
42
+ attach: Adapter['attach'];
43
+ history: Adapter['history'];
44
+ action: Adapter['action'];
45
+ authorize(): Promise<void>;
46
+ observe(listen: (event: SocketEvent) => void): void;
47
+ observeConversations(listen: (event: ConversationEvent) => void): void;
48
+ observeServiceMode(listen: (mode: ServiceMode) => void): void;
49
+ close(): void;
50
+ readyFromStore(): void;
51
+ notifyReady(): void;
52
+ closed(): boolean;
53
+ stopping(): boolean;
54
+ continuing(): boolean;
55
+ reached(): boolean;
56
+ writesHeld(): boolean;
57
+ haltedSince(opens: number): boolean;
58
+ isOpen(): boolean;
59
+ isAnnounced(): boolean;
60
+ isHanded(): boolean;
61
+ generation(): number;
62
+ naming(): boolean;
63
+ hand(rooms: readonly HeldRoom[]): void;
64
+ name(room: HeldRoom): void;
65
+ named(): void;
66
+ abortReads(): void;
67
+ stopReads(): void;
68
+ };
69
+ export declare function createSocket(adapter: Adapter, journal: Log, authorization: Authorization | undefined): RuntimeSocket;