@agentshouse/mdruntime 0.1.0-ca6edc1abd618 → 0.1.0-ca92b54804c33

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 (149) hide show
  1. package/README.md +2 -2
  2. package/dist/adapter.d.ts +101 -70
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +3 -10
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +29 -47
  7. package/dist/bootstrap.d.ts +16 -14
  8. package/dist/bootstrap.d.ts.map +1 -1
  9. package/dist/bootstrap.js +272 -129
  10. package/dist/chain.d.ts +2 -1
  11. package/dist/chain.d.ts.map +1 -1
  12. package/dist/change.d.ts +1 -0
  13. package/dist/change.d.ts.map +1 -1
  14. package/dist/client.d.ts +13 -9
  15. package/dist/client.d.ts.map +1 -1
  16. package/dist/client.js +54 -6
  17. package/dist/collection.d.ts +7 -4
  18. package/dist/collection.d.ts.map +1 -1
  19. package/dist/collection.js +23 -17
  20. package/dist/compile.d.ts +1 -6
  21. package/dist/compile.d.ts.map +1 -1
  22. package/dist/compile.js +108 -243
  23. package/dist/connection.d.ts +14 -11
  24. package/dist/connection.d.ts.map +1 -1
  25. package/dist/connection.js +2264 -1933
  26. package/dist/context.d.ts +2 -0
  27. package/dist/context.d.ts.map +1 -0
  28. package/dist/context.js +7 -0
  29. package/dist/conversation.d.ts +21 -17
  30. package/dist/conversation.d.ts.map +1 -1
  31. package/dist/conversation.js +405 -253
  32. package/dist/durability.d.ts +6 -1
  33. package/dist/durability.d.ts.map +1 -1
  34. package/dist/entry.d.ts +3 -2
  35. package/dist/entry.d.ts.map +1 -1
  36. package/dist/entry.js +18 -8
  37. package/dist/file.d.ts +2 -11
  38. package/dist/file.d.ts.map +1 -1
  39. package/dist/file.js +6 -4
  40. package/dist/host.d.ts +3 -7
  41. package/dist/host.d.ts.map +1 -1
  42. package/dist/host.js +26 -29
  43. package/dist/identity.d.ts +0 -1
  44. package/dist/identity.d.ts.map +1 -1
  45. package/dist/identity.js +0 -3
  46. package/dist/index.d.ts +12 -9
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +4 -1
  49. package/dist/job.d.ts +14 -0
  50. package/dist/job.d.ts.map +1 -0
  51. package/dist/job.js +28 -0
  52. package/dist/live.d.ts +5 -4
  53. package/dist/live.d.ts.map +1 -1
  54. package/dist/live.js +62 -20
  55. package/dist/media.d.ts +8 -0
  56. package/dist/media.d.ts.map +1 -0
  57. package/dist/media.js +218 -0
  58. package/dist/memory.d.ts +12 -5
  59. package/dist/memory.d.ts.map +1 -1
  60. package/dist/memory.js +216 -85
  61. package/dist/messages.d.ts +3 -3
  62. package/dist/messages.d.ts.map +1 -1
  63. package/dist/messages.js +20 -19
  64. package/dist/model.d.ts +8 -10
  65. package/dist/model.d.ts.map +1 -1
  66. package/dist/model.js +5 -17
  67. package/dist/observation.d.ts +3 -2
  68. package/dist/observation.d.ts.map +1 -1
  69. package/dist/observation.js +8 -3
  70. package/dist/outcome.d.ts +13 -5
  71. package/dist/outcome.d.ts.map +1 -1
  72. package/dist/outcome.js +16 -2
  73. package/dist/overlay.d.ts +1 -0
  74. package/dist/overlay.d.ts.map +1 -1
  75. package/dist/overlay.js +11 -0
  76. package/dist/paths.d.ts +1 -0
  77. package/dist/paths.d.ts.map +1 -1
  78. package/dist/paths.js +4 -0
  79. package/dist/query.d.ts +8 -207
  80. package/dist/query.d.ts.map +1 -1
  81. package/dist/query.js +3 -505
  82. package/dist/reach.d.ts +18 -11
  83. package/dist/reach.d.ts.map +1 -1
  84. package/dist/reach.js +195 -126
  85. package/dist/react.d.ts +3 -1
  86. package/dist/react.d.ts.map +1 -1
  87. package/dist/readiness.d.ts +3 -17
  88. package/dist/readiness.d.ts.map +1 -1
  89. package/dist/readiness.js +4 -10
  90. package/dist/recovery.d.ts +1 -0
  91. package/dist/recovery.d.ts.map +1 -1
  92. package/dist/recovery.js +35 -1
  93. package/dist/refresh.d.ts +7 -5
  94. package/dist/refresh.d.ts.map +1 -1
  95. package/dist/refresh.js +33 -5
  96. package/dist/replica.d.ts +10 -8
  97. package/dist/replica.d.ts.map +1 -1
  98. package/dist/replica.js +52 -20
  99. package/dist/room-draft.d.ts +21 -5
  100. package/dist/room-draft.d.ts.map +1 -1
  101. package/dist/room-draft.js +98 -51
  102. package/dist/rows.d.ts +18 -16
  103. package/dist/rows.d.ts.map +1 -1
  104. package/dist/rows.js +45 -153
  105. package/dist/save.d.ts +2 -0
  106. package/dist/save.d.ts.map +1 -1
  107. package/dist/save.js +22 -13
  108. package/dist/search.d.ts +12 -63
  109. package/dist/search.d.ts.map +1 -1
  110. package/dist/search.js +9 -52
  111. package/dist/shared.d.ts +0 -1
  112. package/dist/shared.d.ts.map +1 -1
  113. package/dist/shared.js +0 -10
  114. package/dist/status.d.ts +4 -5
  115. package/dist/status.d.ts.map +1 -1
  116. package/dist/status.js +3 -7
  117. package/dist/store.d.ts +101 -61
  118. package/dist/store.d.ts.map +1 -1
  119. package/dist/store.js +153 -161
  120. package/dist/stored.d.ts +66 -55
  121. package/dist/stored.d.ts.map +1 -1
  122. package/dist/stored.js +341 -273
  123. package/dist/tables.d.ts +90 -63
  124. package/dist/tables.d.ts.map +1 -1
  125. package/dist/tables.js +174 -98
  126. package/dist/transfer.d.ts +0 -5
  127. package/dist/transfer.d.ts.map +1 -1
  128. package/dist/validation.d.ts +3 -4
  129. package/dist/validation.d.ts.map +1 -1
  130. package/dist/validation.js +42 -100
  131. package/dist/windows.d.ts +1 -12
  132. package/dist/windows.d.ts.map +1 -1
  133. package/dist/windows.js +2 -75
  134. package/dist/wire.d.ts +17 -8
  135. package/dist/wire.d.ts.map +1 -1
  136. package/dist/wire.js +5 -2
  137. package/package.json +2 -2
  138. package/dist/fence.d.ts +0 -6
  139. package/dist/fence.d.ts.map +0 -1
  140. package/dist/fence.js +0 -10
  141. package/dist/fulltext.d.ts +0 -27
  142. package/dist/fulltext.d.ts.map +0 -1
  143. package/dist/fulltext.js +0 -368
  144. package/dist/reads.d.ts +0 -11
  145. package/dist/reads.d.ts.map +0 -1
  146. package/dist/reads.js +0 -100
  147. package/dist/words.d.ts +0 -19
  148. package/dist/words.d.ts.map +0 -1
  149. package/dist/words.js +0 -150
package/dist/save.js CHANGED
@@ -4,7 +4,7 @@ import { immutable, leaving, queuedFile, departure, } from './change.js';
4
4
  import { collectionOf, documentsOf, governing, } from './collection.js';
5
5
  import { changeBatchIdentity } from './identity.js';
6
6
  import { overlaying } from './overlay.js';
7
- import { covered, normalize } from './paths.js';
7
+ import { ancestors, covered, normalize } from './paths.js';
8
8
  import { sorting } from './shared.js';
9
9
  import { paced, ROW_WEIGHT, stepped } from './turn.js';
10
10
  import { validatedCollection } from './validation.js';
@@ -321,6 +321,8 @@ function* incoming(collection, removed, candidates) {
321
321
  function affected(change) {
322
322
  return change.kind === 'move' ? [change.path, change.to] : [change.path];
323
323
  }
324
+ const WRITE = ['write'];
325
+ const MOVE_OUT = ['write', 'erase'];
324
326
  function guard(changes, input, removing) {
325
327
  const overridden = new Map();
326
328
  const existing = {
@@ -329,6 +331,7 @@ function guard(changes, input, removing) {
329
331
  add: (path) => void overridden.set(path, true),
330
332
  delete: (path) => void overridden.set(path, false),
331
333
  };
334
+ const occupied = (path) => input.folders.has(path) ? path : (ancestors(path).find((one) => existing.has(one)) ?? null);
332
335
  for (const [index, change] of changes.entries()) {
333
336
  for (const path of affected(change)) {
334
337
  const normalized = normalize(path);
@@ -337,13 +340,14 @@ function guard(changes, input, removing) {
337
340
  if (covered(input.providerOwnedPaths, normalized)) {
338
341
  return refuse('provider-owned-path', normalized);
339
342
  }
340
- const operation = change.kind === 'remove' ? removing : 'write';
341
- if (!input.local && !covered(input.operations[operation], normalized))
342
- return refuse(`${operation}-grant`, normalized);
343
+ for (const operation of change.kind === 'remove' ? removing : WRITE)
344
+ if (!input.local && !covered(input.operations[operation], normalized))
345
+ return refuse(`${operation}-grant`, normalized);
343
346
  }
344
347
  if (change.kind === 'create' || change.kind === 'arrival') {
345
- if (existing.has(change.path))
346
- return refuse('path-collision', change.path);
348
+ const taken = existing.has(change.path) ? change.path : occupied(change.path);
349
+ if (taken !== null)
350
+ return refuse('path-collision', taken);
347
351
  existing.add(change.path);
348
352
  continue;
349
353
  }
@@ -353,6 +357,9 @@ function guard(changes, input, removing) {
353
357
  input.bases.some((base) => base.kind === 'absent' && base.path === change.path))) {
354
358
  return refuse('path-collision', change.path);
355
359
  }
360
+ const taken = occupied(change.path);
361
+ if (taken !== null)
362
+ return refuse('path-collision', taken);
356
363
  if (!input.local &&
357
364
  existing.has(change.path) &&
358
365
  input.visible.revisions[departure(changes, index)] === undefined) {
@@ -364,8 +371,9 @@ function guard(changes, input, removing) {
364
371
  if (change.kind === 'move') {
365
372
  if (!existing.has(change.path))
366
373
  return refuse('path-absent', change.path);
367
- if (existing.has(change.to))
368
- return refuse('path-collision', change.to);
374
+ const taken = existing.has(change.to) ? change.to : occupied(change.to);
375
+ if (taken !== null)
376
+ return refuse('path-collision', taken);
369
377
  if (unrevised(input, change.path)) {
370
378
  return refuse('unknown-revision', change.path);
371
379
  }
@@ -968,7 +976,7 @@ function roomReferencesIn(path, content, composition) {
968
976
  const parsed = parse(content, path);
969
977
  if (!parsed.ok)
970
978
  return [];
971
- return roomReferences(path, content, definitionOf(governing(composition, path), parsed.document.type));
979
+ return roomReferences(parsed.document, definitionOf(governing(composition, path), parsed.document.type));
972
980
  }
973
981
  function* admittedRooms(changes, visible, resulting, composition) {
974
982
  const from = new Map();
@@ -1014,7 +1022,7 @@ async function batching(input) {
1014
1022
  const rewritten = await stepped(rewrites(changes, input.visible));
1015
1023
  if (rewritten.kind === 'refused')
1016
1024
  return rewritten;
1017
- const refusal = guard(changes, input, 'delete');
1025
+ const refusal = guard(changes, input, WRITE);
1018
1026
  if (refusal !== null)
1019
1027
  return refusal;
1020
1028
  const preconditions = await stepped(preconditionsOf(changes, input.visible, input.bases));
@@ -1063,9 +1071,10 @@ function arrivingText(path, to, source, moved) {
1063
1071
  return applied.outcome === 'applied' ? serialize(applied.document) : content;
1064
1072
  }
1065
1073
  function arrivalOf({ path, to }, source, moved) {
1066
- const { documents, revisions, fileIds, changes, binaries } = source.visible;
1074
+ const { documents, revisions, fileIds, created, changes, binaries } = source.visible;
1067
1075
  const kept = {
1068
1076
  ...(fileIds[path] === undefined ? {} : { fileId: fileIds[path] }),
1077
+ ...(created[path] === undefined ? {} : { created: created[path] }),
1069
1078
  ...(changes[path] === undefined ? {} : { change: changes[path] }),
1070
1079
  };
1071
1080
  const heads = {
@@ -1095,7 +1104,7 @@ async function moving(input) {
1095
1104
  if (moves.length === 0)
1096
1105
  return refuse('no-change');
1097
1106
  const removals = moves.map(({ path }) => ({ kind: 'remove', path }));
1098
- const leaves = guard(removals, { ...source, local: input.local, bases: [] }, 'write');
1107
+ const leaves = guard(removals, { ...source, local: input.local, bases: [] }, MOVE_OUT);
1099
1108
  if (leaves !== null)
1100
1109
  return leaves;
1101
1110
  const uploading = moves.find(({ path }) => source.visible.binaries[path]?.state === 'pending');
@@ -1103,7 +1112,7 @@ async function moving(input) {
1103
1112
  return refuse('unknown-revision', uploading.path);
1104
1113
  const moved = new Map(moves.map(({ path, to }) => [path, to]));
1105
1114
  const arrivals = moves.map((move) => arrivalOf(move, source, moved));
1106
- const arrives = guard(arrivals, { ...destination, local: input.local, bases: [] }, 'write');
1115
+ const arrives = guard(arrivals, { ...destination, local: input.local, bases: [] }, WRITE);
1107
1116
  if (arrives !== null)
1108
1117
  return arrives;
1109
1118
  const bound = input.providerLimits.find((limit) => limit.name === MOVE_DOCUMENTS)?.value;
package/dist/search.d.ts CHANGED
@@ -1,73 +1,22 @@
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;
73
22
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;AAEvC,MAAM,MAAM,OAAO,CAAC,IAAI,SAAS,MAAM,IAAI;IACzC,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,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GAC1C,OAAO,CAAC;AAEZ,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAYvD"}
package/dist/search.js CHANGED
@@ -1,57 +1,14 @@
1
- import { flag, invalid, known, limitOf, plain, } from './query.js';
2
- import { decodedCursor } from './windows.js';
3
- export function undeclaredSearch() {
4
- return {
5
- kind: 'undeclared',
6
- code: 'search-undeclared',
7
- fields: { name: 'local_search' },
8
- retryable: false,
9
- };
10
- }
11
- function hitCursor(input) {
12
- if (input === null)
13
- return null;
14
- if (!Array.isArray(input))
15
- return undefined;
16
- if (input.length === 0)
17
- return [];
18
- const [score, first, second] = input;
19
- return input.length === 3 &&
20
- typeof score === 'number' &&
21
- typeof first === 'string' &&
22
- typeof second === 'string'
23
- ? [score, first, second]
24
- : undefined;
25
- }
26
- function searchAfter(input) {
27
- if (input === undefined)
28
- return null;
29
- const decoded = typeof input === 'string' ? decodedCursor(input) : null;
30
- const documents = decoded?.length === 2 ? hitCursor(decoded[0]) : undefined;
31
- const messages = decoded?.length === 2 ? hitCursor(decoded[1]) : undefined;
32
- if (documents === undefined || messages === undefined) {
33
- invalid('after', 'expects the next an earlier search returned');
34
- }
35
- return [documents, messages];
36
- }
1
+ import { invalid, known, plain } from '@agentshouse/mdmodel';
37
2
  export function searchPlanOf(input) {
38
3
  if (!plain(input))
39
4
  invalid('search', 'expects a search object');
40
- known(input, ['text', 'documents', 'collection', 'conversations', 'limit', 'after', 'total'], '');
41
- if (typeof input.text !== 'string')
42
- invalid('text', 'expects text');
43
- const conversations = input.conversations;
44
- if (conversations !== undefined &&
45
- (!Array.isArray(conversations) || conversations.some((named) => typeof named !== 'string'))) {
46
- invalid('conversations', 'expects a list of conversations');
5
+ known(input, ['text', 'rooms'], '');
6
+ if (typeof input.text !== 'string' || input.text.trim() === '')
7
+ invalid('text', 'expects words');
8
+ const rooms = input.rooms;
9
+ if (rooms !== undefined &&
10
+ (!Array.isArray(rooms) || rooms.some((named) => typeof named !== 'string'))) {
11
+ invalid('rooms', 'expects a list of Rooms');
47
12
  }
48
- return {
49
- text: input.text,
50
- documents: input.documents,
51
- collection: flag(input.collection, 'collection'),
52
- conversations: conversations ?? null,
53
- limit: limitOf(input.limit),
54
- after: searchAfter(input.after),
55
- total: flag(input.total, 'total'),
56
- };
13
+ return { text: input.text, rooms: rooms ?? null };
57
14
  }
package/dist/shared.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export type Paths<V> = Readonly<Record<string, V>>;
2
2
  export declare function entriesIn<V>(map: Paths<V>): Generator<readonly [string, V]>;
3
- export declare function keysIn(...maps: readonly Paths<unknown>[]): Generator<number, Set<string>, void>;
4
3
  export declare function sortedKeys(map: Paths<unknown>): Generator<number, readonly string[], void>;
5
4
  export declare function sorting(keys: Iterable<string>): Generator<number, readonly string[], void>;
6
5
  export declare function sharing<V>(map: Paths<V>): Generator<number, Paths<V>, void>;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;AA+LnD,wBAAiB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAO5E;AAeD,wBAAiB,MAAM,CAAC,GAAG,IAAI,EAAE,SAAS,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAShG;AA0BD,wBAAiB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,G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AAC,CAkB9C;AAED,wBAAgB,SAAS,CAAC,CAAC,EACzB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EACd,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,IAAI,GAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,OAAmB,GAC/C,WAAW,CAAC,MAAM,CAAC,CAErB;AAMD,wBAAgB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAiD5D;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE7D;AAED,wBAAiB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAUxF"}
package/dist/shared.js CHANGED
@@ -202,16 +202,6 @@ function* rooted(map) {
202
202
  }
203
203
  return { node, size };
204
204
  }
205
- export function* keysIn(...maps) {
206
- const keys = new Set();
207
- for (const map of maps) {
208
- for (const [key] of entriesIn(map)) {
209
- keys.add(key);
210
- yield ROW_WEIGHT;
211
- }
212
- }
213
- return keys;
214
- }
215
205
  const RUN = 1 << 10;
216
206
  function* merged(left, right) {
217
207
  const into = [];
package/dist/status.d.ts CHANGED
@@ -1,19 +1,20 @@
1
1
  import type { Open } from './open.js';
2
- import type { ProviderRefusal } from './adapter.js';
3
2
  import type { ReturnReason } from './room-draft.js';
4
3
  export type AttentionEntry = {
5
4
  room: string;
6
5
  path: string;
7
6
  returned: ReturnReason;
8
- } | {
7
+ };
8
+ export type UnsentChange = {
9
9
  room: string;
10
- refusal: ProviderRefusal;
10
+ path: string;
11
11
  };
12
12
  export type SyncStatus = {
13
13
  state: Open<'pending' | 'syncing' | 'synced'>;
14
14
  lastCompleted: string | null;
15
15
  providerUnreachable: boolean;
16
16
  attentionRequired: readonly AttentionEntry[];
17
+ unsent: readonly UnsentChange[];
17
18
  reset: string | null;
18
19
  };
19
20
  export type CycleProgress = {
@@ -21,7 +22,5 @@ export type CycleProgress = {
21
22
  reachable: boolean;
22
23
  };
23
24
  export declare const STARTING: SyncStatus;
24
- export declare function transferring(status: SyncStatus): SyncStatus;
25
- export declare function saving(status: SyncStatus): SyncStatus;
26
25
  export declare function same(one: SyncStatus, other: SyncStatus): boolean;
27
26
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,eAAe,CAAA;CAAE,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC;IAC9C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,iBAAiB,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAA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status.js CHANGED
@@ -3,18 +3,14 @@ export const STARTING = {
3
3
  lastCompleted: null,
4
4
  providerUnreachable: false,
5
5
  attentionRequired: [],
6
+ unsent: [],
6
7
  reset: null,
7
8
  };
8
- export function transferring(status) {
9
- return { ...status, state: 'syncing' };
10
- }
11
- export function saving(status) {
12
- return { ...status, state: 'pending' };
13
- }
14
9
  export function same(one, other) {
15
10
  return (one.state === other.state &&
16
11
  one.lastCompleted === other.lastCompleted &&
17
12
  one.providerUnreachable === other.providerUnreachable &&
18
13
  one.reset === other.reset &&
19
- JSON.stringify(one.attentionRequired) === JSON.stringify(other.attentionRequired));
14
+ JSON.stringify(one.attentionRequired) === JSON.stringify(other.attentionRequired) &&
15
+ JSON.stringify(one.unsent) === JSON.stringify(other.unsent));
20
16
  }
package/dist/store.d.ts CHANGED
@@ -1,50 +1,37 @@
1
- import type { BootstrapInventory, Capability, KeptReceipt, Member, ProviderLimit } from './adapter.js';
1
+ import type { BootstrapInventory, Capability, ListedConversation, Member, ProviderLimit } from './adapter.js';
2
2
  import type { ChangeBatch } from './change.js';
3
- import type { Composition } from './collection.js';
3
+ import { type Composition } from './collection.js';
4
4
  import type { Plan } from './query.js';
5
5
  import type { ReplicaRecord } from './replica.js';
6
6
  import type { Submission } from './outcome.js';
7
7
  import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
8
- import type { ModelState } from './model.js';
9
- import type { SearchWindow } from './search.js';
10
- import type { CommittedWrite, ConversationWrite, CountedRoom, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, RoomCommit, RuntimeDatabase, SearchAsk, StoredEntry, StoredFile, TypedEntry, View, Walked } from './tables.js';
8
+ import type { ModelState, StoredModel } from './model.js';
9
+ import type { CommittedWrite, ConversationWrite, HeldConversation, HeldEntry, MessageWindow, QueryAnswer, QueryRoom, Referrer, ReplicaOpened, RoomCommit, RuntimeDatabase, StoredEntry, StoredFile, TypedEntry, View } from './tables.js';
11
10
  export type { ConversationWrite, HeldConversation, MessageWindow } from './tables.js';
12
- export type TransferWriting = {
13
- readonly token: string | null;
14
- readonly written: number;
15
- };
16
11
  export type TransferRecord = {
17
12
  readonly locator: string;
18
13
  readonly transfer: string;
19
14
  readonly selection: string;
20
15
  readonly from: string;
21
16
  readonly last: string;
22
- readonly pageToken: string | null;
23
- readonly writing: TransferWriting | null;
24
- readonly inventory: BootstrapInventory | null;
25
17
  readonly done: BootstrapInventory;
26
18
  readonly models: {
27
19
  readonly collection: ModelState;
28
20
  };
29
21
  readonly key: number | null;
30
22
  };
23
+ export type StoredReplica = Omit<ReplicaRecord, 'model'> & {
24
+ readonly model: StoredModel;
25
+ };
31
26
  export type PendingState = {
32
27
  readonly drafts: readonly SavedDraft[];
33
28
  readonly submission: Submission;
34
29
  readonly lost: boolean;
35
30
  readonly upload?: unknown;
36
- readonly accepted?: string;
37
31
  };
38
32
  export type TargetRecord = {
39
33
  established: boolean;
40
34
  };
41
- export type QueueRecord = {
42
- locator: string;
43
- pending: readonly {
44
- batch: ChangeBatch;
45
- state: PendingState;
46
- }[];
47
- };
48
35
  export type PresentationRecord = {
49
36
  app: string;
50
37
  value: unknown;
@@ -69,83 +56,143 @@ export type CallRecord = {
69
56
  export type AuthoredWrite = {
70
57
  locator: string;
71
58
  queue?: readonly ChangeBatch[];
59
+ stored?: readonly ChangeBatch[];
72
60
  founded?: readonly ChangeBatch[];
73
61
  saved?: ReadonlyMap<string, readonly SavedDraft[]>;
74
62
  roomDrafts?: readonly RoomDraftRecord[];
75
63
  consumedRoomDrafts?: readonly string[];
76
- accepted?: readonly {
77
- readonly id: string;
78
- readonly roomVersion: string;
79
- }[];
80
64
  };
81
65
  export type StagedPage = {
82
66
  readonly entries: readonly StoredEntry[];
83
67
  readonly folders: readonly string[];
68
+ readonly part?: string;
69
+ };
70
+ export type ResumedTransfer = {
71
+ readonly key: number | null;
72
+ readonly transfer: string;
73
+ readonly staged: readonly string[];
84
74
  };
85
75
  export type RefreshedPage = StagedPage & {
86
76
  readonly removals: readonly string[];
87
77
  readonly folderRemovals: readonly string[];
88
78
  };
89
- export type Opened = {
90
- readonly rooms: ReadonlyMap<string, ReplicaRecord>;
91
- readonly transfers: ReadonlyMap<string, TransferRecord>;
92
- readonly unindexed: ReadonlySet<number>;
93
- readonly overlaid: ReadonlyMap<number, ReadonlySet<string>>;
94
- readonly erasing: boolean;
95
- readonly orphans: readonly number[];
79
+ export type HeldRoom = {
80
+ readonly record: StoredReplica;
81
+ readonly indexed: boolean;
82
+ readonly documents: number;
83
+ };
84
+ export type QueuedChange = {
85
+ readonly batch: ChangeBatch;
86
+ readonly state: PendingState;
87
+ };
88
+ export type HeldWork = {
89
+ readonly room: (HeldRoom & {
90
+ readonly overlaid: ReadonlySet<string>;
91
+ }) | null;
92
+ readonly queue: readonly QueuedChange[];
93
+ };
94
+ export type CoveredRoom = {
95
+ readonly key: number;
96
+ readonly transfer: string;
97
+ readonly roomVersion: string;
98
+ readonly indexed: boolean;
99
+ readonly documents: number;
100
+ readonly bytes: number;
101
+ readonly offline: string;
102
+ };
103
+ export type HeldCover = {
104
+ readonly rooms: ReadonlyMap<string, CoveredRoom>;
105
+ readonly queues: ReadonlyMap<string, readonly string[]>;
106
+ };
107
+ export type HeldStatus = {
108
+ readonly queued: readonly string[];
109
+ readonly lastCompleted: string | null;
110
+ readonly unsent: readonly {
111
+ readonly room: string;
112
+ readonly path: string;
113
+ }[];
114
+ readonly resets: readonly {
115
+ readonly locator: string;
116
+ readonly reset: string;
117
+ }[];
118
+ readonly returned: readonly RoomDraftRecord[];
119
+ };
120
+ export type Facts = {
96
121
  readonly lastCompleted: string | null;
97
122
  readonly providerLimits: readonly ProviderLimit[];
98
123
  readonly capabilities: readonly Capability[];
99
124
  readonly member: Member | null;
100
125
  readonly targets: Readonly<Record<string, TargetRecord>>;
101
- readonly presentation: readonly PresentationRecord[];
126
+ readonly conversationList: readonly ListedConversation[] | null;
127
+ readonly conversationCursor: string | null;
102
128
  };
103
129
  export type Commit = {
104
130
  readonly rooms: readonly RoomCommit[];
105
131
  readonly writes?: readonly AuthoredWrite[];
106
132
  readonly files?: readonly StoredFile[];
107
133
  readonly whole?: boolean;
108
- readonly discards?: readonly string[];
109
134
  };
110
135
  export type RuntimeStore = {
111
- opened(): Promise<Opened>;
112
- counts(rooms: readonly CountedRoom[]): Promise<readonly number[]>;
136
+ opened(): Promise<ReplicaOpened>;
137
+ rooms(locators?: readonly string[]): Promise<readonly HeldRoom[]>;
138
+ room(locator: string): Promise<HeldWork>;
139
+ covering(): Promise<HeldCover>;
140
+ offline(locator: string): Promise<string | null>;
141
+ held(): Promise<{
142
+ readonly held: ReadonlySet<string>;
143
+ readonly staged: ReadonlySet<string>;
144
+ }>;
145
+ status(): Promise<HeldStatus>;
146
+ batch(locator: string, id: string): Promise<ChangeBatch | null>;
147
+ order(locator: string): Promise<readonly string[]>;
148
+ queued(): Promise<readonly string[]>;
149
+ moving(): Promise<{
150
+ readonly queued: ReadonlyMap<string, readonly string[]>;
151
+ readonly moving: readonly (QueuedChange & {
152
+ readonly locator: string;
153
+ })[];
154
+ }>;
155
+ pending(locator: string, id: string): Promise<{
156
+ readonly state: PendingState | undefined;
157
+ readonly room: boolean;
158
+ }>;
159
+ facts(): Promise<Facts>;
160
+ presentation(app: string): Promise<unknown>;
161
+ demote(): Promise<void>;
113
162
  query(plan: Plan, rooms: readonly QueryRoom[], budget: number | null): Promise<QueryAnswer>;
114
163
  changes(keys: readonly number[]): number;
115
164
  entries(key: number, view: View, paths: readonly string[]): Promise<readonly HeldEntry[]>;
116
165
  typed(key: number, view: View, paths: readonly string[]): Promise<readonly TypedEntry[]>;
117
- referrers(key: number, view: View, targets: readonly string[], kinds: readonly string[]): Promise<readonly Referrer[]>;
118
- walk(key: number, view: View, after: string | null, bytes: number): Promise<Walked>;
119
- files(key: number, view: View, after: string | null, limit: number): Promise<readonly {
120
- readonly path: string;
121
- readonly revision: string;
122
- }[]>;
166
+ referrers(key: number, view: View, targets: readonly string[]): Promise<readonly Referrer[]>;
167
+ folders(key: number, view: View, paths: readonly string[]): Promise<readonly string[]>;
123
168
  typedWithin(key: number, view: View, roots: readonly string[], within: boolean): Promise<boolean>;
124
- search(ask: SearchAsk): Promise<SearchWindow>;
125
- stage(record: TransferRecord, composition: Composition, page: StagedPage, written?: string): Promise<number | null>;
126
- transferPart(locator: string, token: string): Promise<Uint8Array | null>;
127
- keepPart(locator: string, token: string, part: Uint8Array): Promise<void>;
128
- refresh(key: number, page: RefreshedPage): Promise<void>;
169
+ stage(record: TransferRecord, composition: Composition, page: StagedPage): Promise<number | null>;
170
+ resume(record: TransferRecord, composition: Composition, parts: readonly string[], published: number | null): Promise<ResumedTransfer | null>;
171
+ refresh(key: number, composition: Composition, page: RefreshedPage): Promise<void>;
129
172
  unrefresh(key: number): Promise<void>;
130
173
  commit(commit: Commit): Promise<CommittedWrite>;
131
174
  fence(locators: readonly string[]): Promise<void>;
132
175
  erase(locator: string | null, limit: number): Promise<boolean>;
133
- abandon(locator: string, kept?: boolean): Promise<number | null>;
176
+ abandon(locator: string): Promise<void>;
177
+ unfence(locators: readonly string[]): Promise<ReadonlySet<string>>;
134
178
  release(key: number): Promise<void>;
135
- rederive(key: number, limit: number): Promise<boolean>;
179
+ rederive(key: number, composition: Composition, bytes: number, ms: number, floor: number): Promise<{
180
+ readonly done: boolean;
181
+ readonly text: number;
182
+ }>;
136
183
  fact(name: string, value: unknown): Promise<void>;
137
- queues(): Promise<readonly QueueRecord[]>;
138
184
  submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
139
185
  keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
140
- roomDrafts(): Promise<readonly RoomDraftRecord[]>;
186
+ roomDrafts(locator?: string, paths?: readonly string[]): Promise<readonly RoomDraftRecord[]>;
141
187
  present(record: PresentationRecord): Promise<void>;
142
- conversations(): Promise<readonly HeldConversation[]>;
188
+ conversations(conversations?: readonly string[]): Promise<readonly HeldConversation[]>;
143
189
  keepMessages(write: ConversationWrite): Promise<void>;
144
- messageWindow(conversation: string, limit: number, before: readonly [string, string] | null): Promise<MessageWindow>;
145
- messageCount(conversation: string): Promise<number>;
190
+ messageWindow(conversation: string, limit: number, before: readonly [string, string] | null, phrase?: string | null): Promise<MessageWindow>;
191
+ messageCount(conversation: string, phrase?: string | null): Promise<number>;
146
192
  turnArrived(conversation: string, turn: string): Promise<boolean>;
147
193
  dropConversations(conversations: readonly string[]): Promise<void>;
148
194
  chatDrafts(): Promise<readonly ChatDraftRecord[]>;
195
+ chatDraft(conversation: string): Promise<ChatDraftRecord | null>;
149
196
  keepChatDrafts(records: readonly ChatDraftRecord[]): Promise<void>;
150
197
  dropChatDraft(conversation: string): Promise<void>;
151
198
  calls(): Promise<readonly CallRecord[]>;
@@ -154,16 +201,9 @@ export type RuntimeStore = {
154
201
  keepRoomDraft(record: RoomDraftRecord, files: readonly StoredFile[]): Promise<void>;
155
202
  discardRoomDraft(locator: string, path: string): Promise<void>;
156
203
  fences(): Promise<readonly string[]>;
157
- receivedHeads(): Promise<readonly KeptReceipt[]>;
158
- receivedParts(key: string, count: number): Promise<readonly unknown[]>;
159
- keepReceived(key: string, head: unknown, part?: {
160
- index: number;
161
- value: unknown;
162
- }): Promise<void>;
163
- dropReceived(keys: readonly string[]): Promise<void>;
164
204
  generation(): Promise<string | null>;
165
205
  rememberGeneration(value: string): Promise<void>;
166
206
  file(key: string, type: string): Promise<Blob>;
167
207
  };
168
- export declare function openRuntimeStore(fenced: (locator: string) => boolean, authored: RuntimeDatabase): RuntimeStore;
208
+ export declare function openRuntimeStore(authored: RuntimeDatabase): RuntimeStore;
169
209
  //# sourceMappingURL=store.d.ts.map