@agentshouse/mdruntime 0.1.0-cf1e7fdb9c600 → 0.1.0-cf281e8224a5d
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 +9 -9
- package/dist/acceptance.d.ts +6 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +385 -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 +24 -25
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +8 -4
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +207 -76
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/change.d.ts +1 -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 +18 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -2
- package/dist/compile.d.ts +5 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +202 -80
- package/dist/connection.d.ts +5 -141
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +101 -5280
- package/dist/conversation-live.d.ts +136 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +248 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +29 -35
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +838 -840
- package/dist/discovery.d.ts +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +175 -0
- package/dist/durability.d.ts +15 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +4 -3
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- 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 +1 -0
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +11 -4
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +20 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/install.d.ts +56 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +554 -0
- package/dist/job.d.ts +20 -1
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +26 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +268 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +176 -0
- package/dist/live.d.ts +4 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +52 -16
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +61 -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 +61 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +3 -3
- package/dist/memory.d.ts +3 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +45 -6
- package/dist/messages.d.ts +25 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +89 -16
- package/dist/model.d.ts +1 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -6
- package/dist/models.d.ts +14 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +195 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +57 -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 +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +11 -0
- package/dist/parts.d.ts +60 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +126 -0
- 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 +226 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +10 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/reach.d.ts +8 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +159 -100
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- 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 +171 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +9 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +8 -20
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +55 -0
- package/dist/replica.d.ts +7 -7
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +51 -19
- package/dist/room-draft.d.ts +2 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +3 -3
- 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 +14 -5
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +50 -58
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +5 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +21 -20
- package/dist/saves.d.ts +70 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +1005 -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 +31 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +292 -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/rooms.d.ts +44 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -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 +70 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- 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 +431 -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 +107 -153
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -396
- package/dist/stored.d.ts +59 -65
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +255 -149
- 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 +532 -0
- package/dist/tables.d.ts +114 -51
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +209 -57
- 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 +4 -4
- package/dist/wire.d.ts +16 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +6 -0
- package/package.json +2 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
package/dist/locks.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { emitRooms, LOCKS_TOPIC } from './shown.js';
|
|
2
|
+
async function offlineModes({ store, socket }) {
|
|
3
|
+
const modes = new Map();
|
|
4
|
+
for (const [locator, { room }] of socket.rooms.declarations()) {
|
|
5
|
+
const declaration = room ?? socket.rooms.discovered(locator);
|
|
6
|
+
if (declaration !== undefined)
|
|
7
|
+
modes.set(locator, declaration.replica.offline);
|
|
8
|
+
}
|
|
9
|
+
for (const [locator, { offline }] of (await store.covering()).rooms)
|
|
10
|
+
modes.set(locator, offline);
|
|
11
|
+
return modes;
|
|
12
|
+
}
|
|
13
|
+
export async function locked({ store, socket }, locator) {
|
|
14
|
+
if (store.fences.has(locator) || socket.rooms.standing(locator).confirmed)
|
|
15
|
+
return false;
|
|
16
|
+
const held = socket.rooms.declared(locator)?.room ?? socket.rooms.discovered(locator);
|
|
17
|
+
const mode = (await (await store.open()).offline(locator)) ?? held?.replica.offline;
|
|
18
|
+
return mode === 'locked';
|
|
19
|
+
}
|
|
20
|
+
export async function lockedRooms(runtime) {
|
|
21
|
+
const { store, socket } = runtime;
|
|
22
|
+
return [...(await offlineModes(runtime))]
|
|
23
|
+
.filter(([locator, mode]) => mode === 'locked' &&
|
|
24
|
+
!socket.rooms.standing(locator).confirmed &&
|
|
25
|
+
!store.fences.has(locator))
|
|
26
|
+
.map(([locator]) => locator)
|
|
27
|
+
.sort();
|
|
28
|
+
}
|
|
29
|
+
export async function relocked(runtime, before) {
|
|
30
|
+
const after = await lockedRooms(runtime);
|
|
31
|
+
if (JSON.stringify(after) === JSON.stringify(before))
|
|
32
|
+
return;
|
|
33
|
+
runtime.journal.record(`locked ${after.length}`);
|
|
34
|
+
emitRooms(runtime);
|
|
35
|
+
runtime.store.tell(LOCKS_TOPIC, undefined);
|
|
36
|
+
}
|
|
37
|
+
export function confirmLocks({ socket }, listed) {
|
|
38
|
+
if (!socket.isOpen())
|
|
39
|
+
return;
|
|
40
|
+
for (const room of listed) {
|
|
41
|
+
if (room.replica.admission === 'admitted') {
|
|
42
|
+
socket.rooms.stand(room.locator, { confirmed: true });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function connectionLost(runtime) {
|
|
47
|
+
const { socket } = runtime;
|
|
48
|
+
if (socket.closed())
|
|
49
|
+
return;
|
|
50
|
+
socket.rooms.connectionLost(() => {
|
|
51
|
+
if (socket.isOpen() || socket.closed())
|
|
52
|
+
return;
|
|
53
|
+
void lockedRooms(runtime).then((before) => {
|
|
54
|
+
socket.rooms.standAll({ confirmed: false });
|
|
55
|
+
return relocked(runtime, before);
|
|
56
|
+
}, () => { });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
export function watchLocks({ store }, notify) {
|
|
60
|
+
return store.watch(LOCKS_TOPIC, notify).stop;
|
|
61
|
+
}
|
package/dist/log.d.ts
CHANGED
package/dist/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS;IAGrB,MAAM,QAAQ,MAAM;IAIpB,MAAM;EAIT"}
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS;IAGrB,MAAM,QAAQ,MAAM;IAIpB,MAAM;EAIT;AAED,MAAM,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
package/dist/lost.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Runtime } from './runtime.js';
|
|
2
|
+
export declare function eraseFenced({ store }: Runtime, locators: readonly string[]): Promise<void>;
|
|
3
|
+
export declare function fenceLive(runtime: Runtime, locators: readonly string[]): void;
|
|
4
|
+
export declare function loseRooms(runtime: Runtime, locators: readonly string[]): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=lost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lost.d.ts","sourceRoot":"","sources":["../src/lost.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBAIhF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,QAOtE;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,iBAqC5E"}
|
package/dist/lost.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
2
|
+
import { ERASE_BATCH, forgetInstall } from './install.js';
|
|
3
|
+
import { recoverReads, statusShown } from './shown.js';
|
|
4
|
+
import { yielded } from './turn.js';
|
|
5
|
+
function forget({ store, socket }, locator) {
|
|
6
|
+
forgetInstall(store, locator);
|
|
7
|
+
socket.rooms.forget(locator);
|
|
8
|
+
store.forget(locator);
|
|
9
|
+
}
|
|
10
|
+
export async function eraseFenced({ store }, locators) {
|
|
11
|
+
for (const locator of locators) {
|
|
12
|
+
while (await store.durably((local) => local.erase(locator, ERASE_BATCH)))
|
|
13
|
+
await yielded();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function fenceLive(runtime, locators) {
|
|
17
|
+
const { store, socket, journal } = runtime;
|
|
18
|
+
for (const locator of new Set(locators)) {
|
|
19
|
+
if (!store.fences.raise(locator, socket.session.now().discoveries))
|
|
20
|
+
continue;
|
|
21
|
+
forget(runtime, locator);
|
|
22
|
+
journal.record(`room lost ${locator}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function loseRooms(runtime, locators) {
|
|
26
|
+
const { store } = runtime;
|
|
27
|
+
fenceLive(runtime, locators);
|
|
28
|
+
const fresh = [...new Set(locators)].filter((locator) => {
|
|
29
|
+
const fence = store.fences.of(locator);
|
|
30
|
+
if (fence === undefined || fence.written)
|
|
31
|
+
return false;
|
|
32
|
+
store.fences.mark(locator, true);
|
|
33
|
+
return true;
|
|
34
|
+
});
|
|
35
|
+
if (fresh.length === 0)
|
|
36
|
+
return;
|
|
37
|
+
let held = [];
|
|
38
|
+
try {
|
|
39
|
+
await store.durably(async (local) => {
|
|
40
|
+
held = await local.roomDrafts();
|
|
41
|
+
await local.fence(fresh);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
for (const locator of fresh)
|
|
46
|
+
store.fences.mark(locator, false);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
store.changed(mergeChangeSets(fresh.map((locator) => changeSet(locator, {
|
|
51
|
+
documents: null,
|
|
52
|
+
room: true,
|
|
53
|
+
queue: true,
|
|
54
|
+
drafts: held.filter((draft) => draft.locator === locator).map(({ path }) => path),
|
|
55
|
+
}))));
|
|
56
|
+
recoverReads(runtime);
|
|
57
|
+
statusShown(runtime);
|
|
58
|
+
}
|
|
59
|
+
await store.durably((local) => runtime.unpair(local));
|
|
60
|
+
await eraseFenced(runtime, fresh);
|
|
61
|
+
}
|
package/dist/media.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { type ShownAnswer } from './outcome.js';
|
|
|
3
3
|
export declare const ROOM_MEDIA = "room-media";
|
|
4
4
|
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
5
|
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
-
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient): void;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=media.d.ts.map
|
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAsBD,wBAAgB,eAAe,
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,UAAU,eAAe,CAAC;AAwBvC,KAAK,IAAI,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAIpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAG5E;AAsBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CA0LxF"}
|
package/dist/media.js
CHANGED
|
@@ -37,8 +37,8 @@ function drawnFor(mediaType) {
|
|
|
37
37
|
return 'audio';
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
export function defineRoomMedia(client
|
|
41
|
-
if (
|
|
40
|
+
export function defineRoomMedia(client) {
|
|
41
|
+
if (customElements.get(ROOM_MEDIA) !== undefined)
|
|
42
42
|
return;
|
|
43
43
|
const connected = Promise.resolve(client);
|
|
44
44
|
class RoomMedia extends HTMLElement {
|
|
@@ -214,5 +214,5 @@ export function defineRoomMedia(client, registry = customElements) {
|
|
|
214
214
|
void this.#load();
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
|
|
217
|
+
customElements.define(ROOM_MEDIA, RoomMedia);
|
|
218
218
|
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
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 HeadChange, type ListedAgent, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode, type TypedPath } from './adapter.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
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
documents?: Readonly<Record<string, string>>;
|
|
6
|
+
facts?: Readonly<Record<string, SavedFacts>>;
|
|
6
7
|
revisions?: Readonly<Record<string, string>>;
|
|
7
8
|
fileIds?: Readonly<Record<string, string>>;
|
|
9
|
+
created?: Readonly<Record<string, string>>;
|
|
8
10
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
11
|
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
12
|
folders?: readonly string[];
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"
|
|
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,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAuBtB,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC3C,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/C,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EA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CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAAC;IAC7C,gBAAgB,CAAC,aAAa,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI,CAAC;IACrE,MAAM,CAAC,SAAS,EAAE,MAAM,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACxD,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACzF,MAAM,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,sBAAsB,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3D,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnD,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3C,SAAS,IAAI,SAAS,MAAM,EAAE,CAAC;IAC/B,uBAAuB,IAAI,SAAS,MAAM,EAAE,CAAC;IAC7C,sBAAsB,IAAI,MAAM,GAAG,IAAI,CAAC;CACzC,CAAC;AA0CF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAipBrF"}
|
package/dist/memory.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { documentFacts, parse } from '@agentshouse/mdmodel';
|
|
2
|
+
import { NO_ROOM_TYPES, schemaTypes } from './attached-model.js';
|
|
1
3
|
import { sameChange } from './overlay.js';
|
|
2
4
|
const ATTACHMENTS = 'attachments';
|
|
3
5
|
function lastName(path) {
|
|
@@ -5,7 +7,6 @@ function lastName(path) {
|
|
|
5
7
|
}
|
|
6
8
|
const FIXTURE_RETENTION = {
|
|
7
9
|
history: { kind: 'duration', seconds: 1 },
|
|
8
|
-
outcome: 604_800,
|
|
9
10
|
refreshHorizon: 1,
|
|
10
11
|
};
|
|
11
12
|
function declaredRetention(value) {
|
|
@@ -102,8 +103,35 @@ export function createMemoryAdapter(options = {}) {
|
|
|
102
103
|
return path;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
106
|
+
const saved = new WeakMap();
|
|
107
|
+
function factsAt(room, path, content) {
|
|
108
|
+
const types = schemaTypes(room.model?.kind === 'model' ? room.model.snapshot.schema : null, NO_ROOM_TYPES);
|
|
109
|
+
let held = saved.get(types);
|
|
110
|
+
if (held === undefined) {
|
|
111
|
+
held = new Map();
|
|
112
|
+
saved.set(types, held);
|
|
113
|
+
}
|
|
114
|
+
const key = `${path}\u0000${content}`;
|
|
115
|
+
if (!held.has(key)) {
|
|
116
|
+
const facts = documentFacts(path, parse(content, path), { types });
|
|
117
|
+
held.set(key, facts === null ? null : JSON.parse(JSON.stringify(facts)));
|
|
118
|
+
}
|
|
119
|
+
return held.get(key);
|
|
120
|
+
}
|
|
121
|
+
function factsIn(room, paths) {
|
|
122
|
+
const facts = {};
|
|
123
|
+
for (const path of paths) {
|
|
124
|
+
const content = room.documents?.[path];
|
|
125
|
+
const held = room.facts?.[path] ?? (content === undefined ? null : factsAt(room, path, content));
|
|
126
|
+
if (held !== null)
|
|
127
|
+
facts[path] = held;
|
|
128
|
+
}
|
|
129
|
+
return facts;
|
|
130
|
+
}
|
|
105
131
|
function retain(entries) {
|
|
106
132
|
for (const room of entries) {
|
|
133
|
+
for (const [path, content] of Object.entries(room.documents ?? {}))
|
|
134
|
+
factsAt(room, path, content);
|
|
107
135
|
note(room.locator, room);
|
|
108
136
|
const versions = served.get(room.locator) ?? new Map();
|
|
109
137
|
versions.set(room.roomVersion, room);
|
|
@@ -121,6 +149,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
121
149
|
replica: room.replica,
|
|
122
150
|
...(room.typedSelection === undefined ? {} : { typedSelection: room.typedSelection }),
|
|
123
151
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
152
|
+
authoredPaths: room.authoredPaths,
|
|
124
153
|
};
|
|
125
154
|
}
|
|
126
155
|
function page(room, after) {
|
|
@@ -136,10 +165,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
136
165
|
roomVersion: room.roomVersion,
|
|
137
166
|
...(opening ? { models: modelsOf(room) } : {}),
|
|
138
167
|
documents: named(room.documents ?? {}, taken),
|
|
168
|
+
facts: factsIn(room, taken),
|
|
139
169
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
140
170
|
...(room.fileIds === undefined
|
|
141
171
|
? {}
|
|
142
172
|
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
173
|
+
...(room.created === undefined
|
|
174
|
+
? {}
|
|
175
|
+
: { created: named(room.created, [...taken, ...targets]) }),
|
|
143
176
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
144
177
|
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
145
178
|
...(opening && room.folders !== undefined ? { folders: room.folders } : {}),
|
|
@@ -163,6 +196,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
163
196
|
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
164
197
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
165
198
|
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
199
|
+
room.created?.[path] !== from.created?.[path] ||
|
|
166
200
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
167
201
|
const changed = Object.keys(current)
|
|
168
202
|
.filter((path) => current[path] !== previous[path] || headMoved(path))
|
|
@@ -183,10 +217,14 @@ export function createMemoryAdapter(options = {}) {
|
|
|
183
217
|
roomVersion: room.roomVersion,
|
|
184
218
|
...(models === undefined ? {} : { models }),
|
|
185
219
|
documents: named(current, taken),
|
|
220
|
+
facts: factsIn(room, taken),
|
|
186
221
|
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
187
222
|
...(room.fileIds === undefined
|
|
188
223
|
? {}
|
|
189
224
|
: { fileIds: named(room.fileIds, [...taken, ...targets]) }),
|
|
225
|
+
...(room.created === undefined
|
|
226
|
+
? {}
|
|
227
|
+
: { created: named(room.created, [...taken, ...targets]) }),
|
|
190
228
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
191
229
|
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
192
230
|
...(opening ? foldersMoved(room, from) : {}),
|
|
@@ -424,9 +462,10 @@ export function createMemoryAdapter(options = {}) {
|
|
|
424
462
|
const named = asked.map((room) => room.locator);
|
|
425
463
|
const unknown = asked.flatMap((room) => {
|
|
426
464
|
const current = rooms.find((entry) => entry.locator === room.locator);
|
|
465
|
+
const version = room.roomVersion;
|
|
427
466
|
return current === undefined ||
|
|
428
|
-
|
|
429
|
-
|
|
467
|
+
(version !== null &&
|
|
468
|
+
(current.roomVersion === version || served.get(room.locator)?.has(version) === true))
|
|
430
469
|
? []
|
|
431
470
|
: [room.locator];
|
|
432
471
|
});
|
|
@@ -436,7 +475,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
436
475
|
expiring = expiring.filter((locator) => !named.includes(locator));
|
|
437
476
|
queueMicrotask(() => {
|
|
438
477
|
for (const room of asked) {
|
|
439
|
-
if (expired.includes(room.locator))
|
|
478
|
+
if (expired.includes(room.locator) || room.roomVersion === null)
|
|
440
479
|
carried.delete(room.locator);
|
|
441
480
|
else {
|
|
442
481
|
carried.set(room.locator, room.roomVersion);
|
|
@@ -560,7 +599,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
560
599
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
561
600
|
const blob = heldBlob(room, request.path);
|
|
562
601
|
return blob === undefined
|
|
563
|
-
? { kind: 'rejected', code: '
|
|
602
|
+
? { kind: 'rejected', code: 'not_found', fields: {}, retryable: false }
|
|
564
603
|
: { kind: 'binary', body: blob.stream(), mediaType: blob.type };
|
|
565
604
|
}, request);
|
|
566
605
|
},
|
|
@@ -571,7 +610,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
571
610
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
572
611
|
const blob = heldBlob(room, request.path);
|
|
573
612
|
if (blob === undefined) {
|
|
574
|
-
return { kind: 'rejected', code: '
|
|
613
|
+
return { kind: 'rejected', code: 'not_found', fields: {}, retryable: false };
|
|
575
614
|
}
|
|
576
615
|
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
577
616
|
linked.set(blob, url);
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
|
+
import type { JobMarker } from './job.js';
|
|
2
3
|
import type { Connection } from './tables.js';
|
|
3
4
|
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 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";
|
|
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
7
|
export type HeldConversation = {
|
|
5
8
|
readonly conversation: string;
|
|
6
9
|
readonly read: string | null | undefined;
|
|
@@ -10,6 +13,25 @@ export type MessageWindow = {
|
|
|
10
13
|
readonly messages: AcceptedMessage[];
|
|
11
14
|
readonly more: boolean;
|
|
12
15
|
};
|
|
16
|
+
export type HeldSource = {
|
|
17
|
+
readonly source: unknown;
|
|
18
|
+
readonly sender: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type HeldRow = {
|
|
21
|
+
readonly conversation: string;
|
|
22
|
+
readonly said: {
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly role: string | null;
|
|
25
|
+
readonly at: string | null;
|
|
26
|
+
} | null;
|
|
27
|
+
readonly failure: string | null;
|
|
28
|
+
readonly opened: HeldSource | null;
|
|
29
|
+
readonly asking: (HeldSource & {
|
|
30
|
+
readonly identity: string;
|
|
31
|
+
readonly text: string;
|
|
32
|
+
readonly at: string | null;
|
|
33
|
+
}) | null;
|
|
34
|
+
};
|
|
13
35
|
export type ConversationWrite = {
|
|
14
36
|
readonly conversation: string;
|
|
15
37
|
readonly messages: readonly AcceptedMessage[];
|
|
@@ -18,10 +40,12 @@ export type ConversationWrite = {
|
|
|
18
40
|
readonly partial: boolean;
|
|
19
41
|
};
|
|
20
42
|
};
|
|
21
|
-
export declare function heldConversations(connection: Connection): HeldConversation[];
|
|
43
|
+
export declare function heldConversations(connection: Connection, conversations: readonly string[] | null): HeldConversation[];
|
|
22
44
|
export declare function keptMessages(connection: Connection, { conversation, messages, read }: ConversationWrite): null;
|
|
23
45
|
export declare function messageWindow(connection: Connection, conversation: string, limit: number, before: readonly [string, string] | null, phrase: string | null): MessageWindow;
|
|
24
46
|
export declare function messageCount(connection: Connection, conversation: string, phrase: string | null): number;
|
|
47
|
+
export declare function conversationRows(connection: Connection, conversations: readonly string[]): HeldRow[];
|
|
48
|
+
export declare function jobMarkers(connection: Connection, conversation: string): JobMarker[];
|
|
25
49
|
export declare function turnArrived(connection: Connection, conversation: string, turn: string): boolean;
|
|
26
50
|
export declare function droppedMessages(connection: Connection, conversations: readonly string[]): void;
|
|
27
51
|
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;AACpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAQ1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;AAQF,eAAO,MAAM,IAAI,qwDAwBqD,CAAC;AA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AiB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAG9D"}
|
package/dist/messages.js
CHANGED
|
@@ -1,24 +1,67 @@
|
|
|
1
1
|
import { sql } from '@agentshouse/mdmodel';
|
|
2
|
+
import { EXCERPT } from './read.js';
|
|
3
|
+
const SAID_BY_HOUSE = `json_extract(message, '$.role') = 'house'`;
|
|
4
|
+
const ANSWERS_THE_TURN = `json_extract(message, '$.role') = 'assistant'`;
|
|
5
|
+
const MARKS_A_JOB = `instr(message, '"marker":"job"') > 0`;
|
|
2
6
|
export const MESSAGE_TABLES = [
|
|
3
7
|
'CREATE TABLE conversation_reads (conversation TEXT PRIMARY KEY, read TEXT, partial INTEGER NOT NULL) WITHOUT ROWID',
|
|
4
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)',
|
|
5
9
|
'CREATE UNIQUE INDEX conversation_messages_identity ON conversation_messages (conversation, identity)',
|
|
6
10
|
'CREATE INDEX conversation_messages_position ON conversation_messages (conversation, position, identity)',
|
|
7
11
|
'CREATE INDEX conversation_messages_turn ON conversation_messages (conversation, turn)',
|
|
12
|
+
`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}`,
|
|
8
14
|
];
|
|
15
|
+
const NEWEST_FIRST = 'ORDER BY position DESC, identity DESC LIMIT 1';
|
|
16
|
+
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
17
|
+
const OF_THE_ROW = 'SELECT id FROM conversation_messages WHERE conversation = listed.value';
|
|
18
|
+
export const ROWS = `WITH chosen AS (
|
|
19
|
+
SELECT listed.value AS conversation,
|
|
20
|
+
(${OF_THE_ROW} AND ${ANSWERS_THE_TURN} ${NEWEST_FIRST}) AS answer,
|
|
21
|
+
(${OF_THE_ROW} AND text <> '' ${NEWEST_FIRST}) AS said,
|
|
22
|
+
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} ${OLDEST_FIRST}) AS opened,
|
|
23
|
+
(${OF_THE_ROW} AND ${SAID_BY_HOUSE} AND json_extract(message, '$.waiting') = 1 ${OLDEST_FIRST}) AS asking
|
|
24
|
+
FROM json_each(?) AS listed
|
|
25
|
+
)
|
|
26
|
+
SELECT chosen.conversation AS conversation,
|
|
27
|
+
substr(said.text, 1, ${EXCERPT}) AS said_text,
|
|
28
|
+
json_extract(said.message, '$.role') AS said_role,
|
|
29
|
+
json_extract(said.message, '$.accepted_at') AS said_at,
|
|
30
|
+
substr(json_extract(answer.message, '$.failure'), 1, ${EXCERPT}) AS failure,
|
|
31
|
+
json_extract(opened.message, '$.source') AS opened_source,
|
|
32
|
+
json_extract(opened.message, '$.sender') AS opened_sender,
|
|
33
|
+
asking.identity AS asking_identity,
|
|
34
|
+
asking.text AS asking_text,
|
|
35
|
+
json_extract(asking.message, '$.accepted_at') AS asking_at,
|
|
36
|
+
json_extract(asking.message, '$.source') AS asking_source,
|
|
37
|
+
json_extract(asking.message, '$.sender') AS asking_sender
|
|
38
|
+
FROM chosen
|
|
39
|
+
LEFT JOIN conversation_messages said ON said.id = chosen.said
|
|
40
|
+
LEFT JOIN conversation_messages answer ON answer.id = chosen.answer
|
|
41
|
+
LEFT JOIN conversation_messages opened ON opened.id = chosen.opened
|
|
42
|
+
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`;
|
|
9
50
|
function text(value) {
|
|
10
51
|
return typeof value === 'string' ? value : String(value);
|
|
11
52
|
}
|
|
12
|
-
export function heldConversations(connection) {
|
|
53
|
+
export function heldConversations(connection, conversations) {
|
|
54
|
+
const named = conversations === null ? '' : ' AND conversation IN (SELECT value FROM json_each(?))';
|
|
55
|
+
const bound = conversations === null ? [] : [JSON.stringify(conversations)];
|
|
13
56
|
const held = new Map();
|
|
14
|
-
for (const row of connection.rows(
|
|
57
|
+
for (const row of connection.rows(`SELECT conversation, read, partial FROM conversation_reads WHERE 1 = 1${named}`, bound)) {
|
|
15
58
|
held.set(text(row.conversation), {
|
|
16
59
|
conversation: text(row.conversation),
|
|
17
60
|
read: row.read === null ? null : text(row.read),
|
|
18
61
|
partial: Number(row.partial) === 1,
|
|
19
62
|
});
|
|
20
63
|
}
|
|
21
|
-
for (const row of connection.rows(
|
|
64
|
+
for (const row of connection.rows(`SELECT DISTINCT conversation FROM conversation_messages WHERE conversation NOT IN (SELECT conversation FROM conversation_reads)${named}`, bound)) {
|
|
22
65
|
held.set(text(row.conversation), {
|
|
23
66
|
conversation: text(row.conversation),
|
|
24
67
|
read: undefined,
|
|
@@ -29,19 +72,14 @@ export function heldConversations(connection) {
|
|
|
29
72
|
}
|
|
30
73
|
export function keptMessages(connection, { conversation, messages, read }) {
|
|
31
74
|
for (const message of messages) {
|
|
32
|
-
|
|
33
|
-
|
|
75
|
+
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT (conversation, identity) DO UPDATE SET turn = excluded.turn, position = excluded.position, message = excluded.message, text = excluded.text', [
|
|
76
|
+
conversation,
|
|
77
|
+
message.identity,
|
|
34
78
|
message.turn,
|
|
35
79
|
message.position,
|
|
36
80
|
JSON.stringify(message.message ?? null),
|
|
37
81
|
message.text,
|
|
38
|
-
];
|
|
39
|
-
if (held === undefined) {
|
|
40
|
-
connection.run('INSERT INTO conversation_messages (conversation, identity, turn, position, message, text) VALUES (?, ?, ?, ?, ?, ?)', [conversation, message.identity, ...record]);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
connection.run('UPDATE conversation_messages SET turn = ?, position = ?, message = ?, text = ? WHERE id = ?', [...record, held.id]);
|
|
44
|
-
}
|
|
82
|
+
]);
|
|
45
83
|
}
|
|
46
84
|
if (read !== undefined) {
|
|
47
85
|
connection.run('INSERT OR REPLACE INTO conversation_reads (conversation, read, partial) VALUES (?, ?, ?)', [conversation, read.at, read.partial ? 1 : 0]);
|
|
@@ -74,14 +112,49 @@ export function messageCount(connection, conversation, phrase) {
|
|
|
74
112
|
const [counted] = connection.rows(`SELECT count(*) AS held FROM conversation_messages WHERE conversation = ?${held.sql}`, [conversation, ...held.bind]);
|
|
75
113
|
return Number(counted?.held ?? 0);
|
|
76
114
|
}
|
|
115
|
+
function textOrNull(value) {
|
|
116
|
+
return value === null ? null : text(value);
|
|
117
|
+
}
|
|
118
|
+
function heldSource(source, sender) {
|
|
119
|
+
return {
|
|
120
|
+
source: source === null ? null : JSON.parse(text(source)),
|
|
121
|
+
sender: textOrNull(sender),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export function conversationRows(connection, conversations) {
|
|
125
|
+
return connection.rows(ROWS, [JSON.stringify(conversations)]).map((row) => ({
|
|
126
|
+
conversation: text(row.conversation),
|
|
127
|
+
said: row.said_text === null
|
|
128
|
+
? null
|
|
129
|
+
: {
|
|
130
|
+
text: text(row.said_text),
|
|
131
|
+
role: textOrNull(row.said_role),
|
|
132
|
+
at: textOrNull(row.said_at),
|
|
133
|
+
},
|
|
134
|
+
failure: textOrNull(row.failure),
|
|
135
|
+
opened: row.opened_source === null ? null : heldSource(row.opened_source, row.opened_sender),
|
|
136
|
+
asking: row.asking_identity === null
|
|
137
|
+
? null
|
|
138
|
+
: {
|
|
139
|
+
...heldSource(row.asking_source, row.asking_sender),
|
|
140
|
+
identity: text(row.asking_identity),
|
|
141
|
+
text: text(row.asking_text),
|
|
142
|
+
at: textOrNull(row.asking_at),
|
|
143
|
+
},
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
export function jobMarkers(connection, conversation) {
|
|
147
|
+
return connection
|
|
148
|
+
.rows(JOB_MARKERS, [conversation])
|
|
149
|
+
.map((row) => ({ said: text(row.said), at: text(row.at) }));
|
|
150
|
+
}
|
|
77
151
|
export function turnArrived(connection, conversation, turn) {
|
|
78
152
|
return (connection.rows('SELECT 1 FROM conversation_messages WHERE conversation = ? AND turn = ? LIMIT 1', [conversation, turn]).length > 0);
|
|
79
153
|
}
|
|
80
154
|
export function droppedMessages(connection, conversations) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
155
|
+
const named = [JSON.stringify(conversations)];
|
|
156
|
+
connection.run('DELETE FROM conversation_messages WHERE conversation IN (SELECT value FROM json_each(?))', named);
|
|
157
|
+
connection.run('DELETE FROM conversation_reads WHERE conversation IN (SELECT value FROM json_each(?))', named);
|
|
85
158
|
}
|
|
86
159
|
export function forgottenMessages(connection) {
|
|
87
160
|
connection.run('DELETE FROM conversation_messages');
|
package/dist/model.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type ModelSnapshot = ModelIdentity & {
|
|
|
8
8
|
schema: string | null;
|
|
9
9
|
revision: string | null;
|
|
10
10
|
};
|
|
11
|
-
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'
|
|
11
|
+
export type ModelUnavailableReason = Open<'not-readable' | 'revoked' | 'not-acquired'>;
|
|
12
12
|
export type ModelResult = {
|
|
13
13
|
kind: 'model';
|
|
14
14
|
snapshot: ModelSnapshot;
|
|
@@ -20,8 +20,6 @@ export type MdType = Definition;
|
|
|
20
20
|
export type ModelState = {
|
|
21
21
|
status: 'unavailable';
|
|
22
22
|
reason: ModelUnavailableReason;
|
|
23
|
-
schema?: string | null;
|
|
24
|
-
revision?: string | null;
|
|
25
23
|
} | {
|
|
26
24
|
status: 'current' | 'cached';
|
|
27
25
|
snapshot: ModelSnapshot;
|
|
@@ -37,8 +35,6 @@ export type TypesResult = {
|
|
|
37
35
|
status: Open<'unavailable'>;
|
|
38
36
|
reason: ModelUnavailableReason;
|
|
39
37
|
types: null;
|
|
40
|
-
schema?: string | null;
|
|
41
|
-
revision?: string | null;
|
|
42
38
|
} | {
|
|
43
39
|
status: Open<'current' | 'cached'>;
|
|
44
40
|
identity: string;
|
|
@@ -57,6 +53,4 @@ export declare const NO_MODEL: ModelState;
|
|
|
57
53
|
export declare function definitionOf(state: ModelState, type: string | undefined): Definition | undefined;
|
|
58
54
|
export declare function modelTypes(state: ModelState): TypesResult;
|
|
59
55
|
export declare function storedModel(state: ModelState): StoredModel;
|
|
60
|
-
export declare function cached(state: ModelState): ModelState;
|
|
61
|
-
export declare function sameModel(left: ModelIdentity, right: ModelIdentity): boolean;
|
|
62
56
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAC/F,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,GAAG,SAAS,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"A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,CAAC,CAAC;IAAC,MAAM,EAAE,sBAAsB,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAC5E;IACE,MAAM,EAAE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,aAAa,CAAC;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB,CAAC;AACN,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC;CACpC,CAAC;AACF,eAAO,MAAM,QAAQ,EAAE,UAA8D,CAAC;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAGhG;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAczD;AACD,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAI1D"}
|
package/dist/model.js
CHANGED
|
@@ -23,9 +23,3 @@ export function storedModel(state) {
|
|
|
23
23
|
const { types: _types, ...stored } = state;
|
|
24
24
|
return stored;
|
|
25
25
|
}
|
|
26
|
-
export function cached(state) {
|
|
27
|
-
return state.status === 'unavailable' ? state : { ...state, status: 'cached' };
|
|
28
|
-
}
|
|
29
|
-
export function sameModel(left, right) {
|
|
30
|
-
return left.identity === right.identity && left.version === right.version;
|
|
31
|
-
}
|
package/dist/models.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScopedRefusal } from './adapter.js';
|
|
2
|
+
import { type ModelState } from './model.js';
|
|
3
|
+
import { type ReplicaRecord } from './replica.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { RoomDeclaration } from './socket.js';
|
|
6
|
+
import type { RuntimeStore } from './store.js';
|
|
7
|
+
export declare function declaredAsHeld(held: ReplicaRecord | undefined, room: RoomDeclaration): boolean;
|
|
8
|
+
export declare function revoked(model: ModelState | undefined): boolean;
|
|
9
|
+
export declare function keepNaming(runtime: Runtime, local: RuntimeStore, room: RoomDeclaration): Promise<void>;
|
|
10
|
+
export declare function retainModel(runtime: Runtime, local: RuntimeStore, room: RoomDeclaration, given: ModelState | null): Promise<void>;
|
|
11
|
+
export declare function scoped(runtime: Runtime, result: ScopedRefusal, room: RoomDeclaration, local: RuntimeStore): Promise<void>;
|
|
12
|
+
export declare function settleModels(runtime: Runtime, held: readonly RoomDeclaration[], status: 'current' | 'cached', local: RuntimeStore): Promise<void>;
|
|
13
|
+
export declare function cachedModels(runtime: Runtime, local: RuntimeStore): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAS9F;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS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