@agentshouse/mdruntime 0.1.0-alpha.4 → 0.1.0-alpha.40

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 (125) hide show
  1. package/AGENTS.md +191 -0
  2. package/README.md +44 -0
  3. package/dist/adapter.d.ts +174 -18
  4. package/dist/adapter.d.ts.map +1 -1
  5. package/dist/adapter.js +2 -1
  6. package/dist/adapter.js.map +1 -1
  7. package/dist/bootstrap.d.ts +7 -7
  8. package/dist/bootstrap.d.ts.map +1 -1
  9. package/dist/bootstrap.js +14 -9
  10. package/dist/bootstrap.js.map +1 -1
  11. package/dist/change-set.d.ts +33 -0
  12. package/dist/change-set.d.ts.map +1 -0
  13. package/dist/change-set.js +89 -0
  14. package/dist/change-set.js.map +1 -0
  15. package/dist/change.d.ts +10 -0
  16. package/dist/change.d.ts.map +1 -1
  17. package/dist/change.js.map +1 -1
  18. package/dist/client.d.ts +74 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +232 -0
  21. package/dist/client.js.map +1 -0
  22. package/dist/collection.d.ts +25 -12
  23. package/dist/collection.d.ts.map +1 -1
  24. package/dist/collection.js +113 -31
  25. package/dist/collection.js.map +1 -1
  26. package/dist/connection.d.ts +84 -27
  27. package/dist/connection.d.ts.map +1 -1
  28. package/dist/connection.js +1685 -336
  29. package/dist/connection.js.map +1 -1
  30. package/dist/conversation.d.ts +79 -0
  31. package/dist/conversation.d.ts.map +1 -0
  32. package/dist/conversation.js +593 -0
  33. package/dist/conversation.js.map +1 -0
  34. package/dist/durability.d.ts +9 -0
  35. package/dist/durability.d.ts.map +1 -0
  36. package/dist/durability.js +11 -0
  37. package/dist/durability.js.map +1 -0
  38. package/dist/file.d.ts +20 -0
  39. package/dist/file.d.ts.map +1 -0
  40. package/dist/file.js +149 -0
  41. package/dist/file.js.map +1 -0
  42. package/dist/host.d.ts +14 -0
  43. package/dist/host.d.ts.map +1 -0
  44. package/dist/host.js +211 -0
  45. package/dist/host.js.map +1 -0
  46. package/dist/identity.d.ts +3 -0
  47. package/dist/identity.d.ts.map +1 -0
  48. package/dist/identity.js +23 -0
  49. package/dist/identity.js.map +1 -0
  50. package/dist/index.d.ts +15 -7
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +1 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/memory.d.ts +17 -2
  55. package/dist/memory.d.ts.map +1 -1
  56. package/dist/memory.js +201 -15
  57. package/dist/memory.js.map +1 -1
  58. package/dist/model.d.ts +55 -0
  59. package/dist/model.d.ts.map +1 -0
  60. package/dist/model.js +36 -0
  61. package/dist/model.js.map +1 -0
  62. package/dist/observation.d.ts +25 -0
  63. package/dist/observation.d.ts.map +1 -0
  64. package/dist/observation.js +92 -0
  65. package/dist/observation.js.map +1 -0
  66. package/dist/outcome.d.ts +22 -18
  67. package/dist/outcome.d.ts.map +1 -1
  68. package/dist/outcome.js +1 -11
  69. package/dist/outcome.js.map +1 -1
  70. package/dist/overlay.d.ts +2 -0
  71. package/dist/overlay.d.ts.map +1 -1
  72. package/dist/overlay.js +107 -1
  73. package/dist/overlay.js.map +1 -1
  74. package/dist/paths.d.ts +0 -1
  75. package/dist/paths.d.ts.map +1 -1
  76. package/dist/paths.js +0 -4
  77. package/dist/paths.js.map +1 -1
  78. package/dist/query.d.ts +209 -0
  79. package/dist/query.d.ts.map +1 -0
  80. package/dist/query.js +467 -0
  81. package/dist/query.js.map +1 -0
  82. package/dist/read-side.d.ts +14 -0
  83. package/dist/read-side.d.ts.map +1 -0
  84. package/dist/read-side.js +451 -0
  85. package/dist/read-side.js.map +1 -0
  86. package/dist/refresh.d.ts +3 -3
  87. package/dist/refresh.d.ts.map +1 -1
  88. package/dist/refresh.js +10 -7
  89. package/dist/refresh.js.map +1 -1
  90. package/dist/replica.d.ts +23 -4
  91. package/dist/replica.d.ts.map +1 -1
  92. package/dist/replica.js +224 -13
  93. package/dist/replica.js.map +1 -1
  94. package/dist/room-draft.d.ts +124 -0
  95. package/dist/room-draft.d.ts.map +1 -0
  96. package/dist/room-draft.js +406 -0
  97. package/dist/room-draft.js.map +1 -0
  98. package/dist/rows.d.ts +39 -0
  99. package/dist/rows.d.ts.map +1 -0
  100. package/dist/rows.js +100 -0
  101. package/dist/rows.js.map +1 -0
  102. package/dist/save.d.ts +11 -2
  103. package/dist/save.d.ts.map +1 -1
  104. package/dist/save.js +116 -128
  105. package/dist/save.js.map +1 -1
  106. package/dist/search.d.ts +61 -0
  107. package/dist/search.d.ts.map +1 -0
  108. package/dist/search.js +155 -0
  109. package/dist/search.js.map +1 -0
  110. package/dist/status.d.ts +9 -2
  111. package/dist/status.d.ts.map +1 -1
  112. package/dist/status.js +5 -4
  113. package/dist/status.js.map +1 -1
  114. package/dist/store.d.ts +89 -18
  115. package/dist/store.d.ts.map +1 -1
  116. package/dist/store.js +445 -57
  117. package/dist/store.js.map +1 -1
  118. package/dist/transfer.d.ts +5 -0
  119. package/dist/transfer.d.ts.map +1 -1
  120. package/dist/transfer.js.map +1 -1
  121. package/dist/wire.d.ts +64 -0
  122. package/dist/wire.d.ts.map +1 -0
  123. package/dist/wire.js +144 -0
  124. package/dist/wire.js.map +1 -0
  125. package/package.json +15 -13
package/AGENTS.md ADDED
@@ -0,0 +1,191 @@
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, 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
+ Rooms, Slots, Query, Search, Observe, Types, Room Draft, and Save never touch the
37
+ network.
38
+ History and Call go to the Provider through the Adapter. Each History revision
39
+ names its author, `{ kind: 'user', id }` or `{ kind: 'site', id, name }`. Every
40
+ member of the
41
+ client is asynchronous. Results are detached snapshots. Nothing in this
42
+ surface returns the authorization, performs a request the App's code
43
+ composes, or exposes the browser store.
44
+
45
+ Read deployment facts with `deploymentFacts()` and observe replacements with
46
+ `observe('deployment-facts')`. Interpret the opaque value using the
47
+ host's contract.
48
+
49
+ The in-memory Adapter at `@agentshouse/mdruntime/memory` is for tests and
50
+ ships in no bundle.
51
+
52
+ ## Local Query rules
53
+
54
+ `query(q)` answers once from local state; `observe('query', q)` holds the whole
55
+ result and hears it again only when it changes, keeping every unchanged Document
56
+ the same object, so a component can tell what changed by identity. A query is
57
+ data:
58
+
59
+ - **Filter.** `rooms` names Room locators and defaults to every Room. `types`
60
+ names MD Types, and `any` names untyped Markdown Documents. `pathPrefix` is a
61
+ directory: `notes` keeps `notes/a.md` and not `notes2/a.md`.
62
+ - **Fields.** `where` names frontmatter fields, ANDs them, and nests `$and` and
63
+ `$or`. A bare value is equality; the operators are `$eq`, `$ne`, `$in`, `$nin`,
64
+ `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size` and `$exists`. Equality on a list
65
+ asks whether it contains the value. Missing, null and empty differ:
66
+ `$exists: false` keeps a missing field, `null` an explicit null, `''` empty
67
+ text and `$size: 0` an empty list. A date compares in calendar order and never
68
+ with a date-time. A reference compares by the Room Path it resolves to.
69
+ Untyped frontmatter is plain values. There is no text containment or regular
70
+ expression.
71
+ - **Relations.** `hop: { field, types, where, pathPrefix }` keeps Documents whose
72
+ reference `field` points to a matching Document of the same Room.
73
+ `backlinks: { field, types, where, pathPrefix }` keeps Documents that a
74
+ matching Document of the same Room references. Each keeps a Document once.
75
+ - **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
76
+ `preamble`, `markdown` and `backlinks`, where `fields` and `sections` are
77
+ `'all'` or a list of names. Room and Path always return; a Markdown Document
78
+ also returns its MD Type. A non-Markdown Document or binary link target returns
79
+ only Room and Path. An unselected part is absent. Select only what a screen
80
+ shows: a list that selects the Markdown hears every edit of it.
81
+ - **Order and groups.** `orderBy` sorts by `room`, `path`, `type` or `{ field }`
82
+ with TanStack DB's own options, and ties end with Room, then Path. `groupBy` by
83
+ `room`, `type` or `{ field }` answers `{ groups: [{ key, count }] }`, counted
84
+ over every match and ordered by `count` or a key. `limit` bounds the Documents
85
+ or the groups.
86
+ - **Results and errors.** A result carries no Room Version: read freshness from
87
+ Rooms and Sync Status. An invalid query fails with `invalid-query`,
88
+ `unknown-type`, `unknown-field` or `wrong-kind`, naming where, and never
89
+ answers an empty result in its place.
90
+
91
+ ## Local Search rules
92
+
93
+ `search({ text, documents, conversations, limit })` answers once, by words, from
94
+ local state, with MiniSearch at its default configuration. There is no observed
95
+ search.
96
+
97
+ - **What is found.** A Document by its field values, its sections' headings and
98
+ text, its preamble and its Path; a message by its text. Frontmatter keys, Room
99
+ Drafts, chat drafts and growing text are never found. There are no phrases,
100
+ word forms, typo tolerance or prefix matching.
101
+ - **Narrowing.** `documents` is a Local Query filter: `rooms`, `types`, `where`,
102
+ `pathPrefix`, `hop` and `backlinks`. `conversations` names conversations. Both
103
+ apply before `limit`, which bounds each list; without it every hit returns.
104
+ - **Results.** `{ documents, messages }`, each ranked by `score`, which compares
105
+ hits of one list of one search. A Document hit names its `room`, `path` and
106
+ `type`, a message hit its `conversation` and `identity`, and `matches` maps each
107
+ matched word to the parts it matched in: `fields`, `sections`, `preamble` or
108
+ `path`, or `text`. A hit carries no position; mark the words in the text you
109
+ show. An invalid filter fails with its Local Query error.
110
+
111
+ ## Room Draft, Save, and outcome rules
112
+
113
+ The MD Runtime owns one Room Draft per Room and Path, shared by every App and
114
+ tab. It is durable: it survives reload and navigation. A Room that Discovery
115
+ stops listing takes its Room Drafts, its queue and their outcomes with it.
116
+ Write a Room Draft with `roomDraft.write(room, path, revision, parts)`, naming
117
+ the revision you read, or `null` when there was none, and every part it should
118
+ now change: fields, sections and the preamble, or the whole Markdown, a
119
+ creation, a move, or a removal. A part new to the Room Draft names its base,
120
+ the value you showed when it was opened; the MD Runtime keeps a part's first
121
+ base. A binary link target has a Room Draft too, for a move or a removal, with
122
+ `null` as its base. A write or a discard from an older revision is refused as `stale` with
123
+ the current Room Draft; read it and write again.
124
+
125
+ Save takes one Room and the Room Drafts of it to save, each with its revision,
126
+ validates locally, and on success appends one Change Batch to that Room's
127
+ queue and removes those Room Drafts. It is refused as `stale`, as
128
+ `changed-underneath` naming each part whose base no longer matches the visible
129
+ state, or by a local validation rule, and then creates nothing and leaves every
130
+ Room Draft in place. A directory move or removal is a move or removal part on
131
+ each Document and binary link target beneath it, saved together.
132
+
133
+ Outcomes follow the Provider's answer. Accepted advances the confirmed
134
+ layer. Conflicted and Rejected, an expired outcome record, and a change that no
135
+ longer applies over the Room each leave the queue and return as Room Drafts on
136
+ the Documents they changed, marked with why: the Provider's structured refusal
137
+ code and fields as returned, not known to have applied, or withdrawn locally.
138
+ The rest of the queue keeps synchronizing, and Sync Status requires attention
139
+ until each returned Room Draft is saved again or discarded. `outcome` answers
140
+ the saved Change Batch's outcome, and `null` while it is Pending. Transport
141
+ failure and Provider unavailability keep work Pending and do not infer a
142
+ rejection. A refusal the Provider marks retryable stays Pending until the reset
143
+ it names; the MD Runtime retries the same Change Batch identity and payload and
144
+ never infers an outcome from transport uncertainty. The MD Runtime never
145
+ combines, reorders, or rebases.
146
+
147
+ `serviceMode()` and `observe('service-mode')` answer the Provider's Service
148
+ Mode, `open` or `write-halted`. While writes are halted, Save still succeeds,
149
+ its Change Batch waits unsent, and the queue is submitted in order once the
150
+ Provider reopens writes. An Action is never held: a write the Provider refuses
151
+ for the halt returns that refusal to its caller. Show the Provider as read-only
152
+ instead of retrying.
153
+
154
+ ## The neutrality rule
155
+
156
+ No module outside an Adapter package imports, names, or special-cases a
157
+ Provider. MD UI and every App reach data only through the client entry.
158
+
159
+ ## Content-safety rules
160
+
161
+ The Provider authorization belongs to the Runtime host and is never readable
162
+ by the App's code. The App's code reaches the network only at the external
163
+ origins its manifest declares, empty by default, and the Provider enforces
164
+ that set. Every request to the Provider itself goes through the MD Runtime.
165
+ Rendered Markdown never executes scripts, renders raw HTML only for the
166
+ details and summary elements, and loads images and other resources only from
167
+ origins the Provider's policy allows.
168
+
169
+ ## Launch promises MD UI keeps
170
+
171
+ MD UI uses semantic HTML, is fully operable from a keyboard with visible
172
+ focus and labelled controls, and lays out from a 360 pixel wide viewport to
173
+ a desktop. Its strings are English only, dates and numbers follow the
174
+ browser locale, and content is never translated. Light and dark themes come
175
+ from CSS custom properties with the browser's preference as the default and
176
+ an App's override respected. What an App Creator's agent adds carries none
177
+ of these promises by itself. Reading, querying and searching never wait for
178
+ the network. Data lives only in the App Creator's browser and with the Provider.
179
+
180
+ ## App code imports only the client entry and never constructs a Runtime
181
+
182
+ App code imports only `@agentshouse/mdruntime/client` and calls
183
+ `connectMdRuntime` on the port the host hands it. It never constructs a
184
+ Runtime. It does not import the package main, the host entry, or the Adapter
185
+ package, and it does not call `createMdRuntime` or `serveMdRuntime`. Hosts
186
+ and tests use those entries; the served App does not.
187
+
188
+ ## What an agent must never do
189
+
190
+ An agent must never read the authorization, load code from a Room, call the
191
+ Provider directly, or rebase a refused Change Batch.
package/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # `@agentshouse/mdruntime`
2
+
3
+ The headless core of MD App: local Rooms of typed Markdown Documents with
4
+ query, search, observation, Room Drafts, and queued saves that synchronize
5
+ with a Provider through an Adapter.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install @agentshouse/mdruntime
11
+ ```
12
+
13
+ ## Entries
14
+
15
+ | Entry | For |
16
+ | ------------------------------- | --------------------------------------------------- |
17
+ | `@agentshouse/mdruntime/client` | App code: `connectMdRuntime(port)` |
18
+ | `@agentshouse/mdruntime/host` | The host that serves a Runtime: `serveMdRuntime` |
19
+ | `@agentshouse/mdruntime` | Hosts and tests: `createMdRuntime` and shared types |
20
+ | `@agentshouse/mdruntime/memory` | Tests: `createMemoryAdapter`, an in-memory Adapter |
21
+
22
+ ## Usage
23
+
24
+ App code imports only the client entry and connects on the port its host hands
25
+ it:
26
+
27
+ ```ts
28
+ import { connectMdRuntime } from '@agentshouse/mdruntime/client';
29
+
30
+ const runtime = connectMdRuntime(port);
31
+ const rooms = await runtime.rooms();
32
+ const notes = await runtime.query({ types: ['note'], select: 'all', limit: 20 });
33
+ ```
34
+
35
+ `storageLoss()` and `observe('storage-loss')` report `null` or the stable code
36
+ `storage-loss` when unsynchronized Room Drafts and Pending Changes were lost.
37
+ The host supplies the user-facing wording.
38
+
39
+ The rules an App's agent follows, including Local Query, Local Search, Room
40
+ Draft and Save, are in [`AGENTS.md`](AGENTS.md).
41
+
42
+ ## License
43
+
44
+ MIT
package/dist/adapter.d.ts CHANGED
@@ -1,22 +1,112 @@
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 WorkingNote = {
66
+ noteId: string;
67
+ text: string;
68
+ };
69
+ export type ConversationEvent = {
70
+ kind: 'growing-text';
71
+ conversation: string;
72
+ turn: string;
73
+ text: string;
74
+ } | {
75
+ kind: 'plan';
76
+ conversation: string;
77
+ turn: string;
78
+ plan: unknown;
79
+ } | {
80
+ kind: 'working-note';
81
+ conversation: string;
82
+ note: WorkingNote | null;
83
+ } | {
84
+ kind: 'questions';
85
+ conversation: string;
86
+ questions: readonly unknown[];
87
+ } | {
88
+ kind: 'process';
89
+ conversation: string;
90
+ running: boolean;
91
+ } | {
92
+ kind: 'commands';
93
+ conversation: string;
94
+ commands: readonly unknown[];
95
+ } | {
96
+ kind: 'options';
97
+ conversation: string;
98
+ options: readonly unknown[];
99
+ } | {
100
+ kind: 'accepted-message';
101
+ conversation: string;
102
+ message: AcceptedMessage;
103
+ } | {
104
+ kind: 'gap';
105
+ conversation: string;
106
+ };
107
+ export type ConversationStream = {
108
+ replicate(conversations: readonly string[]): void;
109
+ observe(notify: (event: ConversationEvent) => void): () => void;
20
110
  };
21
111
  export type ActionDeclaration = {
22
112
  name: string;
@@ -27,8 +117,14 @@ export type ProviderLimit = {
27
117
  name: string;
28
118
  value?: number | string;
29
119
  };
120
+ export type HistoryRetention = {
121
+ kind: 'duration';
122
+ seconds: number;
123
+ } | {
124
+ kind: 'no-declared-time-bound';
125
+ };
30
126
  export type Retention = {
31
- history: number;
127
+ history: HistoryRetention;
32
128
  outcome: number;
33
129
  refreshHorizon: number;
34
130
  };
@@ -37,10 +133,16 @@ export type Discovery = {
37
133
  supportedVersions: readonly number[];
38
134
  mdModel: MdModelIdentity;
39
135
  rooms: readonly DiscoveredRoom[];
136
+ slots?: readonly {
137
+ slot: string;
138
+ entries: readonly {
139
+ locator: string;
140
+ segment: string | null;
141
+ }[];
142
+ }[];
40
143
  capabilities: readonly Capability[];
41
144
  providerLimits: readonly ProviderLimit[];
42
145
  retention: Retention;
43
- origins: readonly string[];
44
146
  };
45
147
  export type TransportUncertainty = {
46
148
  kind: 'transport-uncertainty';
@@ -52,11 +154,24 @@ export type RoomNotReadable = {
52
154
  export type RevokedAuthorization = {
53
155
  kind: 'revoked-authorization';
54
156
  };
55
- export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization;
56
- export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization;
157
+ export type ProviderRefusal = {
158
+ code: string;
159
+ fields: Readonly<Record<string, unknown>>;
160
+ };
161
+ export type ScopedRefusal = ProviderRefusal & {
162
+ kind: 'scoped-refusal';
163
+ locator: string;
164
+ scope: 'content' | 'sync' | 'model' | 'operation' | 'undisclosed';
165
+ };
166
+ export type AdapterFailure = TransportUncertainty | RoomNotReadable | RevokedAuthorization | ScopedRefusal;
167
+ export type ContractUnavailable = ProviderRefusal & {
168
+ kind: 'contract-unavailable';
169
+ };
170
+ export type DiscoverResult = Discovery | TransportUncertainty | RevokedAuthorization | ContractUnavailable;
57
171
  export type PageToken = string;
58
172
  export type BootstrapRequest = {
59
173
  locator: string;
174
+ selection: string;
60
175
  pageToken?: PageToken;
61
176
  };
62
177
  export type BootstrapPage = {
@@ -70,6 +185,7 @@ export type BootstrapPage = {
70
185
  export type BootstrapResult = BootstrapPage | AdapterFailure;
71
186
  export type RefreshRequest = {
72
187
  locator: string;
188
+ selection: string;
73
189
  fromRoomVersion: string;
74
190
  pageToken?: PageToken;
75
191
  };
@@ -90,6 +206,15 @@ export type RefreshResult = {
90
206
  export type MutationRequest = {
91
207
  locator: string;
92
208
  changeBatch: ChangeBatch;
209
+ upload?: unknown;
210
+ };
211
+ export type RetryableRefusal = ProviderRefusal & {
212
+ kind: 'retryable-refusal';
213
+ reset?: string;
214
+ };
215
+ export type ServiceMode = 'open' | 'write-halted';
216
+ export type ServiceModeSignal = {
217
+ observe(notify: (mode: ServiceMode) => void): () => void;
93
218
  };
94
219
  export type MutationResult = {
95
220
  kind: 'accepted';
@@ -97,23 +222,31 @@ export type MutationResult = {
97
222
  documents: Readonly<Record<string, string>>;
98
223
  revisions: Readonly<Record<string, string>>;
99
224
  removals: readonly string[];
100
- author: string;
101
- time: string;
102
- } | {
225
+ author?: string;
226
+ time?: string;
227
+ } | (ProviderRefusal & {
103
228
  kind: 'conflicted';
104
- roomVersion: string;
229
+ roomVersion?: string;
105
230
  affected: Readonly<Record<string, string>>;
106
- text: string;
107
- } | {
231
+ }) | (ProviderRefusal & {
108
232
  kind: 'rejected';
109
233
  affected: Readonly<Record<string, string>>;
110
- text: string;
234
+ }) | RetryableRefusal | {
235
+ kind: 'write-halted';
111
236
  } | {
112
237
  kind: 'expired';
113
238
  } | AdapterFailure;
239
+ export type HistoryAuthor = {
240
+ kind: 'user';
241
+ id: string;
242
+ } | {
243
+ kind: 'site';
244
+ id: string;
245
+ name: string;
246
+ };
114
247
  export type HistoryRevision = {
115
248
  revision: string;
116
- author: string;
249
+ author: HistoryAuthor;
117
250
  time: string;
118
251
  };
119
252
  export type HistoryRequest = {
@@ -139,17 +272,40 @@ export type ActionRequest = {
139
272
  export type ActionResult = {
140
273
  kind: 'action';
141
274
  result: unknown;
142
- } | {
275
+ } | (ProviderRefusal & {
143
276
  kind: 'rejected';
144
- text: string;
145
- } | AdapterFailure;
277
+ }) | AdapterFailure;
278
+ export type ModelRequest = {
279
+ locator: string;
280
+ attached: 'collection';
281
+ collectionRoot: string;
282
+ model: ModelIdentity | null;
283
+ } | {
284
+ locator: string;
285
+ attached: 'typed-selection';
286
+ roots: readonly string[];
287
+ model: ModelIdentity | null;
288
+ };
289
+ export type RoomVersionNotification = {
290
+ locator: string;
291
+ roomVersion: string;
292
+ modelChanged?: true;
293
+ };
294
+ export type SelectedRooms = {
295
+ select(locators: readonly string[]): void;
296
+ observe(notify: (notification: RoomVersionNotification) => void): () => void;
297
+ };
146
298
  export type Adapter = {
299
+ model(authorization: Authorization, request: ModelRequest): Promise<ModelResult>;
147
300
  authorize(): Promise<Authorization>;
148
301
  discover(authorization: Authorization): Promise<DiscoverResult>;
149
302
  bootstrap(authorization: Authorization, request: BootstrapRequest): Promise<BootstrapResult>;
150
303
  refresh(authorization: Authorization, request: RefreshRequest): Promise<RefreshResult>;
151
- mutate(authorization: Authorization, request: MutationRequest): Promise<MutationResult>;
304
+ mutate(authorization: Authorization, request: MutationRequest, keep: (upload: unknown) => Promise<void>): Promise<MutationResult>;
152
305
  history(authorization: Authorization, request: HistoryRequest): Promise<HistoryResult>;
153
306
  action(authorization: Authorization, request: ActionRequest): Promise<ActionResult>;
307
+ roomVersions?: SelectedRooms;
308
+ conversations?: ConversationStream;
309
+ serviceMode?: ServiceModeSignal;
154
310
  };
155
311
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AAEnC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,sBAAsB,YACjC,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,EAC5B,cAAc,EACd,kBAAkB,CACV,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAClC,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,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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,CACJ,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,GACvC,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B,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;IACnC,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC,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 | {\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 | {\n kind: 'conflicted';\n roomVersion: string;\n affected: Readonly<Record<string, string>>;\n text: string;\n }\n | {\n kind: 'rejected';\n affected: Readonly<Record<string, string>>;\n text: string;\n }\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 | { 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 WorkingNote = { noteId: string; text: string };\n\nexport type ConversationEvent =\n | { kind: 'growing-text'; conversation: string; turn: string; text: string }\n | { kind: 'plan'; conversation: string; turn: string; plan: unknown }\n | { kind: 'working-note'; conversation: string; note: WorkingNote | null }\n | { kind: 'questions'; conversation: string; questions: readonly unknown[] }\n | { kind: 'process'; conversation: string; running: boolean }\n | { kind: 'commands'; conversation: string; commands: readonly unknown[] }\n | { kind: 'options'; conversation: string; options: readonly unknown[] }\n | { kind: 'accepted-message'; conversation: string; message: AcceptedMessage }\n | { kind: 'gap'; conversation: string };\n\nexport type ConversationStream = {\n replicate(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 upload?: unknown;\n};\n\nexport type RetryableRefusal = ProviderRefusal & {\n kind: 'retryable-refusal';\n reset?: string;\n};\n\nexport type ServiceMode = 'open' | 'write-halted';\n\nexport type ServiceModeSignal = {\n observe(notify: (mode: ServiceMode) => void): () => void;\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: 'write-halted' }\n | { kind: 'expired' }\n | AdapterFailure;\n\nexport type HistoryAuthor =\n | { kind: 'user'; id: string }\n | { kind: 'site'; id: string; name: string };\n\nexport type HistoryRevision = {\n revision: string;\n author: HistoryAuthor;\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 modelChanged?: true;\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(\n authorization: Authorization,\n request: MutationRequest,\n keep: (upload: unknown) => Promise<void>,\n ): 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 serviceMode?: ServiceModeSignal;\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
+ }, continuing: () => boolean): 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,EACzD,UAAU,EAAE,MAAM,OAAO,GACxB,OAAO,CAAC,gBAAgB,CAAC,CAyC3B"}