@agentshouse/app-bridge 0.1.0-c3aff7d33e077 → 0.1.0-c3ee7fcd01608

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 (103) hide show
  1. package/README.md +2 -2
  2. package/dist/index.d.ts +173 -422
  3. package/dist/mdmodel/body.d.ts +84 -0
  4. package/dist/mdmodel/built-in.d.ts +3 -0
  5. package/dist/mdmodel/definition.d.ts +23 -10
  6. package/dist/mdmodel/document.d.ts +14 -8
  7. package/dist/mdmodel/event.d.ts +1 -2
  8. package/dist/mdmodel/fields.d.ts +1 -1
  9. package/dist/mdmodel/house-model.d.ts +869 -0
  10. package/dist/mdmodel/house-references/crockford.d.ts +3 -0
  11. package/dist/mdmodel/house-references/patterns.d.ts +8 -0
  12. package/dist/mdmodel/index.d.ts +31 -15
  13. package/dist/mdmodel/indexed.d.ts +8 -0
  14. package/dist/mdmodel/kinds.d.ts +4 -2
  15. package/dist/mdmodel/markdown.d.ts +74 -0
  16. package/dist/mdmodel/media-type.d.ts +71 -0
  17. package/dist/mdmodel/moment.d.ts +6 -0
  18. package/dist/mdmodel/not-ready.d.ts +1 -0
  19. package/dist/mdmodel/paths.d.ts +15 -1
  20. package/dist/mdmodel/query/language.d.ts +2 -1
  21. package/dist/mdmodel/query/match.d.ts +1 -1
  22. package/dist/mdmodel/query/rows.d.ts +1 -1
  23. package/dist/mdmodel/query/sql.d.ts +5 -1
  24. package/dist/mdmodel/query/walk.d.ts +62 -0
  25. package/dist/mdmodel/references.d.ts +2 -2
  26. package/dist/mdmodel/reserved.d.ts +1 -0
  27. package/dist/mdmodel/room-types.d.ts +6 -0
  28. package/dist/mdmodel/types.d.ts +11 -17
  29. package/dist/mdmodel/validate.d.ts +6 -2
  30. package/dist/mdmodel/yaml.d.ts +4 -4
  31. package/dist/mdruntime/actions.d.ts +8 -2
  32. package/dist/mdruntime/adapter.d.ts +120 -57
  33. package/dist/mdruntime/attached-model.d.ts +0 -1
  34. package/dist/mdruntime/authored.d.ts +87 -0
  35. package/dist/mdruntime/bootstrap.d.ts +1 -1
  36. package/dist/mdruntime/change-set.d.ts +4 -0
  37. package/dist/mdruntime/change.d.ts +4 -0
  38. package/dist/mdruntime/client.d.ts +19 -21
  39. package/dist/mdruntime/collection.d.ts +26 -4
  40. package/dist/mdruntime/compile.d.ts +2 -0
  41. package/dist/mdruntime/conversation-live.d.ts +28 -12
  42. package/dist/mdruntime/conversation-row.d.ts +8 -1
  43. package/dist/mdruntime/conversation.d.ts +37 -12
  44. package/dist/mdruntime/declaration.d.ts +9 -0
  45. package/dist/mdruntime/durability.d.ts +5 -0
  46. package/dist/mdruntime/failure.d.ts +3 -0
  47. package/dist/mdruntime/figures.d.ts +1 -0
  48. package/dist/mdruntime/house-query.d.ts +14 -0
  49. package/dist/mdruntime/install.d.ts +10 -6
  50. package/dist/mdruntime/listing.d.ts +29 -22
  51. package/dist/mdruntime/live.d.ts +5 -3
  52. package/dist/mdruntime/media.d.ts +19 -2
  53. package/dist/mdruntime/messages.d.ts +12 -6
  54. package/dist/mdruntime/modal.d.ts +1 -0
  55. package/dist/mdruntime/model.d.ts +4 -3
  56. package/dist/mdruntime/observation.d.ts +29 -12
  57. package/dist/mdruntime/opened.d.ts +1 -1
  58. package/dist/mdruntime/outcome.d.ts +13 -1
  59. package/dist/mdruntime/overlay.d.ts +6 -2
  60. package/dist/mdruntime/preparation.d.ts +33 -7
  61. package/dist/mdruntime/presence.d.ts +57 -0
  62. package/dist/mdruntime/query.d.ts +0 -1
  63. package/dist/mdruntime/reach.d.ts +15 -6
  64. package/dist/mdruntime/readiness.d.ts +20 -5
  65. package/dist/mdruntime/reads.d.ts +4 -2
  66. package/dist/mdruntime/recovery.d.ts +4 -1
  67. package/dist/mdruntime/replica.d.ts +5 -10
  68. package/dist/mdruntime/retried.d.ts +29 -0
  69. package/dist/mdruntime/room-draft.d.ts +31 -8
  70. package/dist/mdruntime/runtime.d.ts +11 -19
  71. package/dist/mdruntime/save.d.ts +42 -88
  72. package/dist/mdruntime/saves.d.ts +4 -40
  73. package/dist/mdruntime/socket/lanes.d.ts +12 -4
  74. package/dist/mdruntime/socket/session.d.ts +4 -2
  75. package/dist/mdruntime/socket.d.ts +4 -6
  76. package/dist/mdruntime/source.d.ts +5 -7
  77. package/dist/mdruntime/store/installs.d.ts +2 -2
  78. package/dist/mdruntime/store/readiness.d.ts +5 -4
  79. package/dist/mdruntime/store/records.d.ts +23 -8
  80. package/dist/mdruntime/store/rooms-shown.d.ts +7 -0
  81. package/dist/mdruntime/store/space.d.ts +1 -1
  82. package/dist/mdruntime/store.d.ts +26 -16
  83. package/dist/mdruntime/stored.d.ts +33 -15
  84. package/dist/mdruntime/surface.d.ts +12 -6
  85. package/dist/mdruntime/tables.d.ts +19 -58
  86. package/dist/mdruntime/wire.d.ts +66 -7
  87. package/dist/session-content/check.d.ts +17 -0
  88. package/dist/session-content/index.d.ts +6 -0
  89. package/dist/session-content/parts.d.ts +30 -0
  90. package/dist/session-content/state.d.ts +59 -0
  91. package/dist/session-content/turn.d.ts +137 -0
  92. package/dist/test-host.d.ts +8 -1
  93. package/dist/test-host.js +44 -1
  94. package/docs/families.md +61 -33
  95. package/package.json +2 -2
  96. package/dist/mdmodel/blocks.d.ts +0 -10
  97. package/dist/mdmodel/links.d.ts +0 -28
  98. package/dist/mdmodel/profile.d.ts +0 -5
  99. package/dist/mdruntime/job.d.ts +0 -32
  100. package/dist/mdruntime/log.d.ts +0 -5
  101. package/dist/mdruntime/socket/rooms.d.ts +0 -42
  102. package/dist/mdruntime/store/fences.d.ts +0 -15
  103. package/dist/mdruntime/turn.d.ts +0 -8
@@ -1,4 +1,6 @@
1
- import type { QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
1
+ import type { PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult } from './query.js';
2
+ import type { ReadinessShown, RoomCoverage } from './readiness.js';
3
+ import type { AppRoom, ListedRooms } from './listing.js';
2
4
  export type Observation<T> = {
3
5
  current(): T;
4
6
  subscribe(listener: (value: T) => void): () => void;
@@ -9,15 +11,24 @@ export type KeyedResult = {
9
11
  result: QueryResult;
10
12
  keys: readonly RowKey[];
11
13
  };
12
- export type QueryChange = {
13
- changed: readonly (readonly [RowKey, QueryDocument | QueryGroup])[];
14
- removed: readonly RowKey[];
15
- order: readonly RowKey[] | null;
14
+ export type KeyedChange<K, T> = {
15
+ readonly changed: readonly (readonly [K, T])[];
16
+ readonly removed: readonly K[];
17
+ readonly order: readonly K[] | null;
18
+ };
19
+ export type QueryChange = KeyedChange<RowKey, QueryDocument | QueryGroup> & {
16
20
  coverage?: QueryCoverage;
17
21
  next?: string | null;
18
22
  total?: number;
19
23
  };
20
- export type QueryMessage = KeyedResult | QueryChange;
24
+ export type ReadinessChange = {
25
+ readonly shown: ReadinessShown;
26
+ readonly rooms: KeyedChange<string, RoomCoverage>;
27
+ };
28
+ export type PendingChange = {
29
+ readonly pending: KeyedChange<string, PendingRoom>;
30
+ };
31
+ export type QueryMessage = KeyedResult | QueryChange | PendingChange;
21
32
  export type Observed = {
22
33
  observation: Observation<unknown>;
23
34
  receive(message: unknown): void;
@@ -25,15 +36,21 @@ export type Observed = {
25
36
  };
26
37
  export declare function rowsOf(result: QueryResult): readonly (QueryDocument | QueryGroup)[];
27
38
  export declare function whole(message: QueryMessage): message is KeyedResult;
28
- export declare function applied(keyed: KeyedResult, message: QueryMessage): KeyedResult;
29
- export declare function observed(first: unknown, stop: () => void, keyed: boolean): Observed;
30
- export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, keyed: boolean): Promise<Observation<unknown>>;
39
+ export declare function pendingChange(message: QueryMessage): message is PendingChange;
40
+ export declare function unchanged(change: KeyedChange<unknown, unknown>): boolean;
41
+ export declare function keyedChange<K, H, T>(held: ReadonlyMap<K, H>, keys: readonly K[], rows: readonly T[], same: (was: H, now: T) => boolean): KeyedChange<K, T>;
42
+ export declare function keyedAt<K, H, T>(held: ReadonlyMap<K, H>, at: ReadonlyMap<K, T | null>, same: (was: H, now: T) => boolean): KeyedChange<K, T> | null;
43
+ export declare function keyedInto<K, T>(held: Map<K, T>, change: KeyedChange<K, T>): void;
44
+ export declare function samePending(was: PendingRoom, now: PendingRoom): boolean;
45
+ export declare function appRooms({ rooms, models }: ListedRooms): readonly AppRoom[];
46
+ export declare function replaces(topic: string, message: unknown): boolean;
47
+ export declare function observed(first: unknown, stop: () => void, topic: string): Observed;
48
+ export declare function opened(watch: (deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void, topic: string): Promise<Observation<unknown>>;
31
49
  export declare function observing<Topic extends string>(watch: (topic: Topic, input: readonly unknown[], deliver: (message: unknown) => void, fail: (error: unknown) => void) => () => void): (topic: Topic, ...input: unknown[]) => Promise<Observation<unknown>>;
32
50
  export type Digest = {
33
- readonly pending: string;
51
+ readonly pending: Map<string, PendingRoom>;
34
52
  } | {
35
- readonly keys: readonly RowKey[];
36
- readonly rows: ReadonlyMap<RowKey, number>;
53
+ readonly rows: Map<RowKey, number>;
37
54
  readonly coverage: string;
38
55
  readonly next: string | undefined;
39
56
  readonly total: number | undefined;
@@ -18,4 +18,4 @@ export type OpenedFiles = {
18
18
  find(name: OpenedName): Promise<KeptBinary | null>;
19
19
  fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
20
20
  };
21
- export declare function openedFiles(database: RuntimeDatabase, fenced: (locator: string) => boolean): OpenedFiles;
21
+ export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
@@ -1,5 +1,6 @@
1
1
  import type { ActionResult, AdapterFailure, AttachResult, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
2
2
  import type { ChangeBatch } from './change.js';
3
+ import type { Attempt, Retries } from './retried.js';
3
4
  import type { KeptBinary, KeptResult } from './opened.js';
4
5
  type Refused<Kind extends string> = ProviderRefusal & {
5
6
  kind: Kind;
@@ -39,6 +40,10 @@ export type AttachAnswer = {
39
40
  kind: 'attached';
40
41
  path: string;
41
42
  } | Offline | Refused<'rejected'> | Failure;
43
+ export type ConversationAttachAnswer = {
44
+ kind: 'attached';
45
+ link: string;
46
+ } | Offline | Refused<'rejected'> | Refused<'undeclared'> | Failure;
42
47
  export type DownloadAnswer = {
43
48
  kind: 'started';
44
49
  } | Refused<'rejected'> | Refused<'absent'> | Refused<'blocked'> | Failure;
@@ -56,9 +61,14 @@ export declare const UNREADABLE: Refused<'unreadable'>;
56
61
  export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
57
62
  export declare const ABSENT_TARGET: Refused<'absent'>;
58
63
  export declare function absentBinary(path: string): Refused<'absent'>;
64
+ export declare function declaredType(blob: Blob): string;
65
+ export declare function blobOf(binary: Extract<BinaryAnswer, {
66
+ kind: 'binary';
67
+ }>): Promise<Blob>;
59
68
  export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
60
69
  export declare function binaryLinkAnswer(result: BinaryLinkResult, held?: string): BinaryLinkAnswer;
61
70
  export declare function attachAnswer(result: AttachResult): AttachAnswer;
71
+ export declare function linkedAnswer(result: AttachResult): ConversationAttachAnswer;
62
72
  export declare const ROOM_LOCKED = "room-locked";
63
73
  export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
64
74
  locator: string;
@@ -69,7 +79,7 @@ export type Offline = {
69
79
  export declare const OFFLINE: Offline;
70
80
  export declare function answeredResult(value: unknown): boolean;
71
81
  export declare const UNCERTAIN: Failure;
72
- export declare function undeclared(name: string): CallResult;
82
+ export declare function undeclared(name: string): Refused<'undeclared'>;
73
83
  export declare function failure(result: AdapterFailure): Failure;
74
84
  export declare function calledResult(result: ActionResult): CallResult;
75
85
  export declare function historyAnswer(result: HistoryResult): HistoryAnswer;
@@ -84,4 +94,6 @@ export type QueueEntry = {
84
94
  } & (Submission | {
85
95
  readonly state: 'local';
86
96
  });
97
+ export declare const UNANSWERED: ActionResult;
98
+ export declare function handedOutcome(retries: Retries, attempt: Attempt | undefined, result: ActionResult): CallResult;
87
99
  export {};
@@ -1,5 +1,7 @@
1
+ import { type ApplyResult } from '../mdmodel/index.js';
1
2
  import type { BinaryFile, HeadChange } from './adapter.js';
2
- import type { ChangeBatch } from './change.js';
3
+ import { type Composition } from './collection.js';
4
+ import { type ChangeBatch } from './change.js';
3
5
  export type Heads = {
4
6
  revisions: Readonly<Record<string, string>>;
5
7
  fileIds: Readonly<Record<string, string>>;
@@ -22,4 +24,6 @@ export type Layer = Heads & {
22
24
  export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
23
25
  export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
24
26
  export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
25
- export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
27
+ export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
28
+ export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
29
+ export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
@@ -1,19 +1,45 @@
1
- import type { PlanReach } from './query.js';
1
+ import { type InstallShare } from './install.js';
2
+ import { type ReadinessChange } from './observation.js';
2
3
  import { type PortReach } from './reach.js';
3
- import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
4
+ import { type CodeAvailability, type ConnectionAvailability, type FirstTier, type Readiness, type RoomCoverage } from './readiness.js';
4
5
  import type { Runtime } from './runtime.js';
5
6
  export type ReadinessPort = {
6
7
  readonly target: string;
7
8
  readonly code: CodeAvailability;
9
+ readonly first: FirstTier | null;
10
+ readonly inboxed: readonly string[] | null;
8
11
  };
12
+ export type ReadinessMessage = Readiness | ReadinessChange;
9
13
  export type ReadinessWatch = {
10
14
  readonly port: ReadinessPort;
11
15
  readonly reach: PortReach | null;
12
- readonly deliver: (readiness: Readiness) => void;
16
+ readonly deliver: (readiness: ReadinessMessage) => void;
17
+ };
18
+ type Share = InstallShare & {
19
+ readonly coverage: RoomCoverage;
20
+ };
21
+ type Settled = {
22
+ acquiring: number;
23
+ unsettled: number;
24
+ };
25
+ type Totals = Settled & {
26
+ installing: number;
27
+ downloading: number;
28
+ done: number;
29
+ total: number;
30
+ };
31
+ export type ReadinessShowing = {
32
+ readonly listing: number;
33
+ readonly roomsListed: boolean;
34
+ readonly named: ReadonlySet<string> | null;
35
+ readonly rooms: Map<string, Share>;
36
+ readonly first: Map<string, string>;
37
+ readonly totals: Totals;
38
+ shown: string;
13
39
  };
14
40
  export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
15
- export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
16
41
  export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
17
- export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
18
- export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
19
- export declare function filled(runtime: Runtime): void;
42
+ export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[], touched: ReadonlySet<string> | null): Promise<void>;
43
+ export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
44
+ export declare function filled({ store, socket }: Runtime): void;
45
+ export {};
@@ -0,0 +1,57 @@
1
+ import type { DiscoveredRoom, ProviderRefusal, ScopedRefusal } from './adapter.js';
2
+ import type { ModelState } from './model.js';
3
+ type Repairable = {
4
+ readonly reset: string | undefined;
5
+ };
6
+ type Standing = {
7
+ readonly stale: boolean;
8
+ readonly repairable: Repairable | null;
9
+ readonly repairing: boolean;
10
+ readonly reloadDue: boolean;
11
+ };
12
+ export declare function lockingMode(mode: string | undefined): boolean;
13
+ type Listing = {
14
+ readonly whole: boolean;
15
+ readonly live: boolean;
16
+ };
17
+ export type Presence = {
18
+ list(found: readonly DiscoveredRoom[], how: Listing): readonly DiscoveredRoom[];
19
+ room(locator: string): DiscoveredRoom | undefined;
20
+ rooms(): readonly DiscoveredRoom[];
21
+ available(locator: string, selection?: string): boolean;
22
+ refusal(locator: string): ProviderRefusal | null;
23
+ unheldModel(locator: string): ModelState | null;
24
+ refused(locator: string, refusal: ScopedRefusal | null): void;
25
+ readable(locator: string): boolean;
26
+ modelled(locator: string, model: ModelState | null): void;
27
+ installed(locator: string, bootstrapped: boolean): void;
28
+ locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
29
+ lockedAmong(stored: ReadonlyMap<string, {
30
+ readonly offline: string;
31
+ }>, locking: ReadonlySet<string>): readonly string[];
32
+ lockedAs(locator: string, mode: string | undefined): boolean;
33
+ connectionLost(lapsed: () => void): void;
34
+ connectionLive(): void;
35
+ lapse(): void;
36
+ stood(locator: string, stale: boolean, repairable?: Repairable | null): void;
37
+ repairing(locator: string, running: boolean): void;
38
+ reload(locator: string, due: boolean): void;
39
+ standing(locator: string): Standing;
40
+ settled(): boolean;
41
+ repairsOwed(): readonly string[];
42
+ askAgain(locator: string, ask: () => void): void;
43
+ stopAsking(locator?: string): void;
44
+ lose(locator: string, during: number): boolean;
45
+ writing(locator: string): boolean;
46
+ unwritten(locator: string): void;
47
+ lost(locator: string): boolean;
48
+ losing(): boolean;
49
+ listing(): number;
50
+ losses(): number;
51
+ lostSince(locator: string, losses: number): boolean;
52
+ liftable(locator: string, discovery: number): boolean;
53
+ lift(locator: string, discovery: number, unfenced: boolean): void;
54
+ close(): void;
55
+ };
56
+ export declare function createPresence(notReadyWaitMs: (asked: number) => number): Presence;
57
+ export {};
@@ -42,7 +42,6 @@ export type CoveredRoom = {
42
42
  };
43
43
  export type QueryCoverage = {
44
44
  rooms: readonly CoveredRoom[];
45
- indexes: readonly string[];
46
45
  overlay: readonly string[];
47
46
  };
48
47
  export type Awaits = Open<'acquisition' | 'preparation' | 'unlock'>;
@@ -1,9 +1,11 @@
1
- import type { AppRoom } from './listing.js';
2
- import type { ReadinessPort } from './preparation.js';
1
+ import type { ListedRoom } from './listing.js';
2
+ import type { ReadinessMessage, ReadinessPort } from './preparation.js';
3
+ import { type CodeAvailability } from './readiness.js';
3
4
  import type { MdRuntime, RuntimeTopic } from './surface.js';
5
+ import type { QueriedRoom } from './adapter.js';
4
6
  import type { Plan, PlanReach, QueryResult } from './query.js';
5
- import type { Readiness } from './readiness.js';
6
7
  import type { SearchResult } from './search.js';
8
+ import type { HouseQueryResult } from './house-query.js';
7
9
  export type ReachedDocument = {
8
10
  readonly room: string;
9
11
  readonly path: string;
@@ -17,6 +19,7 @@ export type PortReach = {
17
19
  readonly rooms: readonly string[];
18
20
  readonly documents: readonly ReachedDocument[];
19
21
  readonly areas?: readonly ReachedArea[];
22
+ readonly queriesOnly?: readonly QueriedRoom[];
20
23
  readonly conversations: boolean;
21
24
  };
22
25
  export type Deliver = (message: unknown) => void;
@@ -28,19 +31,25 @@ export type RuntimeView = {
28
31
  };
29
32
  export type NarrowedView = RuntimeView & {
30
33
  narrow(reach: PortReach | null): void;
34
+ code(code: CodeAvailability): void;
35
+ close(): void;
31
36
  };
32
37
  export type Reachable = RuntimeView & {
33
38
  plan(input: unknown, reach: PortReach | null): Promise<Plan>;
34
39
  query(plan: Plan): Promise<QueryResult>;
35
40
  watchPlan(plan: Plan, deliver: Deliver, fail: Fail): () => void;
36
41
  search(input: unknown, reach: PortReach | null): Promise<SearchResult>;
37
- watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: Readiness) => void): () => void;
42
+ queryHouse(input: unknown, reach: PortReach | null): Promise<HouseQueryResult>;
43
+ queried(): readonly QueriedRoom[];
44
+ watchReadiness(port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
38
45
  locked(room: string): Promise<boolean>;
39
46
  lockedRooms(): Promise<readonly string[]>;
40
47
  watchLocks(notify: () => void): () => void;
41
48
  located(room: string, path: string, destination: string): Promise<ReachedDocument | null>;
42
- room(locator: string): Promise<AppRoom | undefined>;
49
+ room(locator: string): Promise<ListedRoom | undefined>;
43
50
  };
51
+ export declare function queriedOf(reach: PortReach | null, provided: readonly QueriedRoom[]): readonly QueriedRoom[];
52
+ export declare function queriedOnly(reach: PortReach | null, provided: readonly QueriedRoom[], room: string): boolean;
44
53
  export declare function holds(reach: PortReach | null, room: string): boolean;
45
54
  export declare function governs(reach: PortReach | null, room: {
46
55
  readonly locator: string;
@@ -52,4 +61,4 @@ export declare function governs(reach: PortReach | null, room: {
52
61
  readonly selection: boolean;
53
62
  };
54
63
  export declare function planReach(reach: PortReach | null): PlanReach | null;
55
- export declare function narrowed(runtime: Reachable, given: PortReach | null, port: ReadinessPort): NarrowedView;
64
+ export declare function narrowed(runtime: Reachable, given: PortReach | null, attached: ReadinessPort): NarrowedView;
@@ -1,5 +1,11 @@
1
1
  import type { Open } from './open.js';
2
- export type CodeAvailability = Open<'stored' | 'absent'>;
2
+ import type { ObservedRead } from './reads.js';
3
+ export type CodeAvailability = Open<'stored' | 'boot' | 'absent'>;
4
+ export type FirstTier = {
5
+ readonly handles: readonly string[];
6
+ readonly conversations: boolean;
7
+ readonly inboxes: boolean;
8
+ };
3
9
  export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'unadmitted'>;
4
10
  export type RoomCoverage = {
5
11
  readonly room: string;
@@ -12,7 +18,7 @@ export type TargetCoverage = {
12
18
  readonly rooms: readonly RoomCoverage[];
13
19
  readonly conversations: ConversationCoverage;
14
20
  };
15
- export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
21
+ export type Persistence = Open<'granted' | 'denied' | 'unavailable' | 'memory'>;
16
22
  export type Durability = Open<'persistent' | 'best-effort'>;
17
23
  export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
18
24
  export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
@@ -24,7 +30,6 @@ export type InstallationAmount = {
24
30
  };
25
31
  export type Installation = {
26
32
  readonly step: InstallationStep | null;
27
- readonly rooms: InstallationAmount;
28
33
  readonly bytes: InstallationAmount;
29
34
  };
30
35
  export type ReadinessStatus = Open<'preparing' | 'paused' | 'ready' | 'lost'>;
@@ -42,8 +47,18 @@ export type Readiness = {
42
47
  readonly installation: Installation;
43
48
  readonly lost: boolean;
44
49
  };
50
+ export type ReadinessShown = Omit<Readiness, 'coverage'> & {
51
+ readonly coverage: Omit<TargetCoverage, 'rooms'>;
52
+ };
53
+ export type TierFacts = Omit<TargetCoverage, 'complete' | 'rooms'> & {
54
+ readonly unsettled: number;
55
+ };
45
56
  export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
46
- readonly coverage: Omit<TargetCoverage, 'complete'>;
57
+ readonly coverage: TierFacts;
58
+ readonly first: TierFacts;
47
59
  readonly established: boolean;
48
60
  };
49
- export declare function readinessOf(facts: ReadinessFacts): Readiness;
61
+ export declare const INBOXES_READ = "inboxes/list";
62
+ export declare const COMPLETE_ROOMS: ReadonlySet<string>;
63
+ export declare function inboxRooms({ answer }: ObservedRead): readonly string[] | null;
64
+ export declare function readinessOf(facts: ReadinessFacts): ReadinessShown;
@@ -1,5 +1,6 @@
1
1
  import { type CallResult } from './outcome.js';
2
2
  import type { Recovery } from './recovery.js';
3
+ import type { Attempt, Retries } from './retried.js';
3
4
  import type { Connection, RuntimeDatabase } from './tables.js';
4
5
  export declare const READ_TABLES: readonly string[];
5
6
  export type ReadAt = {
@@ -14,7 +15,7 @@ export type ObservedRead = {
14
15
  };
15
16
  export type ReadAnswers = {
16
17
  watch(name: string, input: unknown, deliver: (read: ObservedRead) => void): () => void;
17
- again(): void;
18
+ again(led?: Promise<unknown>): void;
18
19
  reopened(): void;
19
20
  };
20
21
  export type ReadAnswersOptions = {
@@ -23,7 +24,8 @@ export type ReadAnswersOptions = {
23
24
  readonly unkept: readonly string[];
24
25
  readonly leading: readonly string[];
25
26
  readonly recovery: Recovery;
26
- call(name: string, input: unknown): Promise<CallResult>;
27
+ readonly retries: Retries;
28
+ call(name: string, input: unknown, attempt: Attempt): Promise<CallResult>;
27
29
  online(): boolean;
28
30
  streaming(): boolean;
29
31
  closed(): boolean;
@@ -5,6 +5,7 @@ export type Attempt = (signal: AbortSignal) => Promise<Attempted>;
5
5
  export type AttemptOptions = {
6
6
  readonly at?: number;
7
7
  readonly again?: boolean;
8
+ readonly attempts?: number;
8
9
  };
9
10
  export type RecoveryOptions = {
10
11
  readonly firstMs?: number;
@@ -16,10 +17,12 @@ export type Recovery = {
16
17
  attempt(intent: string, run: Attempt, options?: AttemptOptions): Promise<boolean>;
17
18
  pending(intent: string): boolean;
18
19
  resume(): void;
20
+ again(): void;
21
+ waits(wake: () => void): () => void;
19
22
  cancel(intent: string): void;
20
23
  scope(inFlight?: number): Recovery;
21
24
  retire(): Promise<void>;
22
25
  };
23
26
  export declare function retryDelay(tries: number, firstMs?: number, maxMs?: number): number;
24
- export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean): Promise<T>;
27
+ export declare function untilAnswered<T>(ask: () => Promise<T>, signal: AbortSignal, answered?: (answer: T) => boolean, owner?: Recovery): Promise<T>;
25
28
  export declare function createRecovery(options?: RecoveryOptions): Recovery;
@@ -1,5 +1,5 @@
1
1
  import { type TypedPath } from '../mdmodel/index.js';
2
- import type { BootstrapInventory, SavedFacts, MutationResult, OperationScopes, ReplicaAdmission, TypedSelection } from './adapter.js';
2
+ import type { BootstrapInventory, SavedFacts, MutationResult, RoomDeclaration, TypedSelection } from './adapter.js';
3
3
  import { type ChangeBatch, type Precondition } from './change.js';
4
4
  import { type Collection, type Composition } from './collection.js';
5
5
  import { type ModelState } from './model.js';
@@ -7,13 +7,8 @@ import { type Layer } from './overlay.js';
7
7
  import type { HeldEntry, OverlayEntry, StoredEntry } from './tables.js';
8
8
  export type ReplicaRecord = {
9
9
  readonly locator: string;
10
- readonly name: string;
11
- readonly handle: string;
12
- readonly operations: OperationScopes;
13
- readonly replica: ReplicaAdmission;
10
+ readonly declaration: RoomDeclaration;
14
11
  readonly model: ModelState;
15
- readonly typedSelection: TypedSelection | null;
16
- readonly providerOwnedPaths: readonly string[];
17
12
  readonly roomVersion: string;
18
13
  readonly transfer: string;
19
14
  readonly inventory: BootstrapInventory;
@@ -32,7 +27,7 @@ export type Slice = Layer & {
32
27
  readonly facts: Readonly<Record<string, SavedFacts>>;
33
28
  readonly held: ReadonlySet<string>;
34
29
  };
35
- export declare function compositionOf(record: Pick<ReplicaRecord, 'model' | 'typedSelection'>, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
30
+ export declare function compositionOf(model: ModelState, typedSelection: TypedSelection | null, builtIn: ModelState, typedPaths: readonly TypedPath[]): Composition;
36
31
  export declare function storedRecord(record: ReplicaRecord): string;
37
32
  export declare function slicing(entries: readonly HeldEntry[], paths: Iterable<string>): Generator<number, Slice, void>;
38
33
  export type LayerEntry = Omit<StoredEntry, 'facts'>;
@@ -48,8 +43,8 @@ export type Replayed = {
48
43
  };
49
44
  export declare function replaying(confirmed: Slice, queue: readonly ChangeBatch[], locator: string, composition: Composition): Generator<number, Replayed, void>;
50
45
  export declare function overlayOf(visible: VisibleLayer, touched: Iterable<string>): Generator<number, OverlayEntry[], void>;
51
- export declare function holds(layer: Layer, preconditions: readonly Precondition[]): boolean;
52
- export declare function landed(batch: ChangeBatch, confirmed: Layer, current?: Readonly<Record<string, string>>): boolean;
46
+ export declare function holds(layer: Layer, preconditions: readonly Precondition[], composition: Composition): boolean;
47
+ export declare function landed(batch: ChangeBatch, confirmed: Layer, composition: Composition, current?: Readonly<Record<string, string>>): boolean;
53
48
  export type Standing = {
54
49
  readonly withdrawn: readonly ChangeBatch[];
55
50
  readonly kept: readonly ChangeBatch[];
@@ -0,0 +1,29 @@
1
+ import { type RuntimeShell } from './durability.js';
2
+ export declare const STEPS: readonly ['database', 'sign_in', 'connection', 'code', 'download', 'conversations', 'sending', 'reading'];
3
+ export type Step = (typeof STEPS)[number];
4
+ export type RetriedFailure = {
5
+ readonly step: Step;
6
+ readonly answered: false;
7
+ } | {
8
+ readonly step: Step;
9
+ readonly answered: true;
10
+ readonly error: unknown;
11
+ };
12
+ export type Uncertain = {
13
+ readonly failure?: unknown;
14
+ };
15
+ export type Attempt = {
16
+ readonly step: Step;
17
+ readonly instance: string;
18
+ };
19
+ export declare class Unanswered extends Error {
20
+ }
21
+ export declare function uncertainError(uncertainty: Uncertain): unknown;
22
+ export type Retries = {
23
+ failed(step: Step, instance: string, error: unknown): void;
24
+ unanswered(step: Step, instance: string): void;
25
+ uncertain(step: Step, instance: string, uncertainty: Uncertain): void;
26
+ succeeded(step: Step, instance: string): void;
27
+ };
28
+ export declare function createRetries(shell: Pick<RuntimeShell, 'retried' | 'succeeded'>): Retries;
29
+ export declare function retrying<T>(retries: Retries, step: Step, instance: string, ask: () => Promise<T>): () => Promise<T>;
@@ -1,6 +1,7 @@
1
- import type { ProviderRefusal } from './adapter.js';
1
+ import { type ApplyResult, type Definition, type DefinitionOf, type Document } from '../mdmodel/index.js';
2
+ import type { HeadChange, ProviderRefusal } from './adapter.js';
2
3
  import type { Open } from './open.js';
3
- import type { Change, Precondition } from './change.js';
4
+ import type { Change, PartChange, Precondition } from './change.js';
4
5
  import type { VisibleLayer } from './replica.js';
5
6
  export type FieldValue = {
6
7
  readonly value: unknown;
@@ -92,13 +93,28 @@ type ChangedUnderneath = {
92
93
  export type ReturnReason = ProviderRefusal & {
93
94
  readonly kind: Open<'conflicted' | 'rejected' | 'withdrawn'>;
94
95
  };
95
- export declare function returnedBy(kind: 'withdrawn'): ReturnReason;
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
+ };
96
111
  export type RoomDraft = {
97
112
  readonly room: string;
98
113
  readonly path: string;
99
114
  readonly revision: string;
100
115
  readonly parts: HeldParts;
101
116
  readonly changedUnderneath: ChangedUnderneath;
117
+ readonly marks: Marks;
102
118
  readonly returned: ReturnReason | null;
103
119
  };
104
120
  export type RoomDraftWrite = {
@@ -106,8 +122,6 @@ export type RoomDraftWrite = {
106
122
  readonly roomDraft: RoomDraft | null;
107
123
  } | {
108
124
  readonly outcome: 'stale';
109
- readonly code: string;
110
- readonly retryable: boolean;
111
125
  readonly current: RoomDraft | null;
112
126
  };
113
127
  export declare function staleWrite(current: RoomDraft | null): RoomDraftWrite;
@@ -121,6 +135,7 @@ export type RoomDraftRecord = {
121
135
  readonly path: string;
122
136
  readonly revision: string;
123
137
  readonly parts: HeldParts;
138
+ readonly marks: Marks;
124
139
  readonly returned: ReturnReason | null;
125
140
  };
126
141
  export type SavedDraft = {
@@ -134,6 +149,15 @@ export declare function underneath(parts: HeldParts, path: string, visible: Visi
134
149
  export declare function heldFile(blob: Blob, base: string | null): Promise<HeldFile>;
135
150
  export declare function binaryBase(visible: VisibleLayer | undefined, path: string): string | null;
136
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;
137
161
  export declare function lineEnded(text: string): string;
138
162
  export type TextParts = {
139
163
  readonly fields?: Readonly<Record<string, {
@@ -146,8 +170,8 @@ export type TextParts = {
146
170
  readonly value: string;
147
171
  };
148
172
  };
149
- export declare function partsAfter(markdown: string, parts: TextParts): string;
150
- export declare function returnedInto(existing: HeldParts | undefined, returned: HeldParts): HeldParts;
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;
151
175
  export declare function moveTarget(move: {
152
176
  readonly to: string;
153
177
  }): string;
@@ -169,6 +193,5 @@ export declare function changesOf(path: string, parts: HeldParts): {
169
193
  changes: readonly Change[];
170
194
  bases: readonly Precondition[];
171
195
  };
172
- export declare function joinedDraft(carried: SavedDraft, saved: readonly SavedDraft[]): SavedDraft;
173
196
  export declare function withdrawnDrafts(drafts: readonly SavedDraft[], changes: readonly Change[]): readonly SavedDraft[];
174
197
  export {};
@@ -1,42 +1,34 @@
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';
1
+ import type { Discovery, RoomDeclaration, TypedPath } from './adapter.js';
4
2
  import type { RuntimeShell } from './durability.js';
5
3
  import type { LiveConversations } from './conversation-live.js';
4
+ import type { WriteRule } from './declaration.js';
6
5
  import type { FiguresRead } from './figures.js';
7
- import type { Withheld } from './install.js';
8
6
  import type { LiveQueries } from './live.js';
9
- import type { Log } from './log.js';
10
7
  import type { ModelState } from './model.js';
8
+ import type { Presence } from './presence.js';
11
9
  import type { ReadAnswers } from './reads.js';
12
10
  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';
11
+ import type { Retries } from './retried.js';
12
+ import type { RuntimeSocket } from './socket.js';
13
+ import type { HeldCover, Store } from './store.js';
18
14
  import type { schemaTypes } from './attached-model.js';
19
15
  export type Runtime = {
20
16
  readonly store: Store;
21
17
  readonly socket: RuntimeSocket;
22
- readonly journal: Log;
18
+ readonly presence: Presence;
23
19
  readonly recovery: Recovery;
20
+ readonly retries: Retries;
24
21
  readonly shell: RuntimeShell;
25
22
  readonly localSaves: boolean;
26
23
  readonly roomTypes: Parameters<typeof schemaTypes>[1];
27
24
  readonly builtIn: ModelState;
28
25
  readonly typedPaths: readonly TypedPath[];
29
- readonly pathRule: PathRule;
30
- readonly usableWhenHeld: readonly string[];
26
+ readonly writeRule: (declaration: RoomDeclaration) => WriteRule;
31
27
  readonly build: string;
32
28
  readonly conversations: LiveConversations;
33
29
  readonly liveQueries: LiveQueries<HeldCover>;
34
30
  readonly figures: FiguresRead;
35
31
  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>;
32
+ readonly discover: () => Promise<void>;
33
+ readonly adopt: (unstored: Discovery) => Promise<void>;
42
34
  };