@agentshouse/mdruntime 0.1.0-cdf6e063566ab → 0.1.0-cdf8ca5c0fa11
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 +1 -1
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +30 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +35 -7
- package/dist/adapter.d.ts +71 -16
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts.map +1 -1
- package/dist/authored.js +2 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +2 -2
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +11 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +16 -15
- package/dist/collection.d.ts +1 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +7 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +71 -39
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +5 -3
- package/dist/conversation-live.d.ts +2 -3
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -2
- package/dist/conversation.d.ts +13 -7
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +35 -20
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +1 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +21 -3
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/entry.d.ts +22 -3
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +111 -45
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/host.d.ts +6 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +51 -21
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +16 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +21 -13
- package/dist/listing.d.ts +1 -0
- package/dist/listing.d.ts.map +1 -1
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/loaded.d.ts +5 -3
- package/dist/loaded.d.ts.map +1 -1
- package/dist/loaded.js +12 -6
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +2 -0
- package/dist/media.d.ts +5 -6
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +94 -25
- package/dist/memory.d.ts +2 -2
- package/dist/memory.js +9 -9
- package/dist/messages.d.ts +6 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +10 -1
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +18 -2
- package/dist/outcome.d.ts +21 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +5 -5
- package/dist/overlay.d.ts +19 -8
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/parts.d.ts +3 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +10 -5
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +78 -48
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +75 -53
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +2 -1
- package/dist/reach.d.ts +11 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +97 -23
- package/dist/readiness.d.ts +17 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +17 -7
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +15 -4
- package/dist/reference-forms.d.ts +4 -0
- package/dist/reference-forms.d.ts.map +1 -0
- package/dist/reference-forms.js +74 -0
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +3 -3
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +9 -6
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +8 -6
- package/dist/rows.d.ts +9 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +18 -4
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runtime.d.ts +4 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +6 -6
- package/dist/saves.d.ts +5 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +71 -45
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +17 -4
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +1 -0
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +1 -0
- package/dist/source.d.ts +2 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +2 -0
- package/dist/store/records.d.ts +15 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +12 -4
- package/dist/store.d.ts +3 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -1
- package/dist/stored.d.ts +17 -3
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +138 -31
- package/dist/surface.d.ts +4 -2
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +7 -3
- package/dist/sync.d.ts +2 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +26 -18
- package/dist/tables.d.ts +14 -2
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +10 -3
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +49 -3
- package/dist/wire.d.ts +14 -6
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +12 -11
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
package/dist/live.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAQL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,OAAO,KAAK,EAAE,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C,KAAK,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE5E,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CACzB,IAAI,EAAE,CAAC,EACP,KAAK,EAAE,SAAS,MAAM,EAAE,KACrB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AAEpD,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAmBhD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,EACzB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,IAAI,GACX,MAAM,IAAI,CAAC;IACd,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAWF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAQjE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAEjE;AAyBD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAwKxF"}
|
package/dist/live.js
CHANGED
|
@@ -15,15 +15,24 @@ export function readerOf(plan) {
|
|
|
15
15
|
(named === null || named.has(locator)) &&
|
|
16
16
|
(reached === null || reached.has(locator));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
18
|
+
export function hearerOf(plan) {
|
|
19
|
+
return readerOf(plan.hop === null ? plan : { ...plan, rooms: null });
|
|
20
|
+
}
|
|
21
|
+
function affected({ plan, hears }, set) {
|
|
22
|
+
if (set.rooms.some(hears))
|
|
20
23
|
return true;
|
|
21
24
|
const paths = narrowed(plan) ? new Set(plan.paths) : null;
|
|
22
|
-
return set.documents.some(({ locator, path }) =>
|
|
25
|
+
return set.documents.some(({ locator, path }) => hears(locator) && (paths === null || path === null || paths.has(path)));
|
|
26
|
+
}
|
|
27
|
+
function namingMoved(entry, set) {
|
|
28
|
+
return (entry.awaitsFollowed &&
|
|
29
|
+
(set.rooms.some(entry.reads) || set.documents.some(({ locator }) => entry.reads(locator))));
|
|
30
|
+
}
|
|
31
|
+
function coverShown(cover) {
|
|
32
|
+
return JSON.stringify('pending' in cover ? cover : [cover.coverage, cover.follows]);
|
|
23
33
|
}
|
|
24
34
|
function shown(entry, held) {
|
|
25
|
-
|
|
26
|
-
return JSON.stringify('pending' in cover ? cover : cover.coverage);
|
|
35
|
+
return coverShown(entry.cover(held));
|
|
27
36
|
}
|
|
28
37
|
export function createLiveQueries(run, holding) {
|
|
29
38
|
const entries = new Map();
|
|
@@ -31,11 +40,13 @@ export function createLiveQueries(run, holding) {
|
|
|
31
40
|
let recoveringNow = false;
|
|
32
41
|
let recoveringAll = false;
|
|
33
42
|
const recovering = new Set();
|
|
34
|
-
function deliver(entry, next) {
|
|
43
|
+
function deliver(entry, next, cover) {
|
|
35
44
|
const previous = entry.digest;
|
|
36
45
|
entry.digest = digestOf(next);
|
|
37
46
|
entry.pending = 'pending' in entry.digest ? entry.digest.pending : null;
|
|
38
|
-
entry.
|
|
47
|
+
entry.awaitsFollowed =
|
|
48
|
+
'pending' in next.result && next.result.pending.some(({ room }) => !entry.reads(room));
|
|
49
|
+
entry.covered = coverShown(cover);
|
|
39
50
|
const change = previous === undefined ? null : changeOf(previous, next);
|
|
40
51
|
if (change !== null) {
|
|
41
52
|
for (const listener of entry.ready)
|
|
@@ -48,10 +59,10 @@ export function createLiveQueries(run, holding) {
|
|
|
48
59
|
entry.fresh.clear();
|
|
49
60
|
}
|
|
50
61
|
async function delivered(entry) {
|
|
51
|
-
const { current, ...next } = await run(entry.plan, async () => entry.cover(await holding()));
|
|
62
|
+
const { current, cover, ...next } = await run(entry.plan, async () => entry.cover(await holding()));
|
|
52
63
|
if (closed || entry.listeners.size === 0)
|
|
53
64
|
return null;
|
|
54
|
-
deliver(entry, next);
|
|
65
|
+
deliver(entry, next, cover);
|
|
55
66
|
return current;
|
|
56
67
|
}
|
|
57
68
|
function schedule(entry) {
|
|
@@ -89,7 +100,11 @@ export function createLiveQueries(run, holding) {
|
|
|
89
100
|
}
|
|
90
101
|
function pendingMoved(entry, held, rooms) {
|
|
91
102
|
const { pending } = entry;
|
|
92
|
-
if (pending === null ||
|
|
103
|
+
if (pending === null ||
|
|
104
|
+
pending.size === 0 ||
|
|
105
|
+
entry.running ||
|
|
106
|
+
entry.fresh.size > 0 ||
|
|
107
|
+
entry.awaitsFollowed) {
|
|
93
108
|
return false;
|
|
94
109
|
}
|
|
95
110
|
const at = entry.pendingAt(held, rooms);
|
|
@@ -120,7 +135,7 @@ export function createLiveQueries(run, holding) {
|
|
|
120
135
|
const touched = [...recovering];
|
|
121
136
|
recoveringAll = false;
|
|
122
137
|
recovering.clear();
|
|
123
|
-
const reached = [...entries.values()].filter((entry) => all || touched.some(entry.
|
|
138
|
+
const reached = [...entries.values()].filter((entry) => all || touched.some(entry.hears));
|
|
124
139
|
for (const entry of reached) {
|
|
125
140
|
if (entry.running)
|
|
126
141
|
entry.dirty = true;
|
|
@@ -154,7 +169,7 @@ export function createLiveQueries(run, holding) {
|
|
|
154
169
|
for (const entry of entries.values()) {
|
|
155
170
|
if (!affected(entry, set))
|
|
156
171
|
continue;
|
|
157
|
-
if (entry.pending === null || entry.running) {
|
|
172
|
+
if (entry.pending === null || entry.running || namingMoved(entry, set)) {
|
|
158
173
|
schedule(entry);
|
|
159
174
|
continue;
|
|
160
175
|
}
|
|
@@ -173,6 +188,7 @@ export function createLiveQueries(run, holding) {
|
|
|
173
188
|
entry = {
|
|
174
189
|
plan,
|
|
175
190
|
reads: readerOf(plan),
|
|
191
|
+
hears: hearerOf(plan),
|
|
176
192
|
cover,
|
|
177
193
|
pendingAt,
|
|
178
194
|
listeners: new Set(),
|
|
@@ -180,6 +196,7 @@ export function createLiveQueries(run, holding) {
|
|
|
180
196
|
ready: new Set(),
|
|
181
197
|
digest: undefined,
|
|
182
198
|
pending: null,
|
|
199
|
+
awaitsFollowed: false,
|
|
183
200
|
covered: '',
|
|
184
201
|
dirty: false,
|
|
185
202
|
running: false,
|
package/dist/loaded.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { BuildFile } from './client.js';
|
|
2
|
-
export declare function
|
|
1
|
+
import type { BuildFile, BuiltFile } from './client.js';
|
|
2
|
+
export declare function atAddress<T>(file: BuiltFile, use: (address: string) => Promise<T>): Promise<T>;
|
|
3
|
+
export declare function importedFile(file: BuiltFile | null): Promise<unknown>;
|
|
4
|
+
export declare function parsed(file: BuiltFile | null): Promise<unknown>;
|
|
3
5
|
export declare function perBuild<T>(buildFile: BuildFile, key: string, make: () => Promise<T>): Promise<T>;
|
|
4
|
-
export declare function loaded<T>(buildFile: BuildFile, name: string, read?: (file:
|
|
6
|
+
export declare function loaded<T>(buildFile: BuildFile, name: string, read?: (file: BuiltFile | null) => Promise<unknown>): Promise<T | null>;
|
|
5
7
|
//# sourceMappingURL=loaded.d.ts.map
|
package/dist/loaded.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loaded.d.ts","sourceRoot":"","sources":["../src/loaded.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"loaded.d.ts","sourceRoot":"","sources":["../src/loaded.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxD,wBAAsB,SAAS,CAAC,CAAC,EAC/B,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAErE;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAIrE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAYjG;AAED,wBAAgB,MAAM,CAAC,CAAC,EACtB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,KAAK,OAAO,CAAC,OAAO,CAAgB,GAChE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAEnB"}
|
package/dist/loaded.js
CHANGED
|
@@ -7,19 +7,25 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
9
|
const holdings = new WeakMap();
|
|
10
|
-
async function
|
|
11
|
-
if (file ===
|
|
12
|
-
return
|
|
10
|
+
export async function atAddress(file, use) {
|
|
11
|
+
if (typeof file === 'string')
|
|
12
|
+
return use(file);
|
|
13
13
|
const address = URL.createObjectURL(file);
|
|
14
14
|
try {
|
|
15
|
-
return await
|
|
15
|
+
return await use(address);
|
|
16
16
|
}
|
|
17
17
|
finally {
|
|
18
18
|
URL.revokeObjectURL(address);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
export function importedFile(file) {
|
|
22
|
+
return file === null ? Promise.resolve(null) : atAddress(file, (address) => import(__rewriteRelativeImportExtension(address)));
|
|
23
|
+
}
|
|
21
24
|
export async function parsed(file) {
|
|
22
|
-
|
|
25
|
+
if (file === null)
|
|
26
|
+
return null;
|
|
27
|
+
const text = typeof file === 'string' ? await (await fetch(file)).text() : await file.text();
|
|
28
|
+
return JSON.parse(text);
|
|
23
29
|
}
|
|
24
30
|
export function perBuild(buildFile, key, make) {
|
|
25
31
|
let named = holdings.get(buildFile);
|
|
@@ -35,6 +41,6 @@ export function perBuild(buildFile, key, make) {
|
|
|
35
41
|
making.catch(() => named.delete(key));
|
|
36
42
|
return making;
|
|
37
43
|
}
|
|
38
|
-
export function loaded(buildFile, name, read =
|
|
44
|
+
export function loaded(buildFile, name, read = importedFile) {
|
|
39
45
|
return perBuild(buildFile, name, () => buildFile(name).then(read));
|
|
40
46
|
}
|
package/dist/locks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"locks.d.ts","sourceRoot":"","sources":["../src/locks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG5C,wBAAsB,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAE5F;AAED,wBAAsB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAI1F;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,iBAKzE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,QAU9C;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAE7E"}
|
package/dist/locks.js
CHANGED
|
@@ -4,6 +4,8 @@ export async function locked({ store, presence }, locator) {
|
|
|
4
4
|
return presence.locked(locator, async () => (await store.open()).offline(locator));
|
|
5
5
|
}
|
|
6
6
|
export async function lockedRooms({ store, presence }) {
|
|
7
|
+
if (!store.needed())
|
|
8
|
+
return [];
|
|
7
9
|
const { rooms, locking } = await store.covering();
|
|
8
10
|
return presence.lockedAmong(rooms, locking);
|
|
9
11
|
}
|
package/dist/media.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import { type DownloadAnswer
|
|
2
|
+
import { type DownloadAnswer } from './outcome.js';
|
|
3
3
|
export declare const ROOM_MEDIA = "room-media";
|
|
4
4
|
export declare const KEYED_MEDIA = "ahc-attachment";
|
|
5
5
|
export declare const MEDIA = "room-media, ahc-attachment";
|
|
6
6
|
export declare const DIAGRAM = "md-diagram";
|
|
7
7
|
export declare const VIEWING = "ahc-viewer";
|
|
8
|
-
type
|
|
9
|
-
export type MediaAt = {
|
|
10
|
-
readonly link: string;
|
|
11
|
-
} | {
|
|
8
|
+
type RoomAt = {
|
|
12
9
|
readonly room: string;
|
|
13
10
|
readonly path: string;
|
|
14
11
|
readonly revision: string | undefined;
|
|
15
12
|
};
|
|
16
|
-
export
|
|
13
|
+
export type MediaAt = {
|
|
14
|
+
readonly link: string;
|
|
15
|
+
} | RoomAt;
|
|
17
16
|
export declare function mediaAt(media: Element): MediaAt | null;
|
|
18
17
|
export declare function mediaTag(at: MediaAt): string;
|
|
19
18
|
export declare function downloadAt(client: MdRuntimeClient, at: MediaAt): Promise<DownloadAnswer>;
|
package/dist/media.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAA6B,KAAK,cAAc,EAAoB,MAAM,cAAc,CAAC;AAGhG,eAAO,MAAM,UAAU,eAAe,CAAC;AAEvC,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,eAAO,MAAM,KAAK,+BAAkC,CAAC;AAMrD,eAAO,MAAM,OAAO,eAAe,CAAC;AAEpC,eAAO,MAAM,OAAO,eAAe,CAAC;AAkCpC,KAAK,MAAM,GAAG;IACZ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC;AAEzD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAUtD;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAIxF;AA0DD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAElD;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAMlD;AA0CD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAEtE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,GAAG,IAAI,CAyOxF"}
|
package/dist/media.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAudioType, isImageType, isVideoType } from '@agentshouse/mdmodel';
|
|
2
2
|
import { loaded } from './loaded.js';
|
|
3
3
|
import { downloadAttachment } from './download.js';
|
|
4
|
-
import {
|
|
4
|
+
import { attachmentBlob, UNCERTAIN } from './outcome.js';
|
|
5
5
|
export const ROOM_MEDIA = 'room-media';
|
|
6
6
|
export const KEYED_MEDIA = 'ahc-attachment';
|
|
7
7
|
export const MEDIA = `${ROOM_MEDIA}, ${KEYED_MEDIA}`;
|
|
@@ -25,11 +25,6 @@ const STYLE = `:host{display:block}
|
|
|
25
25
|
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}
|
|
26
26
|
[part=play]{position:absolute;top:50%;left:50%;width:56px;height:56px;margin:-28px 0 0 -28px;border-radius:50%;background:rgb(0 0 0/.6);pointer-events:none}
|
|
27
27
|
[part=play]::before{content:"";position:absolute;top:18px;left:22px;border-style:solid;border-width:10px 0 10px 16px;border-color:transparent transparent transparent #fff}`;
|
|
28
|
-
const shows = new WeakMap();
|
|
29
|
-
export function shownBy(show, client) {
|
|
30
|
-
shows.set(client, show);
|
|
31
|
-
return client;
|
|
32
|
-
}
|
|
33
28
|
export function mediaAt(media) {
|
|
34
29
|
if (media.localName === KEYED_MEDIA) {
|
|
35
30
|
const link = media.getAttribute('link');
|
|
@@ -47,22 +42,42 @@ export function mediaTag(at) {
|
|
|
47
42
|
export function downloadAt(client, at) {
|
|
48
43
|
return 'link' in at
|
|
49
44
|
? downloadAttachment(client, at.link)
|
|
50
|
-
: client.
|
|
45
|
+
: client.attachment.download(at.room, at.path, at.revision);
|
|
51
46
|
}
|
|
52
47
|
function shownAt(client, at) {
|
|
53
48
|
if (at === null)
|
|
54
49
|
return null;
|
|
55
|
-
if ('link' in at)
|
|
56
|
-
return client.conversation
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
if ('link' in at) {
|
|
51
|
+
return client.conversation
|
|
52
|
+
.attachment(at.link)
|
|
53
|
+
.then((shown) => (shown.kind === 'link' ? { ...shown, copies: [] } : shown));
|
|
54
|
+
}
|
|
55
|
+
return client.attachment.show(at.room, at.path, at.revision);
|
|
59
56
|
}
|
|
60
57
|
function ratioOf(width, height) {
|
|
61
58
|
const across = Number(width);
|
|
62
59
|
const down = Number(height);
|
|
63
60
|
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
64
61
|
? `${across} / ${down}`
|
|
65
|
-
:
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
function ownRatio(found, at) {
|
|
65
|
+
const record = 'documents' in found ? found.documents[0]?.attachment : undefined;
|
|
66
|
+
if (record?.state !== 'accepted' ||
|
|
67
|
+
(at.revision !== undefined && record.revision !== at.revision)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return ratioOf(record.width, record.height);
|
|
71
|
+
}
|
|
72
|
+
function offered(drawn, box, copies) {
|
|
73
|
+
if (copies.length === 0) {
|
|
74
|
+
drawn.removeAttribute('srcset');
|
|
75
|
+
drawn.removeAttribute('sizes');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const across = Math.ceil(box.getBoundingClientRect().width);
|
|
79
|
+
drawn.sizes = across > 0 ? `${across}px` : '100vw';
|
|
80
|
+
drawn.srcset = copies.map(({ url, width }) => `${url} ${width}w`).join(', ');
|
|
66
81
|
}
|
|
67
82
|
function refusedForGood(shown) {
|
|
68
83
|
if (shown.kind === 'revoked-authorization')
|
|
@@ -88,14 +103,25 @@ export function viewable(element) {
|
|
|
88
103
|
return false;
|
|
89
104
|
return (rendered(element) || (element.shadowRoot?.querySelector('[part=box] > video') ?? null) !== null);
|
|
90
105
|
}
|
|
91
|
-
function viewed(client, opener, alone) {
|
|
92
|
-
void loaded(client.buildFile, VIEWER).then((file) =>
|
|
93
|
-
opener
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
function viewed(client, opener, alone, taken = () => true) {
|
|
107
|
+
void loaded(client.buildFile, VIEWER).then((file) => {
|
|
108
|
+
if (!opener.isConnected || !taken())
|
|
109
|
+
return;
|
|
110
|
+
file?.openViewer({
|
|
111
|
+
opener,
|
|
112
|
+
alone,
|
|
113
|
+
download: (at) => void downloadAt(client, at),
|
|
114
|
+
});
|
|
115
|
+
});
|
|
97
116
|
}
|
|
98
117
|
function pressed(client) {
|
|
118
|
+
let latest = null;
|
|
119
|
+
const taken = (opener) => () => {
|
|
120
|
+
if (latest !== opener)
|
|
121
|
+
return false;
|
|
122
|
+
latest = null;
|
|
123
|
+
return true;
|
|
124
|
+
};
|
|
99
125
|
return (event) => {
|
|
100
126
|
if (event.defaultPrevented || event.detail > 1)
|
|
101
127
|
return;
|
|
@@ -104,7 +130,8 @@ function pressed(client) {
|
|
|
104
130
|
continue;
|
|
105
131
|
if (viewable(node)) {
|
|
106
132
|
event.preventDefault();
|
|
107
|
-
|
|
133
|
+
latest = node;
|
|
134
|
+
void client.then((one) => viewed(one, node, !rendered(node), taken(node)));
|
|
108
135
|
return;
|
|
109
136
|
}
|
|
110
137
|
if (node.matches(PRESSED_ELSEWHERE))
|
|
@@ -133,6 +160,9 @@ export function defineRoomMedia(client) {
|
|
|
133
160
|
#drawn = null;
|
|
134
161
|
#loaded = false;
|
|
135
162
|
#relinked = 0;
|
|
163
|
+
#failedAt = 0;
|
|
164
|
+
#own = null;
|
|
165
|
+
#measuring = null;
|
|
136
166
|
constructor() {
|
|
137
167
|
super();
|
|
138
168
|
this.#box.setAttribute('part', 'box');
|
|
@@ -149,17 +179,21 @@ export function defineRoomMedia(client) {
|
|
|
149
179
|
void this.#load();
|
|
150
180
|
}, { rootMargin: NEARING });
|
|
151
181
|
this.#watching.observe(this);
|
|
182
|
+
this.#measure();
|
|
152
183
|
}
|
|
153
184
|
disconnectedCallback() {
|
|
154
185
|
this.#watching?.disconnect();
|
|
155
186
|
this.#watching = null;
|
|
156
187
|
this.#near = false;
|
|
157
188
|
this.#asked += 1;
|
|
189
|
+
this.#measure();
|
|
158
190
|
this.#show(null);
|
|
159
191
|
}
|
|
160
192
|
attributeChangedCallback(name, before, after) {
|
|
161
193
|
if (before === after)
|
|
162
194
|
return;
|
|
195
|
+
if (LOADING.has(name))
|
|
196
|
+
this.#measure();
|
|
163
197
|
this.#shape();
|
|
164
198
|
if (this.isConnected)
|
|
165
199
|
this.#label();
|
|
@@ -169,7 +203,28 @@ export function defineRoomMedia(client) {
|
|
|
169
203
|
void this.#load();
|
|
170
204
|
}
|
|
171
205
|
#shape() {
|
|
172
|
-
this.#box.style.aspectRatio =
|
|
206
|
+
this.#box.style.aspectRatio =
|
|
207
|
+
ratioOf(this.getAttribute('width'), this.getAttribute('height')) ?? this.#own ?? SHAPE;
|
|
208
|
+
}
|
|
209
|
+
#measure() {
|
|
210
|
+
void this.#measuring?.then((measured) => measured.close(), () => undefined);
|
|
211
|
+
this.#measuring = null;
|
|
212
|
+
this.#own = null;
|
|
213
|
+
const at = mediaAt(this);
|
|
214
|
+
if (this.#watching === null || at === null || 'link' in at)
|
|
215
|
+
return;
|
|
216
|
+
const measuring = connected.then((one) => one.observe('query', { rooms: [at.room], paths: [at.path], select: {} }));
|
|
217
|
+
this.#measuring = measuring;
|
|
218
|
+
void measuring.then((measured) => {
|
|
219
|
+
const heard = () => {
|
|
220
|
+
if (this.#measuring !== measuring)
|
|
221
|
+
return;
|
|
222
|
+
this.#own = ownRatio(measured.current(), at);
|
|
223
|
+
this.#shape();
|
|
224
|
+
};
|
|
225
|
+
measured.subscribe(heard);
|
|
226
|
+
heard();
|
|
227
|
+
}, () => undefined);
|
|
173
228
|
}
|
|
174
229
|
#label() {
|
|
175
230
|
const alt = this.getAttribute('alt') ?? '';
|
|
@@ -193,7 +248,7 @@ export function defineRoomMedia(client) {
|
|
|
193
248
|
if (asked !== this.#asked)
|
|
194
249
|
return;
|
|
195
250
|
if (shown?.kind === 'link') {
|
|
196
|
-
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
251
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType, shown.copies);
|
|
197
252
|
return;
|
|
198
253
|
}
|
|
199
254
|
if (shown?.kind !== 'binary') {
|
|
@@ -203,13 +258,13 @@ export function defineRoomMedia(client) {
|
|
|
203
258
|
this.#unshown(asked);
|
|
204
259
|
return;
|
|
205
260
|
}
|
|
206
|
-
const copy = await
|
|
261
|
+
const copy = await attachmentBlob(shown).catch(() => null);
|
|
207
262
|
if (asked !== this.#asked)
|
|
208
263
|
return;
|
|
209
264
|
if (copy === null)
|
|
210
265
|
this.#unshown(asked);
|
|
211
266
|
else
|
|
212
|
-
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
267
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType, []);
|
|
213
268
|
}
|
|
214
269
|
#unshown(asked) {
|
|
215
270
|
this.#unreadable();
|
|
@@ -235,7 +290,7 @@ export function defineRoomMedia(client) {
|
|
|
235
290
|
#unreadable() {
|
|
236
291
|
this.#show(null, this.#fallback);
|
|
237
292
|
}
|
|
238
|
-
#draw(shown, mediaType) {
|
|
293
|
+
#draw(shown, mediaType, copies) {
|
|
239
294
|
const tag = drawnFor(mediaType);
|
|
240
295
|
if (tag === null) {
|
|
241
296
|
if (shown.copy)
|
|
@@ -261,12 +316,25 @@ export function defineRoomMedia(client) {
|
|
|
261
316
|
if (drawn !== this.#drawn)
|
|
262
317
|
return;
|
|
263
318
|
this.#loaded = true;
|
|
264
|
-
|
|
319
|
+
if (drawn instanceof HTMLImageElement)
|
|
320
|
+
this.#relinked = 0;
|
|
265
321
|
});
|
|
322
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
323
|
+
const played = () => {
|
|
324
|
+
if (drawn !== this.#drawn || drawn.seeking)
|
|
325
|
+
return;
|
|
326
|
+
if (drawn.ended || drawn.currentTime > this.#failedAt)
|
|
327
|
+
this.#relinked = 0;
|
|
328
|
+
};
|
|
329
|
+
drawn.addEventListener('timeupdate', played);
|
|
330
|
+
drawn.addEventListener('ended', played);
|
|
331
|
+
}
|
|
266
332
|
drawn.addEventListener('error', () => this.#failed(drawn));
|
|
267
333
|
}
|
|
268
334
|
this.#drawn = drawn;
|
|
269
335
|
this.#show(shown, drawn);
|
|
336
|
+
if (drawn instanceof HTMLImageElement)
|
|
337
|
+
offered(drawn, this.#box, copies);
|
|
270
338
|
drawn.src = shown.url;
|
|
271
339
|
}
|
|
272
340
|
#failed(drawn) {
|
|
@@ -280,6 +348,7 @@ export function defineRoomMedia(client) {
|
|
|
280
348
|
if (drawn instanceof HTMLMediaElement) {
|
|
281
349
|
const at = drawn.currentTime;
|
|
282
350
|
const playing = !drawn.paused;
|
|
351
|
+
this.#failedAt = at;
|
|
283
352
|
drawn.addEventListener('loadedmetadata', () => {
|
|
284
353
|
drawn.currentTime = at;
|
|
285
354
|
if (playing)
|
package/dist/memory.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { ModelResult } from './model.js';
|
|
3
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type
|
|
3
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type Attachment, 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';
|
|
4
4
|
export type MemoryRoom = Omit<DiscoveredRoom, 'typedSelection' | 'authoredPaths'> & {
|
|
5
5
|
typedSelection?: TypedSelection | null;
|
|
6
6
|
authoredPaths?: readonly string[];
|
|
@@ -11,7 +11,7 @@ export type MemoryRoom = Omit<DiscoveredRoom, 'typedSelection' | 'authoredPaths'
|
|
|
11
11
|
fileIds?: Readonly<Record<string, string>>;
|
|
12
12
|
created?: Readonly<Record<string, string>>;
|
|
13
13
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
14
|
-
|
|
14
|
+
attachments?: Readonly<Record<string, Attachment>>;
|
|
15
15
|
folders?: readonly string[];
|
|
16
16
|
blobs?: Readonly<Record<string, Blob>>;
|
|
17
17
|
};
|
package/dist/memory.js
CHANGED
|
@@ -100,11 +100,11 @@ export function createMemoryAdapter(options = {}) {
|
|
|
100
100
|
const wanted = ordinals.get(`${locator}\u0000${target}`);
|
|
101
101
|
return held !== undefined && wanted !== undefined && held >= wanted;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function heldBytes(room, path) {
|
|
104
104
|
return attached.get(`${room.locator}\u0000${path}`) ?? room.blobs?.[path];
|
|
105
105
|
}
|
|
106
106
|
function linkTo(room, path) {
|
|
107
|
-
const blob = room === undefined ? undefined :
|
|
107
|
+
const blob = room === undefined ? undefined : heldBytes(room, path);
|
|
108
108
|
if (blob === undefined)
|
|
109
109
|
return UNFOUND;
|
|
110
110
|
const url = linked.get(blob) ?? URL.createObjectURL(blob);
|
|
@@ -128,7 +128,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
128
128
|
const extension = dot > 0 ? name.slice(dot) : '';
|
|
129
129
|
for (let count = 1;; count += 1) {
|
|
130
130
|
const path = `${ATTACHMENTS}/${count === 1 ? stem : `${stem}-${count}`}${extension}`;
|
|
131
|
-
if (
|
|
131
|
+
if (heldBytes(room, path) === undefined && room.documents?.[path] === undefined)
|
|
132
132
|
return path;
|
|
133
133
|
}
|
|
134
134
|
}
|
|
@@ -193,7 +193,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
193
193
|
const size = pageSize ?? paths.length;
|
|
194
194
|
const taken = paths.slice(from, from + size);
|
|
195
195
|
const next = from + taken.length;
|
|
196
|
-
const targets = opening ? Object.keys(room.
|
|
196
|
+
const targets = opening ? Object.keys(room.attachments ?? {}) : [];
|
|
197
197
|
return {
|
|
198
198
|
kind: 'bootstrap',
|
|
199
199
|
roomVersion: room.roomVersion,
|
|
@@ -208,7 +208,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
208
208
|
? {}
|
|
209
209
|
: { created: named(room.created, [...taken, ...targets]) }),
|
|
210
210
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
211
|
-
|
|
211
|
+
attachments: named(room.attachments ?? {}, targets),
|
|
212
212
|
...(opening && room.folders !== undefined ? { folders: room.folders } : {}),
|
|
213
213
|
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
214
214
|
};
|
|
@@ -226,8 +226,8 @@ export function createMemoryAdapter(options = {}) {
|
|
|
226
226
|
function advancement(room, from, at, whole = false) {
|
|
227
227
|
const current = room.documents ?? {};
|
|
228
228
|
const previous = from.documents ?? {};
|
|
229
|
-
const currentTargets = new Set(Object.keys(room.
|
|
230
|
-
const previousTargets = new Set(Object.keys(from.
|
|
229
|
+
const currentTargets = new Set(Object.keys(room.attachments ?? {}));
|
|
230
|
+
const previousTargets = new Set(Object.keys(from.attachments ?? {}));
|
|
231
231
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
232
232
|
room.fileIds?.[path] !== from.fileIds?.[path] ||
|
|
233
233
|
room.created?.[path] !== from.created?.[path] ||
|
|
@@ -260,7 +260,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
260
260
|
? {}
|
|
261
261
|
: { created: named(room.created, [...taken, ...targets]) }),
|
|
262
262
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
263
|
-
|
|
263
|
+
attachments: named(room.attachments ?? {}, targets),
|
|
264
264
|
...(opening ? foldersMoved(room, from) : {}),
|
|
265
265
|
removals: opening
|
|
266
266
|
? [
|
|
@@ -653,7 +653,7 @@ export function createMemoryAdapter(options = {}) {
|
|
|
653
653
|
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
654
654
|
if (room === undefined)
|
|
655
655
|
return { kind: 'room-not-readable', locator: request.locator };
|
|
656
|
-
const blob =
|
|
656
|
+
const blob = heldBytes(room, request.path);
|
|
657
657
|
return blob === undefined
|
|
658
658
|
? { kind: 'rejected', code: 'not_found', fields: {}, retryable: false }
|
|
659
659
|
: { kind: 'binary', body: blob.stream(), mediaType: declaredType(blob) };
|
package/dist/messages.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { SessionState } from '@agentshouse/session-content';
|
|
1
2
|
import type { AcceptedMessage } from './adapter.js';
|
|
2
3
|
import type { Connection } from './tables.js';
|
|
3
4
|
export declare const MESSAGE_TABLES: readonly string[];
|
|
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 answer.turn AS answered,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn') AS opened_turn,\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";
|
|
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 answer.turn AS answered,\n json_extract(answer.message, '$.content.state') AS saved_state,\n json_extract(answer.message, '$.accepted_at') AS saved_at,\n substr(json_extract(answer.message, '$.failure'), 1, 512) AS failure,\n COALESCE(\n (SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),\n CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < (SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil') THEN answer.turn END\n ) AS opened_turn,\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";
|
|
5
6
|
export type HeldConversation = {
|
|
6
7
|
readonly conversation: string;
|
|
7
8
|
readonly read: string | null | undefined;
|
|
@@ -23,6 +24,10 @@ export type HeldRow = {
|
|
|
23
24
|
readonly at: string | null;
|
|
24
25
|
} | null;
|
|
25
26
|
readonly answered: string | null;
|
|
27
|
+
readonly saved: {
|
|
28
|
+
readonly state: SessionState;
|
|
29
|
+
readonly at: string;
|
|
30
|
+
} | null;
|
|
26
31
|
readonly openedTurn: string | null;
|
|
27
32
|
readonly failure: string | null;
|
|
28
33
|
readonly opened: HeldSource | null;
|
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;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAQ3C,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAM1D,eAAO,MAAM,cA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AC1B,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,CA6BX;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAO/F;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ,EAAE,CAMpE;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,GAAG,IAAI,CAM9F;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAEnE"}
|
package/dist/messages.js
CHANGED
|
@@ -16,6 +16,7 @@ export const MESSAGE_TABLES = [
|
|
|
16
16
|
const NEWEST_FIRST = 'ORDER BY position DESC, identity DESC LIMIT 1';
|
|
17
17
|
const OLDEST_FIRST = 'ORDER BY position, identity LIMIT 1';
|
|
18
18
|
const OF_THE_ROW = 'SELECT id FROM conversation_messages WHERE conversation = listed.value';
|
|
19
|
+
const READ_UNTIL = `(SELECT julianday(json_extract(value, '$')) FROM replica_facts WHERE name = 'readUntil')`;
|
|
19
20
|
export const ROWS = `WITH chosen AS (
|
|
20
21
|
SELECT listed.value AS conversation,
|
|
21
22
|
(${OF_THE_ROW} AND ${ANSWERS_THE_TURN} ${NEWEST_FIRST}) AS answer,
|
|
@@ -29,8 +30,13 @@ export const ROWS = `WITH chosen AS (
|
|
|
29
30
|
json_extract(said.message, '$.role') AS said_role,
|
|
30
31
|
json_extract(said.message, '$.accepted_at') AS said_at,
|
|
31
32
|
answer.turn AS answered,
|
|
33
|
+
json_extract(answer.message, '$.content.state') AS saved_state,
|
|
34
|
+
json_extract(answer.message, '$.accepted_at') AS saved_at,
|
|
32
35
|
substr(json_extract(answer.message, '$.failure'), 1, ${EXCERPT}) AS failure,
|
|
33
|
-
(
|
|
36
|
+
COALESCE(
|
|
37
|
+
(SELECT value FROM conversation_facts WHERE conversation = chosen.conversation AND name = 'openedTurn'),
|
|
38
|
+
CASE WHEN julianday(json_extract(answer.message, '$.accepted_at')) < ${READ_UNTIL} THEN answer.turn END
|
|
39
|
+
) AS opened_turn,
|
|
34
40
|
json_extract(opened.message, '$.source') AS opened_source,
|
|
35
41
|
json_extract(opened.message, '$.sender') AS opened_sender,
|
|
36
42
|
asking.identity AS asking_identity,
|
|
@@ -127,6 +133,9 @@ export function conversationRows(connection, conversations) {
|
|
|
127
133
|
at: textOrNull(row.said_at),
|
|
128
134
|
},
|
|
129
135
|
answered: textOrNull(row.answered),
|
|
136
|
+
saved: row.saved_state === null || row.saved_at === null
|
|
137
|
+
? null
|
|
138
|
+
: { state: JSON.parse(text(row.saved_state)), at: text(row.saved_at) },
|
|
130
139
|
openedTurn: textOrNull(row.opened_turn),
|
|
131
140
|
failure: textOrNull(row.failure),
|
|
132
141
|
opened: row.opened_source === null ? null : heldSource(row.opened_source, row.opened_sender),
|