@agentshouse/mdruntime 0.1.0-c49444f2a8fc6 → 0.1.0-c4c5934c45f21
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/README.md +8 -8
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +308 -0
- package/dist/act-lanes.d.ts +33 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +177 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +31 -44
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +19 -13
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -14
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +200 -75
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +104 -5308
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +249 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +43 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +906 -1024
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +148 -0
- package/dist/durability.d.ts +9 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +45 -12
- package/dist/index.d.ts +22 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/install.d.ts +54 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +538 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +272 -0
- package/dist/listing.d.ts +48 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +139 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +7 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +33 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +50 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -4
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -20
- package/dist/messages.d.ts +1 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -32
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +156 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +59 -0
- package/dist/outcome.d.ts +4 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -51
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +14 -111
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +233 -0
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +270 -0
- package/dist/query.d.ts +10 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +5 -1
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts +3 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +38 -8
- package/dist/react.d.ts +18 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -1
- package/dist/readiness.d.ts +0 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +37 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +174 -0
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +57 -0
- package/dist/replica.d.ts +5 -13
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +34 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +232 -112
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +413 -0
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +32 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +290 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +67 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +170 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +212 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +430 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +112 -204
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +158 -394
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +28 -14
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +223 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +521 -0
- package/dist/tables.d.ts +32 -8
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +43 -12
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +48 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +16 -3
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
package/dist/memory.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type SavedFacts, type HeadChange, type ListedAgent, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode, type TypedPath } from './adapter.js';
|
|
3
|
-
export type MemoryRoom = DiscoveredRoom & {
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type SavedFacts, type HeadChange, type ListedAgent, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode, type TypedPath, type TypedSelection } from './adapter.js';
|
|
3
|
+
export type MemoryRoom = Omit<DiscoveredRoom, 'typedSelection' | 'authoredPaths'> & {
|
|
4
|
+
typedSelection?: TypedSelection | null;
|
|
5
|
+
authoredPaths?: readonly string[];
|
|
4
6
|
model?: ModelResult;
|
|
5
7
|
documents?: Readonly<Record<string, string>>;
|
|
6
8
|
facts?: Readonly<Record<string, SavedFacts>>;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EAIZ,KAAK,UAAU,EAMf,KAAK,UAAU,EACf,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAKtB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,UAAU,EAGf,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAGX,KAAK,aAAa,EAIlB,KAAK,SAAS,EAGd,K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entshouse/mdmodel';
|
|
2
2
|
import { NO_ROOM_TYPES, schemaTypes } from './attached-model.js';
|
|
3
3
|
import { sameChange } from './overlay.js';
|
|
4
4
|
const ATTACHMENTS = 'attachments';
|
|
@@ -53,7 +53,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
53
53
|
const listeners = new Set();
|
|
54
54
|
const modeObservers = new Set();
|
|
55
55
|
const scripted = new Map();
|
|
56
|
-
const
|
|
56
|
+
const repeats = new Map();
|
|
57
57
|
const historyPageSize = options.historyPageSize;
|
|
58
58
|
const attached = new Map();
|
|
59
59
|
const linked = new WeakMap();
|
|
@@ -113,7 +113,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
113
113
|
}
|
|
114
114
|
const key = `${path}\u0000${content}`;
|
|
115
115
|
if (!held.has(key)) {
|
|
116
|
-
const facts = documentFacts(path, parse(content, path
|
|
116
|
+
const facts = documentFacts(path, parse(content, path, definitionAt({ types }, path, options.typedPaths)), {
|
|
117
|
+
types,
|
|
118
|
+
});
|
|
117
119
|
held.set(key, facts === null ? null : JSON.parse(JSON.stringify(facts)));
|
|
118
120
|
}
|
|
119
121
|
return held.get(key);
|
|
@@ -147,8 +149,9 @@ export function createMemoryAdapter(options = {}) {
|
|
|
147
149
|
roomVersion: room.roomVersion,
|
|
148
150
|
operations: room.operations,
|
|
149
151
|
replica: room.replica,
|
|
150
|
-
|
|
152
|
+
typedSelection: room.typedSelection ?? null,
|
|
151
153
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
154
|
+
authoredPaths: room.authoredPaths ?? ['**'],
|
|
152
155
|
};
|
|
153
156
|
}
|
|
154
157
|
function page(room, after) {
|
|
@@ -258,16 +261,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
258
261
|
}
|
|
259
262
|
function pageOf(conversation, after) {
|
|
260
263
|
const messages = conversation.messages ?? [];
|
|
261
|
-
const first = typeof after === 'string' ? messages.findIndex((message) => message.
|
|
264
|
+
const first = typeof after === 'string' ? messages.findIndex((message) => message.change > after) : 0;
|
|
262
265
|
const from = first === -1 ? messages.length : first;
|
|
263
266
|
const page = messages.slice(from, from + (historyPageSize ?? messages.length));
|
|
264
267
|
const last = page.at(-1);
|
|
265
268
|
return {
|
|
266
269
|
conversation: conversation.conversation,
|
|
267
270
|
messages: page,
|
|
268
|
-
...(last !== undefined && from + page.length < messages.length
|
|
269
|
-
? { next: last.position }
|
|
270
|
-
: {}),
|
|
271
|
+
...(last !== undefined && from + page.length < messages.length ? { next: last.change } : {}),
|
|
271
272
|
};
|
|
272
273
|
}
|
|
273
274
|
function historiesOf(request) {
|
|
@@ -287,11 +288,20 @@ export function createMemoryAdapter(options = {}) {
|
|
|
287
288
|
function conversationAction(request) {
|
|
288
289
|
const name = request.name;
|
|
289
290
|
const input = (request.input ?? {});
|
|
291
|
+
const operation = typeof input.operation_id === 'string' ? `${name}\u0000${input.operation_id}` : null;
|
|
292
|
+
const first = (answer) => {
|
|
293
|
+
if (operation !== null)
|
|
294
|
+
repeats.set(operation, answer);
|
|
295
|
+
return answer;
|
|
296
|
+
};
|
|
297
|
+
const repeated = operation === null ? undefined : repeats.get(operation);
|
|
290
298
|
if (name === 'conversations/create') {
|
|
299
|
+
if (repeated !== undefined)
|
|
300
|
+
return repeated;
|
|
291
301
|
issued += 1;
|
|
292
302
|
const conversation = `conversation-${issued}`;
|
|
293
303
|
scripted.set(conversation, { conversation });
|
|
294
|
-
return { kind: 'action', result: { conversation_id: conversation } };
|
|
304
|
+
return first({ kind: 'action', result: { conversation_id: conversation } });
|
|
295
305
|
}
|
|
296
306
|
const named = typeof input.conversation_id === 'string' ? input.conversation_id : '';
|
|
297
307
|
const conversation = scripted.get(named);
|
|
@@ -307,24 +317,30 @@ export function createMemoryAdapter(options = {}) {
|
|
|
307
317
|
if (outcome !== undefined)
|
|
308
318
|
return outcome;
|
|
309
319
|
if (name === 'conversations/send') {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (answered !== undefined)
|
|
313
|
-
return { kind: 'action', result: { message_id: answered } };
|
|
320
|
+
if (repeated !== undefined)
|
|
321
|
+
return repeated;
|
|
314
322
|
issued += 1;
|
|
315
|
-
|
|
316
|
-
if (operation !== null)
|
|
317
|
-
sentTurns.set(operation, turn);
|
|
318
|
-
return { kind: 'action', result: { message_id: turn } };
|
|
323
|
+
return first({ kind: 'action', result: { message_id: `turn-${issued}` } });
|
|
319
324
|
}
|
|
320
325
|
if (name === 'conversations/delete')
|
|
321
326
|
scripted.delete(named);
|
|
322
327
|
return { kind: 'action', result: { conversation_id: named } };
|
|
323
328
|
}
|
|
329
|
+
function decided(request) {
|
|
330
|
+
const { request: asked, message, decision, } = (request.input ?? {});
|
|
331
|
+
return {
|
|
332
|
+
kind: 'action',
|
|
333
|
+
result: {
|
|
334
|
+
request: asked,
|
|
335
|
+
...(message === undefined ? {} : { message }),
|
|
336
|
+
state: decision === 'approve' ? 'started' : 'declined',
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
324
340
|
function announceList() {
|
|
325
341
|
const entries = [...scripted.values()].flatMap(({ conversation, listed, messages = [] }) => listed === undefined
|
|
326
342
|
? []
|
|
327
|
-
: [{ conversation, ...listed, newest: messages.at(-1)?.
|
|
343
|
+
: [{ conversation, ...listed, newest: messages.at(-1)?.change ?? null }]);
|
|
328
344
|
for (const listener of listeners) {
|
|
329
345
|
listener({ kind: 'list', entries, whole: true, more: false, cursor: null });
|
|
330
346
|
}
|
|
@@ -598,7 +614,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
598
614
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
599
615
|
const blob = heldBlob(room, request.path);
|
|
600
616
|
return blob === undefined
|
|
601
|
-
? { kind: 'rejected', code: '
|
|
617
|
+
? { kind: 'rejected', code: 'not_found', fields: {}, retryable: false }
|
|
602
618
|
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
603
619
|
}, request);
|
|
604
620
|
},
|
|
@@ -609,7 +625,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
609
625
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
610
626
|
const blob = heldBlob(room, request.path);
|
|
611
627
|
if (blob === undefined) {
|
|
612
|
-
return { kind: 'rejected', code: '
|
|
628
|
+
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
613
629
|
}
|
|
614
630
|
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
615
631
|
linked.set(blob, url);
|
|
@@ -630,6 +646,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
630
646
|
return resolveScript(scripts.action, () => {
|
|
631
647
|
if (request.name.startsWith('conversations/'))
|
|
632
648
|
return conversationAction(request);
|
|
649
|
+
if (request.name === 'agent-functions/decide')
|
|
650
|
+
return decided(request);
|
|
633
651
|
return { kind: 'rejected', code: 'unscripted-action', fields: {}, retryable: false };
|
|
634
652
|
}, request).then((answer) => {
|
|
635
653
|
if (answer.kind === 'action' && answer.at !== undefined)
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
-
import type { JobMarker } from './job.js';
|
|
3
2
|
import type { Connection } from './tables.js';
|
|
4
3
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
5
|
-
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n
|
|
6
|
-
export declare const JOB_MARKERS = "SELECT json_extract(part.value, '$.text') AS said,\n json_extract(message, '$.accepted_at') AS at\n FROM conversation_messages, json_each(message, '$.parts') AS part\n WHERE conversation = ? AND instr(message, '\"marker\":\"job\"') > 0\n AND json_extract(part.value, '$.type') = 'marker'\n AND json_extract(part.value, '$.marker') = 'job'\n ORDER BY position, identity, part.key";
|
|
4
|
+
export declare const ROWS = "WITH chosen AS (\n SELECT listed.value AS conversation,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'assistant' ORDER BY position DESC, identity DESC LIMIT 1) AS answer,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND text <> '' ORDER BY position DESC, identity DESC LIMIT 1) AS said,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' ORDER BY position, identity LIMIT 1) AS opened,\n (SELECT id FROM conversation_messages WHERE conversation = listed.value AND json_extract(message, '$.role') = 'house' AND json_extract(message, '$.waiting') = 1 ORDER BY position, identity LIMIT 1) AS asking\n FROM json_each(?) AS listed\n )\n SELECT chosen.conversation AS conversation,\n substr(said.text, 1, 512) AS said_text,\n json_extract(said.message, '$.role') AS said_role,\n json_extract(said.message, '$.accepted_at') AS said_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n json_extract(opened.message, '$.source') AS opened_source,\n json_extract(opened.message, '$.sender') AS opened_sender,\n asking.identity AS asking_identity,\n asking.text AS asking_text,\n json_extract(asking.message, '$.accepted_at') AS asking_at,\n json_extract(asking.message, '$.source') AS asking_source,\n json_extract(asking.message, '$.sender') AS asking_sender\n FROM chosen\n LEFT JOIN conversation_messages said ON said.id = chosen.said\n LEFT JOIN conversation_messages answer ON answer.id = chosen.answer\n LEFT JOIN conversation_messages opened ON opened.id = chosen.opened\n LEFT JOIN conversation_messages asking ON asking.id = chosen.asking";
|
|
7
5
|
export type HeldConversation = {
|
|
8
6
|
readonly conversation: string;
|
|
9
7
|
readonly read: string | null | undefined;
|
|
@@ -45,7 +43,6 @@ export declare function keptMessages(connection: Connection, { conversation, mes
|
|
|
45
43
|
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
46
44
|
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
47
45
|
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
48
|
-
export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
|
|
49
46
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
50
47
|
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
51
48
|
export declare function forgottenMessages(connection: Connection): void;
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAQF,eAAO,MAAM,IAAI,qwDAwBqD,CAAC;AAEvE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM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AQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3E,CAAC;AAMF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GACtC,gBAAgB,EAAE,CA0BpB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,iBAAiB,GAClD,IAAI,CAsBN;AAmBD,wBAAgB,aAAa,CAC3B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EACxC,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,aAAa,CAWf;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,MAAM,CAOR;AAaD,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,OAAO,EAAE,CAuBX;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAU9F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAG9D"}
|
package/dist/messages.js
CHANGED
|
@@ -2,15 +2,13 @@ import { sql } from '@agentshouse/mdmodel';
|
|
|
2
2
|
import { EXCERPT } from './read.js';
|
|
3
3
|
const SAID_BY_HOUSE = `json_extract(message, '$.role') = 'house'`;
|
|
4
4
|
const ANSWERS_THE_TURN = `json_extract(message, '$.role') = 'assistant'`;
|
|
5
|
-
const MARKS_A_JOB = `instr(message, '"marker":"job"') > 0`;
|
|
6
5
|
export const MESSAGE_TABLES = [
|
|
7
6
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
8
|
-
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
7
|
+
'CREATE TABLE conversation_messages (id INTEGER PRIMARY KEY, conversation TEXT NOT NULL, identity TEXT NOT NULL, turn TEXT NOT NULL, position TEXT NOT NULL, change TEXT NOT NULL, message TEXT NOT NULL, text TEXT NOT NULL)',
|
|
9
8
|
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
10
9
|
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
11
10
|
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
12
11
|
`CREATE INDEX conversation_messages_house ON conversation_messages (conversation, position, identity) WHERE ${SAID_BY_HOUSE}`,
|
|
13
|
-
`CREATE INDEX conversation_messages_jobs ON conversation_messages (conversation, position, identity) WHERE ${MARKS_A_JOB}`,
|
|
14
12
|
];
|
|
15
13
|
const NEWEST_FIRST = 'ORDER BY position DESC, identity DESC LIMIT 1';
|
|
16
14
|
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
@@ -31,7 +29,7 @@ export const ROWS = `WITH chosen AS (
|
|
|
31
29
|
json_extract(opened.message, '$.source') AS opened_source,
|
|
32
30
|
json_extract(opened.message, '$.sender') AS opened_sender,
|
|
33
31
|
asking.identity AS asking_identity,
|
|
34
|
-
|
|
32
|
+
asking.text AS asking_text,
|
|
35
33
|
json_extract(asking.message, '$.accepted_at') AS asking_at,
|
|
36
34
|
json_extract(asking.message, '$.source') AS asking_source,
|
|
37
35
|
json_extract(asking.message, '$.sender') AS asking_sender
|
|
@@ -40,13 +38,6 @@ export const ROWS = `WITH chosen AS (
|
|
|
40
38
|
LEFT JOIN conversation_messages answer ON answer.id = chosen.answer
|
|
41
39
|
LEFT JOIN conversation_messages opened ON opened.id = chosen.opened
|
|
42
40
|
LEFT JOIN conversation_messages asking ON asking.id = chosen.asking`;
|
|
43
|
-
export const JOB_MARKERS = `SELECT json_extract(part.value, '$.text') AS said,
|
|
44
|
-
json_extract(message, '$.accepted_at') AS at
|
|
45
|
-
FROM conversation_messages, json_each(message, '$.parts') AS part
|
|
46
|
-
WHERE conversation = ? AND ${MARKS_A_JOB}
|
|
47
|
-
AND json_extract(part.value, '$.type') = 'marker'
|
|
48
|
-
AND json_extract(part.value, '$.marker') = 'job'
|
|
49
|
-
ORDER BY position, identity, part.key`;
|
|
50
41
|
function text(value) {
|
|
51
42
|
return typeof value === 'string' ? value : String(value);
|
|
52
43
|
}
|
|
@@ -72,19 +63,15 @@ export function heldConversations(connection, conversations) {
|
|
|
72
63
|
}
|
|
73
64
|
export function keptMessages(connection, { conversation, messages, read }) {
|
|
74
65
|
for (const message of messages) {
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, change, message, text) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (conversation, identity) DO UPDATE SET turn = excluded.turn, position = excluded.position, change = excluded.change, message = excluded.message, text = excluded.text', [
|
|
67
|
+
conversation,
|
|
68
|
+
message.identity,
|
|
77
69
|
message.turn,
|
|
78
70
|
message.position,
|
|
71
|
+
message.change,
|
|
79
72
|
JSON.stringify(message.message ?? null),
|
|
80
73
|
message.text,
|
|
81
|
-
];
|
|
82
|
-
if (held === undefined) {
|
|
83
|
-
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, held.id]);
|
|
87
|
-
}
|
|
74
|
+
]);
|
|
88
75
|
}
|
|
89
76
|
if (read !== undefined) {
|
|
90
77
|
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
@@ -96,6 +83,7 @@ function accepted(row) {
|
|
|
96
83
|
identity: text(row.identity),
|
|
97
84
|
turn: text(row.turn),
|
|
98
85
|
position: text(row.position),
|
|
86
|
+
change: text(row.change),
|
|
99
87
|
text: text(row.text),
|
|
100
88
|
message: JSON.parse(text(row.message)),
|
|
101
89
|
};
|
|
@@ -107,7 +95,7 @@ function holding(phrase) {
|
|
|
107
95
|
}
|
|
108
96
|
export function messageWindow(connection, conversation, limit, before, phrase) {
|
|
109
97
|
const held = holding(phrase);
|
|
110
|
-
const rows = connection.rows(`SELECT identity, turn, position, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
98
|
+
const rows = connection.rows(`SELECT identity, turn, position, change, message, text FROM conversation_messages WHERE conversation = ?${held.sql}${before === null ? '' : ' AND (position < ? OR (position = ? AND identity < ?))'} ORDER BY position DESC, identity DESC LIMIT ?`, before === null
|
|
111
99
|
? [conversation, ...held.bind, limit + 1]
|
|
112
100
|
: [conversation, ...held.bind, before[0], before[0], before[1], limit + 1]);
|
|
113
101
|
return { messages: rows.slice(0, limit).map(accepted).reverse(), more: rows.length > limit };
|
|
@@ -118,11 +106,11 @@ export function messageCount(connection, conversation, phrase) {
|
|
|
118
106
|
return Number(counted?.held ?? 0);
|
|
119
107
|
}
|
|
120
108
|
function textOrNull(value) {
|
|
121
|
-
return value === null
|
|
109
|
+
return value === null ? null : text(value);
|
|
122
110
|
}
|
|
123
111
|
function heldSource(source, sender) {
|
|
124
112
|
return {
|
|
125
|
-
source: source === null
|
|
113
|
+
source: source === null ? null : JSON.parse(text(source)),
|
|
126
114
|
sender: textOrNull(sender),
|
|
127
115
|
};
|
|
128
116
|
}
|
|
@@ -148,19 +136,13 @@ export function conversationRows(connection, conversations) {
|
|
|
148
136
|
},
|
|
149
137
|
}));
|
|
150
138
|
}
|
|
151
|
-
export function jobMarkers(connection, conversation) {
|
|
152
|
-
return connection
|
|
153
|
-
.rows(JOB_MARKERS, [conversation])
|
|
154
|
-
.map((row) => ({ said: text(row.said), at: text(row.at) }));
|
|
155
|
-
}
|
|
156
139
|
export function turnArrived(connection, conversation, turn) {
|
|
157
140
|
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
158
141
|
}
|
|
159
142
|
export function droppedMessages(connection, conversations) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
143
|
+
const named = [JSON.stringify(conversations)];
|
|
144
|
+
connection.run('DELETE FROM conversation_messages WHERE conversation IN (SELECT value FROM json_each(?))', named);
|
|
145
|
+
connection.run('DELETE FROM conversation_reads WHERE conversation IN (SELECT value FROM json_each(?))', named);
|
|
164
146
|
}
|
|
165
147
|
export function forgottenMessages(connection) {
|
|
166
148
|
connection.run('DELETE FROM conversation_messages');
|
package/dist/model.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ export type ValidationReceipt = {
|
|
|
50
50
|
source: Open<'current' | 'cached'>;
|
|
51
51
|
};
|
|
52
52
|
export declare const NO_MODEL: ModelState;
|
|
53
|
-
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
54
53
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
55
54
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
56
55
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d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SAAS,GAAG,QAAQ,CAAC,CAAC;CACpC,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,UAA8D,CAAC;AACtF,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAczD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D"}
|
package/dist/model.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
export const NO_MODEL = { status: 'unavailable', reason: 'not-acquired' };
|
|
2
|
-
export function definitionOf(state, type) {
|
|
3
|
-
if (state.status === 'unavailable' || type === undefined)
|
|
4
|
-
return undefined;
|
|
5
|
-
return Object.hasOwn(state.types, type) ? state.types[type] : undefined;
|
|
6
|
-
}
|
|
7
2
|
export function modelTypes(state) {
|
|
8
3
|
return state.status === 'unavailable'
|
|
9
4
|
? { ...state, types: null }
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RoomDeclaration, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import { type ModelState } from './model.js';
|
|
3
|
+
import type { Runtime } from './runtime.js';
|
|
4
|
+
import type { RuntimeStore } from './store.js';
|
|
5
|
+
export declare function revoked(model: ModelState | undefined): boolean;
|
|
6
|
+
export declare function retainModel(runtime: Runtime, locator: string, declaration: RoomDeclaration, given: ModelState | null, refused?: true): Promise<void>;
|
|
7
|
+
export declare function scoped(runtime: Runtime, result: ScopedRefusal, locator: string, declaration: RoomDeclaration): Promise<void>;
|
|
8
|
+
export declare function settleModels(runtime: Runtime, held: ReadonlyMap<string, RoomDeclaration>, status: 'current' | 'cached', local: RuntimeStore): Promise<void>;
|
|
9
|
+
export declare function cachedModels(runtime: Runtime, local: RuntimeStore): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAOnE,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAc,YAAY,EAAS,MAAM,YAAY,CAAC;AAMlE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAE9D;AA0DD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,EAC5B,KAAK,EAAE,UAAU,GAAG,IAAI,EACxB,OAAO,CAAC,EAAE,IAAI,iBA2Bf;AAED,wBAAsB,MAAM,CAC1B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,eAAe,iBAoB7B;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,EAC1C,MAAM,EAAE,SAAS,GAAG,QAAQ,EAC5B,KAAK,EAAE,YAAY,iBA+CpB;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvF"}
|
package/dist/models.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import { changeSet } from './change-set.js';
|
|
3
|
+
import { composedOf } from './collection.js';
|
|
4
|
+
import { declared, sameDeclaration } from './declaration.js';
|
|
5
|
+
import { uncaught } from './failure.js';
|
|
6
|
+
import { declarationOf, listedLocators } from './listing.js';
|
|
7
|
+
import { loseRooms } from './lost.js';
|
|
8
|
+
import { NO_MODEL } from './model.js';
|
|
9
|
+
import { settle } from './queue.js';
|
|
10
|
+
import { storedRecord } from './replica.js';
|
|
11
|
+
import { emitRooms } from './shown.js';
|
|
12
|
+
function declaredAsHeld(held, declaration) {
|
|
13
|
+
return held === undefined || sameDeclaration(held.declaration, declaration);
|
|
14
|
+
}
|
|
15
|
+
export function revoked(model) {
|
|
16
|
+
return model?.status === 'unavailable' && model.reason === 'revoked';
|
|
17
|
+
}
|
|
18
|
+
function unheldModelOf({ presence }, locator) {
|
|
19
|
+
return presence.unheldModel(locator) ?? NO_MODEL;
|
|
20
|
+
}
|
|
21
|
+
async function modelNow(runtime, locator) {
|
|
22
|
+
return (await runtime.store.record(locator))?.model ?? unheldModelOf(runtime, locator);
|
|
23
|
+
}
|
|
24
|
+
function restands(held, model, declaration) {
|
|
25
|
+
return (JSON.stringify(held.model) !== JSON.stringify(model) ||
|
|
26
|
+
!equalValue(held.declaration.typedSelection, declaration.typedSelection));
|
|
27
|
+
}
|
|
28
|
+
function recordAlone(store, record) {
|
|
29
|
+
return {
|
|
30
|
+
locator: record.locator,
|
|
31
|
+
key: record.key,
|
|
32
|
+
record: storedRecord(record),
|
|
33
|
+
composed: composedOf(store.composed(record)),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function unheld(runtime, locator, model) {
|
|
37
|
+
runtime.presence.modelled(locator, model);
|
|
38
|
+
emitRooms(runtime);
|
|
39
|
+
}
|
|
40
|
+
function recorded(runtime, locator, declaration, model) {
|
|
41
|
+
const { store, socket } = runtime;
|
|
42
|
+
return store.exclusive(async () => {
|
|
43
|
+
if (!socket.continuing())
|
|
44
|
+
return;
|
|
45
|
+
const current = await store.record(locator);
|
|
46
|
+
if (current === undefined) {
|
|
47
|
+
unheld(runtime, locator, model);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const answer = await (await store.open()).commit({ rooms: [recordAlone(store, { ...current, declaration, model })] });
|
|
51
|
+
void store.changed(changeSet(locator, {
|
|
52
|
+
documents: answer.changed[locator] ?? [],
|
|
53
|
+
room: true,
|
|
54
|
+
unindexed: answer.indexed[locator] === false,
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export async function retainModel(runtime, locator, declaration, given, refused) {
|
|
59
|
+
const { store, socket } = runtime;
|
|
60
|
+
const held = await store.record(locator);
|
|
61
|
+
const previous = held?.model ?? unheldModelOf(runtime, locator);
|
|
62
|
+
const next = given ?? previous;
|
|
63
|
+
if (JSON.stringify(previous) === JSON.stringify(next) && declaredAsHeld(held, declaration))
|
|
64
|
+
return;
|
|
65
|
+
if (held !== undefined && !restands(held, next, declaration)) {
|
|
66
|
+
await recorded(runtime, locator, declaration, next);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
await settle(runtime, [locator], async (works) => {
|
|
70
|
+
if (!socket.continuing())
|
|
71
|
+
return [];
|
|
72
|
+
const current = works.get(locator)?.replica;
|
|
73
|
+
if (current === undefined) {
|
|
74
|
+
unheld(runtime, locator, next);
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
locator,
|
|
80
|
+
record: { ...current.record, declaration, model: next },
|
|
81
|
+
...(refused === undefined ? {} : { refused }),
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export async function scoped(runtime, result, locator, declaration) {
|
|
87
|
+
const { socket, presence, journal } = runtime;
|
|
88
|
+
if (result.scope === 'content' && !result.retryable) {
|
|
89
|
+
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
90
|
+
await loseRooms(runtime, [locator]);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
presence.refused(locator, result);
|
|
94
|
+
if (result.scope === 'model')
|
|
95
|
+
await retainModel(runtime, locator, declaration, { status: 'unavailable', reason: 'not-readable' }, true);
|
|
96
|
+
if (!socket.continuing())
|
|
97
|
+
return;
|
|
98
|
+
emitRooms(runtime);
|
|
99
|
+
journal.record(`scoped refusal ${locator} ${result.scope} ${result.code}`);
|
|
100
|
+
}
|
|
101
|
+
export async function settleModels(runtime, held, status, local) {
|
|
102
|
+
const { store, socket, presence, journal } = runtime;
|
|
103
|
+
const owed = (model) => model.status !== 'unavailable' && model.status !== status;
|
|
104
|
+
const declaredAnew = await store.exclusive(async () => {
|
|
105
|
+
if (!socket.continuing())
|
|
106
|
+
return [];
|
|
107
|
+
const stored = await store.rooms([...held.keys()]);
|
|
108
|
+
const unchanged = [...held].filter(([locator, declaration]) => {
|
|
109
|
+
const record = stored.get(locator)?.record;
|
|
110
|
+
return (owed(record?.model ?? unheldModelOf(runtime, locator)) &&
|
|
111
|
+
declaredAsHeld(record, declaration));
|
|
112
|
+
});
|
|
113
|
+
const records = unchanged.flatMap(([locator]) => {
|
|
114
|
+
const record = stored.get(locator)?.record;
|
|
115
|
+
return record === undefined
|
|
116
|
+
? []
|
|
117
|
+
: [{ ...record, model: { ...record.model, status } }];
|
|
118
|
+
});
|
|
119
|
+
if (records.length > 0) {
|
|
120
|
+
try {
|
|
121
|
+
await local.commit({ rooms: records.map((record) => recordAlone(store, record)) });
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
journal.record(`model ${status} persistence failed`);
|
|
125
|
+
uncaught(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
for (const [locator] of unchanged) {
|
|
129
|
+
const unheldModel = presence.unheldModel(locator);
|
|
130
|
+
if (!stored.has(locator) && unheldModel !== null) {
|
|
131
|
+
presence.modelled(locator, { ...unheldModel, status });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (unchanged.length > 0)
|
|
135
|
+
emitRooms(runtime);
|
|
136
|
+
const kept = new Set(unchanged.map(([locator]) => locator));
|
|
137
|
+
return [...held].filter(([locator]) => !kept.has(locator) &&
|
|
138
|
+
owed(stored.get(locator)?.record.model ?? unheldModelOf(runtime, locator)));
|
|
139
|
+
});
|
|
140
|
+
for (const [locator, declaration] of declaredAnew) {
|
|
141
|
+
const model = await modelNow(runtime, locator);
|
|
142
|
+
if (owed(model))
|
|
143
|
+
await retainModel(runtime, locator, declaration, { ...model, status });
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export async function cachedModels(runtime, local) {
|
|
147
|
+
const { store, presence } = runtime;
|
|
148
|
+
const held = await store.rooms();
|
|
149
|
+
await settleModels(runtime, new Map(listedLocators(runtime, held).flatMap((locator) => {
|
|
150
|
+
const discovered = presence.room(locator);
|
|
151
|
+
const declaration = discovered === undefined
|
|
152
|
+
? declarationOf(runtime, locator, held.get(locator))?.room
|
|
153
|
+
: declared(discovered);
|
|
154
|
+
return declaration === undefined ? [] : [[locator, declaration]];
|
|
155
|
+
})), 'cached', local);
|
|
156
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observation.d.ts","sourceRoot":"","sources":["../src/observation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExF,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,IAAI,CAAC,CAAC;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACpD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,CAAC,CAAC,EAAE,CAAC;IACpE,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAChC,QAAQ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AAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,IAAI,CA+BjF"}
|
package/dist/observation.js
CHANGED
|
@@ -90,24 +90,19 @@ export function opened(watch, keyed) {
|
|
|
90
90
|
return new Promise((resolve, reject) => {
|
|
91
91
|
let handle;
|
|
92
92
|
let stop = () => { };
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
stop();
|
|
105
|
-
reject(error);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
93
|
+
stop = watch((message) => {
|
|
94
|
+
if (handle !== undefined) {
|
|
95
|
+
handle.receive(message);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
handle = observed(message, () => stop(), keyed);
|
|
99
|
+
resolve(handle.observation);
|
|
100
|
+
}, (error) => {
|
|
101
|
+
if (handle !== undefined)
|
|
102
|
+
return;
|
|
103
|
+
stop();
|
|
109
104
|
reject(error);
|
|
110
|
-
}
|
|
105
|
+
});
|
|
111
106
|
});
|
|
112
107
|
}
|
|
113
108
|
export function observing(watch) {
|
package/dist/opened.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export type OpenedFiles = {
|
|
|
18
18
|
find(name: OpenedName): Promise<KeptBinary | null>;
|
|
19
19
|
fetch(name: OpenedName, read: () => Promise<BinaryResult>): Promise<KeptResult>;
|
|
20
20
|
};
|
|
21
|
-
export declare function openedFiles(database: RuntimeDatabase,
|
|
21
|
+
export declare function openedFiles(database: RuntimeDatabase, lost: (locator: string) => boolean): OpenedFiles;
|
|
22
22
|
//# sourceMappingURL=opened.d.ts.map
|
package/dist/opened.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opened.d.ts","sourceRoot":"","sources":["../src/opened.ts"],"names":[],"mappings":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