@agentshouse/mdruntime 0.1.0-cee9c8aa4cd86 → 0.1.0-cefbc8bb8a1c0
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 +10 -8
- package/dist/adapter.d.ts +31 -18
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +2 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +28 -4
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +15 -4
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +140 -90
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +54 -7
- package/dist/collection.d.ts +5 -0
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +85 -30
- package/dist/connection.d.ts +9 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +961 -476
- package/dist/conversation.d.ts +7 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +166 -41
- package/dist/durability.d.ts +2 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +1 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/fulltext.d.ts.map +1 -1
- package/dist/fulltext.js +8 -6
- package/dist/host.d.ts +4 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +43 -15
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +2 -1
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +2 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +46 -19
- package/dist/model.d.ts +6 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/observation.d.ts +1 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +1 -1
- package/dist/outcome.d.ts +13 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -5
- package/dist/overlay.js +1 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +9 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +12 -1
- package/dist/reach.d.ts +8 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +68 -45
- package/dist/readiness.d.ts +17 -7
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +6 -6
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +10 -17
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +6 -2
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +61 -27
- package/dist/replica.d.ts +5 -4
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +4 -3
- package/dist/room-draft.d.ts +18 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +73 -6
- package/dist/rows.d.ts +15 -6
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +102 -74
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +13 -7
- package/dist/status.d.ts +5 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +18 -12
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +25 -20
- package/dist/stored.d.ts +10 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +210 -174
- package/dist/tables.d.ts +26 -6
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +57 -6
- package/dist/wire.d.ts +5 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -2
- package/dist/words.d.ts.map +1 -1
- package/dist/words.js +8 -2
- package/package.json +11 -18
- package/AGENTS.md +0 -320
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- package/dist/chat/kit.d.ts +0 -61
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -21
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -246
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -70
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
package/dist/host.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CodeAvailability, Persistence, Readiness, SearchObligation, Space } from './readiness.js';
|
|
4
4
|
import type { EntrySeed } from './seed.js';
|
|
5
5
|
import { type RuntimePort } from './wire.js';
|
|
6
6
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
@@ -11,13 +11,14 @@ export type AttachedPort = {
|
|
|
11
11
|
narrow(reach: PortReach): void;
|
|
12
12
|
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
13
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
|
-
code(code: CodeAvailability,
|
|
14
|
+
code(code: CodeAvailability, space: Space | null): void;
|
|
15
15
|
search(search: SearchObligation): void;
|
|
16
16
|
};
|
|
17
17
|
export type MdRuntimeHost = {
|
|
18
18
|
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability, search?: SearchObligation): AttachedPort;
|
|
19
19
|
seed(entry: EntrySeed): void;
|
|
20
20
|
persisted(answer: Persistence): void;
|
|
21
|
+
shown(onScreen: boolean): void;
|
|
21
22
|
endAuthorization(holder?: string): Promise<void>;
|
|
22
23
|
lose(locators: readonly string[]): Promise<void>;
|
|
23
24
|
stop(): Promise<void>;
|
|
@@ -25,7 +26,7 @@ export type MdRuntimeHost = {
|
|
|
25
26
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
26
27
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
27
28
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
28
|
-
export type {
|
|
29
|
+
export type { CodeAvailability, Persistence, SearchObligation, Space } from './readiness.js';
|
|
29
30
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
30
31
|
export type { RuntimePort } from './wire.js';
|
|
31
32
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,g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Q,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAsIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA0L3E;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { composeRuntime, } from './connection.js';
|
|
2
2
|
import { queryKey } from './query.js';
|
|
3
|
+
import { untilAnswered } from './recovery.js';
|
|
3
4
|
import { described } from './failure.js';
|
|
4
5
|
import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
|
|
5
6
|
const NARROWED = new Set(['within', 'whole']);
|
|
@@ -25,8 +26,10 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
25
26
|
return md.binaryFile.read(input[0], input[1], input[2]);
|
|
26
27
|
case 'binaryFile.link':
|
|
27
28
|
return md.binaryFile.link(input[0], input[1], input[2]);
|
|
28
|
-
case 'binaryFile.
|
|
29
|
-
return md.binaryFile.
|
|
29
|
+
case 'binaryFile.show':
|
|
30
|
+
return md.binaryFile.show(input[0], input[1], input[2]);
|
|
31
|
+
case 'binaryFile.attach':
|
|
32
|
+
return md.binaryFile.attach(input[0], input[1]);
|
|
30
33
|
case 'binaryFile.part':
|
|
31
34
|
return md.binaryFile.part(input[0], input[1]);
|
|
32
35
|
case 'call':
|
|
@@ -48,7 +51,7 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
48
51
|
case 'roomDraft.read':
|
|
49
52
|
return md.roomDraft.read(input[0], input[1]);
|
|
50
53
|
case 'roomDraft.write':
|
|
51
|
-
return md.roomDraft.write(input[0], input[1], input[2], input[3]);
|
|
54
|
+
return md.roomDraft.write(input[0], input[1], input[2], input[3], input[4]);
|
|
52
55
|
case 'roomDraft.discard':
|
|
53
56
|
return md.roomDraft.discard(input[0], input[1], input[2]);
|
|
54
57
|
case 'presentation.read':
|
|
@@ -65,8 +68,6 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
65
68
|
return md.conversation.create(input[0]);
|
|
66
69
|
case 'conversation.send':
|
|
67
70
|
return md.conversation.send(input[0], input[1], input[2]);
|
|
68
|
-
case 'conversation.attach':
|
|
69
|
-
return md.conversation.attach(input[0], input[1]);
|
|
70
71
|
case 'conversation.answer':
|
|
71
72
|
return md.conversation.answer(input[0], input[1]);
|
|
72
73
|
case 'conversation.interrupt':
|
|
@@ -85,6 +86,14 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
85
86
|
return md.chatDraft.discard(input[0]);
|
|
86
87
|
}
|
|
87
88
|
}
|
|
89
|
+
function attempted(work) {
|
|
90
|
+
try {
|
|
91
|
+
return Promise.resolve(work());
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return Promise.reject(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
88
97
|
function answeredResult(value) {
|
|
89
98
|
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
90
99
|
}
|
|
@@ -106,6 +115,8 @@ export function serveMdRuntime(options) {
|
|
|
106
115
|
const { md } = runtime;
|
|
107
116
|
const attachments = new Map();
|
|
108
117
|
let authorized = true;
|
|
118
|
+
let opening = null;
|
|
119
|
+
const opened = () => (opening ??= untilAnswered(() => md.loaded(), closing.signal));
|
|
109
120
|
const watchFacts = (deliver) => {
|
|
110
121
|
deliver(structuredClone(deploymentFacts));
|
|
111
122
|
return () => { };
|
|
@@ -114,7 +125,7 @@ export function serveMdRuntime(options) {
|
|
|
114
125
|
if (!authorized)
|
|
115
126
|
throw new Error(AUTHORIZATION_ENDED);
|
|
116
127
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
117
|
-
let facts = { target: app, code,
|
|
128
|
+
let facts = { target: app, code, space: null, search };
|
|
118
129
|
const view = runtime.within(reach ?? null, facts);
|
|
119
130
|
const observations = new Map();
|
|
120
131
|
const followed = new Set();
|
|
@@ -157,6 +168,20 @@ export function serveMdRuntime(options) {
|
|
|
157
168
|
? watchFacts(deliver)
|
|
158
169
|
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
|
|
159
170
|
};
|
|
171
|
+
const reply = async (id, query, pending) => {
|
|
172
|
+
try {
|
|
173
|
+
const value = await pending;
|
|
174
|
+
if (!serving)
|
|
175
|
+
return;
|
|
176
|
+
send({ kind: 'result', id, value });
|
|
177
|
+
if (query !== undefined && answeredResult(value))
|
|
178
|
+
answeredQuery(query);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
if (serving)
|
|
182
|
+
send({ kind: 'failure', id, ...described(error) });
|
|
183
|
+
}
|
|
184
|
+
};
|
|
160
185
|
const serve = async (message) => {
|
|
161
186
|
if (message.kind === 'hello')
|
|
162
187
|
return;
|
|
@@ -166,24 +191,24 @@ export function serveMdRuntime(options) {
|
|
|
166
191
|
return;
|
|
167
192
|
}
|
|
168
193
|
try {
|
|
169
|
-
if (message.kind !== 'observe'
|
|
194
|
+
if (message.kind !== 'observe')
|
|
170
195
|
await md.loaded();
|
|
196
|
+
else if (message.topic !== 'room-drafts')
|
|
197
|
+
await opened();
|
|
171
198
|
if (message.kind === 'observe') {
|
|
172
199
|
if (serving)
|
|
173
200
|
observe(message.id, message.topic, message.input);
|
|
174
201
|
return;
|
|
175
202
|
}
|
|
176
|
-
const value = await answered(NARROWED.has(WIRE.members[message.member].reach) ? view.md : md, app, writtenBy, message.member, message.input);
|
|
177
|
-
if (!serving)
|
|
178
|
-
return;
|
|
179
|
-
send({ kind: 'result', id: message.id, value });
|
|
180
|
-
if (message.member === 'query' && answeredResult(value))
|
|
181
|
-
answeredQuery(message.input[0]);
|
|
182
203
|
}
|
|
183
204
|
catch (error) {
|
|
184
205
|
if (serving)
|
|
185
206
|
send({ kind: 'failure', id: message.id, ...described(error) });
|
|
207
|
+
return;
|
|
186
208
|
}
|
|
209
|
+
const { id, member, input } = message;
|
|
210
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? view.md : md, app, writtenBy, member, input));
|
|
211
|
+
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
187
212
|
};
|
|
188
213
|
port.addEventListener('message', (event) => {
|
|
189
214
|
if (!serving)
|
|
@@ -202,10 +227,10 @@ export function serveMdRuntime(options) {
|
|
|
202
227
|
if (serving)
|
|
203
228
|
view.narrow(next);
|
|
204
229
|
},
|
|
205
|
-
code(next,
|
|
230
|
+
code(next, space) {
|
|
206
231
|
if (!serving)
|
|
207
232
|
return;
|
|
208
|
-
facts = { ...facts, code: next,
|
|
233
|
+
facts = { ...facts, code: next, space };
|
|
209
234
|
view.facts(facts);
|
|
210
235
|
},
|
|
211
236
|
search(next) {
|
|
@@ -245,6 +270,9 @@ export function serveMdRuntime(options) {
|
|
|
245
270
|
persisted(answer) {
|
|
246
271
|
runtime.persisted(answer);
|
|
247
272
|
},
|
|
273
|
+
shown(onScreen) {
|
|
274
|
+
runtime.shown(onScreen);
|
|
275
|
+
},
|
|
248
276
|
async endAuthorization(holder) {
|
|
249
277
|
authorized = false;
|
|
250
278
|
for (const [detach, send] of [...attachments]) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult,
|
|
1
|
+
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, AttachRequest, AttachResult, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, DiscoveryScope, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRevisions, HeldRoom, KeptReceipt, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, StreamReceipts, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
3
3
|
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
-
export type { ChosenFile, FileDeclaration } from './file.js';
|
|
5
4
|
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
5
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { BinaryAnswer, BinaryLinkAnswer, CallResult, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
8
|
-
export type { BinaryFileRecord
|
|
6
|
+
export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
7
|
+
export type { BinaryFileRecord } from './binary.js';
|
|
9
8
|
export type { RuntimeError } from './failure.js';
|
|
10
9
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
11
10
|
export type { SaveRefusal } from './save.js';
|
|
12
11
|
export type { DocumentHit, DocumentPart, MessageHit, MessagePart, SearchCoverage, SearchHits, SearchPending, SearchRequest, SearchResult, SearchUndeclared, Snippet, } from './search.js';
|
|
13
12
|
export { departure } from './change.js';
|
|
14
|
-
export { partsAfter } from './room-draft.js';
|
|
13
|
+
export { partsAfter, partsChanges } from './room-draft.js';
|
|
15
14
|
export { cutName, nameFrom, transliterated } from './name.js';
|
|
16
|
-
export { SESSION_STARTED } from './conversation.js';
|
|
15
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
17
16
|
export { changeBatchIdentity } from './identity.js';
|
|
18
|
-
export { ROW_WEIGHT, stepped } from './turn.js';
|
|
17
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
18
|
+
export { untilAnswered } from './recovery.js';
|
|
19
19
|
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
20
20
|
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
21
21
|
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
22
|
-
export type { RuntimeShell
|
|
23
|
-
export type {
|
|
22
|
+
export type { RuntimeShell } from './durability.js';
|
|
23
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationPause, InstallationStep, Persistence, Readiness, ReadinessStatus, RefusedRoom, RoomCoverage, RoomPreparation, SearchObligation, Space, TargetCoverage, } from './readiness.js';
|
|
24
24
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
25
25
|
export type { Awaits, Backlink, CoveredRoom, Direction, DocumentQuery, DocumentResult, Filter, GroupQuery, GroupResult, Key, LocalQuery, OrderOptions, PendingResult, PendingRoom, Predicate, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, Related, Select, Value, Where, } from './query.js';
|
|
26
26
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,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AAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,eAAe,EACf,WAAW,EACX,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,KAAK,EACL,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,cAAc,EACd,MAAM,EACN,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { departure } from './change.js';
|
|
2
|
-
export { partsAfter } from './room-draft.js';
|
|
2
|
+
export { partsAfter, partsChanges } from './room-draft.js';
|
|
3
3
|
export { cutName, nameFrom, transliterated } from './name.js';
|
|
4
|
-
export { SESSION_STARTED } from './conversation.js';
|
|
4
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
5
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
|
-
export { ROW_WEIGHT, stepped } from './turn.js';
|
|
6
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
7
|
+
export { untilAnswered } from './recovery.js';
|
|
7
8
|
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
8
9
|
export { attempts, identities, intentOf, } from './attempt.js';
|
|
9
10
|
export { expectedList, expecting } from './expectation.js';
|
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,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;
|
|
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,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAEnE,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,EAAE,OAAO,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACvF,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAoCF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAuFvD"}
|
package/dist/live.js
CHANGED
|
@@ -14,7 +14,8 @@ function reads(plan, locator) {
|
|
|
14
14
|
if (plan.reach === null)
|
|
15
15
|
return true;
|
|
16
16
|
return (plan.reach.rooms.includes(locator) ||
|
|
17
|
-
plan.reach.documents.some((document) => roomOfKey(document) === locator)
|
|
17
|
+
plan.reach.documents.some((document) => roomOfKey(document) === locator) ||
|
|
18
|
+
plan.reach.areas.some((area) => area.room === locator && area.types.length > 0));
|
|
18
19
|
}
|
|
19
20
|
function affected(plan, set) {
|
|
20
21
|
if (set.rooms.some((locator) => reads(plan, locator)))
|
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MdRuntimeClient } from './client.js';
|
|
2
|
+
import { type ShownAnswer } from './outcome.js';
|
|
3
|
+
export declare const ROOM_MEDIA = "room-media";
|
|
4
|
+
type Show = (room: string, path: string, revision?: string) => Promise<ShownAnswer>;
|
|
5
|
+
export declare function shownBy(show: Show, client: MdRuntimeClient): MdRuntimeClient;
|
|
6
|
+
export declare function defineRoomMedia(client: Promise<MdRuntimeClient> | MdRuntimeClient, registry?: CustomElementRegistry): void;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +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,CAC7B,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,EAClD,QAAQ,GAAE,qBAAsC,GAC/C,IAAI,CA0LN"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { UNCERTAIN } from './outcome.js';
|
|
2
|
+
export const ROOM_MEDIA = 'room-media';
|
|
3
|
+
const ATTRIBUTES = ['room', 'path', 'revision', 'width', 'height', 'alt'];
|
|
4
|
+
const LOADING = new Set(['room', 'path', 'revision']);
|
|
5
|
+
const NEARING = '600px 0px';
|
|
6
|
+
const RELINKS = 2;
|
|
7
|
+
// The Room's stream brings a file seconds after the text that links it, minutes after on a first open, and a page's reach of its Rooms settles seconds after it opens, so a file not shown yet is asked for again every three seconds.
|
|
8
|
+
const UNSHOWN_MS = 3_000;
|
|
9
|
+
const SHAPE = '16 / 9';
|
|
10
|
+
const STYLE = `:host{display:block}
|
|
11
|
+
[part=box]{position:relative;overflow:hidden}
|
|
12
|
+
[part=box]>img,[part=box]>video,[part=box]>audio{display:block;width:100%;height:100%;object-fit:contain}
|
|
13
|
+
[part=box]>slot{display:flex;align-items:center;justify-content:center;width:100%;height:100%;text-align:center}`;
|
|
14
|
+
const shows = new WeakMap();
|
|
15
|
+
export function shownBy(show, client) {
|
|
16
|
+
shows.set(client, show);
|
|
17
|
+
return client;
|
|
18
|
+
}
|
|
19
|
+
function ratioOf(width, height) {
|
|
20
|
+
const across = Number(width);
|
|
21
|
+
const down = Number(height);
|
|
22
|
+
return Number.isFinite(across) && Number.isFinite(down) && across > 0 && down > 0
|
|
23
|
+
? `${across} / ${down}`
|
|
24
|
+
: SHAPE;
|
|
25
|
+
}
|
|
26
|
+
function refusedForGood(shown) {
|
|
27
|
+
if (shown.kind === 'revoked-authorization')
|
|
28
|
+
return true;
|
|
29
|
+
return (shown.kind === 'rejected' || shown.kind === 'scoped-refusal') && !shown.retryable;
|
|
30
|
+
}
|
|
31
|
+
function drawnFor(mediaType) {
|
|
32
|
+
if (mediaType.startsWith('image/'))
|
|
33
|
+
return 'img';
|
|
34
|
+
if (mediaType.startsWith('video/'))
|
|
35
|
+
return 'video';
|
|
36
|
+
if (mediaType.startsWith('audio/'))
|
|
37
|
+
return 'audio';
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
export function defineRoomMedia(client, registry = customElements) {
|
|
41
|
+
if (registry.get(ROOM_MEDIA) !== undefined)
|
|
42
|
+
return;
|
|
43
|
+
const connected = Promise.resolve(client);
|
|
44
|
+
class RoomMedia extends HTMLElement {
|
|
45
|
+
static observedAttributes = ATTRIBUTES;
|
|
46
|
+
#root = this.attachShadow({ mode: 'open' });
|
|
47
|
+
#box = document.createElement('div');
|
|
48
|
+
#fallback = document.createElement('slot');
|
|
49
|
+
#watching = null;
|
|
50
|
+
#near = false;
|
|
51
|
+
#asked = 0;
|
|
52
|
+
#shown = null;
|
|
53
|
+
#drawn = null;
|
|
54
|
+
#loaded = false;
|
|
55
|
+
#relinked = 0;
|
|
56
|
+
constructor() {
|
|
57
|
+
super();
|
|
58
|
+
this.#box.setAttribute('part', 'box');
|
|
59
|
+
this.#root.append(Object.assign(document.createElement('style'), { textContent: STYLE }), this.#box);
|
|
60
|
+
this.#shape();
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() {
|
|
63
|
+
this.#label();
|
|
64
|
+
this.#watching ??= new IntersectionObserver((seen) => {
|
|
65
|
+
if (!seen.some((entry) => entry.isIntersecting) || this.#near)
|
|
66
|
+
return;
|
|
67
|
+
this.#near = true;
|
|
68
|
+
void this.#load();
|
|
69
|
+
}, { rootMargin: NEARING });
|
|
70
|
+
this.#watching.observe(this);
|
|
71
|
+
}
|
|
72
|
+
disconnectedCallback() {
|
|
73
|
+
this.#watching?.disconnect();
|
|
74
|
+
this.#watching = null;
|
|
75
|
+
this.#near = false;
|
|
76
|
+
this.#asked += 1;
|
|
77
|
+
this.#show(null);
|
|
78
|
+
}
|
|
79
|
+
attributeChangedCallback(name, before, after) {
|
|
80
|
+
if (before === after)
|
|
81
|
+
return;
|
|
82
|
+
this.#shape();
|
|
83
|
+
if (this.isConnected)
|
|
84
|
+
this.#label();
|
|
85
|
+
if (!LOADING.has(name) || !this.#near)
|
|
86
|
+
return;
|
|
87
|
+
this.#relinked = 0;
|
|
88
|
+
void this.#load();
|
|
89
|
+
}
|
|
90
|
+
#shape() {
|
|
91
|
+
this.#box.style.aspectRatio = ratioOf(this.getAttribute('width'), this.getAttribute('height'));
|
|
92
|
+
}
|
|
93
|
+
#label() {
|
|
94
|
+
const alt = this.getAttribute('alt') ?? '';
|
|
95
|
+
const drawn = this.#drawn;
|
|
96
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
97
|
+
this.removeAttribute('role');
|
|
98
|
+
this.removeAttribute('aria-label');
|
|
99
|
+
drawn.setAttribute('aria-label', alt);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.setAttribute('role', 'img');
|
|
103
|
+
this.setAttribute('aria-label', alt);
|
|
104
|
+
if (drawn !== null)
|
|
105
|
+
drawn.alt = '';
|
|
106
|
+
}
|
|
107
|
+
async #load() {
|
|
108
|
+
const asked = (this.#asked += 1);
|
|
109
|
+
this.#loaded = false;
|
|
110
|
+
const room = this.getAttribute('room');
|
|
111
|
+
const path = this.getAttribute('path');
|
|
112
|
+
const revision = this.getAttribute('revision') ?? undefined;
|
|
113
|
+
if (room === null || path === null) {
|
|
114
|
+
this.#unreadable();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const show = shows.get(await connected);
|
|
118
|
+
const shown = show === undefined ? null : await show(room, path, revision).catch(() => UNCERTAIN);
|
|
119
|
+
if (asked !== this.#asked)
|
|
120
|
+
return;
|
|
121
|
+
if (shown?.kind === 'link') {
|
|
122
|
+
this.#draw({ url: shown.url, copy: false }, shown.mediaType);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (shown?.kind !== 'binary') {
|
|
126
|
+
if (shown === null || refusedForGood(shown))
|
|
127
|
+
this.#unreadable();
|
|
128
|
+
else
|
|
129
|
+
this.#unshown(asked);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const copy = await new Response(shown.stream, {
|
|
133
|
+
headers: { 'content-type': shown.mediaType },
|
|
134
|
+
})
|
|
135
|
+
.blob()
|
|
136
|
+
.catch(() => null);
|
|
137
|
+
if (asked !== this.#asked)
|
|
138
|
+
return;
|
|
139
|
+
if (copy === null)
|
|
140
|
+
this.#unshown(asked);
|
|
141
|
+
else
|
|
142
|
+
this.#draw({ url: URL.createObjectURL(copy), copy: true }, shown.mediaType);
|
|
143
|
+
}
|
|
144
|
+
#unshown(asked) {
|
|
145
|
+
this.#unreadable();
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
if (asked === this.#asked && this.#near)
|
|
148
|
+
void this.#load();
|
|
149
|
+
}, UNSHOWN_MS);
|
|
150
|
+
}
|
|
151
|
+
#show(shown, content = null) {
|
|
152
|
+
if (this.#shown?.copy === true)
|
|
153
|
+
URL.revokeObjectURL(this.#shown.url);
|
|
154
|
+
this.#shown = shown;
|
|
155
|
+
if (content !== this.#drawn)
|
|
156
|
+
this.#drawn = null;
|
|
157
|
+
if (content === null)
|
|
158
|
+
this.#box.replaceChildren();
|
|
159
|
+
else if (content.parentNode !== this.#box)
|
|
160
|
+
this.#box.replaceChildren(content);
|
|
161
|
+
this.#label();
|
|
162
|
+
}
|
|
163
|
+
#unreadable() {
|
|
164
|
+
this.#show(null, this.#fallback);
|
|
165
|
+
}
|
|
166
|
+
#draw(shown, mediaType) {
|
|
167
|
+
const tag = drawnFor(mediaType);
|
|
168
|
+
if (tag === null) {
|
|
169
|
+
if (shown.copy)
|
|
170
|
+
URL.revokeObjectURL(shown.url);
|
|
171
|
+
this.#unreadable();
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const kept = this.#drawn?.localName === tag ? this.#drawn : null;
|
|
175
|
+
const drawn = kept ?? document.createElement(tag);
|
|
176
|
+
if (kept === null) {
|
|
177
|
+
if (drawn instanceof HTMLImageElement)
|
|
178
|
+
drawn.decoding = 'async';
|
|
179
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
180
|
+
drawn.controls = true;
|
|
181
|
+
drawn.preload = 'metadata';
|
|
182
|
+
if (drawn instanceof HTMLVideoElement)
|
|
183
|
+
drawn.playsInline = true;
|
|
184
|
+
}
|
|
185
|
+
drawn.addEventListener(drawn instanceof HTMLImageElement ? 'load' : 'loadedmetadata', () => {
|
|
186
|
+
if (drawn !== this.#drawn)
|
|
187
|
+
return;
|
|
188
|
+
this.#loaded = true;
|
|
189
|
+
this.#relinked = 0;
|
|
190
|
+
});
|
|
191
|
+
drawn.addEventListener('error', () => this.#failed(drawn));
|
|
192
|
+
}
|
|
193
|
+
this.#drawn = drawn;
|
|
194
|
+
this.#show(shown, drawn);
|
|
195
|
+
drawn.src = shown.url;
|
|
196
|
+
}
|
|
197
|
+
#failed(drawn) {
|
|
198
|
+
if (drawn !== this.#drawn)
|
|
199
|
+
return;
|
|
200
|
+
if (this.#shown?.copy !== false || !this.#loaded || this.#relinked >= RELINKS) {
|
|
201
|
+
this.#unreadable();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
this.#relinked += 1;
|
|
205
|
+
if (drawn instanceof HTMLMediaElement) {
|
|
206
|
+
const at = drawn.currentTime;
|
|
207
|
+
const playing = !drawn.paused;
|
|
208
|
+
drawn.addEventListener('loadedmetadata', () => {
|
|
209
|
+
drawn.currentTime = at;
|
|
210
|
+
if (playing)
|
|
211
|
+
void drawn.play().catch(() => undefined);
|
|
212
|
+
}, { once: true });
|
|
213
|
+
}
|
|
214
|
+
void this.#load();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
registry.define(ROOM_MEDIA, RoomMedia);
|
|
218
|
+
}
|
package/dist/memory.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { ModelResult } from './model.js';
|
|
|
2
2
|
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveryScope, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
|
-
selectionModel?: ModelResult;
|
|
6
5
|
documents?: Readonly<Record<string, string>>;
|
|
7
6
|
revisions?: Readonly<Record<string, string>>;
|
|
8
7
|
fileIds?: Readonly<Record<string, string>>;
|
|
@@ -13,7 +12,7 @@ export type MemoryRoom = DiscoveredRoom & {
|
|
|
13
12
|
};
|
|
14
13
|
export type MemoryConversation = {
|
|
15
14
|
conversation: string;
|
|
16
|
-
listed?: Omit<ListedConversation, 'conversation'>;
|
|
15
|
+
listed?: Omit<ListedConversation, 'conversation' | 'newest'>;
|
|
17
16
|
messages?: readonly AcceptedMessage[];
|
|
18
17
|
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
19
18
|
};
|
|
@@ -28,6 +27,7 @@ export type MemoryAdapterOptions = {
|
|
|
28
27
|
member?: Member;
|
|
29
28
|
unopened?: boolean;
|
|
30
29
|
exhaustiveDiscovery?: true;
|
|
30
|
+
roomTypes?: string;
|
|
31
31
|
};
|
|
32
32
|
export type MemoryAdapter = Adapter & {
|
|
33
33
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,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,EAItB,KAAK,cAAc,E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