@agentshouse/mdruntime 0.1.0-cf6d5f0a5c9c8 → 0.1.0-cf890bb538119

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 (256) hide show
  1. package/AGENTS.md +298 -232
  2. package/README.md +19 -8
  3. package/dist/adapter.d.ts +127 -32
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/attached-model.d.ts +4 -1
  6. package/dist/attached-model.d.ts.map +1 -1
  7. package/dist/attached-model.js +13 -3
  8. package/dist/attempt.d.ts +16 -0
  9. package/dist/attempt.d.ts.map +1 -0
  10. package/dist/attempt.js +70 -0
  11. package/dist/binary.d.ts +23 -0
  12. package/dist/binary.d.ts.map +1 -0
  13. package/dist/binary.js +8 -0
  14. package/dist/bootstrap.d.ts +16 -8
  15. package/dist/bootstrap.d.ts.map +1 -1
  16. package/dist/bootstrap.js +102 -50
  17. package/dist/chain.d.ts +11 -0
  18. package/dist/chain.d.ts.map +1 -0
  19. package/dist/chain.js +64 -0
  20. package/dist/change-set.d.ts +9 -14
  21. package/dist/change-set.d.ts.map +1 -1
  22. package/dist/change-set.js +11 -62
  23. package/dist/change.d.ts +45 -0
  24. package/dist/change.d.ts.map +1 -1
  25. package/dist/change.js +34 -0
  26. package/dist/chat/acts.d.ts +33 -0
  27. package/dist/chat/acts.d.ts.map +1 -0
  28. package/dist/chat/acts.js +36 -0
  29. package/dist/chat/context.d.ts +3 -0
  30. package/dist/chat/context.d.ts.map +1 -0
  31. package/dist/chat/context.js +10 -0
  32. package/dist/chat/earlier.d.ts +10 -0
  33. package/dist/chat/earlier.d.ts.map +1 -0
  34. package/dist/chat/earlier.js +54 -0
  35. package/dist/chat/house.d.ts +25 -0
  36. package/dist/chat/house.d.ts.map +1 -0
  37. package/dist/chat/house.js +38 -0
  38. package/dist/chat/input.d.ts +11 -0
  39. package/dist/chat/input.d.ts.map +1 -0
  40. package/dist/chat/input.js +92 -0
  41. package/dist/chat/kit.d.ts +61 -0
  42. package/dist/chat/kit.d.ts.map +1 -0
  43. package/dist/chat/kit.js +123 -0
  44. package/dist/chat/lasting.d.ts +6 -0
  45. package/dist/chat/lasting.d.ts.map +1 -0
  46. package/dist/chat/lasting.js +19 -0
  47. package/dist/chat/list.d.ts +28 -0
  48. package/dist/chat/list.d.ts.map +1 -0
  49. package/dist/chat/list.js +103 -0
  50. package/dist/chat/markdown.d.ts +21 -0
  51. package/dist/chat/markdown.d.ts.map +1 -0
  52. package/dist/chat/markdown.js +246 -0
  53. package/dist/chat/message.d.ts +7 -0
  54. package/dist/chat/message.d.ts.map +1 -0
  55. package/dist/chat/message.js +254 -0
  56. package/dist/chat/messages.d.ts +35 -0
  57. package/dist/chat/messages.d.ts.map +1 -0
  58. package/dist/chat/messages.js +210 -0
  59. package/dist/chat/name.d.ts +7 -0
  60. package/dist/chat/name.d.ts.map +1 -0
  61. package/dist/chat/name.js +37 -0
  62. package/dist/chat/opened.d.ts +12 -0
  63. package/dist/chat/opened.d.ts.map +1 -0
  64. package/dist/chat/opened.js +19 -0
  65. package/dist/chat/overlay.d.ts +32 -0
  66. package/dist/chat/overlay.d.ts.map +1 -0
  67. package/dist/chat/overlay.js +103 -0
  68. package/dist/chat/parts.d.ts +58 -0
  69. package/dist/chat/parts.d.ts.map +1 -0
  70. package/dist/chat/parts.js +120 -0
  71. package/dist/chat/pieces.d.ts +62 -0
  72. package/dist/chat/pieces.d.ts.map +1 -0
  73. package/dist/chat/pieces.js +1110 -0
  74. package/dist/chat/process.d.ts +20 -0
  75. package/dist/chat/process.d.ts.map +1 -0
  76. package/dist/chat/process.js +32 -0
  77. package/dist/chat/provider.d.ts +70 -0
  78. package/dist/chat/provider.d.ts.map +1 -0
  79. package/dist/chat/provider.js +635 -0
  80. package/dist/chat/question.d.ts +9 -0
  81. package/dist/chat/question.d.ts.map +1 -0
  82. package/dist/chat/question.js +69 -0
  83. package/dist/chat/questions.d.ts +31 -0
  84. package/dist/chat/questions.d.ts.map +1 -0
  85. package/dist/chat/questions.js +111 -0
  86. package/dist/chat/read.d.ts +5 -0
  87. package/dist/chat/read.d.ts.map +1 -0
  88. package/dist/chat/read.js +13 -0
  89. package/dist/chat/ready.d.ts +37 -0
  90. package/dist/chat/ready.d.ts.map +1 -0
  91. package/dist/chat/ready.js +93 -0
  92. package/dist/chat/room-file.d.ts +8 -0
  93. package/dist/chat/room-file.d.ts.map +1 -0
  94. package/dist/chat/room-file.js +72 -0
  95. package/dist/chat/steady.d.ts +3 -0
  96. package/dist/chat/steady.d.ts.map +1 -0
  97. package/dist/chat/steady.js +26 -0
  98. package/dist/chat/style.d.ts +4 -0
  99. package/dist/chat/style.d.ts.map +1 -0
  100. package/dist/chat/style.js +307 -0
  101. package/dist/chat.d.ts +15 -0
  102. package/dist/chat.d.ts.map +1 -0
  103. package/dist/chat.js +8 -0
  104. package/dist/client.d.ts +33 -13
  105. package/dist/client.d.ts.map +1 -1
  106. package/dist/client.js +73 -18
  107. package/dist/collection.d.ts +7 -6
  108. package/dist/collection.d.ts.map +1 -1
  109. package/dist/collection.js +31 -77
  110. package/dist/compile.d.ts +16 -0
  111. package/dist/compile.d.ts.map +1 -0
  112. package/dist/compile.js +721 -0
  113. package/dist/connection.d.ts +56 -18
  114. package/dist/connection.d.ts.map +1 -1
  115. package/dist/connection.js +3320 -686
  116. package/dist/conversation.d.ts +39 -12
  117. package/dist/conversation.d.ts.map +1 -1
  118. package/dist/conversation.js +552 -177
  119. package/dist/digest.d.ts +7 -0
  120. package/dist/digest.d.ts.map +1 -0
  121. package/dist/digest.js +113 -0
  122. package/dist/durability.d.ts +8 -1
  123. package/dist/durability.d.ts.map +1 -1
  124. package/dist/entry.d.ts +19 -0
  125. package/dist/entry.d.ts.map +1 -0
  126. package/dist/entry.js +151 -0
  127. package/dist/expectation.d.ts +21 -0
  128. package/dist/expectation.d.ts.map +1 -0
  129. package/dist/expectation.js +70 -0
  130. package/dist/failure.d.ts +13 -0
  131. package/dist/failure.d.ts.map +1 -0
  132. package/dist/failure.js +19 -0
  133. package/dist/fence.d.ts +6 -0
  134. package/dist/fence.d.ts.map +1 -0
  135. package/dist/fence.js +10 -0
  136. package/dist/file.d.ts +2 -10
  137. package/dist/file.d.ts.map +1 -1
  138. package/dist/file.js +3 -120
  139. package/dist/fulltext.d.ts +27 -0
  140. package/dist/fulltext.d.ts.map +1 -0
  141. package/dist/fulltext.js +368 -0
  142. package/dist/host.d.ts +14 -3
  143. package/dist/host.d.ts.map +1 -1
  144. package/dist/host.js +110 -21
  145. package/dist/identity.d.ts +3 -0
  146. package/dist/identity.d.ts.map +1 -1
  147. package/dist/identity.js +9 -0
  148. package/dist/index.d.ts +21 -10
  149. package/dist/index.d.ts.map +1 -1
  150. package/dist/index.js +8 -0
  151. package/dist/live.d.ts +22 -0
  152. package/dist/live.d.ts.map +1 -0
  153. package/dist/live.js +123 -0
  154. package/dist/memory.d.ts +11 -4
  155. package/dist/memory.d.ts.map +1 -1
  156. package/dist/memory.js +97 -23
  157. package/dist/messages.d.ts +28 -0
  158. package/dist/messages.d.ts.map +1 -0
  159. package/dist/messages.js +90 -0
  160. package/dist/model.d.ts +7 -4
  161. package/dist/model.d.ts.map +1 -1
  162. package/dist/model.js +10 -1
  163. package/dist/name.d.ts +4 -0
  164. package/dist/name.d.ts.map +1 -0
  165. package/dist/name.js +122 -0
  166. package/dist/observation.d.ts +19 -2
  167. package/dist/observation.d.ts.map +1 -1
  168. package/dist/observation.js +113 -12
  169. package/dist/open.d.ts +2 -0
  170. package/dist/open.d.ts.map +1 -0
  171. package/dist/open.js +1 -0
  172. package/dist/opened.d.ts +22 -0
  173. package/dist/opened.d.ts.map +1 -0
  174. package/dist/opened.js +107 -0
  175. package/dist/outcome.d.ts +63 -3
  176. package/dist/outcome.d.ts.map +1 -1
  177. package/dist/outcome.js +70 -1
  178. package/dist/overlay.d.ts +15 -5
  179. package/dist/overlay.d.ts.map +1 -1
  180. package/dist/overlay.js +136 -180
  181. package/dist/query.d.ts +64 -4
  182. package/dist/query.d.ts.map +1 -1
  183. package/dist/query.js +51 -7
  184. package/dist/reach.d.ts +13 -4
  185. package/dist/reach.d.ts.map +1 -1
  186. package/dist/reach.js +212 -57
  187. package/dist/react.d.ts +12 -8
  188. package/dist/react.d.ts.map +1 -1
  189. package/dist/react.js +8 -17
  190. package/dist/readiness.d.ts +53 -0
  191. package/dist/readiness.d.ts.map +1 -0
  192. package/dist/readiness.js +33 -0
  193. package/dist/reads.d.ts +11 -0
  194. package/dist/reads.d.ts.map +1 -0
  195. package/dist/reads.js +98 -0
  196. package/dist/recovery.d.ts +25 -0
  197. package/dist/recovery.d.ts.map +1 -0
  198. package/dist/recovery.js +198 -0
  199. package/dist/refresh.d.ts +12 -15
  200. package/dist/refresh.d.ts.map +1 -1
  201. package/dist/refresh.js +74 -49
  202. package/dist/replica.d.ts +58 -33
  203. package/dist/replica.d.ts.map +1 -1
  204. package/dist/replica.js +317 -157
  205. package/dist/room-draft.d.ts +40 -9
  206. package/dist/room-draft.d.ts.map +1 -1
  207. package/dist/room-draft.js +152 -36
  208. package/dist/rows.d.ts +28 -35
  209. package/dist/rows.d.ts.map +1 -1
  210. package/dist/rows.js +113 -70
  211. package/dist/save.d.ts +71 -4
  212. package/dist/save.d.ts.map +1 -1
  213. package/dist/save.js +810 -147
  214. package/dist/search.d.ts +41 -29
  215. package/dist/search.d.ts.map +1 -1
  216. package/dist/search.js +37 -105
  217. package/dist/seed.d.ts +16 -0
  218. package/dist/seed.d.ts.map +1 -0
  219. package/dist/seed.js +75 -0
  220. package/dist/shared.d.ts +16 -0
  221. package/dist/shared.d.ts.map +1 -0
  222. package/dist/shared.js +431 -0
  223. package/dist/status.d.ts +6 -2
  224. package/dist/status.d.ts.map +1 -1
  225. package/dist/status.js +0 -8
  226. package/dist/store.d.ts +113 -79
  227. package/dist/store.d.ts.map +1 -1
  228. package/dist/store.js +351 -463
  229. package/dist/stored.d.ts +138 -0
  230. package/dist/stored.d.ts.map +1 -0
  231. package/dist/stored.js +544 -0
  232. package/dist/tables.d.ts +332 -0
  233. package/dist/tables.d.ts.map +1 -0
  234. package/dist/tables.js +570 -0
  235. package/dist/turn.d.ts +9 -0
  236. package/dist/turn.d.ts.map +1 -0
  237. package/dist/turn.js +75 -0
  238. package/dist/validation.d.ts +30 -0
  239. package/dist/validation.d.ts.map +1 -0
  240. package/dist/validation.js +162 -0
  241. package/dist/windows.d.ts +22 -0
  242. package/dist/windows.d.ts.map +1 -0
  243. package/dist/windows.js +89 -0
  244. package/dist/wire.d.ts +172 -33
  245. package/dist/wire.d.ts.map +1 -1
  246. package/dist/wire.js +68 -31
  247. package/dist/words.d.ts +19 -0
  248. package/dist/words.d.ts.map +1 -0
  249. package/dist/words.js +150 -0
  250. package/package.json +33 -15
  251. package/dist/attachment.d.ts +0 -3
  252. package/dist/attachment.d.ts.map +0 -1
  253. package/dist/attachment.js +0 -8
  254. package/dist/read-side.d.ts +0 -18
  255. package/dist/read-side.d.ts.map +0 -1
  256. package/dist/read-side.js +0 -433
@@ -1 +1 @@
1
- {"version":3,"file":"room-draft.d.ts","sourceRoot":"","sources":["../src/room-draft.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,C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AU,EAAE,CAqBvB"}
@@ -1,19 +1,20 @@
1
- import { apply, parse, serialize } from '@agentshouse/mdmodel';
1
+ import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
2
+ import { runtimeError } from './failure.js';
3
+ import { sha256 } from './digest.js';
4
+ import { binaryLocalId } from './identity.js';
2
5
  import { normalize } from './paths.js';
6
+ export function returnedBy(kind) {
7
+ return { kind, code: kind, fields: {}, retryable: false };
8
+ }
9
+ export function staleWrite(current) {
10
+ return { outcome: 'stale', code: 'stale', retryable: false, current };
11
+ }
3
12
  function malformed() {
4
- throw new Error('room-draft-malformed');
13
+ throw runtimeError('room-draft-malformed');
5
14
  }
6
15
  function plain(value) {
7
16
  return typeof value === 'object' && value !== null && !Array.isArray(value);
8
17
  }
9
- function frontmatterValue(value) {
10
- if (Array.isArray(value))
11
- return value.every(frontmatterValue);
12
- return (value === null ||
13
- typeof value === 'string' ||
14
- typeof value === 'boolean' ||
15
- (typeof value === 'number' && Number.isFinite(value)));
16
- }
17
18
  function text(value) {
18
19
  return typeof value === 'string' ? value : malformed();
19
20
  }
@@ -61,6 +62,7 @@ const PART_NAMES = new Set([
61
62
  'creation',
62
63
  'move',
63
64
  'removal',
65
+ 'file',
64
66
  ]);
65
67
  export function readParts(value) {
66
68
  if (!plain(value) || Object.keys(value).some((name) => !PART_NAMES.has(name)))
@@ -88,7 +90,12 @@ export function readParts(value) {
88
90
  if (!plain(value.move))
89
91
  malformed();
90
92
  const base = markdownBase(value.move.base);
91
- parts.move = { to: text(value.move.to), ...(base === undefined ? {} : { base }) };
93
+ const room = optionalText(value.move.room);
94
+ parts.move = {
95
+ to: text(value.move.to),
96
+ ...(room === undefined ? {} : { room }),
97
+ ...(base === undefined ? {} : { base }),
98
+ };
92
99
  }
93
100
  if (value.removal !== undefined) {
94
101
  if (!plain(value.removal))
@@ -96,6 +103,13 @@ export function readParts(value) {
96
103
  const base = markdownBase(value.removal.base);
97
104
  parts.removal = base === undefined ? {} : { base };
98
105
  }
106
+ if (value.file !== undefined) {
107
+ if (!plain(value.file) || !(value.file.blob instanceof Blob))
108
+ malformed();
109
+ if (Object.keys(value).length > 1)
110
+ throw runtimeError('room-draft-file-exclusive');
111
+ parts.file = { blob: value.file.blob };
112
+ }
99
113
  return parts;
100
114
  }
101
115
  function named(record) {
@@ -108,17 +122,45 @@ function kept(prior, base) {
108
122
  if (prior !== undefined)
109
123
  return prior.base;
110
124
  if (base === undefined)
111
- throw new Error('room-draft-base-missing');
125
+ throw runtimeError('room-draft-base-missing');
112
126
  return base;
113
127
  }
128
+ function movePart(current, move) {
129
+ return {
130
+ to: move.to,
131
+ ...(move.room === undefined ? {} : { room: move.room }),
132
+ base: kept(current, move.base),
133
+ };
134
+ }
114
135
  function editsText(parts) {
115
136
  return (parts.preamble !== undefined ||
116
137
  named(parts.fields).length > 0 ||
117
138
  named(parts.sections).length > 0);
118
139
  }
119
- export function held(current, parts) {
140
+ export function held(current, parts, file) {
120
141
  if (parts.markdown !== undefined && editsText(parts)) {
121
- throw new Error('room-draft-markdown-exclusive');
142
+ throw runtimeError('room-draft-markdown-exclusive');
143
+ }
144
+ if (file !== undefined) {
145
+ if (current !== undefined && current.file === undefined) {
146
+ throw runtimeError('room-draft-file-exclusive');
147
+ }
148
+ return { file: { ...file, base: current?.file === undefined ? file.base : current.file.base } };
149
+ }
150
+ if (current?.file !== undefined) {
151
+ if (editsText(parts) ||
152
+ parts.markdown !== undefined ||
153
+ parts.creation !== undefined ||
154
+ (parts.move === undefined && parts.removal === undefined)) {
155
+ throw runtimeError('room-draft-file-exclusive');
156
+ }
157
+ return {
158
+ file: current.file,
159
+ ...(parts.move === undefined ? {} : { move: movePart(current.move, parts.move) }),
160
+ ...(parts.removal === undefined
161
+ ? {}
162
+ : { removal: { base: kept(current.removal, parts.removal.base) } }),
163
+ };
122
164
  }
123
165
  const next = {};
124
166
  const fields = named(parts.fields);
@@ -149,24 +191,15 @@ export function held(current, parts) {
149
191
  }
150
192
  if (parts.creation !== undefined)
151
193
  next.creation = parts.creation;
152
- if (parts.move !== undefined) {
153
- next.move = { to: parts.move.to, base: kept(current?.move, parts.move.base) };
154
- }
194
+ if (parts.move !== undefined)
195
+ next.move = movePart(current?.move, parts.move);
155
196
  if (parts.removal !== undefined) {
156
197
  next.removal = { base: kept(current?.removal, parts.removal.base) };
157
198
  }
158
199
  if (Object.keys(next).length === 0)
159
- throw new Error('room-draft-empty');
200
+ throw runtimeError('room-draft-empty');
160
201
  return next;
161
202
  }
162
- export function equalValue(left, right) {
163
- if (left === right)
164
- return true;
165
- return (Array.isArray(left) &&
166
- Array.isArray(right) &&
167
- left.length === right.length &&
168
- left.every((item, index) => equalValue(item, right[index])));
169
- }
170
203
  function sameField(left, right) {
171
204
  if (left === null || right === null)
172
205
  return left === right;
@@ -207,8 +240,27 @@ export function underneath(parts, path, visible) {
207
240
  report.move = markdown;
208
241
  if (parts.removal !== undefined && markdown !== parts.removal.base)
209
242
  report.removal = markdown;
243
+ if (parts.file !== undefined) {
244
+ const file = binaryBase(visible, path);
245
+ if (file !== parts.file.base || markdown !== null)
246
+ report.file = file;
247
+ }
210
248
  return report;
211
249
  }
250
+ const UNTYPED_MEDIA_TYPE = 'application/octet-stream';
251
+ export async function heldFile(blob, base) {
252
+ return {
253
+ localId: binaryLocalId(),
254
+ ...(blob instanceof File ? { name: blob.name } : {}),
255
+ byteLength: blob.size,
256
+ mediaType: blob.type === '' ? UNTYPED_MEDIA_TYPE : blob.type,
257
+ sha256: await sha256(blob),
258
+ base,
259
+ };
260
+ }
261
+ export function binaryBase(visible, path) {
262
+ return visible?.binaries[path] === undefined ? null : (visible.revisions[path] ?? null);
263
+ }
212
264
  export function changedParts(path, report) {
213
265
  return [
214
266
  ...(report.creation === undefined ? [] : [{ path, part: 'creation' }]),
@@ -218,6 +270,7 @@ export function changedParts(path, report) {
218
270
  ...(report.markdown === undefined ? [] : [{ path, part: 'markdown' }]),
219
271
  ...(report.move === undefined ? [] : [{ path, part: 'move' }]),
220
272
  ...(report.removal === undefined ? [] : [{ path, part: 'removal' }]),
273
+ ...(report.file === undefined ? [] : [{ path, part: 'file' }]),
221
274
  ];
222
275
  }
223
276
  function joined(existing, returned) {
@@ -234,16 +287,15 @@ function frontmatterOf(fields) {
234
287
  const opened = parse('---\n---\n');
235
288
  if (!opened.ok)
236
289
  return malformed();
237
- let document = opened.document;
238
- for (const [name, part] of fields) {
239
- const next = apply(document, { kind: 'field', name, value: part.value, prior: undefined });
240
- if (next.outcome !== 'applied')
241
- return malformed();
242
- document = next.document;
243
- }
244
- return serialize(document);
290
+ const next = apply(opened.document, fields.map(([name, part]) => ({
291
+ kind: 'field',
292
+ name,
293
+ value: part.value,
294
+ prior: undefined,
295
+ })));
296
+ return next.outcome === 'applied' ? serialize(next.document) : malformed();
245
297
  }
246
- function concatenated(markdown, parts) {
298
+ export function partsAfter(markdown, parts) {
247
299
  const fields = named(parts.fields);
248
300
  const pieces = [
249
301
  ...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
@@ -274,18 +326,21 @@ export function returnedInto(existing, returned) {
274
326
  delete next.fields;
275
327
  delete next.sections;
276
328
  delete next.preamble;
277
- const value = concatenated(whole.value, existing.markdown === undefined ? existing : returned);
329
+ const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
278
330
  next.markdown = { value, base: whole.base };
279
331
  }
280
332
  const creation = existing.creation ?? returned.creation;
281
333
  const move = existing.move ?? returned.move;
282
334
  const removal = existing.removal ?? returned.removal;
335
+ const file = existing.file ?? returned.file;
283
336
  if (creation !== undefined)
284
337
  next.creation = creation;
285
338
  if (move !== undefined)
286
339
  next.move = move;
287
340
  if (removal !== undefined)
288
341
  next.removal = removal;
342
+ if (file !== undefined)
343
+ next.file = file;
289
344
  return next;
290
345
  }
291
346
  export function moveTarget(move) {
@@ -321,9 +376,70 @@ export function changesOf(path, parts) {
321
376
  if (parts.markdown !== undefined) {
322
377
  changes.push({ kind: 'replace', path, content: parts.markdown.value });
323
378
  }
379
+ if (parts.file !== undefined && parts.removal === undefined) {
380
+ const { base, name: _name, ...file } = parts.file;
381
+ const at = parts.move === undefined ? path : moveTarget(parts.move);
382
+ if (base !== null && at !== path)
383
+ changes.push({ kind: 'move', path, to: at });
384
+ changes.push({ kind: 'binary', path: at, ...file });
385
+ if (base === null && at !== path)
386
+ bases.push({ kind: 'absent', path: at });
387
+ return { changes, bases };
388
+ }
389
+ if (parts.file?.base === null)
390
+ return { changes, bases };
324
391
  if (parts.move !== undefined)
325
392
  changes.push({ kind: 'move', path, to: moveTarget(parts.move) });
326
393
  if (parts.removal !== undefined)
327
394
  changes.push({ kind: 'remove', path });
328
395
  return { changes, bases };
329
396
  }
397
+ function rebased(before, after) {
398
+ return before === undefined ? after : { ...after, base: before.base };
399
+ }
400
+ function rebasedAll(before, after) {
401
+ return {
402
+ ...before,
403
+ ...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
404
+ };
405
+ }
406
+ export function joinedDraft(carried, saved) {
407
+ const draft = saved.find((item) => item.path === carried.path);
408
+ if (draft === undefined)
409
+ return carried;
410
+ const held = carried.parts;
411
+ const next = draft.parts;
412
+ return {
413
+ path: carried.path,
414
+ parts: {
415
+ ...held,
416
+ ...next,
417
+ ...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
418
+ ...(next.sections === undefined
419
+ ? {}
420
+ : { sections: rebasedAll(held.sections, next.sections) }),
421
+ ...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
422
+ ...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
423
+ },
424
+ };
425
+ }
426
+ export function withdrawnDrafts(drafts, changes) {
427
+ return drafts.flatMap((draft) => {
428
+ const file = draft.parts.file;
429
+ const at = draft.parts.move?.to ?? draft.path;
430
+ const change = changes.find((item) => (item.kind === 'move' || item.kind === 'remove') && item.path === at);
431
+ if (file === undefined || change === undefined)
432
+ return [draft];
433
+ if (change.kind === 'move') {
434
+ return [
435
+ {
436
+ path: draft.path,
437
+ parts: change.to === draft.path ? { file } : { file, move: { to: change.to, base: null } },
438
+ },
439
+ ];
440
+ }
441
+ return file.base === null
442
+ ? []
443
+ : [{ path: draft.path, parts: { file, removal: { base: null } } }];
444
+ });
445
+ }
package/dist/rows.d.ts CHANGED
@@ -1,44 +1,37 @@
1
- import { type Document } from '@agentshouse/mdmodel';
2
- import type { HeadChange } from './adapter.js';
3
1
  import { type Composition } from './collection.js';
4
- type Fields = Readonly<Record<string, unknown>>;
5
- export type DocumentRow = {
6
- key: string;
7
- kind: 'document';
8
- room: string;
9
- path: string;
10
- type: string | null;
11
- fields: Fields;
12
- values: Fields;
13
- reached: Readonly<Record<string, readonly unknown[]>>;
14
- directories: readonly string[];
15
- body: string;
16
- change: HeadChange | null;
2
+ export type ValueKind = 'string' | 'number' | 'boolean' | 'null' | 'array' | 'object' | 'undefined';
3
+ type HeldValue = {
4
+ readonly form: string;
5
+ readonly held: number;
6
+ readonly item: number;
7
+ readonly kind: ValueKind;
8
+ readonly value: string | number | null;
9
+ readonly size: number | null;
10
+ readonly single: boolean;
17
11
  };
18
- export type BodyRow = {
19
- key: string;
20
- kind: 'body';
21
- room: string;
22
- path: string;
23
- preamble: string;
24
- sections: Readonly<Record<string, string>>;
25
- markdown: string;
12
+ type LinkKind = 'field' | 'section' | 'body';
13
+ type HeldLink = {
14
+ readonly kind: LinkKind;
15
+ readonly form: string;
16
+ readonly target: string;
17
+ readonly field: string;
26
18
  };
27
- export type ReferenceRow = {
28
- key: string;
29
- kind: 'reference';
30
- room: string;
31
- source: string;
32
- target: string;
33
- field: string;
34
- forms: readonly string[];
35
- path: string;
36
- type: string;
19
+ export type Derived = {
20
+ readonly type: string | null;
21
+ readonly declared: string | null;
22
+ readonly queried: boolean;
23
+ readonly folder: string;
24
+ readonly fields: string | null;
25
+ readonly values: readonly HeldValue[];
26
+ readonly links: readonly HeldLink[];
37
27
  };
38
- export type Row = DocumentRow | BodyRow | ReferenceRow;
39
28
  export declare function documentKey(room: string, path: string): string;
40
29
  export declare function roomOfKey(key: string): string;
30
+ export declare function pathOfKey(key: string): string;
41
31
  export declare function markdownPath(path: string): boolean;
42
- export declare function rowsOf(room: string, path: string, document: Document | null, composition: Composition, change: HeadChange | null): readonly Row[];
32
+ export declare function settingsTextPath(path: string): boolean;
33
+ export declare function folderOf(path: string): string;
34
+ export declare function kindOf(value: unknown): ValueKind;
35
+ export declare function derived(path: string, content: string | null, composition: Composition): Derived;
43
36
  export {};
44
37
  //# sourceMappingURL=rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,QAAQ,EACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM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AAM,CAE7C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAqBD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAMhD;AA2ID,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAmB/F"}
package/dist/rows.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ARRAY_INDEX, escapePointer, references, target, } from '@agentshouse/mdmodel';
1
+ import { ARRAY_INDEX, bodyAfterFrontmatter, bodyLinks, escapePointer, parseFrontmatter, references, sectionReferences, target, } from '@agentshouse/mdmodel';
2
2
  import { governing } from './collection.js';
3
3
  import { definitionOf } from './model.js';
4
4
  function keyOf(...parts) {
@@ -10,6 +10,18 @@ export function documentKey(room, path) {
10
10
  export function roomOfKey(key) {
11
11
  return key.split('\u0000')[1];
12
12
  }
13
+ export function pathOfKey(key) {
14
+ return key.split('\u0000')[2];
15
+ }
16
+ export function markdownPath(path) {
17
+ return path.endsWith('.md');
18
+ }
19
+ export function settingsTextPath(path) {
20
+ return /^settings\/.+\.ya?ml$/u.test(path);
21
+ }
22
+ export function folderOf(path) {
23
+ return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
24
+ }
13
25
  function plainObject(value) {
14
26
  return typeof value === 'object' && value !== null && !Array.isArray(value);
15
27
  }
@@ -18,6 +30,54 @@ function compared(reading, exact, value) {
18
30
  return value;
19
31
  return (typeof value === 'string' ? target(reading.path, value) : null) ?? undefined;
20
32
  }
33
+ export function kindOf(value) {
34
+ if (value === undefined)
35
+ return 'undefined';
36
+ if (value === null)
37
+ return 'null';
38
+ if (Array.isArray(value))
39
+ return 'array';
40
+ if (typeof value === 'object')
41
+ return 'object';
42
+ return typeof value;
43
+ }
44
+ function scalarOf(value) {
45
+ if (typeof value === 'string' || typeof value === 'number')
46
+ return value;
47
+ if (typeof value === 'boolean')
48
+ return value ? 1 : 0;
49
+ if (Array.isArray(value))
50
+ return JSON.stringify(value);
51
+ return null;
52
+ }
53
+ function held(reading, form, value, single) {
54
+ const at = reading.reached.get(form) ?? 0;
55
+ reading.reached.set(form, at + 1);
56
+ const kind = kindOf(value);
57
+ reading.values.push({
58
+ form,
59
+ held: at,
60
+ item: -1,
61
+ kind,
62
+ value: scalarOf(value),
63
+ size: Array.isArray(value) ? value.length : null,
64
+ single,
65
+ });
66
+ if (!Array.isArray(value))
67
+ return;
68
+ value.forEach((item, index) => {
69
+ const itemKind = kindOf(item);
70
+ reading.values.push({
71
+ form,
72
+ held: at,
73
+ item: index,
74
+ kind: itemKind,
75
+ value: itemKind === 'array' ? null : scalarOf(item),
76
+ size: null,
77
+ single: false,
78
+ });
79
+ });
80
+ }
21
81
  function record(reading, node, forms, exact) {
22
82
  const value = Array.isArray(node)
23
83
  ? node.map((item, index) => compared(reading, `${exact}/${index}`, item))
@@ -25,10 +85,7 @@ function record(reading, node, forms, exact) {
25
85
  for (const form of forms) {
26
86
  if (form.pending)
27
87
  continue;
28
- (reading.reached[form.text] ??= []).push(value);
29
- if (!form.through && value !== undefined && !plainObject(value)) {
30
- reading.values[form.text] = value;
31
- }
88
+ held(reading, form.text, value, !form.through && value !== undefined && !plainObject(value));
32
89
  }
33
90
  if (Array.isArray(node) || plainObject(node) || !reading.references.has(exact))
34
91
  return;
@@ -64,80 +121,66 @@ function walk(reading, node, forms, exact) {
64
121
  : [{ text: `${form.text}/${segment}`, through: form.through, pending: false }]), `${exact}/${segment}`);
65
122
  }
66
123
  }
67
- function directoriesOf(path) {
68
- const parts = path.split('/').slice(0, -1);
69
- return ['', ...parts.map((_, index) => parts.slice(0, index + 1).join('/'))];
70
- }
71
- export function markdownPath(path) {
72
- return path.endsWith('.md');
73
- }
74
- export function rowsOf(room, path, document, composition, change) {
75
- const key = documentKey(room, path);
76
- const body = keyOf('b', room, path);
77
- if (document === null || !markdownPath(path)) {
78
- return [
79
- {
80
- key,
81
- kind: 'document',
82
- room,
83
- path,
84
- type: null,
85
- fields: {},
86
- values: {},
87
- reached: {},
88
- directories: directoriesOf(path),
89
- body,
90
- change,
91
- },
92
- ];
124
+ function bodyTargets(path, content) {
125
+ const seen = new Set();
126
+ const found = [];
127
+ for (const { target: reached } of bodyLinks(bodyAfterFrontmatter(content), path)) {
128
+ if (seen.has(reached))
129
+ continue;
130
+ seen.add(reached);
131
+ found.push({ kind: 'body', form: '', target: reached, field: '' });
93
132
  }
94
- const type = document.type ?? 'any';
133
+ return found;
134
+ }
135
+ function typedRows(path, content, document, composition) {
95
136
  const definition = definitionOf(governing(composition, path), document.type);
96
137
  const reading = {
97
138
  path,
98
139
  references: new Set(definition === undefined ? [] : references(document, definition).map((one) => one.pointer)),
99
- values: {},
100
- reached: {},
140
+ values: [],
141
+ reached: new Map(),
101
142
  targets: new Map(),
102
143
  };
103
144
  for (const [name, value] of Object.entries(document.fields)) {
104
145
  const segment = escapePointer(name);
105
146
  walk(reading, value, [{ text: `/${segment}`, through: false, pending: false }], `/${segment}`);
106
147
  }
107
- const { values, reached } = reading;
108
- return [
109
- {
110
- key,
111
- kind: 'document',
112
- room,
113
- path,
114
- type,
115
- fields: document.fields,
116
- values,
117
- reached,
118
- directories: directoriesOf(path),
119
- body,
120
- change,
121
- },
122
- {
123
- key: body,
124
- kind: 'body',
125
- room,
126
- path,
127
- preamble: document.preamble,
128
- sections: document.sections,
129
- markdown: document.content,
130
- },
131
- ...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
132
- key: keyOf('r', room, path, field, found),
133
- kind: 'reference',
134
- room,
135
- source: key,
136
- target: documentKey(room, found),
137
- field,
138
- forms: [...forms].sort(),
139
- path,
140
- type,
141
- })),
142
- ];
148
+ const links = [];
149
+ for (const { field, target: reached, forms } of reading.targets.values()) {
150
+ for (const form of [...forms].sort()) {
151
+ links.push({ kind: 'field', form, target: reached, field });
152
+ }
153
+ }
154
+ if (definition !== undefined) {
155
+ const sectioned = new Set();
156
+ for (const { target: reached } of sectionReferences(path, content, definition)) {
157
+ if (reached === null || sectioned.has(reached))
158
+ continue;
159
+ sectioned.add(reached);
160
+ links.push({ kind: 'section', form: '', target: reached, field: '' });
161
+ }
162
+ }
163
+ return { values: reading.values, links: [...links, ...bodyTargets(path, content)] };
164
+ }
165
+ export function derived(path, content, composition) {
166
+ const folder = folderOf(path);
167
+ const unread = { values: [], links: [], fields: null, folder, type: null };
168
+ if (content === null)
169
+ return { ...unread, declared: null, queried: true };
170
+ const read = parseFrontmatter(content, path);
171
+ const declared = read.ok ? (read.frontmatter.type ?? 'any') : null;
172
+ if (!markdownPath(path)) {
173
+ return { ...unread, declared, queried: true, links: bodyTargets(path, content) };
174
+ }
175
+ if (!read.ok)
176
+ return { ...unread, declared, queried: false };
177
+ const document = read.frontmatter;
178
+ return {
179
+ type: document.type ?? 'any',
180
+ declared,
181
+ queried: true,
182
+ folder,
183
+ fields: JSON.stringify(document.fields),
184
+ ...typedRows(path, content, document, composition),
185
+ };
143
186
  }