@agentshouse/mdruntime 0.1.0-alpha.3 → 0.1.0-alpha.31

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 (128) hide show
  1. package/AGENTS.md +178 -0
  2. package/dist/adapter.d.ts +150 -18
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +2 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/bootstrap.d.ts +7 -7
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/bootstrap.js +13 -9
  9. package/dist/bootstrap.js.map +1 -1
  10. package/dist/change-set.d.ts +33 -0
  11. package/dist/change-set.d.ts.map +1 -0
  12. package/dist/change-set.js +89 -0
  13. package/dist/change-set.js.map +1 -0
  14. package/dist/change.d.ts +10 -0
  15. package/dist/change.d.ts.map +1 -1
  16. package/dist/change.js.map +1 -1
  17. package/dist/client.d.ts +72 -0
  18. package/dist/client.d.ts.map +1 -0
  19. package/dist/client.js +231 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/collection.d.ts +22 -12
  22. package/dist/collection.d.ts.map +1 -1
  23. package/dist/collection.js +88 -30
  24. package/dist/collection.js.map +1 -1
  25. package/dist/connection.d.ts +90 -20
  26. package/dist/connection.d.ts.map +1 -1
  27. package/dist/connection.js +1776 -194
  28. package/dist/connection.js.map +1 -1
  29. package/dist/conversation.d.ts +72 -0
  30. package/dist/conversation.d.ts.map +1 -0
  31. package/dist/conversation.js +529 -0
  32. package/dist/conversation.js.map +1 -0
  33. package/dist/durability.d.ts +9 -0
  34. package/dist/durability.d.ts.map +1 -0
  35. package/dist/durability.js +11 -0
  36. package/dist/durability.js.map +1 -0
  37. package/dist/file.d.ts +20 -0
  38. package/dist/file.d.ts.map +1 -0
  39. package/dist/file.js +149 -0
  40. package/dist/file.js.map +1 -0
  41. package/dist/host.d.ts +13 -0
  42. package/dist/host.d.ts.map +1 -0
  43. package/dist/host.js +205 -0
  44. package/dist/host.js.map +1 -0
  45. package/dist/identity.d.ts +3 -0
  46. package/dist/identity.d.ts.map +1 -0
  47. package/dist/identity.js +23 -0
  48. package/dist/identity.js.map +1 -0
  49. package/dist/index.d.ts +15 -6
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/log.d.ts +5 -0
  54. package/dist/log.d.ts.map +1 -0
  55. package/dist/log.js +15 -0
  56. package/dist/log.js.map +1 -0
  57. package/dist/memory.d.ts +17 -2
  58. package/dist/memory.d.ts.map +1 -1
  59. package/dist/memory.js +201 -15
  60. package/dist/memory.js.map +1 -1
  61. package/dist/model.d.ts +56 -0
  62. package/dist/model.d.ts.map +1 -0
  63. package/dist/model.js +37 -0
  64. package/dist/model.js.map +1 -0
  65. package/dist/observation.d.ts +25 -0
  66. package/dist/observation.d.ts.map +1 -0
  67. package/dist/observation.js +92 -0
  68. package/dist/observation.js.map +1 -0
  69. package/dist/outcome.d.ts +34 -0
  70. package/dist/outcome.d.ts.map +1 -0
  71. package/dist/outcome.js +3 -0
  72. package/dist/outcome.js.map +1 -0
  73. package/dist/overlay.d.ts +2 -0
  74. package/dist/overlay.d.ts.map +1 -1
  75. package/dist/overlay.js +107 -1
  76. package/dist/overlay.js.map +1 -1
  77. package/dist/paths.d.ts +0 -1
  78. package/dist/paths.d.ts.map +1 -1
  79. package/dist/paths.js +0 -4
  80. package/dist/paths.js.map +1 -1
  81. package/dist/query.d.ts +209 -0
  82. package/dist/query.d.ts.map +1 -0
  83. package/dist/query.js +467 -0
  84. package/dist/query.js.map +1 -0
  85. package/dist/read-side.d.ts +14 -0
  86. package/dist/read-side.d.ts.map +1 -0
  87. package/dist/read-side.js +451 -0
  88. package/dist/read-side.js.map +1 -0
  89. package/dist/refresh.d.ts +2 -2
  90. package/dist/refresh.d.ts.map +1 -1
  91. package/dist/refresh.js +8 -6
  92. package/dist/refresh.js.map +1 -1
  93. package/dist/replica.d.ts +22 -3
  94. package/dist/replica.d.ts.map +1 -1
  95. package/dist/replica.js +170 -8
  96. package/dist/replica.js.map +1 -1
  97. package/dist/room-draft.d.ts +124 -0
  98. package/dist/room-draft.d.ts.map +1 -0
  99. package/dist/room-draft.js +406 -0
  100. package/dist/room-draft.js.map +1 -0
  101. package/dist/rows.d.ts +39 -0
  102. package/dist/rows.d.ts.map +1 -0
  103. package/dist/rows.js +100 -0
  104. package/dist/rows.js.map +1 -0
  105. package/dist/save.d.ts +11 -2
  106. package/dist/save.d.ts.map +1 -1
  107. package/dist/save.js +104 -128
  108. package/dist/save.js.map +1 -1
  109. package/dist/search.d.ts +61 -0
  110. package/dist/search.d.ts.map +1 -0
  111. package/dist/search.js +155 -0
  112. package/dist/search.js.map +1 -0
  113. package/dist/status.d.ts +9 -1
  114. package/dist/status.d.ts.map +1 -1
  115. package/dist/status.js +7 -4
  116. package/dist/status.js.map +1 -1
  117. package/dist/store.d.ts +87 -15
  118. package/dist/store.d.ts.map +1 -1
  119. package/dist/store.js +436 -54
  120. package/dist/store.js.map +1 -1
  121. package/dist/transfer.d.ts +5 -0
  122. package/dist/transfer.d.ts.map +1 -1
  123. package/dist/transfer.js.map +1 -1
  124. package/dist/wire.d.ts +64 -0
  125. package/dist/wire.d.ts.map +1 -0
  126. package/dist/wire.js +142 -0
  127. package/dist/wire.js.map +1 -0
  128. package/package.json +14 -4
package/AGENTS.md ADDED
@@ -0,0 +1,178 @@
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, Log,
11
+ storage loss, the reported persistence answer, deployment facts, Sync Status, reauthorization,
12
+ 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, with the
23
+ growing text and the session summary while it is viewed, and its chat draft.
24
+ `chatDraft.write` and `chatDraft.discard` keep what the App Creator composes;
25
+ sending it is a Provider Action that needs the Provider reachable and is never
26
+ queued.
27
+
28
+ Slots answers each Slot the Provider declares, in its order, with its entries
29
+ in order, each a Room and its segment; a Room two Slots list is the same Room.
30
+
31
+ Rooms, Slots, Query, Search, Observe, Types, Room Draft, and Save never touch the
32
+ network.
33
+ History and Call go to the Provider through the Adapter. Every member of the
34
+ client is asynchronous. Results are detached snapshots. Nothing in this
35
+ surface returns the authorization, performs a request the App's code
36
+ composes, or exposes the browser store.
37
+
38
+ Read deployment facts with `deploymentFacts()` and observe replacements with
39
+ `observe('deployment-facts')`. Interpret the opaque value using the
40
+ host's contract. [R038](https://github.com/agentshouse/mdruntime/blob/main/docs/requirements/ledger.md#r038--runtime-host-and-remote-client)
41
+ owns their boundary.
42
+
43
+ The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
44
+ ships in no bundle.
45
+
46
+ ## Local Query rules
47
+
48
+ `query(q)` answers once from local state; `observe('query', q)` holds the whole
49
+ result and hears it again only when it changes, keeping every unchanged Document
50
+ the same object, so a component can tell what changed by identity. A query is
51
+ data:
52
+
53
+ - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
54
+ names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
55
+ directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
56
+ - **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
57
+ `$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
58
+ `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
59
+ asks whether it contains the value. Missing, null and empty differ:
60
+ `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
61
+ text and `$size: 0` an empty list. A date compares in calendar order and never
62
+ with a date-time. A reference compares by the Room Path it resolves to.
63
+ Untyped frontmatter is plain values. There is no text containment or regular
64
+ expression.
65
+ - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
66
+ reference `field` points to a matching Document of the same Room.
67
+ `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
68
+ matching Document of the same Room references. Each keeps a Document once.
69
+ - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
70
+ `preamble`, `markdown` and `backlinks`, where `fields` and `sections` are
71
+ `'all'` or a list of names. Room and Path always return; a Markdown Document
72
+ also returns its MD Type. A non-Markdown Document or binary link target returns
73
+ only Room and Path. An unselected part is absent. Select only what a screen
74
+ shows: a list that selects the Markdown hears every edit of it.
75
+ - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
76
+ with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
77
+ `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
78
+ over every match and ordered by `count` or a key. `limit` bounds the Documents
79
+ or the groups.
80
+ - **Results and errors.** A result carries no Room Version: read freshness from
81
+ Rooms and Sync Status. An invalid query fails with `invalid-query`,
82
+ `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
83
+ answers an empty result in its place.
84
+
85
+ ## Local Search rules
86
+
87
+ `search({ text, documents, conversations, limit })` answers once, by words, from
88
+ local state, with MiniSearch at its default configuration. There is no observed
89
+ search.
90
+
91
+ - **What is found.** A Document by its field values, its sections' headings and
92
+ text, its preamble and its Path; a message by its text. Frontmatter keys, Room
93
+ Drafts, chat drafts and growing text are never found. There are no phrases,
94
+ word forms, typo tolerance or prefix matching.
95
+ - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
96
+ `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
97
+ apply before `limit`, which bounds each list; without it every hit returns.
98
+ - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
99
+ hits of one list of one search. A Document hit names its `room`, `path` and
100
+ `type`, a message hit its `conversation` and `identity`, and `matches` maps each
101
+ matched word to the parts it matched in: `fields`, `sections`, `preamble` or
102
+ `path`, or `text`. A hit carries no position; mark the words in the text you
103
+ show. An invalid filter fails with its Local Query error.
104
+
105
+ ## Room Draft, Save, and outcome rules
106
+
107
+ The MD Runtime owns one Room Draft per Room and Path, shared by every App and
108
+ tab. It is durable: it survives reload and navigation. A Room that Discovery
109
+ stops listing takes its Room Drafts, its queue and their outcomes with it.
110
+ Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
111
+ the revision you read, or `null` when there was none, and every part it should
112
+ now change: fields, sections and the preamble, or the whole Markdown, a
113
+ creation, a move, or a removal. A part new to the Room Draft names its base,
114
+ the value you showed when it was opened; the MD Runtime keeps a part's first
115
+ base. A binary link target has a Room Draft too, for a move or a removal, with
116
+ `null` as its base. A write or a discard from an older revision is refused as `stale` with
117
+ the current Room Draft; read it and write again.
118
+
119
+ Save takes one Room and the Room Drafts of it to save, each with its revision,
120
+ validates locally, and on success appends one Change Batch to that Room's
121
+ queue and removes those Room Drafts. It is refused as `stale`, as
122
+ `changed-underneath` naming each part whose base no longer matches the visible
123
+ state, or by a local validation rule, and then creates nothing and leaves every
124
+ Room Draft in place. A directory move or removal is a move or removal part on
125
+ each Document and binary link target beneath it, saved together.
126
+
127
+ Outcomes follow the Provider's answer. Accepted advances the confirmed
128
+ layer. Conflicted and Rejected, an expired outcome record, and a change that no
129
+ longer applies over the Room each leave the queue and return as Room Drafts on
130
+ the Documents they changed, marked with why: the Provider's structured refusal
131
+ code and fields as returned, not known to have applied, or withdrawn locally.
132
+ The rest of the queue keeps synchronizing, and Sync Status requires attention
133
+ until each returned Room Draft is saved again or discarded. `outcome` answers
134
+ the saved Change Batch's outcome, and `null` while it is Pending. Transport
135
+ failure and Provider unavailability keep work Pending and do not infer a
136
+ rejection. A refusal the Provider marks retryable stays Pending until the reset
137
+ it names; the MD Runtime retries the same Change Batch identity and payload and
138
+ never infers an outcome from transport uncertainty. The MD Runtime never
139
+ combines, reorders, or rebases.
140
+
141
+ ## The neutrality rule
142
+
143
+ No module outside an Adapter package imports, names, or special-cases a
144
+ Provider. MD UI and every App reach data only through the client entry.
145
+
146
+ ## Content-safety rules
147
+
148
+ The Provider authorization belongs to the Runtime host and is never readable
149
+ by the App's code. The App's code reaches the network only at the external
150
+ origins its manifest declares, empty by default, and the Provider enforces
151
+ that set. Every request to the Provider itself goes through the MD Runtime.
152
+ Rendered Markdown never executes scripts, renders raw HTML only for the
153
+ details and summary elements, and loads images and other resources only from
154
+ origins the Provider's policy allows.
155
+
156
+ ## Launch promises MD UI keeps
157
+
158
+ MD UI uses semantic HTML, is fully operable from a keyboard with visible
159
+ focus and labelled controls, and lays out from a 360 pixel wide viewport to
160
+ a desktop. Its strings are English only, dates and numbers follow the
161
+ browser locale, and content is never translated. Light and dark themes come
162
+ from CSS custom properties with the browser's preference as the default and
163
+ an App's override respected. What an App Creator's agent adds carries none
164
+ of these promises by itself. Reading, querying and searching never wait for
165
+ the network. Data lives only in the App Creator's browser and with the Provider.
166
+
167
+ ## App code imports only the client entry and never constructs a Runtime
168
+
169
+ App code imports only `@agentshouse/mdruntime/client` and calls
170
+ `connectMdRuntime` on the port the host hands it. It never constructs a
171
+ Runtime. It does not import the package main, the host entry, or the Adapter
172
+ package, and it does not call `createMdRuntime` or `serveMdRuntime`. Hosts
173
+ and tests use those entries; the served App does not.
174
+
175
+ ## What an agent must never do
176
+
177
+ An agent must never read the authorization, load code from a Room, call the
178
+ Provider directly, or rebase a refused Change Batch.
package/dist/adapter.d.ts CHANGED
@@ -1,22 +1,88 @@
1
+ import type { ModelIdentity, ModelResult } from './model.js';
1
2
  import type { ChangeBatch } from './change.js';
2
3
  export type Authorization = object;
3
4
  export declare const ROOM_CONTRACT_VERSION = 1;
4
- export declare const VERSION_1_CAPABILITIES: readonly ['stable-file-ids', 'ranked-provider-search', 'room-version-notifications', 'room-history', 'provider-actions'];
5
+ export declare const VERSION_1_CAPABILITIES: readonly ['stable-file-ids', 'ranked-provider-search', 'room-version-notifications', 'room-history', 'provider-actions', 'move-reference-rewrites'];
5
6
  export type MdModelIdentity = {
6
7
  identity: string;
7
8
  version: string;
8
9
  };
10
+ export type TypedSelection = {
11
+ roots: readonly string[];
12
+ attachedModel: ModelIdentity | null;
13
+ };
14
+ export type OperationScopes = {
15
+ read: readonly string[];
16
+ sync: readonly string[];
17
+ write: readonly string[];
18
+ delete: readonly string[];
19
+ };
20
+ export type ReplicaAdmission = {
21
+ selection: string;
22
+ admission: 'admitted' | 'unavailable';
23
+ };
9
24
  export type DiscoveredRoom = {
25
+ collectionRoot: string;
10
26
  name: string;
11
27
  locator: string;
12
28
  roomVersion: string;
13
- writeGrants: readonly string[];
29
+ operations: OperationScopes;
30
+ replica: ReplicaAdmission;
31
+ attachedModel: ModelIdentity | null;
32
+ typedSelection?: TypedSelection;
14
33
  providerOwnedPaths: readonly string[];
15
34
  };
16
35
  export type Capability = {
17
36
  name: string;
18
37
  limits?: readonly ProviderLimit[];
19
38
  actions?: readonly ActionDeclaration[];
39
+ conversationCards?: ConversationCards;
40
+ };
41
+ export type ConversationCards = {
42
+ locator: string;
43
+ type: string;
44
+ identity: string;
45
+ agent: string;
46
+ };
47
+ export type ConversationAction = 'conversation.create' | 'conversation.send' | 'conversation.answer' | 'conversation.interrupt' | 'conversation.kill' | 'conversation.cancel' | 'conversation.delete' | 'conversation.history';
48
+ export type ConversationMessage = {
49
+ identity: string;
50
+ turn: string;
51
+ text: string;
52
+ message: unknown;
53
+ };
54
+ export type AcceptedMessage = ConversationMessage & {
55
+ position: string;
56
+ };
57
+ export type ConversationHistoryRequest = {
58
+ conversation: string;
59
+ after?: string;
60
+ };
61
+ export type ConversationHistoryPage = {
62
+ messages: readonly AcceptedMessage[];
63
+ next?: string;
64
+ };
65
+ export type ConversationEvent = {
66
+ kind: 'growing-text';
67
+ conversation: string;
68
+ turn: string;
69
+ text: string;
70
+ } | {
71
+ kind: 'accepted-message';
72
+ conversation: string;
73
+ message: AcceptedMessage;
74
+ } | {
75
+ kind: 'session-summary';
76
+ conversation: string;
77
+ summary: unknown;
78
+ } | {
79
+ kind: 'gap';
80
+ conversation: string;
81
+ };
82
+ export type ConversationStream = {
83
+ replicate(conversations: readonly string[]): void;
84
+ view(conversations: readonly string[]): void;
85
+ observe(notify: (event: ConversationEvent) => void): () => void;
20
86
  };
21
87
  export type ActionDeclaration = {
22
88
  name: string;
@@ -27,8 +93,14 @@ export type ProviderLimit = {
27
93
  name: string;
28
94
  value?: number | string;
29
95
  };
96
+ export type HistoryRetention = {
97
+ kind: 'duration';
98
+ seconds: number;
99
+ } | {
100
+ kind: 'no-declared-time-bound';
101
+ };
30
102
  export type Retention = {
31
- history: number;
103
+ history: HistoryRetention;
32
104
  outcome: number;
33
105
  refreshHorizon: number;
34
106
  };
@@ -37,10 +109,16 @@ export type Discovery = {
37
109
  supportedVersions: readonly number[];
38
110
  mdModel: MdModelIdentity;
39
111
  rooms: readonly DiscoveredRoom[];
112
+ slots?: readonly {
113
+ slot: string;
114
+ entries: readonly {
115
+ locator: string;
116
+ segment: string | null;
117
+ }[];
118
+ }[];
40
119
  capabilities: readonly Capability[];
41
120
  providerLimits: readonly ProviderLimit[];
42
121
  retention: Retention;
43
- origins: readonly string[];
44
122
  };
45
123
  export type TransportUncertainty = {
46
124
  kind: 'transport-uncertainty';
@@ -52,11 +130,24 @@ export type RoomNotReadable = {
52
130
  export type RevokedAuthorization = {
53
131
  kind: 'revoked-authorization';
54
132
  };
55
- export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization;
56
- export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization;
133
+ export type ProviderRefusal = {
134
+ code: string;
135
+ fields: Readonly<Record<string, unknown>>;
136
+ };
137
+ export type ScopedRefusal = ProviderRefusal & {
138
+ kind: 'scoped-refusal';
139
+ locator: string;
140
+ scope: 'content' | 'sync' | 'model' | 'operation' | 'undisclosed';
141
+ };
142
+ export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
143
+ export type ContractUnavailable = ProviderRefusal & {
144
+ kind: 'contract-unavailable';
145
+ };
146
+ export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
57
147
  export type PageToken = string;
58
148
  export type BootstrapRequest = {
59
149
  locator: string;
150
+ selection: string;
60
151
  pageToken?: PageToken;
61
152
  };
62
153
  export type BootstrapPage = {
@@ -70,6 +161,7 @@ export type BootstrapPage = {
70
161
  export type BootstrapResult = BootstrapPage | AdapterFailure;
71
162
  export type RefreshRequest = {
72
163
  locator: string;
164
+ selection: string;
73
165
  fromRoomVersion: string;
74
166
  pageToken?: PageToken;
75
167
  };
@@ -91,29 +183,48 @@ export type MutationRequest = {
91
183
  locator: string;
92
184
  changeBatch: ChangeBatch;
93
185
  };
186
+ export type RetryableRefusal = ProviderRefusal & {
187
+ kind: 'retryable-refusal';
188
+ reset?: string;
189
+ };
94
190
  export type MutationResult = {
95
191
  kind: 'accepted';
96
192
  roomVersion: string;
97
- } | {
193
+ documents: Readonly<Record<string, string>>;
194
+ revisions: Readonly<Record<string, string>>;
195
+ removals: readonly string[];
196
+ author?: string;
197
+ time?: string;
198
+ } | (ProviderRefusal & {
98
199
  kind: 'conflicted';
99
- roomVersion: string;
100
- text: string;
101
- } | {
200
+ roomVersion?: string;
201
+ affected: Readonly<Record<string, string>>;
202
+ }) | (ProviderRefusal & {
102
203
  kind: 'rejected';
103
- text: string;
204
+ affected: Readonly<Record<string, string>>;
205
+ }) | RetryableRefusal | {
206
+ kind: 'expired';
104
207
  } | AdapterFailure;
208
+ export type HistoryRevision = {
209
+ revision: string;
210
+ author: string;
211
+ time: string;
212
+ };
105
213
  export type HistoryRequest = {
106
214
  locator: string;
107
215
  path: string;
216
+ revision?: string;
108
217
  pageToken?: PageToken;
109
218
  };
110
219
  export type HistoryResult = {
111
220
  kind: 'history';
112
- revisions: readonly {
113
- author: string;
114
- time: string;
115
- }[];
221
+ revisions: readonly HistoryRevision[];
116
222
  pageToken?: PageToken;
223
+ } | {
224
+ kind: 'revision';
225
+ content: string;
226
+ } | {
227
+ kind: 'no-history';
117
228
  } | AdapterFailure;
118
229
  export type ActionRequest = {
119
230
  name: string;
@@ -122,11 +233,30 @@ export type ActionRequest = {
122
233
  export type ActionResult = {
123
234
  kind: 'action';
124
235
  result: unknown;
125
- } | {
236
+ } | (ProviderRefusal & {
126
237
  kind: 'rejected';
127
- text: string;
128
- } | AdapterFailure;
238
+ }) | AdapterFailure;
239
+ export type ModelRequest = {
240
+ locator: string;
241
+ attached: 'collection';
242
+ collectionRoot: string;
243
+ model: ModelIdentity | null;
244
+ } | {
245
+ locator: string;
246
+ attached: 'typed-selection';
247
+ roots: readonly string[];
248
+ model: ModelIdentity | null;
249
+ };
250
+ export type RoomVersionNotification = {
251
+ locator: string;
252
+ roomVersion: string;
253
+ };
254
+ export type SelectedRooms = {
255
+ select(locators: readonly string[]): void;
256
+ observe(notify: (notification: RoomVersionNotification) => void): () => void;
257
+ };
129
258
  export type Adapter = {
259
+ model(authorization: Authorization, request: ModelRequest): Promise<ModelResult>;
130
260
  authorize(): Promise<Authorization>;
131
261
  discover(authorization: Authorization): Promise<DiscoverResult>;
132
262
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
@@ -134,5 +264,7 @@ export type Adapter = {
134
264
  mutate(authorization: Authorization, request: MutationRequest): Promise<MutationResult>;
135
265
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
136
266
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
267
+ roomVersions?: SelectedRooms;
268
+ conversations?: ConversationStream;
137
269
  };
138
270
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src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C;CAC9E,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACjF,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAChE,SAAS,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7F,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACvF,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACxF,OAAO,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACvF,MAAM,CAAC,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACpF,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,kBAAkB,CAAC;CACpC,CAAC"}
package/dist/adapter.js CHANGED
@@ -4,7 +4,8 @@ export const VERSION_1_CAPABILITIES = [
4
4
  'ranked-provider-search',
5
5
  'room-version-notifications',
6
6
  'room-history',
7
- 'provider-actions'
7
+ 'provider-actions',
8
+ 'move-reference-rewrites'
8
9
  ];
9
10
 
10
11
  //# sourceMappingURL=adapter.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime/src/adapter.ts"],"sourcesContent":["import type { ChangeBatch } from './change.js';\n\nexport type Authorization = object;\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const VERSION_1_CAPABILITIES = [\n 'stable-file-ids',\n 'ranked-provider-search',\n 'room-version-notifications',\n 'room-history',\n 'provider-actions',\n] as const;\n\nexport type MdModelIdentity = {\n identity: string;\n version: string;\n};\n\nexport type DiscoveredRoom = {\n name: string;\n locator: string;\n roomVersion: string;\n writeGrants: readonly string[];\n providerOwnedPaths: readonly string[];\n};\n\nexport type Capability = {\n name: string;\n limits?: readonly ProviderLimit[];\n actions?: readonly ActionDeclaration[];\n};\n\nexport type ActionDeclaration = {\n name: string;\n inputShape: unknown;\n resultKind: unknown;\n};\n\nexport type ProviderLimit = {\n name: string;\n value?: number | string;\n};\n\nexport type Retention = {\n history: number;\n outcome: number;\n refreshHorizon: number;\n};\n\nexport type Discovery = {\n kind: 'discovery';\n supportedVersions: readonly number[];\n mdModel: MdModelIdentity;\n rooms: readonly DiscoveredRoom[];\n capabilities: readonly Capability[];\n providerLimits: readonly ProviderLimit[];\n retention: Retention;\n origins: readonly string[];\n};\n\nexport type TransportUncertainty = { kind: 'transport-uncertainty' };\nexport type RoomNotReadable = { kind: 'room-not-readable'; locator: string };\nexport type RevokedAuthorization = { kind: 'revoked-authorization' };\n\nexport type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization;\n\nexport type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization;\n\nexport type PageToken = string;\n\nexport type BootstrapRequest = {\n locator: string;\n pageToken?: PageToken;\n};\n\nexport type BootstrapPage = {\n kind: 'bootstrap';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type BootstrapResult = BootstrapPage | AdapterFailure;\n\nexport type RefreshRequest = {\n locator: string;\n fromRoomVersion: string;\n pageToken?: PageToken;\n};\n\nexport type RefreshPage = {\n kind: 'net-advancement';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n removals: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type RefreshResult =\n | { kind: 'still-current' }\n | RefreshPage\n | { kind: 'beyond-horizon' }\n | AdapterFailure;\n\nexport type MutationRequest = {\n locator: string;\n changeBatch: ChangeBatch;\n};\n\nexport type MutationResult =\n | { kind: 'accepted'; roomVersion: string }\n | { kind: 'conflicted'; roomVersion: string; text: string }\n | { kind: 'rejected'; text: string }\n | AdapterFailure;\n\nexport type HistoryRequest = {\n locator: string;\n path: string;\n pageToken?: PageToken;\n};\n\nexport type HistoryResult =\n | {\n kind: 'history';\n revisions: readonly { author: string; time: string }[];\n pageToken?: PageToken;\n }\n | AdapterFailure;\n\nexport type ActionRequest = {\n name: string;\n input: unknown;\n};\n\nexport type ActionResult =\n | { kind: 'action'; result: unknown }\n | { kind: 'rejected'; text: string }\n | AdapterFailure;\n\nexport type Adapter = {\n authorize(): Promise<Authorization>;\n discover(authorization: Authorization): Promise<DiscoverResult>;\n bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;\n refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;\n mutate(authorization: Authorization, request: MutationRequest): Promise<MutationResult>;\n history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;\n action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;\n};\n"],"names":["ROOM_CONTRACT_VERSION","VERSION_1_CAPABILITIES"],"mappings":"AAIA,OAAO,MAAMA,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,yBAAyB;IACpC;IACA;IACA;IACA;IACA;CACD,CAAU"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/adapter.ts"],"sourcesContent":["import type { ModelIdentity, ModelResult } from './model.js';\nimport type { ChangeBatch } from './change.js';\n\nexport type Authorization = object;\n\nexport const ROOM_CONTRACT_VERSION = 1;\n\nexport const VERSION_1_CAPABILITIES = [\n 'stable-file-ids',\n 'ranked-provider-search',\n 'room-version-notifications',\n 'room-history',\n 'provider-actions',\n 'move-reference-rewrites',\n] as const;\n\nexport type MdModelIdentity = {\n identity: string;\n version: string;\n};\n\nexport type TypedSelection = {\n roots: readonly string[];\n attachedModel: ModelIdentity | null;\n};\n\nexport type OperationScopes = {\n read: readonly string[];\n sync: readonly string[];\n write: readonly string[];\n delete: readonly string[];\n};\nexport type ReplicaAdmission = { selection: string; admission: 'admitted' | 'unavailable' };\n\nexport type DiscoveredRoom = {\n collectionRoot: string;\n name: string;\n locator: string;\n roomVersion: string;\n operations: OperationScopes;\n replica: ReplicaAdmission;\n attachedModel: ModelIdentity | null;\n typedSelection?: TypedSelection;\n providerOwnedPaths: readonly string[];\n};\n\nexport type Capability = {\n name: string;\n limits?: readonly ProviderLimit[];\n actions?: readonly ActionDeclaration[];\n conversationCards?: ConversationCards;\n};\n\nexport type ConversationCards = {\n locator: string;\n type: string;\n identity: string;\n agent: string;\n};\n\nexport type ConversationAction =\n | 'conversation.create'\n | 'conversation.send'\n | 'conversation.answer'\n | 'conversation.interrupt'\n | 'conversation.kill'\n | 'conversation.cancel'\n | 'conversation.delete'\n | 'conversation.history';\n\nexport type ConversationMessage = {\n identity: string;\n turn: string;\n text: string;\n message: unknown;\n};\n\nexport type AcceptedMessage = ConversationMessage & { position: string };\n\nexport type ConversationHistoryRequest = {\n conversation: string;\n after?: string;\n};\n\nexport type ConversationHistoryPage = {\n messages: readonly AcceptedMessage[];\n next?: string;\n};\n\nexport type ConversationEvent =\n | { kind: 'growing-text'; conversation: string; turn: string; text: string }\n | { kind: 'accepted-message'; conversation: string; message: AcceptedMessage }\n | { kind: 'session-summary'; conversation: string; summary: unknown }\n | { kind: 'gap'; conversation: string };\n\nexport type ConversationStream = {\n replicate(conversations: readonly string[]): void;\n view(conversations: readonly string[]): void;\n observe(notify: (event: ConversationEvent) => void): () => void;\n};\n\nexport type ActionDeclaration = {\n name: string;\n inputShape: unknown;\n resultKind: unknown;\n};\n\nexport type ProviderLimit = {\n name: string;\n value?: number | string;\n};\n\nexport type HistoryRetention =\n | { kind: 'duration'; seconds: number }\n | { kind: 'no-declared-time-bound' };\n\nexport type Retention = {\n history: HistoryRetention;\n outcome: number;\n refreshHorizon: number;\n};\n\nexport type Discovery = {\n kind: 'discovery';\n supportedVersions: readonly number[];\n mdModel: MdModelIdentity;\n rooms: readonly DiscoveredRoom[];\n slots?: readonly {\n slot: string;\n entries: readonly { locator: string; segment: string | null }[];\n }[];\n capabilities: readonly Capability[];\n providerLimits: readonly ProviderLimit[];\n retention: Retention;\n};\n\nexport type TransportUncertainty = { kind: 'transport-uncertainty' };\nexport type RoomNotReadable = { kind: 'room-not-readable'; locator: string };\nexport type RevokedAuthorization = { kind: 'revoked-authorization' };\n\nexport type ProviderRefusal = {\n code: string;\n fields: Readonly<Record<string, unknown>>;\n};\n\nexport type ScopedRefusal = ProviderRefusal & {\n kind: 'scoped-refusal';\n locator: string;\n scope: 'content' | 'sync' | 'model' | 'operation' | 'undisclosed';\n};\nexport type AdapterFailure =\n | TransportUncertainty\n | RoomNotReadable\n | RevokedAuthorization\n | ScopedRefusal;\n\nexport type ContractUnavailable = ProviderRefusal & { kind: 'contract-unavailable' };\n\nexport type DiscoverResult =\n | Discovery\n | TransportUncertainty\n | RevokedAuthorization\n | ContractUnavailable;\n\nexport type PageToken = string;\n\nexport type BootstrapRequest = {\n locator: string;\n selection: string;\n pageToken?: PageToken;\n};\n\nexport type BootstrapPage = {\n kind: 'bootstrap';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type BootstrapResult = BootstrapPage | AdapterFailure;\n\nexport type RefreshRequest = {\n locator: string;\n selection: string;\n fromRoomVersion: string;\n pageToken?: PageToken;\n};\n\nexport type RefreshPage = {\n kind: 'net-advancement';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n removals: readonly string[];\n pageToken?: PageToken;\n};\n\nexport type RefreshResult =\n | { kind: 'still-current' }\n | RefreshPage\n | { kind: 'beyond-horizon' }\n | AdapterFailure;\n\nexport type MutationRequest = {\n locator: string;\n changeBatch: ChangeBatch;\n};\n\nexport type RetryableRefusal = ProviderRefusal & {\n kind: 'retryable-refusal';\n reset?: string;\n};\n\nexport type MutationResult =\n | {\n kind: 'accepted';\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n revisions: Readonly<Record<string, string>>;\n removals: readonly string[];\n author?: string;\n time?: string;\n }\n | (ProviderRefusal & {\n kind: 'conflicted';\n roomVersion?: string;\n affected: Readonly<Record<string, string>>;\n })\n | (ProviderRefusal & {\n kind: 'rejected';\n affected: Readonly<Record<string, string>>;\n })\n | RetryableRefusal\n | { kind: 'expired' }\n | AdapterFailure;\n\nexport type HistoryRevision = {\n revision: string;\n author: string;\n time: string;\n};\n\nexport type HistoryRequest = {\n locator: string;\n path: string;\n revision?: string;\n pageToken?: PageToken;\n};\n\nexport type HistoryResult =\n | {\n kind: 'history';\n revisions: readonly HistoryRevision[];\n pageToken?: PageToken;\n }\n | {\n kind: 'revision';\n content: string;\n }\n | { kind: 'no-history' }\n | AdapterFailure;\n\nexport type ActionRequest = {\n name: string;\n input: unknown;\n};\n\nexport type ActionResult =\n | { kind: 'action'; result: unknown }\n | (ProviderRefusal & { kind: 'rejected' })\n | AdapterFailure;\n\nexport type ModelRequest =\n | { locator: string; attached: 'collection'; collectionRoot: string; model: ModelIdentity | null }\n | {\n locator: string;\n attached: 'typed-selection';\n roots: readonly string[];\n model: ModelIdentity | null;\n };\n\nexport type RoomVersionNotification = {\n locator: string;\n roomVersion: string;\n};\n\nexport type SelectedRooms = {\n select(locators: readonly string[]): void;\n observe(notify: (notification: RoomVersionNotification) => void): () => void;\n};\n\nexport type Adapter = {\n model(authorization: Authorization, request: ModelRequest): Promise<ModelResult>;\n authorize(): Promise<Authorization>;\n discover(authorization: Authorization): Promise<DiscoverResult>;\n bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;\n refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;\n mutate(authorization: Authorization, request: MutationRequest): Promise<MutationResult>;\n history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;\n action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;\n roomVersions?: SelectedRooms;\n conversations?: ConversationStream;\n};\n"],"names":["ROOM_CONTRACT_VERSION","VERSION_1_CAPABILITIES"],"mappings":"AAKA,OAAO,MAAMA,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,yBAAyB;IACpC;IACA;IACA;IACA;IACA;IACA;CACD,CAAU"}
@@ -1,9 +1,9 @@
1
+ import type { ModelState } from './model.js';
1
2
  import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';
2
- import { type ConfirmedLayer } from './replica.js';
3
- import { type Unconfirmed } from './transfer.js';
4
- export type BootstrapOutcome = {
5
- kind: 'staged';
6
- confirmed: ConfirmedLayer;
7
- } | Unconfirmed | AdapterFailure;
8
- export declare function bootstrapRoom(adapter: Adapter, authorization: Authorization, room: DiscoveredRoom): Promise<BootstrapOutcome>;
3
+ import { type Staged } from './replica.js';
4
+ export type BootstrapOutcome = Staged | AdapterFailure;
5
+ export declare function bootstrapRoom(adapter: Adapter, authorization: Authorization, room: DiscoveredRoom, models: {
6
+ collection: ModelState;
7
+ selection: ModelState;
8
+ }): Promise<BootstrapOutcome>;
9
9
  //# sourceMappingURL=bootstrap.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAC7C,WAAW,GACX,cAAc,CAAC;AAEnB,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,gBAAgB,CAAC,CA4B3B"}
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAc,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAGvD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,cAAc,CAAC;AAEvD,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,UAAU,CAAA;CAAE,GACxD,OAAO,CAAC,gBAAgB,CAAC,CAwC3B"}
package/dist/bootstrap.js CHANGED
@@ -1,8 +1,9 @@
1
- import { readConfirmed } from './replica.js';
1
+ import { readStaged } from './replica.js';
2
2
  import { unconfirmed } from './transfer.js';
3
- export async function bootstrapRoom(adapter, authorization, room) {
3
+ export async function bootstrapRoom(adapter, authorization, room, models) {
4
4
  const first = await adapter.bootstrap(authorization, {
5
- locator: room.locator
5
+ locator: room.locator,
6
+ selection: room.replica.selection
6
7
  });
7
8
  if (first.kind !== 'bootstrap') return first;
8
9
  const roomVersion = first.roomVersion;
@@ -17,6 +18,7 @@ export async function bootstrapRoom(adapter, authorization, room) {
17
18
  while(pageToken !== undefined){
18
19
  const page = await adapter.bootstrap(authorization, {
19
20
  locator: room.locator,
21
+ selection: room.replica.selection,
20
22
  pageToken
21
23
  });
22
24
  if (page.kind !== 'bootstrap') return page;
@@ -26,10 +28,16 @@ export async function bootstrapRoom(adapter, authorization, room) {
26
28
  for (const target of page.binaryTargets)binaryTargets.add(target);
27
29
  pageToken = page.pageToken;
28
30
  }
29
- const confirmed = readConfirmed({
31
+ return readStaged({
30
32
  locator: room.locator,
33
+ collectionRoot: room.collectionRoot,
31
34
  name: room.name,
32
- writeGrants: room.writeGrants,
35
+ operations: room.operations,
36
+ replica: room.replica,
37
+ attachedModel: room.attachedModel,
38
+ model: models.collection,
39
+ typedSelection: room.typedSelection ?? null,
40
+ selectionModel: models.selection,
33
41
  providerOwnedPaths: room.providerOwnedPaths,
34
42
  roomVersion,
35
43
  documents,
@@ -38,10 +46,6 @@ export async function bootstrapRoom(adapter, authorization, room) {
38
46
  ].sort(),
39
47
  revisions
40
48
  });
41
- return confirmed === null ? unconfirmed : {
42
- kind: 'staged',
43
- confirmed
44
- };
45
49
  }
46
50
 
47
51
  //# sourceMappingURL=bootstrap.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readConfirmed, type ConfirmedLayer } from './replica.js';\nimport { unconfirmed, type Unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome =\n | { kind: 'staged'; confirmed: ConfirmedLayer }\n | Unconfirmed\n | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, { locator: room.locator });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n const page = await adapter.bootstrap(authorization, { locator: room.locator, pageToken });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n const confirmed = readConfirmed({\n locator: room.locator,\n name: room.name,\n writeGrants: room.writeGrants,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n });\n return confirmed === null ? unconfirmed : { kind: 'staged', confirmed };\n}\n"],"names":["readConfirmed","unconfirmed","bootstrapRoom","adapter","authorization","room","first","bootstrap","locator","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","confirmed","name","writeGrants","providerOwnedPaths","sort"],"mappings":"AACA,SAASA,aAAa,QAA6B,eAAe;AAClE,SAASC,WAAW,QAA0B,gBAAgB;AAO9D,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB;IAEpB,MAAMC,QAAQ,MAAMH,QAAQI,SAAS,CAACH,eAAe;QAAEI,SAASH,KAAKG,OAAO;IAAC;IAC7E,IAAIF,MAAMG,IAAI,KAAK,aAAa,OAAOH;IACvC,MAAMI,cAAcJ,MAAMI,WAAW;IACrC,MAAMC,YAAoC;QAAE,GAAGL,MAAMK,SAAS;IAAC;IAC/D,MAAMC,YAAoC;QAAE,GAAGN,MAAMM,SAAS;IAAC;IAC/D,MAAMC,gBAAgB,IAAIC,IAAIR,MAAMO,aAAa;IACjD,IAAIE,YAAYT,MAAMS,SAAS;IAC/B,MAAOA,cAAcC,UAAW;QAC9B,MAAMC,OAAO,MAAMd,QAAQI,SAAS,CAACH,eAAe;YAAEI,SAASH,KAAKG,OAAO;YAAEO;QAAU;QACvF,IAAIE,KAAKR,IAAI,KAAK,aAAa,OAAOQ;QACtC,IAAIA,KAAKP,WAAW,KAAKA,aAAa,OAAOT;QAC7CiB,OAAOC,MAAM,CAACR,WAAWM,KAAKN,SAAS;QACvCO,OAAOC,MAAM,CAACP,WAAWK,KAAKL,SAAS;QACvC,KAAK,MAAMQ,UAAUH,KAAKJ,aAAa,CAAEA,cAAcQ,GAAG,CAACD;QAC3DL,YAAYE,KAAKF,SAAS;IAC5B;IACA,MAAMO,YAAYtB,cAAc;QAC9BQ,SAASH,KAAKG,OAAO;QACrBe,MAAMlB,KAAKkB,IAAI;QACfC,aAAanB,KAAKmB,WAAW;QAC7BC,oBAAoBpB,KAAKoB,kBAAkB;QAC3Cf;QACAC;QACAE,eAAe;eAAIA;SAAc,CAACa,IAAI;QACtCd;IACF;IACA,OAAOU,cAAc,OAAOrB,cAAc;QAAEQ,MAAM;QAAUa;IAAU;AACxE"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readStaged, type Staged } from './replica.js';\nimport { unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome = Staged | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n models: { collection: ModelState; selection: ModelState },\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n const page = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n pageToken,\n });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n return readStaged({\n locator: room.locator,\n collectionRoot: room.collectionRoot,\n name: room.name,\n operations: room.operations,\n replica: room.replica,\n attachedModel: room.attachedModel,\n model: models.collection,\n typedSelection: room.typedSelection ?? null,\n selectionModel: models.selection,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n });\n}\n"],"names":["readStaged","unconfirmed","bootstrapRoom","adapter","authorization","room","models","first","bootstrap","locator","selection","replica","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","collectionRoot","name","operations","attachedModel","model","collection","typedSelection","selectionModel","providerOwnedPaths","sort"],"mappings":"AAEA,SAASA,UAAU,QAAqB,eAAe;AACvD,SAASC,WAAW,QAAQ,gBAAgB;AAI5C,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB,EACpBC,MAAyD;IAEzD,MAAMC,QAAQ,MAAMJ,QAAQK,SAAS,CAACJ,eAAe;QACnDK,SAASJ,KAAKI,OAAO;QACrBC,WAAWL,KAAKM,OAAO,CAACD,SAAS;IACnC;IACA,IAAIH,MAAMK,IAAI,KAAK,aAAa,OAAOL;IACvC,MAAMM,cAAcN,MAAMM,WAAW;IACrC,MAAMC,YAAoC;QAAE,GAAGP,MAAMO,SAAS;IAAC;IAC/D,MAAMC,YAAoC;QAAE,GAAGR,MAAMQ,SAAS;IAAC;IAC/D,MAAMC,gBAAgB,IAAIC,IAAIV,MAAMS,aAAa;IACjD,IAAIE,YAAYX,MAAMW,SAAS;IAC/B,MAAOA,cAAcC,UAAW;QAC9B,MAAMC,OAAO,MAAMjB,QAAQK,SAAS,CAACJ,eAAe;YAClDK,SAASJ,KAAKI,OAAO;YACrBC,WAAWL,KAAKM,OAAO,CAACD,SAAS;YACjCQ;QACF;QACA,IAAIE,KAAKR,IAAI,KAAK,aAAa,OAAOQ;QACtC,IAAIA,KAAKP,WAAW,KAAKA,aAAa,OAAOZ;QAC7CoB,OAAOC,MAAM,CAACR,WAAWM,KAAKN,SAAS;QACvCO,OAAOC,MAAM,CAACP,WAAWK,KAAKL,SAAS;QACvC,KAAK,MAAMQ,UAAUH,KAAKJ,aAAa,CAAEA,cAAcQ,GAAG,CAACD;QAC3DL,YAAYE,KAAKF,SAAS;IAC5B;IACA,OAAOlB,WAAW;QAChBS,SAASJ,KAAKI,OAAO;QACrBgB,gBAAgBpB,KAAKoB,cAAc;QACnCC,MAAMrB,KAAKqB,IAAI;QACfC,YAAYtB,KAAKsB,UAAU;QAC3BhB,SAASN,KAAKM,OAAO;QACrBiB,eAAevB,KAAKuB,aAAa;QACjCC,OAAOvB,OAAOwB,UAAU;QACxBC,gBAAgB1B,KAAK0B,cAAc,IAAI;QACvCC,gBAAgB1B,OAAOI,SAAS;QAChCuB,oBAAoB5B,KAAK4B,kBAAkB;QAC3CpB;QACAC;QACAE,eAAe;eAAIA;SAAc,CAACkB,IAAI;QACtCnB;IACF;AACF"}
@@ -0,0 +1,33 @@
1
+ import { type Replica } from './replica.js';
2
+ import { type Row } from './rows.js';
3
+ export type DocumentChange = {
4
+ locator: string;
5
+ path: string;
6
+ before: readonly Row[];
7
+ after: readonly Row[];
8
+ };
9
+ export type MessageChange = {
10
+ conversation: string;
11
+ identity: string;
12
+ };
13
+ export type ChangeSet = {
14
+ documents: readonly DocumentChange[];
15
+ drafts: readonly {
16
+ locator: string;
17
+ path: string;
18
+ }[];
19
+ rooms: readonly string[];
20
+ queues: readonly string[];
21
+ presentations: readonly string[];
22
+ messages: readonly MessageChange[];
23
+ conversations: readonly string[];
24
+ };
25
+ export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
26
+ drafts?: readonly string[];
27
+ room?: boolean;
28
+ queue?: boolean;
29
+ presentation?: string;
30
+ }): ChangeSet;
31
+ export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
32
+ export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
33
+ //# sourceMappingURL=change-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version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