@agentshouse/mdruntime 0.1.0-c3903a68dcbbf → 0.1.0-c3a5b012b4a8c

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 (197) hide show
  1. package/README.md +26 -13
  2. package/dist/adapter.d.ts +244 -88
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +1 -9
  5. package/dist/attached-model.d.ts +8 -0
  6. package/dist/attached-model.d.ts.map +1 -0
  7. package/dist/attached-model.js +46 -0
  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 +18 -0
  12. package/dist/binary.d.ts.map +1 -0
  13. package/dist/binary.js +8 -0
  14. package/dist/bootstrap.d.ts +40 -6
  15. package/dist/bootstrap.d.ts.map +1 -1
  16. package/dist/bootstrap.js +336 -52
  17. package/dist/chain.d.ts +12 -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 -60
  23. package/dist/change.d.ts +46 -0
  24. package/dist/change.d.ts.map +1 -1
  25. package/dist/change.js +34 -0
  26. package/dist/client.d.ts +44 -24
  27. package/dist/client.d.ts.map +1 -1
  28. package/dist/client.js +161 -36
  29. package/dist/collection.d.ts +13 -16
  30. package/dist/collection.d.ts.map +1 -1
  31. package/dist/collection.js +52 -66
  32. package/dist/compile.d.ts +11 -0
  33. package/dist/compile.d.ts.map +1 -0
  34. package/dist/compile.js +717 -0
  35. package/dist/connection.d.ts +69 -44
  36. package/dist/connection.d.ts.map +1 -1
  37. package/dist/connection.js +4581 -1472
  38. package/dist/context.d.ts +2 -0
  39. package/dist/context.d.ts.map +1 -0
  40. package/dist/context.js +7 -0
  41. package/dist/conversation-row.d.ts +33 -0
  42. package/dist/conversation-row.d.ts.map +1 -0
  43. package/dist/conversation-row.js +47 -0
  44. package/dist/conversation.d.ts +76 -27
  45. package/dist/conversation.d.ts.map +1 -1
  46. package/dist/conversation.js +1052 -273
  47. package/dist/digest.d.ts +7 -0
  48. package/dist/digest.d.ts.map +1 -0
  49. package/dist/digest.js +113 -0
  50. package/dist/durability.d.ts +10 -1
  51. package/dist/durability.d.ts.map +1 -1
  52. package/dist/durability.js +5 -0
  53. package/dist/entry.d.ts +20 -0
  54. package/dist/entry.d.ts.map +1 -0
  55. package/dist/entry.js +161 -0
  56. package/dist/expectation.d.ts +21 -0
  57. package/dist/expectation.d.ts.map +1 -0
  58. package/dist/expectation.js +70 -0
  59. package/dist/failure.d.ts +13 -0
  60. package/dist/failure.d.ts.map +1 -0
  61. package/dist/failure.js +19 -0
  62. package/dist/file.d.ts +2 -19
  63. package/dist/file.d.ts.map +1 -1
  64. package/dist/file.js +7 -122
  65. package/dist/host.d.ts +17 -3
  66. package/dist/host.d.ts.map +1 -1
  67. package/dist/host.js +163 -75
  68. package/dist/identity.d.ts +3 -0
  69. package/dist/identity.d.ts.map +1 -1
  70. package/dist/identity.js +13 -1
  71. package/dist/index.d.ts +26 -11
  72. package/dist/index.d.ts.map +1 -1
  73. package/dist/index.js +12 -1
  74. package/dist/job.d.ts +33 -0
  75. package/dist/job.d.ts.map +1 -0
  76. package/dist/job.js +54 -0
  77. package/dist/live.d.ts +23 -0
  78. package/dist/live.d.ts.map +1 -0
  79. package/dist/live.js +165 -0
  80. package/dist/media.d.ts +8 -0
  81. package/dist/media.d.ts.map +1 -0
  82. package/dist/media.js +218 -0
  83. package/dist/memory.d.ts +30 -9
  84. package/dist/memory.d.ts.map +1 -1
  85. package/dist/memory.js +337 -87
  86. package/dist/messages.d.ts +52 -0
  87. package/dist/messages.d.ts.map +1 -0
  88. package/dist/messages.js +168 -0
  89. package/dist/model.d.ts +17 -16
  90. package/dist/model.d.ts.map +1 -1
  91. package/dist/model.js +9 -9
  92. package/dist/name.d.ts +4 -0
  93. package/dist/name.d.ts.map +1 -0
  94. package/dist/name.js +122 -0
  95. package/dist/observation.d.ts +22 -2
  96. package/dist/observation.d.ts.map +1 -1
  97. package/dist/observation.js +133 -17
  98. package/dist/open.d.ts +2 -0
  99. package/dist/open.d.ts.map +1 -0
  100. package/dist/open.js +1 -0
  101. package/dist/opened.d.ts +22 -0
  102. package/dist/opened.d.ts.map +1 -0
  103. package/dist/opened.js +107 -0
  104. package/dist/outcome.d.ts +72 -21
  105. package/dist/outcome.d.ts.map +1 -1
  106. package/dist/outcome.js +81 -1
  107. package/dist/overlay.d.ts +16 -5
  108. package/dist/overlay.d.ts.map +1 -1
  109. package/dist/overlay.js +147 -180
  110. package/dist/parts.d.ts +59 -0
  111. package/dist/parts.d.ts.map +1 -0
  112. package/dist/parts.js +118 -0
  113. package/dist/paths.d.ts +1 -1
  114. package/dist/paths.d.ts.map +1 -1
  115. package/dist/paths.js +4 -16
  116. package/dist/query.d.ts +56 -180
  117. package/dist/query.d.ts.map +1 -1
  118. package/dist/query.js +3 -422
  119. package/dist/questions.d.ts +32 -0
  120. package/dist/questions.d.ts.map +1 -0
  121. package/dist/questions.js +118 -0
  122. package/dist/reach.d.ts +54 -0
  123. package/dist/reach.d.ts.map +1 -0
  124. package/dist/reach.js +483 -0
  125. package/dist/react.d.ts +45 -0
  126. package/dist/react.d.ts.map +1 -0
  127. package/dist/react.js +54 -0
  128. package/dist/read.d.ts +7 -0
  129. package/dist/read.d.ts.map +1 -0
  130. package/dist/read.js +17 -0
  131. package/dist/readiness.d.ts +50 -0
  132. package/dist/readiness.d.ts.map +1 -0
  133. package/dist/readiness.js +27 -0
  134. package/dist/recovery.d.ts +26 -0
  135. package/dist/recovery.d.ts.map +1 -0
  136. package/dist/recovery.js +232 -0
  137. package/dist/refresh.d.ts +21 -7
  138. package/dist/refresh.d.ts.map +1 -1
  139. package/dist/refresh.js +155 -55
  140. package/dist/replica.d.ts +61 -33
  141. package/dist/replica.d.ts.map +1 -1
  142. package/dist/replica.js +355 -162
  143. package/dist/room-draft.d.ts +62 -11
  144. package/dist/room-draft.d.ts.map +1 -1
  145. package/dist/room-draft.js +281 -83
  146. package/dist/rows.d.ts +32 -34
  147. package/dist/rows.d.ts.map +1 -1
  148. package/dist/rows.js +65 -87
  149. package/dist/save.d.ts +74 -6
  150. package/dist/save.d.ts.map +1 -1
  151. package/dist/save.js +902 -183
  152. package/dist/search.d.ts +15 -54
  153. package/dist/search.d.ts.map +1 -1
  154. package/dist/search.js +10 -121
  155. package/dist/seed.d.ts +16 -0
  156. package/dist/seed.d.ts.map +1 -0
  157. package/dist/seed.js +75 -0
  158. package/dist/shared.d.ts +15 -0
  159. package/dist/shared.d.ts.map +1 -0
  160. package/dist/shared.js +421 -0
  161. package/dist/source.d.ts +61 -0
  162. package/dist/source.d.ts.map +1 -0
  163. package/dist/source.js +81 -0
  164. package/dist/status.d.ts +7 -4
  165. package/dist/status.d.ts.map +1 -1
  166. package/dist/status.js +3 -15
  167. package/dist/store.d.ts +178 -80
  168. package/dist/store.d.ts.map +1 -1
  169. package/dist/store.js +372 -381
  170. package/dist/stored.d.ts +156 -0
  171. package/dist/stored.d.ts.map +1 -0
  172. package/dist/stored.js +637 -0
  173. package/dist/tables.d.ts +388 -0
  174. package/dist/tables.d.ts.map +1 -0
  175. package/dist/tables.js +706 -0
  176. package/dist/transfer.d.ts +0 -5
  177. package/dist/transfer.d.ts.map +1 -1
  178. package/dist/turn.d.ts +9 -0
  179. package/dist/turn.d.ts.map +1 -0
  180. package/dist/turn.js +75 -0
  181. package/dist/validation.d.ts +29 -0
  182. package/dist/validation.d.ts.map +1 -0
  183. package/dist/validation.js +104 -0
  184. package/dist/windows.d.ts +11 -0
  185. package/dist/windows.d.ts.map +1 -0
  186. package/dist/windows.js +16 -0
  187. package/dist/wire.d.ts +199 -19
  188. package/dist/wire.d.ts.map +1 -1
  189. package/dist/wire.js +92 -67
  190. package/package.json +33 -10
  191. package/AGENTS.md +0 -210
  192. package/dist/attachment.d.ts +0 -3
  193. package/dist/attachment.d.ts.map +0 -1
  194. package/dist/attachment.js +0 -8
  195. package/dist/read-side.d.ts +0 -14
  196. package/dist/read-side.d.ts.map +0 -1
  197. package/dist/read-side.js +0 -371
package/dist/wire.js CHANGED
@@ -1,69 +1,81 @@
1
- export const RUNTIME_WIRE_PROTOCOL = 8;
2
- export const PROTOCOL_MISMATCH = {
3
- reason: 'client-host-protocol-mismatch',
4
- reauthorizationOffered: false,
5
- refusal: null,
1
+ import { UNCERTAIN } from './outcome.js';
2
+ const MEMBERS = {
3
+ rooms: { reach: 'within', effect: 'read' },
4
+ query: { reach: 'within', effect: 'read' },
5
+ search: { reach: 'within', effect: 'read' },
6
+ types: { reach: 'within', effect: 'read' },
7
+ save: { reach: 'within', effect: 'write' },
8
+ saveParts: { reach: 'within', effect: 'write' },
9
+ history: { reach: 'within', effect: 'read' },
10
+ resolve: { reach: 'within', effect: 'read' },
11
+ 'binaryFile.read': { reach: 'within', effect: 'read' },
12
+ 'binaryFile.link': { reach: 'within', effect: 'read' },
13
+ 'binaryFile.show': { reach: 'within', effect: 'read' },
14
+ 'binaryFile.attach': { reach: 'within', effect: 'action' },
15
+ 'binaryFile.part': { reach: 'within', effect: 'read' },
16
+ call: { reach: 'actions', effect: 'action' },
17
+ reached: { reach: 'within', effect: 'read' },
18
+ log: { reach: 'whole', effect: 'read' },
19
+ cleanUp: { reach: 'whole', effect: 'write' },
20
+ unsent: { reach: 'whole', effect: 'read' },
21
+ reset: { reach: 'whole', effect: 'write' },
22
+ persistence: { reach: 'runtime', effect: 'read' },
23
+ retry: { reach: 'runtime', effect: 'write' },
24
+ reauthorize: { reach: 'runtime', effect: 'write' },
25
+ 'roomDraft.list': { reach: 'within', effect: 'read' },
26
+ 'roomDraft.read': { reach: 'within', effect: 'read' },
27
+ 'roomDraft.write': { reach: 'within', effect: 'write' },
28
+ 'roomDraft.discard': { reach: 'within', effect: 'write' },
29
+ 'presentation.read': { reach: 'app', effect: 'read' },
30
+ 'presentation.write': { reach: 'app', effect: 'write' },
31
+ 'presentation.edit': { reach: 'app', effect: 'write' },
32
+ 'conversation.list': { reach: 'within', effect: 'read' },
33
+ 'conversation.read': { reach: 'within', effect: 'read' },
34
+ 'conversation.create': { reach: 'within', effect: 'action' },
35
+ 'conversation.send': { reach: 'within', effect: 'action' },
36
+ 'conversation.answer': { reach: 'within', effect: 'action' },
37
+ 'conversation.interrupt': { reach: 'within', effect: 'action' },
38
+ 'conversation.kill': { reach: 'within', effect: 'action' },
39
+ 'conversation.delete': { reach: 'within', effect: 'action' },
40
+ 'chatDraft.write': { reach: 'within', effect: 'write' },
41
+ 'chatDraft.prepend': { reach: 'within', effect: 'write' },
42
+ 'chatDraft.discard': { reach: 'within', effect: 'write' },
6
43
  };
7
- const MEMBERS = [
8
- 'rooms',
9
- 'slots',
10
- 'query',
11
- 'search',
12
- 'types',
13
- 'syncStatus',
14
- 'serviceMode',
15
- 'save',
16
- 'outcome',
17
- 'history',
18
- 'call',
19
- 'reached',
20
- 'log',
21
- 'storageLoss',
22
- 'persistence',
23
- 'deploymentFacts',
24
- 'reauthorize',
25
- 'roomDraft.list',
26
- 'roomDraft.read',
27
- 'roomDraft.write',
28
- 'roomDraft.discard',
29
- 'presentation.read',
30
- 'presentation.write',
31
- 'conversation.list',
32
- 'conversation.read',
33
- 'conversation.create',
34
- 'conversation.send',
35
- 'conversation.answer',
36
- 'conversation.interrupt',
37
- 'conversation.kill',
38
- 'conversation.cancel',
39
- 'conversation.delete',
40
- 'chatDraft.write',
41
- 'chatDraft.discard',
42
- ];
43
- const TOPICS = [
44
- 'rooms',
45
- 'connection-refusal',
46
- 'storage-loss',
47
- 'deployment-facts',
48
- 'sync-status',
49
- 'service-mode',
50
- 'query',
51
- 'queue',
52
- 'room-drafts',
53
- 'presentation',
54
- 'conversation',
55
- ];
56
- export const AUTHORIZATION_ENDED = 'the host authorization ended';
57
- export const PORT_CLOSED = 'the port closed';
58
- export function envelope(message) {
59
- return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };
60
- }
61
- export function carried(data) {
62
- if (typeof data !== 'object' || data === null || !('mdRuntime' in data))
44
+ const TOPICS = {
45
+ rooms: 'within',
46
+ readiness: 'within',
47
+ 'connection-refusal': 'runtime',
48
+ 'storage-loss': 'runtime',
49
+ 'deployment-facts': 'runtime',
50
+ 'sync-status': 'within',
51
+ 'service-mode': 'runtime',
52
+ member: 'runtime',
53
+ 'authority-changes': 'runtime',
54
+ query: 'within',
55
+ queue: 'within',
56
+ 'room-drafts': 'within',
57
+ presentation: 'app',
58
+ conversation: 'within',
59
+ conversations: 'within',
60
+ agents: 'within',
61
+ };
62
+ export const WIRE = { members: MEMBERS, topics: TOPICS };
63
+ export function unanswered(call) {
64
+ const { effect } = MEMBERS[call.member];
65
+ if (effect === 'read')
63
66
  return null;
64
- const record = data;
65
- return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };
67
+ if (effect === 'action')
68
+ return { kind: 'result', id: call.id, value: UNCERTAIN };
69
+ return {
70
+ kind: 'failure',
71
+ id: call.id,
72
+ message: UNCERTAIN.code,
73
+ code: UNCERTAIN.code,
74
+ retryable: UNCERTAIN.retryable,
75
+ };
66
76
  }
77
+ export const AUTHORIZATION_ENDED = 'the host authorization ended';
78
+ export const PORT_CLOSED = 'the port closed';
67
79
  function body(message) {
68
80
  if (typeof message !== 'object' || message === null)
69
81
  return null;
@@ -83,7 +95,9 @@ export function request(message) {
83
95
  return { kind: 'stop', id: shape.id };
84
96
  if (!Array.isArray(record.input))
85
97
  return null;
86
- if (shape.kind === 'call' && MEMBERS.includes(record.member)) {
98
+ if (shape.kind === 'call' &&
99
+ typeof record.member === 'string' &&
100
+ Object.hasOwn(MEMBERS, record.member)) {
87
101
  return {
88
102
  kind: 'call',
89
103
  id: shape.id,
@@ -91,7 +105,9 @@ export function request(message) {
91
105
  input: record.input,
92
106
  };
93
107
  }
94
- if (shape.kind === 'observe' && TOPICS.includes(record.topic)) {
108
+ if (shape.kind === 'observe' &&
109
+ typeof record.topic === 'string' &&
110
+ Object.hasOwn(TOPICS, record.topic)) {
95
111
  return {
96
112
  kind: 'observe',
97
113
  id: shape.id,
@@ -117,8 +133,17 @@ export function answer(message) {
117
133
  return { kind: 'result', id: shape.id, value: record.value };
118
134
  if (shape.kind === 'event')
119
135
  return { kind: 'event', id: shape.id, value: record.value };
120
- if (shape.kind === 'failure' && typeof record.message === 'string') {
121
- return { kind: 'failure', id: shape.id, message: record.message };
136
+ if (shape.kind === 'failure' &&
137
+ typeof record.message === 'string' &&
138
+ typeof record.code === 'string' &&
139
+ typeof record.retryable === 'boolean') {
140
+ return {
141
+ kind: 'failure',
142
+ id: shape.id,
143
+ message: record.message,
144
+ code: record.code,
145
+ retryable: record.retryable,
146
+ };
122
147
  }
123
148
  return null;
124
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentshouse/mdruntime",
3
- "version": "0.1.0-c3903a68dcbbf",
3
+ "version": "0.1.0-c3a5b012b4a8c",
4
4
  "description": "The headless core of MD App",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,36 +9,59 @@
9
9
  "access": "public"
10
10
  },
11
11
  "engines": {
12
- "node": ">=24.21.0"
12
+ "node": ">=24.22.1"
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
16
  "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
17
+ "default": "./dist/index.js"
18
18
  },
19
19
  "./host": {
20
20
  "types": "./dist/host.d.ts",
21
- "import": "./dist/host.js"
21
+ "default": "./dist/host.js"
22
22
  },
23
23
  "./client": {
24
24
  "types": "./dist/client.d.ts",
25
- "import": "./dist/client.js"
25
+ "default": "./dist/client.js"
26
+ },
27
+ "./entry": {
28
+ "types": "./dist/entry.d.ts",
29
+ "default": "./dist/entry.js"
26
30
  },
27
31
  "./memory": {
28
32
  "types": "./dist/memory.d.ts",
29
- "import": "./dist/memory.js"
33
+ "default": "./dist/memory.js"
34
+ },
35
+ "./tables": {
36
+ "types": "./dist/tables.d.ts",
37
+ "default": "./dist/tables.js"
38
+ },
39
+ "./react": {
40
+ "types": "./dist/react.d.ts",
41
+ "default": "./dist/react.js"
42
+ },
43
+ "./digest": {
44
+ "types": "./dist/digest.d.ts",
45
+ "default": "./dist/digest.js"
30
46
  },
31
47
  "./package.json": "./package.json"
32
48
  },
33
49
  "files": [
34
50
  "dist",
35
- "AGENTS.md",
51
+ "!dist/chat.*",
52
+ "!dist/chat/",
36
53
  "README.md",
37
54
  "LICENSE"
38
55
  ],
39
56
  "dependencies": {
40
- "@agentshouse/mdmodel": "0.1.0-cf72583e19192",
41
- "@tanstack/db": "0.9.2",
42
- "minisearch": "7.2.0"
57
+ "@agentshouse/mdmodel": "0.1.0-cae8e240cefab"
58
+ },
59
+ "peerDependencies": {
60
+ "react": ">=18"
61
+ },
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/agentshouse/core.git",
65
+ "directory": "mdruntime/packages/mdruntime"
43
66
  }
44
67
  }
package/AGENTS.md DELETED
@@ -1,210 +0,0 @@
1
- # Instructions for the App Creator's agent
2
-
3
- These instructions address an agent in an environment with Git. Obtain the
4
- App Repository, change it, build, and push. They are documentation, not
5
- enforcement.
6
-
7
- ## The MD Runtime API
8
-
9
- App code reaches the MD Runtime through the remote client. The surfaces are
10
- Rooms, Slots, Query, Search, Observe, Types, Room Draft, Save, History, Call, Reached, Log,
11
- storage loss, the reported persistence answer, deployment facts, Sync Status, the Service Mode,
12
- reauthorization, conversation, the chat draft, and Presentation State.
13
-
14
- Every `observe` resolves, once its first value has arrived, to a handle:
15
- `current()` is the latest complete value, `subscribe(listener)` hears each later
16
- value whole and returns its unsubscribe, and `close()` ends the observation.
17
- Closing the port ends every handle and rejects every pending call and
18
- observation; a client that reconnects observes again.
19
-
20
- Each conversation a Provider card names is held complete in the browser.
21
- Observe one with `observe('conversation', id, { limit })`: the view
22
- holds its latest `limit` messages, or all of them, oldest first, its chat
23
- draft, and what the Provider streams for it whether or not anything views it:
24
- the growing text and plan of the running turn, the open questions, the process
25
- state, the CLI's commands and options, and the latest `workingNote`. These live
26
- only in memory: the turn's accepted message replaces its growing text and plan,
27
- a working note is never part of a message, and none of them is stored or
28
- searchable.
29
- `chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
30
- sending it is a Provider Action that needs the Provider reachable and is never
31
- queued.
32
-
33
- Slots answers each Slot the Provider declares, in its order, with its entries
34
- in order, each a Room and its segment; a Room two Slots list is the same Room.
35
-
36
- Each Room in Rooms lists its `attachments`, the files the Provider holds for it
37
- that its Documents link by the Provider's reference, ordered by `reference`,
38
- each with `name`, `byteLength`, `mediaType` and the Provider's own entry as
39
- `entry`. They are as the Provider last declared them and hold no bytes;
40
- open one through the Provider Action that serves it.
41
-
42
- Rooms, Slots, Query, Search, Observe, Types, Room Draft, Save, and Reached never
43
- touch the network.
44
- History and Call go to the Provider through the Adapter. A Call result whose
45
- effect the Provider places in a Room carries `at`, that Room and Room Version;
46
- `reached(room, roomVersion)` answers whether the Room's confirmed state has
47
- reached it, and the MD Runtime keeps refreshing that Room until it has;
48
- `reached(room, roomVersion, path)` answers whether the held confirmed copy of
49
- that document was written at a later Room Version. Each History revision
50
- names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. Every
51
- member of the
52
- client is asynchronous. Results are detached snapshots. Nothing in this
53
- surface returns the authorization, performs a request the App's code
54
- composes, or exposes the browser store.
55
-
56
- Read deployment facts with `deploymentFacts()` and observe replacements with
57
- `observe('deployment-facts')`. Interpret the opaque value using the
58
- host's contract.
59
-
60
- The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
61
- ships in no bundle.
62
-
63
- ## Local Query rules
64
-
65
- `query(q)` answers once from local state; `observe('query', q)` holds the whole
66
- result and hears it again only when it changes, keeping every unchanged Document
67
- the same object, so a component can tell what changed by identity. A query is
68
- data:
69
-
70
- - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
71
- names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
72
- directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
73
- - **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
74
- `$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
75
- `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
76
- asks whether it contains the value. Missing, null and empty differ:
77
- `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
78
- text and `$size: 0` an empty list. A date compares in calendar order and never
79
- with a date-time. A reference compares by the Room Path it resolves to.
80
- Untyped frontmatter is plain values. There is no text containment or regular
81
- expression.
82
- - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
83
- reference `field` points to a matching Document of the same Room.
84
- `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
85
- matching Document of the same Room references. Each keeps a Document once.
86
- - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
87
- `preamble`, `markdown`, `backlinks` and `change`, where `fields` and `sections`
88
- are `'all'` or a list of names. Room and Path always return; a Markdown
89
- Document also returns its MD Type. A non-Markdown Document or binary link
90
- target returns only Room and Path. An unselected part is absent. Select only
91
- what a screen shows: a list that selects the Markdown hears every edit of it.
92
- - **Change.** `change` is `{ author, time }` of the Document's head revision as
93
- the Provider last delivered it: `author` is `{ kind: 'user' | 'site', id, name }`
94
- or `null` for a write the Provider made itself, and `time` is the Provider's
95
- ISO 8601 change time. It is `null` where the Provider delivered no time, as at
96
- a Site. An unsent edit or move keeps it, an unsent creation has none, and a
97
- saved write takes the Provider's own once it is Accepted and refreshed. A
98
- Room's last change is its Document with the latest `time`.
99
- - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
100
- with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
101
- `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
102
- over every match and ordered by `count` or a key. `limit` bounds the Documents
103
- or the groups.
104
- - **Results and errors.** A result carries no Room Version: read freshness from
105
- Rooms and Sync Status. An invalid query fails with `invalid-query`,
106
- `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
107
- answers an empty result in its place.
108
-
109
- ## Local Search rules
110
-
111
- `search({ text, documents, conversations, limit })` answers once, by words, from
112
- local state, with MiniSearch at its default configuration. There is no observed
113
- search.
114
-
115
- - **What is found.** A Document by its field values, its sections' headings and
116
- text, its preamble and its Path; a message by its text. Frontmatter keys, Room
117
- Drafts, chat drafts and growing text are never found. There are no phrases,
118
- word forms, typo tolerance or prefix matching.
119
- - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
120
- `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
121
- apply before `limit`, which bounds each list; without it every hit returns.
122
- - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
123
- hits of one list of one search. A Document hit names its `room`, `path` and
124
- `type`, a message hit its `conversation` and `identity`, and `matches` maps each
125
- matched word to the parts it matched in: `fields`, `sections`, `preamble` or
126
- `path`, or `text`. A hit carries no position; mark the words in the text you
127
- show. An invalid filter fails with its Local Query error.
128
-
129
- ## Room Draft, Save, and outcome rules
130
-
131
- The MD Runtime owns one Room Draft per Room and Path, shared by every App and
132
- tab. It is durable: it survives reload and navigation. A Room that Discovery
133
- stops listing takes its Room Drafts, its queue and their outcomes with it.
134
- Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
135
- the revision you read, or `null` when there was none, and every part it should
136
- now change: fields, sections and the preamble, or the whole Markdown, a
137
- creation, a move, or a removal. A part new to the Room Draft names its base,
138
- the value you showed when it was opened; the MD Runtime keeps a part's first
139
- base. A binary link target has a Room Draft too, for a move or a removal, with
140
- `null` as its base. A write or a discard from an older revision is refused as `stale` with
141
- the current Room Draft; read it and write again.
142
-
143
- Save takes one Room and the Room Drafts of it to save, each with its revision,
144
- validates locally, and on success appends one Change Batch to that Room's
145
- queue and removes those Room Drafts. It is refused as `stale`, as
146
- `changed-underneath` naming each part whose base no longer matches the visible
147
- state, or by a local validation rule, and then creates nothing and leaves every
148
- Room Draft in place. A directory move or removal is a move or removal part on
149
- each Document and binary link target beneath it, saved together.
150
-
151
- Outcomes follow the Provider's answer. An Accepted Change Batch stays in the
152
- queue, drawn over the confirmed layer, until the confirmed layer reaches the
153
- Room Version it was accepted at, and then leaves it. Conflicted and Rejected, an expired outcome record, and a change that no
154
- longer applies over the Room each leave the queue and return as Room Drafts on
155
- the Documents they changed, marked with why: the Provider's structured refusal
156
- code and fields as returned, not known to have applied, or withdrawn locally.
157
- The rest of the queue keeps synchronizing, and Sync Status requires attention
158
- until each returned Room Draft is saved again or discarded. `outcome` answers
159
- the saved Change Batch's outcome, and `null` while it is Pending. Transport
160
- failure and Provider unavailability keep work Pending and do not infer a
161
- rejection. A refusal the Provider marks retryable stays Pending until the reset
162
- it names; the MD Runtime retries the same Change Batch identity and payload and
163
- never infers an outcome from transport uncertainty. The MD Runtime never
164
- combines, reorders, or rebases.
165
-
166
- `serviceMode()` and `observe('service-mode')` answer the Provider's Service
167
- Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
168
- its Change Batch waits unsent, and the queue is submitted in order once the
169
- Provider reopens writes. An Action is never held: a write the Provider refuses
170
- for the halt returns that refusal to its caller. Show the Provider as read-only
171
- instead of retrying.
172
-
173
- ## The neutrality rule
174
-
175
- No module outside an Adapter package imports, names, or special-cases a
176
- Provider. MD UI and every App reach data only through the client entry.
177
-
178
- ## Content-safety rules
179
-
180
- The Provider authorization belongs to the Runtime host and is never readable
181
- by the App's code. The App's code reaches the network only at the external
182
- origins its manifest declares, empty by default, and the Provider enforces
183
- that set. Every request to the Provider itself goes through the MD Runtime.
184
- Rendered Markdown never executes scripts, renders raw HTML only for the
185
- details and summary elements, and loads images and other resources only from
186
- origins the Provider's policy allows.
187
-
188
- ## Launch promises MD UI keeps
189
-
190
- MD UI uses semantic HTML, is fully operable from a keyboard with visible
191
- focus and labelled controls, and lays out from a 360 pixel wide viewport to
192
- a desktop. Its strings are English only, dates and numbers follow the
193
- browser locale, and content is never translated. Light and dark themes come
194
- from CSS custom properties with the browser's preference as the default and
195
- an App's override respected. What an App Creator's agent adds carries none
196
- of these promises by itself. Reading, querying and searching never wait for
197
- the network. Data lives only in the App Creator's browser and with the Provider.
198
-
199
- ## App code imports only the client entry and never constructs a Runtime
200
-
201
- App code imports only `@agentshouse/mdruntime/client` and calls
202
- `connectMdRuntime` on the port the host hands it. It never constructs a
203
- Runtime. It does not import the package main, the host entry, or the Adapter
204
- package, and it does not call `createMdRuntime` or `serveMdRuntime`. Hosts
205
- and tests use those entries; the served App does not.
206
-
207
- ## What an agent must never do
208
-
209
- An agent must never read the authorization, load code from a Room, call the
210
- Provider directly, or rebase a refused Change Batch.
@@ -1,3 +0,0 @@
1
- import type { RoomAttachment } from './adapter.js';
2
- export declare function declaredAttachments(pages: readonly (readonly RoomAttachment[])[]): readonly RoomAttachment[];
3
- //# sourceMappingURL=attachment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,GAC5C,SAAS,cAAc,EAAE,CAQ3B"}
@@ -1,8 +0,0 @@
1
- export function declaredAttachments(pages) {
2
- const byReference = new Map();
3
- for (const page of pages) {
4
- for (const attachment of page)
5
- byReference.set(attachment.reference, attachment);
6
- }
7
- return [...byReference.values()].sort((left, right) => left.reference < right.reference ? -1 : left.reference > right.reference ? 1 : 0);
8
- }
@@ -1,14 +0,0 @@
1
- import type { ChangeSet } from './change-set.js';
2
- import { type KeyedResult, type QueryChange } from './observation.js';
3
- import type { Plan, QueryResult } from './query.js';
4
- import type { SearchedDocument } from './search.js';
5
- export type ReadSide = {
6
- apply(set: ChangeSet): void;
7
- query(plan: Plan): Promise<QueryResult>;
8
- watch(plan: Plan, identity: string, deliver: (message: KeyedResult | QueryChange) => void): () => void;
9
- documents(): readonly SearchedDocument[];
10
- document(room: string, path: string): SearchedDocument | null;
11
- close(): void;
12
- };
13
- export declare function createReadSide(): ReadSide;
14
- //# sourceMappingURL=read-side.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAOV,IAAI,EAGJ,WAAW,EAIZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAqDpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,KAAK,IAAI,GACpD,MAAM,IAAI,CAAC;IACd,SAAS,IAAI,SAAS,gBAAgB,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAySF,wBAAgB,cAAc,IAAI,QAAQ,CA4HzC"}