@agentshouse/mdruntime 0.1.0-alpha.23 → 0.1.0-alpha.25
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.
- package/AGENTS.md +70 -18
- package/dist/change-set.d.ts +4 -11
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -16
- package/dist/change-set.js.map +1 -1
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js.map +1 -1
- package/dist/client.d.ts +16 -15
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +17 -22
- package/dist/client.js.map +1 -1
- package/dist/collection.d.ts +0 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +0 -5
- package/dist/collection.js.map +1 -1
- package/dist/connection.d.ts +21 -23
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +435 -352
- package/dist/connection.js.map +1 -1
- package/dist/conversation.d.ts +4 -4
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +12 -6
- package/dist/conversation.js.map +1 -1
- package/dist/durability.js +1 -1
- package/dist/durability.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +12 -14
- package/dist/host.js.map +1 -1
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +7 -0
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/outcome.d.ts +17 -20
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -21
- package/dist/outcome.js.map +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +1 -1
- package/dist/overlay.js.map +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +8 -0
- package/dist/paths.js.map +1 -1
- package/dist/query.d.ts +199 -10
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +450 -14
- package/dist/query.js.map +1 -1
- package/dist/read-side.d.ts +10 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +374 -0
- package/dist/read-side.js.map +1 -0
- package/dist/replica.d.ts +1 -0
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +54 -0
- package/dist/replica.js.map +1 -1
- package/dist/room-draft.d.ts +124 -0
- package/dist/room-draft.d.ts.map +1 -0
- package/dist/room-draft.js +403 -0
- package/dist/room-draft.js.map +1 -0
- package/dist/rows.d.ts +39 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +85 -0
- package/dist/rows.js.map +1 -0
- package/dist/save.d.ts +4 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +34 -100
- package/dist/save.js.map +1 -1
- package/dist/status.d.ts +4 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js.map +1 -1
- package/dist/store.d.ts +18 -12
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +43 -34
- package/dist/store.js.map +1 -1
- package/dist/wire.d.ts +3 -3
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -7
- package/dist/wire.js.map +1 -1
- package/package.json +2 -2
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc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AO,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AA8DF,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlD;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CA6S9D"}
|
package/dist/store.js
CHANGED
|
@@ -5,13 +5,13 @@ const BINARY_TARGETS = 'binaryTargets';
|
|
|
5
5
|
const PENDING_CHANGES = 'pendingChanges';
|
|
6
6
|
const OUTCOMES = 'outcomes';
|
|
7
7
|
const DECLARATIONS = 'declarations';
|
|
8
|
-
const
|
|
8
|
+
const ROOM_DRAFTS = 'roomDrafts';
|
|
9
9
|
const PRESENTATION = 'presentation';
|
|
10
10
|
const CONVERSATIONS = 'conversations';
|
|
11
11
|
const MESSAGES = 'messages';
|
|
12
12
|
const CHAT_DRAFTS = 'chatDrafts';
|
|
13
13
|
const CURRENT = 'current';
|
|
14
|
-
const SCHEMA =
|
|
14
|
+
const SCHEMA = 13;
|
|
15
15
|
function settled(request) {
|
|
16
16
|
return new Promise((resolve, reject)=>{
|
|
17
17
|
request.onsuccess = ()=>resolve(request.result);
|
|
@@ -100,7 +100,7 @@ export async function openRuntimeStore() {
|
|
|
100
100
|
});
|
|
101
101
|
outcomes.createIndex('locator', 'locator');
|
|
102
102
|
database.createObjectStore(DECLARATIONS);
|
|
103
|
-
database.createObjectStore(
|
|
103
|
+
database.createObjectStore(ROOM_DRAFTS, {
|
|
104
104
|
keyPath: [
|
|
105
105
|
'locator',
|
|
106
106
|
'path'
|
|
@@ -165,14 +165,14 @@ export async function openRuntimeStore() {
|
|
|
165
165
|
...byRoom.values()
|
|
166
166
|
];
|
|
167
167
|
},
|
|
168
|
-
async write ({ next, previous, queue, previousQueue, outcomes,
|
|
168
|
+
async write ({ next, previous, queue, previousQueue, saved, outcomes, roomDrafts, consumedRoomDrafts }) {
|
|
169
169
|
const transaction = database.transaction([
|
|
170
170
|
ROOMS,
|
|
171
171
|
DOCUMENTS,
|
|
172
172
|
BINARY_TARGETS,
|
|
173
173
|
PENDING_CHANGES,
|
|
174
174
|
OUTCOMES,
|
|
175
|
-
|
|
175
|
+
ROOM_DRAFTS
|
|
176
176
|
], 'readwrite');
|
|
177
177
|
transaction.objectStore(ROOMS).put(roomRecord(next, queue));
|
|
178
178
|
const documents = transaction.objectStore(DOCUMENTS);
|
|
@@ -225,7 +225,11 @@ export async function openRuntimeStore() {
|
|
|
225
225
|
locator: next.locator,
|
|
226
226
|
id: batch.id,
|
|
227
227
|
batch,
|
|
228
|
-
|
|
228
|
+
drafts: saved ?? [],
|
|
229
|
+
submission: {
|
|
230
|
+
state: 'waiting'
|
|
231
|
+
},
|
|
232
|
+
lost: false
|
|
229
233
|
});
|
|
230
234
|
}
|
|
231
235
|
}
|
|
@@ -239,11 +243,12 @@ export async function openRuntimeStore() {
|
|
|
239
243
|
outcome: entry.outcome
|
|
240
244
|
});
|
|
241
245
|
}
|
|
242
|
-
const draftStore = transaction.objectStore(
|
|
243
|
-
for (const path of
|
|
246
|
+
const draftStore = transaction.objectStore(ROOM_DRAFTS);
|
|
247
|
+
for (const path of consumedRoomDrafts ?? [])draftStore.delete([
|
|
244
248
|
next.locator,
|
|
245
249
|
path
|
|
246
250
|
]);
|
|
251
|
+
for (const record of roomDrafts ?? [])draftStore.put(record);
|
|
247
252
|
await completed(transaction);
|
|
248
253
|
},
|
|
249
254
|
async revokeModels (records) {
|
|
@@ -299,14 +304,22 @@ export async function openRuntimeStore() {
|
|
|
299
304
|
]);
|
|
300
305
|
const byId = new Map(pending.map((record)=>[
|
|
301
306
|
`${record.locator}\0${record.id}`,
|
|
302
|
-
record
|
|
307
|
+
record
|
|
303
308
|
]));
|
|
304
309
|
return rooms.map((room)=>({
|
|
305
310
|
locator: room.locator,
|
|
306
|
-
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
|
|
311
|
+
pending: room.order.map((id)=>{
|
|
312
|
+
const record = byId.get(`${room.locator}\0${id}`);
|
|
313
|
+
if (record === undefined) throw new Error(`Missing Pending Change ${room.locator}/${id}`);
|
|
314
|
+
const { batch, drafts, submission, lost } = record;
|
|
315
|
+
return {
|
|
316
|
+
batch,
|
|
317
|
+
state: {
|
|
318
|
+
drafts,
|
|
319
|
+
submission,
|
|
320
|
+
lost
|
|
321
|
+
}
|
|
322
|
+
};
|
|
310
323
|
})
|
|
311
324
|
}));
|
|
312
325
|
},
|
|
@@ -314,30 +327,26 @@ export async function openRuntimeStore() {
|
|
|
314
327
|
const transaction = database.transaction(OUTCOMES, 'readonly');
|
|
315
328
|
return settled(transaction.objectStore(OUTCOMES).getAll());
|
|
316
329
|
},
|
|
317
|
-
async
|
|
330
|
+
async submit (locator, id, submission, lost) {
|
|
318
331
|
const transaction = database.transaction(PENDING_CHANGES, 'readwrite');
|
|
319
332
|
const pending = transaction.objectStore(PENDING_CHANGES);
|
|
320
|
-
let marked = false;
|
|
321
333
|
const request = pending.get([
|
|
322
334
|
locator,
|
|
323
335
|
id
|
|
324
336
|
]);
|
|
325
337
|
request.onsuccess = ()=>{
|
|
326
338
|
const record = request.result;
|
|
327
|
-
if (record !== undefined
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
marked = true;
|
|
333
|
-
}
|
|
339
|
+
if (record !== undefined) pending.put({
|
|
340
|
+
...record,
|
|
341
|
+
submission,
|
|
342
|
+
lost
|
|
343
|
+
});
|
|
334
344
|
};
|
|
335
345
|
await completed(transaction);
|
|
336
|
-
return marked;
|
|
337
346
|
},
|
|
338
|
-
async
|
|
339
|
-
const transaction = database.transaction(
|
|
340
|
-
return settled(transaction.objectStore(
|
|
347
|
+
async roomDrafts () {
|
|
348
|
+
const transaction = database.transaction(ROOM_DRAFTS, 'readonly');
|
|
349
|
+
return settled(transaction.objectStore(ROOM_DRAFTS).getAll());
|
|
341
350
|
},
|
|
342
351
|
async presentation () {
|
|
343
352
|
const transaction = database.transaction(PRESENTATION, 'readonly');
|
|
@@ -431,14 +440,14 @@ export async function openRuntimeStore() {
|
|
|
431
440
|
transaction.objectStore(CHAT_DRAFTS).delete(conversation);
|
|
432
441
|
await completed(transaction);
|
|
433
442
|
},
|
|
434
|
-
async
|
|
435
|
-
const transaction = database.transaction(
|
|
436
|
-
transaction.objectStore(
|
|
443
|
+
async keepRoomDraft (record) {
|
|
444
|
+
const transaction = database.transaction(ROOM_DRAFTS, 'readwrite');
|
|
445
|
+
transaction.objectStore(ROOM_DRAFTS).put(record);
|
|
437
446
|
await completed(transaction);
|
|
438
447
|
},
|
|
439
|
-
async
|
|
440
|
-
const transaction = database.transaction(
|
|
441
|
-
transaction.objectStore(
|
|
448
|
+
async discardRoomDraft (locator, path) {
|
|
449
|
+
const transaction = database.transaction(ROOM_DRAFTS, 'readwrite');
|
|
450
|
+
transaction.objectStore(ROOM_DRAFTS).delete([
|
|
442
451
|
locator,
|
|
443
452
|
path
|
|
444
453
|
]);
|
|
@@ -451,7 +460,7 @@ export async function openRuntimeStore() {
|
|
|
451
460
|
BINARY_TARGETS,
|
|
452
461
|
PENDING_CHANGES,
|
|
453
462
|
OUTCOMES,
|
|
454
|
-
|
|
463
|
+
ROOM_DRAFTS
|
|
455
464
|
], 'readwrite');
|
|
456
465
|
for (const locator of locators){
|
|
457
466
|
transaction.objectStore(ROOMS).delete(locator);
|
|
@@ -459,7 +468,7 @@ export async function openRuntimeStore() {
|
|
|
459
468
|
DOCUMENTS,
|
|
460
469
|
BINARY_TARGETS,
|
|
461
470
|
PENDING_CHANGES,
|
|
462
|
-
|
|
471
|
+
ROOM_DRAFTS
|
|
463
472
|
]){
|
|
464
473
|
removeRoomEntries(transaction.objectStore(name), locator);
|
|
465
474
|
}
|
package/dist/store.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/store.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type {\n Capability,\n Discovery,\n OperationScopes,\n ProviderLimit,\n ReplicaAdmission,\n TypedSelection,\n} from './adapter.js';\nimport type { AcceptedMessage } from './adapter.js';\nimport type { ChangeBatch } from './change.js';\nimport type { ChatDraftFile } from './file.js';\nimport type { SubmissionOutcome } from './outcome.js';\n\nconst DATABASE = 'mdruntime';\nconst ROOMS = 'rooms';\nconst DOCUMENTS = 'documents';\nconst BINARY_TARGETS = 'binaryTargets';\nconst PENDING_CHANGES = 'pendingChanges';\nconst OUTCOMES = 'outcomes';\nconst DECLARATIONS = 'declarations';\nconst DRAFTS = 'drafts';\nconst PRESENTATION = 'presentation';\nconst CONVERSATIONS = 'conversations';\nconst MESSAGES = 'messages';\nconst CHAT_DRAFTS = 'chatDrafts';\nconst CURRENT = 'current';\nconst SCHEMA = 12;\n\nexport type ReplicaRecord = {\n collectionRoot: string;\n locator: string;\n name: string;\n operations: OperationScopes;\n replica: ReplicaAdmission;\n model: ModelState;\n attachedModel: import('./model.js').ModelIdentity | null;\n typedSelection: TypedSelection | null;\n selectionModel: ModelState;\n providerOwnedPaths: readonly string[];\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n revisions: Readonly<Record<string, string>>;\n};\n\ntype RoomRecord = Omit<ReplicaRecord, 'documents' | 'binaryTargets' | 'revisions'> & {\n order: readonly string[];\n};\n\ntype DocumentRecord = {\n locator: string;\n path: string;\n content: string;\n revision: string | null;\n};\n\ntype BinaryTargetRecord = { locator: string; path: string; revision: string | null };\n\ntype PendingChangeRecord = {\n locator: string;\n id: string;\n batch: ChangeBatch;\n submitted: boolean;\n};\n\nexport type OutcomeRecord = {\n locator: string;\n id: string;\n outcome: SubmissionOutcome;\n};\n\ntype DeclarationRecord = {\n lastCompleted: string | null;\n generation: string | null;\n providerLimits: readonly ProviderLimit[];\n capabilities: readonly Capability[];\n slots: NonNullable<Discovery['slots']>;\n};\n\nexport type QueueRecord = {\n locator: string;\n batches: readonly ChangeBatch[];\n};\n\nexport type DraftRecord = {\n locator: string;\n path: string;\n content: unknown;\n};\n\nexport type PresentationRecord = {\n app: string;\n value: unknown;\n};\n\ntype ConversationRecord = {\n conversation: string;\n read: string | null;\n};\n\ntype MessageRecord = AcceptedMessage & { conversation: string };\n\nexport type HeldConversation = {\n conversation: string;\n read: string | null | undefined;\n messages: readonly AcceptedMessage[];\n};\n\nexport type ConversationWrite = {\n conversation: string;\n messages: readonly AcceptedMessage[];\n read?: string | null;\n sealed?: boolean;\n};\n\nexport type ChatDraftRecord = {\n conversation: string;\n text: string;\n files: readonly ChatDraftFile[];\n turn: string | null;\n};\n\nexport type RecordWrite = {\n next: ReplicaRecord;\n previous: ReplicaRecord | null;\n queue: readonly ChangeBatch[];\n previousQueue?: readonly ChangeBatch[];\n outcomes?: readonly { id: string; outcome: SubmissionOutcome | null }[];\n consumedDrafts?: readonly string[];\n};\n\nexport type RuntimeStore = {\n all(): Promise<readonly ReplicaRecord[]>;\n write(input: RecordWrite): Promise<void>;\n revokeModels(\n records: readonly { record: ReplicaRecord; queue: readonly ChangeBatch[] }[],\n ): Promise<void>;\n lastCompleted(): Promise<string | null>;\n complete(at: string): Promise<void>;\n providerLimits(): Promise<readonly ProviderLimit[]>;\n capabilities(): Promise<readonly Capability[]>;\n slots(): Promise<NonNullable<Discovery['slots']>>;\n declare(\n limits: readonly ProviderLimit[],\n capabilities: readonly Capability[],\n slots: NonNullable<Discovery['slots']>,\n ): Promise<void>;\n queues(): Promise<readonly QueueRecord[]>;\n outcomes(): Promise<readonly OutcomeRecord[]>;\n markSubmitted(locator: string, id: string): Promise<boolean>;\n drafts(): Promise<readonly DraftRecord[]>;\n presentation(): Promise<readonly PresentationRecord[]>;\n present(record: PresentationRecord): Promise<void>;\n conversations(): Promise<readonly HeldConversation[]>;\n keepMessages(write: ConversationWrite): Promise<void>;\n dropConversations(conversations: readonly string[]): Promise<void>;\n chatDrafts(): Promise<readonly ChatDraftRecord[]>;\n keepChatDraft(record: ChatDraftRecord): Promise<void>;\n dropChatDraft(conversation: string): Promise<void>;\n keep(draft: DraftRecord): Promise<void>;\n discard(locator: string, path: string): Promise<void>;\n dropRooms(locators: readonly string[]): Promise<void>;\n generation(): Promise<string | null>;\n rememberGeneration(value: string): Promise<void>;\n close(): void;\n};\n\nfunction settled<T>(request: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n });\n}\n\nfunction completed(transaction: IDBTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n transaction.oncomplete = () => resolve();\n transaction.onerror = () => reject(transaction.error);\n transaction.onabort = () => reject(transaction.error);\n });\n}\n\nconst EMPTY_DECLARATIONS: DeclarationRecord = {\n lastCompleted: null,\n generation: null,\n providerLimits: [],\n capabilities: [],\n slots: [],\n};\n\nfunction declaration(database: IDBDatabase): Promise<DeclarationRecord> {\n const transaction = database.transaction(DECLARATIONS, 'readonly');\n return settled<DeclarationRecord | undefined>(\n transaction.objectStore(DECLARATIONS).get(CURRENT),\n ).then((record) => record ?? EMPTY_DECLARATIONS);\n}\n\nfunction updateDeclaration(\n database: IDBDatabase,\n update: (record: DeclarationRecord) => DeclarationRecord,\n): Promise<void> {\n const transaction = database.transaction(DECLARATIONS, 'readwrite');\n const store = transaction.objectStore(DECLARATIONS);\n const prior = store.get(CURRENT);\n prior.onsuccess = () => {\n store.put(\n update((prior.result as DeclarationRecord | undefined) ?? EMPTY_DECLARATIONS),\n CURRENT,\n );\n };\n return completed(transaction);\n}\n\nfunction roomRecord(record: ReplicaRecord, queue: readonly ChangeBatch[]): RoomRecord {\n const { documents, binaryTargets, revisions, ...room } = record;\n return { ...room, order: queue.map((batch) => batch.id) };\n}\n\nfunction removeRoomEntries(store: IDBObjectStore, locator: string) {\n const keys = store.getAllKeys();\n keys.onsuccess = () => {\n for (const key of keys.result) {\n if (Array.isArray(key) && key[0] === locator) store.delete(key);\n }\n };\n}\n\nexport function removeRuntimeStore(): Promise<void> {\n return new Promise((resolve, reject) => {\n const removal = indexedDB.deleteDatabase(DATABASE);\n removal.onsuccess = () => resolve();\n removal.onerror = () => reject(removal.error);\n });\n}\n\nexport async function openRuntimeStore(): Promise<RuntimeStore> {\n const opening = indexedDB.open(DATABASE, SCHEMA);\n opening.onupgradeneeded = () => {\n const database = opening.result;\n for (const name of [...database.objectStoreNames]) database.deleteObjectStore(name);\n database.createObjectStore(ROOMS, { keyPath: 'locator' });\n database.createObjectStore(DOCUMENTS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(BINARY_TARGETS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(PENDING_CHANGES, { keyPath: ['locator', 'id'] });\n const outcomes = database.createObjectStore(OUTCOMES, { keyPath: 'id' });\n outcomes.createIndex('locator', 'locator');\n database.createObjectStore(DECLARATIONS);\n database.createObjectStore(DRAFTS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(PRESENTATION, { keyPath: 'app' });\n database.createObjectStore(CONVERSATIONS, { keyPath: 'conversation' });\n const messages = database.createObjectStore(MESSAGES, {\n keyPath: ['conversation', 'identity'],\n });\n messages.createIndex('conversation', 'conversation');\n database.createObjectStore(CHAT_DRAFTS, { keyPath: 'conversation' });\n };\n const database = await settled(opening);\n return {\n async all() {\n const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS], 'readonly');\n const [rooms, documents, targets] = await Promise.all([\n settled<RoomRecord[]>(transaction.objectStore(ROOMS).getAll()),\n settled<DocumentRecord[]>(transaction.objectStore(DOCUMENTS).getAll()),\n settled<BinaryTargetRecord[]>(transaction.objectStore(BINARY_TARGETS).getAll()),\n ]);\n const byRoom = new Map<string, ReplicaRecord>();\n for (const { order, ...room } of rooms) {\n byRoom.set(room.locator, { ...room, documents: {}, revisions: {}, binaryTargets: [] });\n }\n for (const document of documents) {\n const room = byRoom.get(document.locator);\n if (room === undefined) continue;\n (room.documents as Record<string, string>)[document.path] = document.content;\n if (document.revision !== null) {\n (room.revisions as Record<string, string>)[document.path] = document.revision;\n }\n }\n for (const target of targets) {\n const room = byRoom.get(target.locator);\n if (room === undefined) continue;\n (room.binaryTargets as string[]).push(target.path);\n if (target.revision !== null) {\n (room.revisions as Record<string, string>)[target.path] = target.revision;\n }\n }\n return [...byRoom.values()];\n },\n async write({ next, previous, queue, previousQueue, outcomes, consumedDrafts }) {\n const transaction = database.transaction(\n [ROOMS, DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, OUTCOMES, DRAFTS],\n 'readwrite',\n );\n transaction.objectStore(ROOMS).put(roomRecord(next, queue));\n const documents = transaction.objectStore(DOCUMENTS);\n for (const path of Object.keys(previous?.documents ?? {})) {\n if (next.documents[path] === undefined) documents.delete([next.locator, path]);\n }\n for (const [path, content] of Object.entries(next.documents)) {\n if (\n previous?.documents[path] === content &&\n previous.revisions[path] === next.revisions[path]\n )\n continue;\n documents.put({\n locator: next.locator,\n path,\n content,\n revision: next.revisions[path] ?? null,\n } satisfies DocumentRecord);\n }\n const targets = transaction.objectStore(BINARY_TARGETS);\n const beforeTargets = new Set(previous?.binaryTargets ?? []);\n const afterTargets = new Set(next.binaryTargets);\n for (const path of beforeTargets) {\n if (!afterTargets.has(path)) targets.delete([next.locator, path]);\n }\n for (const path of afterTargets) {\n if (!beforeTargets.has(path) || previous?.revisions[path] !== next.revisions[path]) {\n targets.put({\n locator: next.locator,\n path,\n revision: next.revisions[path] ?? null,\n });\n }\n }\n if (previousQueue !== undefined) {\n const pending = transaction.objectStore(PENDING_CHANGES);\n const before = new Set(previousQueue.map((batch) => batch.id));\n const after = new Set(queue.map((batch) => batch.id));\n for (const id of before) {\n if (!after.has(id)) pending.delete([next.locator, id]);\n }\n for (const batch of queue) {\n if (!before.has(batch.id)) {\n pending.put({ locator: next.locator, id: batch.id, batch, submitted: false });\n }\n }\n }\n const outcomeStore = transaction.objectStore(OUTCOMES);\n for (const entry of outcomes ?? []) {\n if (entry.outcome === null) outcomeStore.delete(entry.id);\n else outcomeStore.put({ locator: next.locator, id: entry.id, outcome: entry.outcome });\n }\n const draftStore = transaction.objectStore(DRAFTS);\n for (const path of consumedDrafts ?? []) draftStore.delete([next.locator, path]);\n await completed(transaction);\n },\n async revokeModels(records) {\n const transaction = database.transaction(ROOMS, 'readwrite');\n const rooms = transaction.objectStore(ROOMS);\n const revoked: ModelState = { status: 'unavailable', reason: 'revoked' };\n for (const { record, queue } of records) {\n rooms.put(roomRecord({ ...record, model: revoked, selectionModel: revoked }, queue));\n }\n await completed(transaction);\n },\n async lastCompleted() {\n return (await declaration(database)).lastCompleted;\n },\n complete(at) {\n return updateDeclaration(database, (record) => ({ ...record, lastCompleted: at }));\n },\n async providerLimits() {\n return (await declaration(database)).providerLimits;\n },\n async capabilities() {\n return (await declaration(database)).capabilities;\n },\n async slots() {\n return (await declaration(database)).slots;\n },\n declare(limits, capabilities, slots) {\n return updateDeclaration(database, (record) => ({\n ...record,\n providerLimits: limits,\n capabilities,\n slots,\n }));\n },\n async queues() {\n const transaction = database.transaction([ROOMS, PENDING_CHANGES], 'readonly');\n const [rooms, pending] = await Promise.all([\n settled<RoomRecord[]>(transaction.objectStore(ROOMS).getAll()),\n settled<PendingChangeRecord[]>(transaction.objectStore(PENDING_CHANGES).getAll()),\n ]);\n const byId = new Map(\n pending.map((record) => [`${record.locator}\\0${record.id}`, record.batch]),\n );\n return rooms.map((room) => ({\n locator: room.locator,\n batches: room.order.map((id) => {\n const batch = byId.get(`${room.locator}\\0${id}`);\n if (batch === undefined) throw new Error(`Missing Pending Change ${room.locator}/${id}`);\n return batch;\n }),\n }));\n },\n async outcomes() {\n const transaction = database.transaction(OUTCOMES, 'readonly');\n return settled<OutcomeRecord[]>(transaction.objectStore(OUTCOMES).getAll());\n },\n async markSubmitted(locator, id) {\n const transaction = database.transaction(PENDING_CHANGES, 'readwrite');\n const pending = transaction.objectStore(PENDING_CHANGES);\n let marked = false;\n const request = pending.get([locator, id]);\n request.onsuccess = () => {\n const record = request.result as PendingChangeRecord | undefined;\n if (record !== undefined && !record.submitted) {\n pending.put({ ...record, submitted: true });\n marked = true;\n }\n };\n await completed(transaction);\n return marked;\n },\n async drafts() {\n const transaction = database.transaction(DRAFTS, 'readonly');\n return settled<DraftRecord[]>(transaction.objectStore(DRAFTS).getAll());\n },\n async presentation() {\n const transaction = database.transaction(PRESENTATION, 'readonly');\n return settled<PresentationRecord[]>(transaction.objectStore(PRESENTATION).getAll());\n },\n async present(record) {\n const transaction = database.transaction(PRESENTATION, 'readwrite');\n transaction.objectStore(PRESENTATION).put(record);\n await completed(transaction);\n },\n async conversations() {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES], 'readonly');\n const [reads, messages] = await Promise.all([\n settled<ConversationRecord[]>(transaction.objectStore(CONVERSATIONS).getAll()),\n settled<MessageRecord[]>(transaction.objectStore(MESSAGES).getAll()),\n ]);\n const held = new Map<string, HeldConversation & { messages: AcceptedMessage[] }>();\n for (const { conversation, read } of reads) {\n held.set(conversation, { conversation, read, messages: [] });\n }\n for (const { conversation, ...message } of messages) {\n const entry = held.get(conversation) ?? { conversation, read: undefined, messages: [] };\n entry.messages.push(message);\n held.set(conversation, entry);\n }\n return [...held.values()];\n },\n async keepMessages({ conversation, messages, read, sealed }) {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES, CHAT_DRAFTS], 'readwrite');\n const stored = transaction.objectStore(MESSAGES);\n for (const message of messages) {\n stored.put({ ...message, conversation } satisfies MessageRecord);\n }\n if (read !== undefined) {\n transaction\n .objectStore(CONVERSATIONS)\n .put({ conversation, read } satisfies ConversationRecord);\n }\n if (sealed === true) transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n await completed(transaction);\n },\n async dropConversations(conversations) {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES, CHAT_DRAFTS], 'readwrite');\n const messages = transaction.objectStore(MESSAGES);\n for (const conversation of conversations) {\n transaction.objectStore(CONVERSATIONS).delete(conversation);\n transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n const keys = messages.index('conversation').getAllKeys(conversation);\n keys.onsuccess = () => {\n for (const key of keys.result) messages.delete(key);\n };\n }\n await completed(transaction);\n },\n async chatDrafts() {\n const transaction = database.transaction(CHAT_DRAFTS, 'readonly');\n return settled<ChatDraftRecord[]>(transaction.objectStore(CHAT_DRAFTS).getAll());\n },\n async keepChatDraft(record) {\n const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');\n transaction.objectStore(CHAT_DRAFTS).put(record);\n await completed(transaction);\n },\n async dropChatDraft(conversation) {\n const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');\n transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n await completed(transaction);\n },\n async keep(draft) {\n const transaction = database.transaction(DRAFTS, 'readwrite');\n transaction.objectStore(DRAFTS).put(draft);\n await completed(transaction);\n },\n async discard(locator, path) {\n const transaction = database.transaction(DRAFTS, 'readwrite');\n transaction.objectStore(DRAFTS).delete([locator, path]);\n await completed(transaction);\n },\n async dropRooms(locators) {\n const transaction = database.transaction(\n [ROOMS, DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, OUTCOMES, DRAFTS],\n 'readwrite',\n );\n for (const locator of locators) {\n transaction.objectStore(ROOMS).delete(locator);\n for (const name of [DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, DRAFTS]) {\n removeRoomEntries(transaction.objectStore(name), locator);\n }\n const outcomes = transaction.objectStore(OUTCOMES);\n const ids = outcomes.index('locator').getAllKeys(locator);\n ids.onsuccess = () => {\n for (const id of ids.result) outcomes.delete(id);\n };\n }\n await completed(transaction);\n },\n async generation() {\n return (await declaration(database)).generation;\n },\n rememberGeneration(value) {\n return updateDeclaration(database, (record) => ({ ...record, generation: value }));\n },\n close() {\n database.close();\n },\n };\n}\n"],"names":["DATABASE","ROOMS","DOCUMENTS","BINARY_TARGETS","PENDING_CHANGES","OUTCOMES","DECLARATIONS","DRAFTS","PRESENTATION","CONVERSATIONS","MESSAGES","CHAT_DRAFTS","CURRENT","SCHEMA","settled","request","Promise","resolve","reject","onsuccess","result","onerror","error","completed","transaction","oncomplete","onabort","EMPTY_DECLARATIONS","lastCompleted","generation","providerLimits","capabilities","slots","declaration","database","objectStore","get","then","record","updateDeclaration","update","store","prior","put","roomRecord","queue","documents","binaryTargets","revisions","room","order","map","batch","id","removeRoomEntries","locator","keys","getAllKeys","key","Array","isArray","delete","removeRuntimeStore","removal","indexedDB","deleteDatabase","openRuntimeStore","opening","open","onupgradeneeded","name","objectStoreNames","deleteObjectStore","createObjectStore","keyPath","outcomes","createIndex","messages","all","rooms","targets","getAll","byRoom","Map","set","document","undefined","path","content","revision","target","push","values","write","next","previous","previousQueue","consumedDrafts","Object","entries","beforeTargets","Set","afterTargets","has","pending","before","after","submitted","outcomeStore","entry","outcome","draftStore","revokeModels","records","revoked","status","reason","model","selectionModel","complete","at","declare","limits","queues","byId","batches","Error","markSubmitted","marked","drafts","presentation","present","conversations","reads","held","conversation","read","message","keepMessages","sealed","stored","dropConversations","index","chatDrafts","keepChatDraft","dropChatDraft","keep","draft","discard","dropRooms","locators","ids","rememberGeneration","value","close"],"mappings":"AAcA,MAAMA,WAAW;AACjB,MAAMC,QAAQ;AACd,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AACvB,MAAMC,kBAAkB;AACxB,MAAMC,WAAW;AACjB,MAAMC,eAAe;AACrB,MAAMC,SAAS;AACf,MAAMC,eAAe;AACrB,MAAMC,gBAAgB;AACtB,MAAMC,WAAW;AACjB,MAAMC,cAAc;AACpB,MAAMC,UAAU;AAChB,MAAMC,SAAS;AA6If,SAASC,QAAWC,OAAsB;IACxC,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3BH,QAAQI,SAAS,GAAG,IAAMF,QAAQF,QAAQK,MAAM;QAChDL,QAAQM,OAAO,GAAG,IAAMH,OAAOH,QAAQO,KAAK;IAC9C;AACF;AAEA,SAASC,UAAUC,WAA2B;IAC5C,OAAO,IAAIR,QAAQ,CAACC,SAASC;QAC3BM,YAAYC,UAAU,GAAG,IAAMR;QAC/BO,YAAYH,OAAO,GAAG,IAAMH,OAAOM,YAAYF,KAAK;QACpDE,YAAY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kBL,UAAU,CAACI,SAAY,CAAA;oBAAE,GAAGA,MAAM;oBAAET,YAAY4H;gBAAM,CAAA;QACjF;QACAC;YACExH,SAASwH,KAAK;QAChB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/store.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type {\n Capability,\n Discovery,\n OperationScopes,\n ProviderLimit,\n ReplicaAdmission,\n TypedSelection,\n} from './adapter.js';\nimport type { AcceptedMessage } from './adapter.js';\nimport type { ChangeBatch } from './change.js';\nimport type { ChatDraftFile } from './file.js';\nimport type { Submission, SubmissionOutcome } from './outcome.js';\nimport type { RoomDraftRecord, SavedDraft } from './room-draft.js';\n\nconst DATABASE = 'mdruntime';\nconst ROOMS = 'rooms';\nconst DOCUMENTS = 'documents';\nconst BINARY_TARGETS = 'binaryTargets';\nconst PENDING_CHANGES = 'pendingChanges';\nconst OUTCOMES = 'outcomes';\nconst DECLARATIONS = 'declarations';\nconst ROOM_DRAFTS = 'roomDrafts';\nconst PRESENTATION = 'presentation';\nconst CONVERSATIONS = 'conversations';\nconst MESSAGES = 'messages';\nconst CHAT_DRAFTS = 'chatDrafts';\nconst CURRENT = 'current';\nconst SCHEMA = 13;\n\nexport type ReplicaRecord = {\n collectionRoot: string;\n locator: string;\n name: string;\n operations: OperationScopes;\n replica: ReplicaAdmission;\n model: ModelState;\n attachedModel: import('./model.js').ModelIdentity | null;\n typedSelection: TypedSelection | null;\n selectionModel: ModelState;\n providerOwnedPaths: readonly string[];\n roomVersion: string;\n documents: Readonly<Record<string, string>>;\n binaryTargets: readonly string[];\n revisions: Readonly<Record<string, string>>;\n};\n\ntype RoomRecord = Omit<ReplicaRecord, 'documents' | 'binaryTargets' | 'revisions'> & {\n order: readonly string[];\n};\n\ntype DocumentRecord = {\n locator: string;\n path: string;\n content: string;\n revision: string | null;\n};\n\ntype BinaryTargetRecord = { locator: string; path: string; revision: string | null };\n\nexport type PendingState = {\n readonly drafts: readonly SavedDraft[];\n readonly submission: Submission;\n readonly lost: boolean;\n};\n\ntype PendingChangeRecord = PendingState & {\n locator: string;\n id: string;\n batch: ChangeBatch;\n};\n\nexport type OutcomeRecord = {\n locator: string;\n id: string;\n outcome: SubmissionOutcome;\n};\n\ntype DeclarationRecord = {\n lastCompleted: string | null;\n generation: string | null;\n providerLimits: readonly ProviderLimit[];\n capabilities: readonly Capability[];\n slots: NonNullable<Discovery['slots']>;\n};\n\nexport type QueueRecord = {\n locator: string;\n pending: readonly { batch: ChangeBatch; state: PendingState }[];\n};\n\nexport type PresentationRecord = {\n app: string;\n value: unknown;\n};\n\ntype ConversationRecord = {\n conversation: string;\n read: string | null;\n};\n\ntype MessageRecord = AcceptedMessage & { conversation: string };\n\nexport type HeldConversation = {\n conversation: string;\n read: string | null | undefined;\n messages: readonly AcceptedMessage[];\n};\n\nexport type ConversationWrite = {\n conversation: string;\n messages: readonly AcceptedMessage[];\n read?: string | null;\n sealed?: boolean;\n};\n\nexport type ChatDraftRecord = {\n conversation: string;\n text: string;\n files: readonly ChatDraftFile[];\n turn: string | null;\n};\n\nexport type RecordWrite = {\n next: ReplicaRecord;\n previous: ReplicaRecord | null;\n queue: readonly ChangeBatch[];\n previousQueue?: readonly ChangeBatch[];\n saved?: readonly SavedDraft[];\n outcomes?: readonly { id: string; outcome: SubmissionOutcome | null }[];\n roomDrafts?: readonly RoomDraftRecord[];\n consumedRoomDrafts?: readonly string[];\n};\n\nexport type RuntimeStore = {\n all(): Promise<readonly ReplicaRecord[]>;\n write(input: RecordWrite): Promise<void>;\n revokeModels(\n records: readonly { record: ReplicaRecord; queue: readonly ChangeBatch[] }[],\n ): Promise<void>;\n lastCompleted(): Promise<string | null>;\n complete(at: string): Promise<void>;\n providerLimits(): Promise<readonly ProviderLimit[]>;\n capabilities(): Promise<readonly Capability[]>;\n slots(): Promise<NonNullable<Discovery['slots']>>;\n declare(\n limits: readonly ProviderLimit[],\n capabilities: readonly Capability[],\n slots: NonNullable<Discovery['slots']>,\n ): Promise<void>;\n queues(): Promise<readonly QueueRecord[]>;\n outcomes(): Promise<readonly OutcomeRecord[]>;\n submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;\n roomDrafts(): Promise<readonly RoomDraftRecord[]>;\n presentation(): Promise<readonly PresentationRecord[]>;\n present(record: PresentationRecord): Promise<void>;\n conversations(): Promise<readonly HeldConversation[]>;\n keepMessages(write: ConversationWrite): Promise<void>;\n dropConversations(conversations: readonly string[]): Promise<void>;\n chatDrafts(): Promise<readonly ChatDraftRecord[]>;\n keepChatDraft(record: ChatDraftRecord): Promise<void>;\n dropChatDraft(conversation: string): Promise<void>;\n keepRoomDraft(record: RoomDraftRecord): Promise<void>;\n discardRoomDraft(locator: string, path: string): Promise<void>;\n dropRooms(locators: readonly string[]): Promise<void>;\n generation(): Promise<string | null>;\n rememberGeneration(value: string): Promise<void>;\n close(): void;\n};\n\nfunction settled<T>(request: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error);\n });\n}\n\nfunction completed(transaction: IDBTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n transaction.oncomplete = () => resolve();\n transaction.onerror = () => reject(transaction.error);\n transaction.onabort = () => reject(transaction.error);\n });\n}\n\nconst EMPTY_DECLARATIONS: DeclarationRecord = {\n lastCompleted: null,\n generation: null,\n providerLimits: [],\n capabilities: [],\n slots: [],\n};\n\nfunction declaration(database: IDBDatabase): Promise<DeclarationRecord> {\n const transaction = database.transaction(DECLARATIONS, 'readonly');\n return settled<DeclarationRecord | undefined>(\n transaction.objectStore(DECLARATIONS).get(CURRENT),\n ).then((record) => record ?? EMPTY_DECLARATIONS);\n}\n\nfunction updateDeclaration(\n database: IDBDatabase,\n update: (record: DeclarationRecord) => DeclarationRecord,\n): Promise<void> {\n const transaction = database.transaction(DECLARATIONS, 'readwrite');\n const store = transaction.objectStore(DECLARATIONS);\n const prior = store.get(CURRENT);\n prior.onsuccess = () => {\n store.put(\n update((prior.result as DeclarationRecord | undefined) ?? EMPTY_DECLARATIONS),\n CURRENT,\n );\n };\n return completed(transaction);\n}\n\nfunction roomRecord(record: ReplicaRecord, queue: readonly ChangeBatch[]): RoomRecord {\n const { documents, binaryTargets, revisions, ...room } = record;\n return { ...room, order: queue.map((batch) => batch.id) };\n}\n\nfunction removeRoomEntries(store: IDBObjectStore, locator: string) {\n const keys = store.getAllKeys();\n keys.onsuccess = () => {\n for (const key of keys.result) {\n if (Array.isArray(key) && key[0] === locator) store.delete(key);\n }\n };\n}\n\nexport function removeRuntimeStore(): Promise<void> {\n return new Promise((resolve, reject) => {\n const removal = indexedDB.deleteDatabase(DATABASE);\n removal.onsuccess = () => resolve();\n removal.onerror = () => reject(removal.error);\n });\n}\n\nexport async function openRuntimeStore(): Promise<RuntimeStore> {\n const opening = indexedDB.open(DATABASE, SCHEMA);\n opening.onupgradeneeded = () => {\n const database = opening.result;\n for (const name of [...database.objectStoreNames]) database.deleteObjectStore(name);\n database.createObjectStore(ROOMS, { keyPath: 'locator' });\n database.createObjectStore(DOCUMENTS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(BINARY_TARGETS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(PENDING_CHANGES, { keyPath: ['locator', 'id'] });\n const outcomes = database.createObjectStore(OUTCOMES, { keyPath: 'id' });\n outcomes.createIndex('locator', 'locator');\n database.createObjectStore(DECLARATIONS);\n database.createObjectStore(ROOM_DRAFTS, { keyPath: ['locator', 'path'] });\n database.createObjectStore(PRESENTATION, { keyPath: 'app' });\n database.createObjectStore(CONVERSATIONS, { keyPath: 'conversation' });\n const messages = database.createObjectStore(MESSAGES, {\n keyPath: ['conversation', 'identity'],\n });\n messages.createIndex('conversation', 'conversation');\n database.createObjectStore(CHAT_DRAFTS, { keyPath: 'conversation' });\n };\n const database = await settled(opening);\n return {\n async all() {\n const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS], 'readonly');\n const [rooms, documents, targets] = await Promise.all([\n settled<RoomRecord[]>(transaction.objectStore(ROOMS).getAll()),\n settled<DocumentRecord[]>(transaction.objectStore(DOCUMENTS).getAll()),\n settled<BinaryTargetRecord[]>(transaction.objectStore(BINARY_TARGETS).getAll()),\n ]);\n const byRoom = new Map<string, ReplicaRecord>();\n for (const { order, ...room } of rooms) {\n byRoom.set(room.locator, { ...room, documents: {}, revisions: {}, binaryTargets: [] });\n }\n for (const document of documents) {\n const room = byRoom.get(document.locator);\n if (room === undefined) continue;\n (room.documents as Record<string, string>)[document.path] = document.content;\n if (document.revision !== null) {\n (room.revisions as Record<string, string>)[document.path] = document.revision;\n }\n }\n for (const target of targets) {\n const room = byRoom.get(target.locator);\n if (room === undefined) continue;\n (room.binaryTargets as string[]).push(target.path);\n if (target.revision !== null) {\n (room.revisions as Record<string, string>)[target.path] = target.revision;\n }\n }\n return [...byRoom.values()];\n },\n async write({\n next,\n previous,\n queue,\n previousQueue,\n saved,\n outcomes,\n roomDrafts,\n consumedRoomDrafts,\n }) {\n const transaction = database.transaction(\n [ROOMS, DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, OUTCOMES, ROOM_DRAFTS],\n 'readwrite',\n );\n transaction.objectStore(ROOMS).put(roomRecord(next, queue));\n const documents = transaction.objectStore(DOCUMENTS);\n for (const path of Object.keys(previous?.documents ?? {})) {\n if (next.documents[path] === undefined) documents.delete([next.locator, path]);\n }\n for (const [path, content] of Object.entries(next.documents)) {\n if (\n previous?.documents[path] === content &&\n previous.revisions[path] === next.revisions[path]\n )\n continue;\n documents.put({\n locator: next.locator,\n path,\n content,\n revision: next.revisions[path] ?? null,\n } satisfies DocumentRecord);\n }\n const targets = transaction.objectStore(BINARY_TARGETS);\n const beforeTargets = new Set(previous?.binaryTargets ?? []);\n const afterTargets = new Set(next.binaryTargets);\n for (const path of beforeTargets) {\n if (!afterTargets.has(path)) targets.delete([next.locator, path]);\n }\n for (const path of afterTargets) {\n if (!beforeTargets.has(path) || previous?.revisions[path] !== next.revisions[path]) {\n targets.put({\n locator: next.locator,\n path,\n revision: next.revisions[path] ?? null,\n });\n }\n }\n if (previousQueue !== undefined) {\n const pending = transaction.objectStore(PENDING_CHANGES);\n const before = new Set(previousQueue.map((batch) => batch.id));\n const after = new Set(queue.map((batch) => batch.id));\n for (const id of before) {\n if (!after.has(id)) pending.delete([next.locator, id]);\n }\n for (const batch of queue) {\n if (!before.has(batch.id)) {\n pending.put({\n locator: next.locator,\n id: batch.id,\n batch,\n drafts: saved ?? [],\n submission: { state: 'waiting' },\n lost: false,\n } satisfies PendingChangeRecord);\n }\n }\n }\n const outcomeStore = transaction.objectStore(OUTCOMES);\n for (const entry of outcomes ?? []) {\n if (entry.outcome === null) outcomeStore.delete(entry.id);\n else outcomeStore.put({ locator: next.locator, id: entry.id, outcome: entry.outcome });\n }\n const draftStore = transaction.objectStore(ROOM_DRAFTS);\n for (const path of consumedRoomDrafts ?? []) draftStore.delete([next.locator, path]);\n for (const record of roomDrafts ?? []) draftStore.put(record);\n await completed(transaction);\n },\n async revokeModels(records) {\n const transaction = database.transaction(ROOMS, 'readwrite');\n const rooms = transaction.objectStore(ROOMS);\n const revoked: ModelState = { status: 'unavailable', reason: 'revoked' };\n for (const { record, queue } of records) {\n rooms.put(roomRecord({ ...record, model: revoked, selectionModel: revoked }, queue));\n }\n await completed(transaction);\n },\n async lastCompleted() {\n return (await declaration(database)).lastCompleted;\n },\n complete(at) {\n return updateDeclaration(database, (record) => ({ ...record, lastCompleted: at }));\n },\n async providerLimits() {\n return (await declaration(database)).providerLimits;\n },\n async capabilities() {\n return (await declaration(database)).capabilities;\n },\n async slots() {\n return (await declaration(database)).slots;\n },\n declare(limits, capabilities, slots) {\n return updateDeclaration(database, (record) => ({\n ...record,\n providerLimits: limits,\n capabilities,\n slots,\n }));\n },\n async queues() {\n const transaction = database.transaction([ROOMS, PENDING_CHANGES], 'readonly');\n const [rooms, pending] = await Promise.all([\n settled<RoomRecord[]>(transaction.objectStore(ROOMS).getAll()),\n settled<PendingChangeRecord[]>(transaction.objectStore(PENDING_CHANGES).getAll()),\n ]);\n const byId = new Map(pending.map((record) => [`${record.locator}\\0${record.id}`, record]));\n return rooms.map((room) => ({\n locator: room.locator,\n pending: room.order.map((id) => {\n const record = byId.get(`${room.locator}\\0${id}`);\n if (record === undefined) throw new Error(`Missing Pending Change ${room.locator}/${id}`);\n const { batch, drafts, submission, lost } = record;\n return { batch, state: { drafts, submission, lost } };\n }),\n }));\n },\n async outcomes() {\n const transaction = database.transaction(OUTCOMES, 'readonly');\n return settled<OutcomeRecord[]>(transaction.objectStore(OUTCOMES).getAll());\n },\n async submit(locator, id, submission, lost) {\n const transaction = database.transaction(PENDING_CHANGES, 'readwrite');\n const pending = transaction.objectStore(PENDING_CHANGES);\n const request = pending.get([locator, id]);\n request.onsuccess = () => {\n const record = request.result as PendingChangeRecord | undefined;\n if (record !== undefined) pending.put({ ...record, submission, lost });\n };\n await completed(transaction);\n },\n async roomDrafts() {\n const transaction = database.transaction(ROOM_DRAFTS, 'readonly');\n return settled<RoomDraftRecord[]>(transaction.objectStore(ROOM_DRAFTS).getAll());\n },\n async presentation() {\n const transaction = database.transaction(PRESENTATION, 'readonly');\n return settled<PresentationRecord[]>(transaction.objectStore(PRESENTATION).getAll());\n },\n async present(record) {\n const transaction = database.transaction(PRESENTATION, 'readwrite');\n transaction.objectStore(PRESENTATION).put(record);\n await completed(transaction);\n },\n async conversations() {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES], 'readonly');\n const [reads, messages] = await Promise.all([\n settled<ConversationRecord[]>(transaction.objectStore(CONVERSATIONS).getAll()),\n settled<MessageRecord[]>(transaction.objectStore(MESSAGES).getAll()),\n ]);\n const held = new Map<string, HeldConversation & { messages: AcceptedMessage[] }>();\n for (const { conversation, read } of reads) {\n held.set(conversation, { conversation, read, messages: [] });\n }\n for (const { conversation, ...message } of messages) {\n const entry = held.get(conversation) ?? { conversation, read: undefined, messages: [] };\n entry.messages.push(message);\n held.set(conversation, entry);\n }\n return [...held.values()];\n },\n async keepMessages({ conversation, messages, read, sealed }) {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES, CHAT_DRAFTS], 'readwrite');\n const stored = transaction.objectStore(MESSAGES);\n for (const message of messages) {\n stored.put({ ...message, conversation } satisfies MessageRecord);\n }\n if (read !== undefined) {\n transaction\n .objectStore(CONVERSATIONS)\n .put({ conversation, read } satisfies ConversationRecord);\n }\n if (sealed === true) transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n await completed(transaction);\n },\n async dropConversations(conversations) {\n const transaction = database.transaction([CONVERSATIONS, MESSAGES, CHAT_DRAFTS], 'readwrite');\n const messages = transaction.objectStore(MESSAGES);\n for (const conversation of conversations) {\n transaction.objectStore(CONVERSATIONS).delete(conversation);\n transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n const keys = messages.index('conversation').getAllKeys(conversation);\n keys.onsuccess = () => {\n for (const key of keys.result) messages.delete(key);\n };\n }\n await completed(transaction);\n },\n async chatDrafts() {\n const transaction = database.transaction(CHAT_DRAFTS, 'readonly');\n return settled<ChatDraftRecord[]>(transaction.objectStore(CHAT_DRAFTS).getAll());\n },\n async keepChatDraft(record) {\n const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');\n transaction.objectStore(CHAT_DRAFTS).put(record);\n await completed(transaction);\n },\n async dropChatDraft(conversation) {\n const transaction = database.transaction(CHAT_DRAFTS, 'readwrite');\n transaction.objectStore(CHAT_DRAFTS).delete(conversation);\n await completed(transaction);\n },\n async keepRoomDraft(record) {\n const transaction = database.transaction(ROOM_DRAFTS, 'readwrite');\n transaction.objectStore(ROOM_DRAFTS).put(record);\n await completed(transaction);\n },\n async discardRoomDraft(locator, path) {\n const transaction = database.transaction(ROOM_DRAFTS, 'readwrite');\n transaction.objectStore(ROOM_DRAFTS).delete([locator, path]);\n await completed(transaction);\n },\n async dropRooms(locators) {\n const transaction = database.transaction(\n [ROOMS, DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, OUTCOMES, ROOM_DRAFTS],\n 'readwrite',\n );\n for (const locator of locators) {\n transaction.objectStore(ROOMS).delete(locator);\n for (const name of [DOCUMENTS, BINARY_TARGETS, PENDING_CHANGES, ROOM_DRAFTS]) {\n removeRoomEntries(transaction.objectStore(name), locator);\n }\n const outcomes = transaction.objectStore(OUTCOMES);\n const ids = outcomes.index('locator').getAllKeys(locator);\n ids.onsuccess = () => {\n for (const id of ids.result) outcomes.delete(id);\n };\n }\n await completed(transaction);\n },\n async generation() {\n return (await declaration(database)).generation;\n },\n rememberGeneration(value) {\n return updateDeclaration(database, (record) => ({ ...record, generation: value }));\n },\n close() {\n database.close();\n },\n };\n}\n"],"names":["DATABASE","ROOMS","DOCUMENTS","BINARY_TARGETS","PENDING_CHANGES","OUTCOMES","DECLARATIONS","ROOM_DRAFTS","PRESENTATION","CONVERSATIONS","MESSAGES","CHAT_DRAFTS","CURRENT","SCHEMA","settled","request","Promise","resolve","reject","onsuccess","result","onerror","error","completed","transaction","oncomplete","onabort","EMPTY_DECLARATIONS","lastCompleted","generation","providerLimits","capabilities","slots","declaration","database","objectStore","get","then","record","updateDeclaration","update","store","prior","put","roomRecord","queue","documents","binaryTargets","revisions","room","order","map","batch","id","removeRoomEntries","locator","keys","getAllKeys","key","Array","isArray","delete","removeRuntimeStore","removal","indexedDB","deleteDatabase","openRuntimeStore","opening","open","onupgradeneeded","name","objectStoreNames","deleteObjectStore","createObjectStore","keyPath","outcomes","createIndex","messages","all","rooms","targets","getAll","byRoom","Map","set","document","undefined","path","content","revision","target","push","values","write","next","previous","previousQueue","saved","roomDrafts","consumedRoomDrafts","Object","entries","beforeTargets","Set","afterTargets","has","pending","before","after","drafts","submission","state","lost","outcomeStore","entry","outcome","draftStore","revokeModels","records","revoked","status","reason","model","selectionModel","complete","at","declare","limits","queues","byId","Error","submit","presentation","present","conversations","reads","held","conversation","read","message","keepMessages","sealed","stored","dropConversations","index","chatDrafts","keepChatDraft","dropChatDraft","keepRoomDraft","discardRoomDraft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F,OAAO,EAAEgC,IAAI;YAClC,MAAM/D,cAAcU,SAASV,WAAW,CAACjB,aAAa;YACtDiB,YAAYW,WAAW,CAAC5B,aAAasD,MAAM,CAAC;gBAACN;gBAASgC;aAAK;YAC3D,MAAMhE,UAAUC;QAClB;QACA,MAAM8H,WAAUC,QAAQ;YACtB,MAAM/H,cAAcU,SAASV,WAAW,CACtC;gBAACvB;gBAAOC;gBAAWC;gBAAgBC;gBAAiBC;gBAAUE;aAAY,EAC1E;YAEF,KAAK,MAAMgD,WAAWgG,SAAU;gBAC9B/H,YAAYW,WAAW,CAAClC,OAAO4D,MAAM,CAACN;gBACtC,KAAK,MAAMe,QAAQ;oBAACpE;oBAAWC;oBAAgBC;oBAAiBG;iBAAY,CAAE;oBAC5E+C,kBAAkB9B,YAAYW,WAAW,CAACmC,OAAOf;gBACnD;gBACA,MAAMoB,WAAWnD,YAAYW,WAAW,CAAC9B;gBACzC,MAAMmJ,MAAM7E,SAASqE,KAAK,CAAC,WAAWvF,UAAU,CAACF;gBACjDiG,IAAIrI,SAAS,GAAG;oBACd,KAAK,MAAMkC,MAAMmG,IAAIpI,MAAM,CAAEuD,SAASd,MAAM,CAACR;gBAC/C;YACF;YACA,MAAM9B,UAAUC;QAClB;QACA,MAAMK;YACJ,OAAO,AAAC,CAAA,MAAMI,YAAYC,SAAQ,EAAGL,UAAU;QACjD;QACA4H,oBAAmBC,KAAK;YACtB,OAAOnH,kBAAkBL,UAAU,CAACI,SAAY,CAAA;oBAAE,GAAGA,MAAM;oBAAET,YAAY6H;gBAAM,CAAA;QACjF;QACAC;YACEzH,SAASyH,KAAK;QAChB;IACF;AACF"}
|
package/dist/wire.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConnectionRefusal } from './connection.js';
|
|
2
|
-
export declare const RUNTIME_WIRE_PROTOCOL =
|
|
2
|
+
export declare const RUNTIME_WIRE_PROTOCOL = 5;
|
|
3
3
|
export declare const PROTOCOL_MISMATCH: ConnectionRefusal;
|
|
4
4
|
export type RuntimePort = {
|
|
5
5
|
postMessage(message: unknown): void;
|
|
@@ -8,8 +8,8 @@ export type RuntimePort = {
|
|
|
8
8
|
}) => void): void;
|
|
9
9
|
start(): void;
|
|
10
10
|
};
|
|
11
|
-
declare const MEMBERS: readonly ['rooms', 'slots', 'query', 'types', 'syncStatus', 'save', 'outcome', 'history', 'call', 'log', 'storageLoss', 'persistence', 'deploymentFacts', 'reauthorize', '
|
|
12
|
-
declare const TOPICS: readonly ['rooms', 'connection-refusal', 'storage-loss', 'deployment-facts', 'sync-status', 'query', 'queue', 'drafts', 'presentation', 'conversation'];
|
|
11
|
+
declare const MEMBERS: readonly ['rooms', 'slots', 'query', 'types', 'syncStatus', 'save', 'outcome', 'history', 'call', 'log', 'storageLoss', 'persistence', 'deploymentFacts', 'reauthorize', 'roomDraft.list', 'roomDraft.read', 'roomDraft.write', 'roomDraft.discard', 'presentation.read', 'presentation.write', 'conversation.list', 'conversation.read', 'conversation.create', 'conversation.send', 'conversation.answer', 'conversation.interrupt', 'conversation.kill', 'conversation.cancel', 'conversation.delete', 'chatDraft.write', 'chatDraft.discard'];
|
|
12
|
+
declare const TOPICS: readonly ['rooms', 'connection-refusal', 'storage-loss', 'deployment-facts', 'sync-status', 'query', 'queue', 'room-drafts', 'presentation', 'conversation'];
|
|
13
13
|
export type WireMember = (typeof MEMBERS)[number];
|
|
14
14
|
export type WireTopic = (typeof TOPICS)[number];
|
|
15
15
|
export type WireRequest = {
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,eAAO,MAAM,iBAAiB,EAAE,iBAI/B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,WA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E,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,GAC/C;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEtB,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE,MAAM,MAAM,YAAY,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,wBAAgB,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,GAAG,YAAY,CAExE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAIrD;AAQD,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CAyB5D;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAe1D"}
|
package/dist/wire.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const RUNTIME_WIRE_PROTOCOL =
|
|
1
|
+
export const RUNTIME_WIRE_PROTOCOL = 5;
|
|
2
2
|
export const PROTOCOL_MISMATCH = {
|
|
3
3
|
reason: 'client-host-protocol-mismatch',
|
|
4
4
|
reauthorizationOffered: false,
|
|
@@ -19,11 +19,10 @@ const MEMBERS = [
|
|
|
19
19
|
'persistence',
|
|
20
20
|
'deploymentFacts',
|
|
21
21
|
'reauthorize',
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'queue.discard',
|
|
22
|
+
'roomDraft.list',
|
|
23
|
+
'roomDraft.read',
|
|
24
|
+
'roomDraft.write',
|
|
25
|
+
'roomDraft.discard',
|
|
27
26
|
'presentation.read',
|
|
28
27
|
'presentation.write',
|
|
29
28
|
'conversation.list',
|
|
@@ -46,7 +45,7 @@ const TOPICS = [
|
|
|
46
45
|
'sync-status',
|
|
47
46
|
'query',
|
|
48
47
|
'queue',
|
|
49
|
-
'drafts',
|
|
48
|
+
'room-drafts',
|
|
50
49
|
'presentation',
|
|
51
50
|
'conversation'
|
|
52
51
|
];
|
package/dist/wire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/wire.ts"],"sourcesContent":["import type { ConnectionRefusal } from './connection.js';\n\nexport const RUNTIME_WIRE_PROTOCOL =
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/wire.ts"],"sourcesContent":["import type { ConnectionRefusal } from './connection.js';\n\nexport const RUNTIME_WIRE_PROTOCOL = 5;\n\nexport const PROTOCOL_MISMATCH: ConnectionRefusal = {\n reason: 'client-host-protocol-mismatch',\n reauthorizationOffered: false,\n refusal: null,\n};\n\nexport type RuntimePort = {\n postMessage(message: unknown): void;\n addEventListener(type: 'message' | 'close', listener: (event: { data?: unknown }) => void): void;\n start(): void;\n};\n\nconst MEMBERS = [\n 'rooms',\n 'slots',\n 'query',\n 'types',\n 'syncStatus',\n 'save',\n 'outcome',\n 'history',\n 'call',\n 'log',\n 'storageLoss',\n 'persistence',\n 'deploymentFacts',\n 'reauthorize',\n 'roomDraft.list',\n 'roomDraft.read',\n 'roomDraft.write',\n 'roomDraft.discard',\n 'presentation.read',\n 'presentation.write',\n 'conversation.list',\n 'conversation.read',\n 'conversation.create',\n 'conversation.send',\n 'conversation.answer',\n 'conversation.interrupt',\n 'conversation.kill',\n 'conversation.cancel',\n 'conversation.delete',\n 'chatDraft.write',\n 'chatDraft.discard',\n] as const;\n\nconst TOPICS = [\n 'rooms',\n 'connection-refusal',\n 'storage-loss',\n 'deployment-facts',\n 'sync-status',\n 'query',\n 'queue',\n 'room-drafts',\n 'presentation',\n 'conversation',\n] as const;\n\nexport type WireMember = (typeof MEMBERS)[number];\nexport type WireTopic = (typeof TOPICS)[number];\n\nexport type WireRequest =\n | { kind: 'hello' }\n | { kind: 'call'; id: number; member: WireMember; input: readonly unknown[] }\n | { kind: 'observe'; id: number; topic: WireTopic; input: readonly unknown[] }\n | { kind: 'stop'; id: number };\n\nexport type WireAnswer =\n | { kind: 'result'; id: number; value: unknown }\n | { kind: 'failure'; id: number; message: string }\n | { kind: 'event'; id: number; value: unknown }\n | { kind: 'refusal'; refusal: ConnectionRefusal }\n | { kind: 'ended' };\n\nexport const AUTHORIZATION_ENDED = 'the host authorization ended';\n\nexport type WireEnvelope = { mdRuntime: number; message: WireRequest | WireAnswer };\n\nexport type Carried = { matching: boolean; message: unknown };\n\nexport function envelope(message: WireRequest | WireAnswer): WireEnvelope {\n return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };\n}\n\nexport function carried(data: unknown): Carried | null {\n if (typeof data !== 'object' || data === null || !('mdRuntime' in data)) return null;\n const record = data as { mdRuntime: unknown; message?: unknown };\n return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };\n}\n\nfunction body(message: unknown): { kind: unknown; id: unknown } | null {\n if (typeof message !== 'object' || message === null) return null;\n const record = message as { kind?: unknown; id?: unknown };\n return { kind: record.kind, id: record.id };\n}\n\nexport function request(message: unknown): WireRequest | null {\n const shape = body(message);\n if (shape === null) return null;\n if (shape.kind === 'hello') return { kind: 'hello' };\n if (typeof shape.id !== 'number') return null;\n const record = message as { input?: unknown; member?: unknown; topic?: unknown };\n if (shape.kind === 'stop') return { kind: 'stop', id: shape.id };\n if (!Array.isArray(record.input)) return null;\n if (shape.kind === 'call' && MEMBERS.includes(record.member as WireMember)) {\n return {\n kind: 'call',\n id: shape.id,\n member: record.member as WireMember,\n input: record.input as readonly unknown[],\n };\n }\n if (shape.kind === 'observe' && TOPICS.includes(record.topic as WireTopic)) {\n return {\n kind: 'observe',\n id: shape.id,\n topic: record.topic as WireTopic,\n input: record.input as readonly unknown[],\n };\n }\n return null;\n}\n\nexport function answer(message: unknown): WireAnswer | null {\n const shape = body(message);\n if (shape === null) return null;\n const record = message as { value?: unknown; message?: unknown; refusal?: unknown };\n if (shape.kind === 'refusal') {\n return { kind: 'refusal', refusal: record.refusal as ConnectionRefusal };\n }\n if (shape.kind === 'ended') return { kind: 'ended' };\n if (typeof shape.id !== 'number') return null;\n if (shape.kind === 'result') return { kind: 'result', id: shape.id, value: record.value };\n if (shape.kind === 'event') return { kind: 'event', id: shape.id, value: record.value };\n if (shape.kind === 'failure' && typeof record.message === 'string') {\n return { kind: 'failure', id: shape.id, message: record.message };\n }\n return null;\n}\n"],"names":["RUNTIME_WIRE_PROTOCOL","PROTOCOL_MISMATCH","reason","reauthorizationOffered","refusal","MEMBERS","TOPICS","AUTHORIZATION_ENDED","envelope","message","mdRuntime","carried","data","record","matching","body","kind","id","request","shape","Array","isArray","input","includes","member","topic","answer","value"],"mappings":"AAEA,OAAO,MAAMA,wBAAwB,EAAE;AAEvC,OAAO,MAAMC,oBAAuC;IAClDC,QAAQ;IACRC,wBAAwB;IACxBC,SAAS;AACX,EAAE;AAQF,MAAMC,UAAU;IACd;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,MAAMC,SAAS;IACb;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAkBD,OAAO,MAAMC,sBAAsB,+BAA+B;AAMlE,OAAO,SAASC,SAASC,OAAiC;IACxD,OAAO;QAAEC,WAAWV;QAAuBS;IAAQ;AACrD;AAEA,OAAO,SAASE,QAAQC,IAAa;IACnC,IAAI,OAAOA,SAAS,YAAYA,SAAS,QAAQ,CAAE,CAAA,eAAeA,IAAG,GAAI,OAAO;IAChF,MAAMC,SAASD;IACf,OAAO;QAAEE,UAAUD,OAAOH,SAAS,KAAKV;QAAuBS,SAASI,OA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AIe,MAAMH,IAAI,KAAK,SAAS,OAAO;QAAEA,MAAM;IAAQ;IACnD,IAAI,OAAOG,MAAMF,EAAE,KAAK,UAAU,OAAO;IACzC,IAAIE,MAAMH,IAAI,KAAK,UAAU,OAAO;QAAEA,MAAM;QAAUC,IAAIE,MAAMF,EAAE;QAAEU,OAAOd,OAAOc,KAAK;IAAC;IACxF,IAAIR,MAAMH,IAAI,KAAK,SAAS,OAAO;QAAEA,MAAM;QAASC,IAAIE,MAAMF,EAAE;QAAEU,OAAOd,OAAOc,KAAK;IAAC;IACtF,IAAIR,MAAMH,IAAI,KAAK,aAAa,OAAOH,OAAOJ,OAAO,KAAK,UAAU;QAClE,OAAO;YAAEO,MAAM;YAAWC,IAAIE,MAAMF,EAAE;YAAER,SAASI,OAAOJ,OAAO;QAAC;IAClE;IACA,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentshouse/mdruntime",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.25",
|
|
4
4
|
"description": "The headless core of MD App",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,6 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@agentshouse/mdmodel": "0.1.0-alpha.14",
|
|
49
|
-
"@
|
|
49
|
+
"@tanstack/db": "0.9.2"
|
|
50
50
|
}
|
|
51
51
|
}
|