@agentshouse/mdruntime 0.1.0-c1ffd2bc60355 → 0.1.0-c20970f71a6a9
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 +11 -9
- package/dist/adapter.d.ts +89 -53
- 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/bootstrap.d.ts +10 -13
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +100 -89
- package/dist/client.d.ts +8 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -6
- package/dist/collection.d.ts +5 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +1 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +113 -45
- package/dist/connection.d.ts +8 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1311 -1067
- package/dist/conversation.d.ts +15 -14
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +222 -140
- package/dist/durability.d.ts +0 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +1 -0
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +2 -1
- package/dist/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/host.d.ts +3 -6
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +12 -19
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.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 +10 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +178 -90
- package/dist/messages.d.ts +2 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +15 -16
- package/dist/model.d.ts +6 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -10
- 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 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/phrase.d.ts +3 -0
- package/dist/phrase.d.ts.map +1 -0
- package/dist/phrase.js +8 -0
- package/dist/query.d.ts +10 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +20 -1
- package/dist/reach.d.ts +10 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +53 -29
- package/dist/react.d.ts +1 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +3 -17
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- 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 +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +47 -11
- package/dist/replica.d.ts +3 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +7 -7
- package/dist/room-draft.d.ts +18 -3
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +94 -47
- package/dist/rows.d.ts +17 -7
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +120 -87
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +11 -5
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +30 -37
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +61 -66
- package/dist/stored.d.ts +41 -24
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +196 -214
- package/dist/tables.d.ts +48 -49
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +23 -62
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +35 -96
- package/dist/wire.d.ts +9 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +3 -2
- package/package.json +10 -17
- package/AGENTS.md +0 -317
- 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 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -229
- 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/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/file.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../src/file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,CAStF"}
|
package/dist/file.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { sha256 } from './digest.js';
|
|
2
|
-
export async function
|
|
2
|
+
export async function attachedFile(locator, file) {
|
|
3
3
|
return {
|
|
4
|
+
locator,
|
|
4
5
|
name: file.name,
|
|
5
|
-
mediaType: file.
|
|
6
|
-
byteLength: file.
|
|
7
|
-
|
|
6
|
+
mediaType: file.type,
|
|
7
|
+
byteLength: file.size,
|
|
8
|
+
sha256: await sha256(file),
|
|
9
|
+
blob: file,
|
|
8
10
|
};
|
|
9
11
|
}
|
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 { CodeAvailability, Persistence, Readiness,
|
|
3
|
+
import type { CodeAvailability, Persistence, Readiness, 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 & {
|
|
@@ -12,21 +12,18 @@ export type AttachedPort = {
|
|
|
12
12
|
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
13
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
14
|
code(code: CodeAvailability, space: Space | null): void;
|
|
15
|
-
search(search: SearchObligation): void;
|
|
16
15
|
};
|
|
17
16
|
export type MdRuntimeHost = {
|
|
18
|
-
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability
|
|
17
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability): AttachedPort;
|
|
19
18
|
seed(entry: EntrySeed): void;
|
|
20
19
|
persisted(answer: Persistence): void;
|
|
21
|
-
shown(onScreen: boolean): void;
|
|
22
20
|
endAuthorization(holder?: string): Promise<void>;
|
|
23
|
-
lose(locators: readonly string[]): Promise<void>;
|
|
24
21
|
stop(): Promise<void>;
|
|
25
22
|
};
|
|
26
23
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
27
24
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
28
25
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
29
|
-
export type { CodeAvailability, Persistence,
|
|
26
|
+
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
30
27
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
31
28
|
export type { RuntimePort } from './wire.js';
|
|
32
29
|
//# 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":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAItB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAItB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,E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AW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3E,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,6 +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]);
|
|
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]);
|
|
28
33
|
case 'binaryFile.part':
|
|
29
34
|
return md.binaryFile.part(input[0], input[1]);
|
|
30
35
|
case 'call':
|
|
@@ -63,16 +68,12 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
63
68
|
return md.conversation.create(input[0]);
|
|
64
69
|
case 'conversation.send':
|
|
65
70
|
return md.conversation.send(input[0], input[1], input[2]);
|
|
66
|
-
case 'conversation.attach':
|
|
67
|
-
return md.conversation.attach(input[0], input[1]);
|
|
68
71
|
case 'conversation.answer':
|
|
69
72
|
return md.conversation.answer(input[0], input[1]);
|
|
70
73
|
case 'conversation.interrupt':
|
|
71
74
|
return md.conversation.interrupt(input[0]);
|
|
72
75
|
case 'conversation.kill':
|
|
73
76
|
return md.conversation.kill(input[0]);
|
|
74
|
-
case 'conversation.cancel':
|
|
75
|
-
return md.conversation.cancel(input[0], input[1]);
|
|
76
77
|
case 'conversation.delete':
|
|
77
78
|
return md.conversation.delete(input[0]);
|
|
78
79
|
case 'chatDraft.write':
|
|
@@ -112,15 +113,17 @@ export function serveMdRuntime(options) {
|
|
|
112
113
|
const { md } = runtime;
|
|
113
114
|
const attachments = new Map();
|
|
114
115
|
let authorized = true;
|
|
116
|
+
let opening = null;
|
|
117
|
+
const opened = () => (opening ??= untilAnswered(() => md.loaded(), closing.signal));
|
|
115
118
|
const watchFacts = (deliver) => {
|
|
116
119
|
deliver(structuredClone(deploymentFacts));
|
|
117
120
|
return () => { };
|
|
118
121
|
};
|
|
119
|
-
function attach(port, app, release, reach, code = 'stored'
|
|
122
|
+
function attach(port, app, release, reach, code = 'stored') {
|
|
120
123
|
if (!authorized)
|
|
121
124
|
throw new Error(AUTHORIZATION_ENDED);
|
|
122
125
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
123
|
-
let facts = { target: app, code, space: null
|
|
126
|
+
let facts = { target: app, code, space: null };
|
|
124
127
|
const view = runtime.within(reach ?? null, facts);
|
|
125
128
|
const observations = new Map();
|
|
126
129
|
const followed = new Set();
|
|
@@ -186,8 +189,10 @@ export function serveMdRuntime(options) {
|
|
|
186
189
|
return;
|
|
187
190
|
}
|
|
188
191
|
try {
|
|
189
|
-
if (message.kind !== 'observe'
|
|
192
|
+
if (message.kind !== 'observe')
|
|
190
193
|
await md.loaded();
|
|
194
|
+
else if (message.topic !== 'room-drafts')
|
|
195
|
+
await opened();
|
|
191
196
|
if (message.kind === 'observe') {
|
|
192
197
|
if (serving)
|
|
193
198
|
observe(message.id, message.topic, message.input);
|
|
@@ -226,12 +231,6 @@ export function serveMdRuntime(options) {
|
|
|
226
231
|
facts = { ...facts, code: next, space };
|
|
227
232
|
view.facts(facts);
|
|
228
233
|
},
|
|
229
|
-
search(next) {
|
|
230
|
-
if (!serving)
|
|
231
|
-
return;
|
|
232
|
-
facts = { ...facts, search: next };
|
|
233
|
-
view.facts(facts);
|
|
234
|
-
},
|
|
235
234
|
answered(queries, done) {
|
|
236
235
|
const keys = queries.map(queryKey);
|
|
237
236
|
if (keys.every((key) => answeredKeys.has(key)))
|
|
@@ -263,9 +262,6 @@ export function serveMdRuntime(options) {
|
|
|
263
262
|
persisted(answer) {
|
|
264
263
|
runtime.persisted(answer);
|
|
265
264
|
},
|
|
266
|
-
shown(onScreen) {
|
|
267
|
-
runtime.shown(onScreen);
|
|
268
|
-
},
|
|
269
265
|
async endAuthorization(holder) {
|
|
270
266
|
authorized = false;
|
|
271
267
|
for (const [detach, send] of [...attachments]) {
|
|
@@ -277,9 +273,6 @@ export function serveMdRuntime(options) {
|
|
|
277
273
|
await options.shell.dropGeneration();
|
|
278
274
|
}
|
|
279
275
|
},
|
|
280
|
-
lose(locators) {
|
|
281
|
-
return runtime.lose(locators);
|
|
282
|
-
},
|
|
283
276
|
stop() {
|
|
284
277
|
return runtime.stop();
|
|
285
278
|
},
|
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, AuthorityChange, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldContent, HeldFile, HeldRoom, ListedAgent, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, Outline, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomChange, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, SearchAnswer, SearchAsk, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
3
|
-
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
|
-
export type { ChosenFile, FileDeclaration } from './file.js';
|
|
3
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.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';
|
|
6
|
+
export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
8
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
|
-
export type {
|
|
11
|
+
export type { SearchFound, SearchHit, SearchRequest, SearchResult } 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
15
|
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
17
16
|
export { changeBatchIdentity } from './identity.js';
|
|
18
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
22
|
export type { RuntimeShell } from './durability.js';
|
|
23
|
-
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount,
|
|
23
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationStep, Persistence, Readiness, ReadinessStatus, RoomCoverage, RoomPreparation, 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,
|
|
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,eAAe,EACf,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,OAAO,EACP,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,YAAY,EACZ,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,Y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,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
4
|
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
5
5
|
export { changeBatchIdentity } from './identity.js';
|
|
6
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/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
|
@@ -1,8 +1,7 @@
|
|
|
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
|
|
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 } 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,13 +12,14 @@ 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
|
-
outcomes?: Partial<Record<ConversationAction, ActionResult>>;
|
|
17
|
+
outcomes?: Partial<Record<ConversationAction | 'history', ActionResult>>;
|
|
19
18
|
};
|
|
20
19
|
export type MemoryAdapterOptions = {
|
|
21
20
|
rooms?: readonly MemoryRoom[];
|
|
22
21
|
conversations?: readonly MemoryConversation[];
|
|
22
|
+
agents?: readonly ListedAgent[];
|
|
23
23
|
historyPageSize?: number;
|
|
24
24
|
pageSize?: number;
|
|
25
25
|
capabilities?: readonly Capability[];
|
|
@@ -27,9 +27,11 @@ export type MemoryAdapterOptions = {
|
|
|
27
27
|
retention?: Retention;
|
|
28
28
|
member?: Member;
|
|
29
29
|
unopened?: boolean;
|
|
30
|
-
|
|
30
|
+
roomTypes?: string;
|
|
31
31
|
};
|
|
32
32
|
export type MemoryAdapter = Adapter & {
|
|
33
|
+
discover: NonNullable<Adapter['discover']>;
|
|
34
|
+
refresh: NonNullable<Adapter['refresh']>;
|
|
33
35
|
setRooms(rooms: readonly MemoryRoom[]): void;
|
|
34
36
|
setConversations(conversations: readonly MemoryConversation[]): void;
|
|
35
37
|
script(operation: keyof Adapter, answer: unknown): void;
|
|
@@ -37,17 +39,19 @@ export type MemoryAdapter = Adapter & {
|
|
|
37
39
|
close(closing?: {
|
|
38
40
|
revoked?: boolean;
|
|
39
41
|
lost?: boolean;
|
|
42
|
+
authorityChanged?: boolean;
|
|
40
43
|
}): void;
|
|
41
44
|
expire(locators: readonly string[]): void;
|
|
42
45
|
notifyRoomVersion(notification: {
|
|
43
46
|
locator: string;
|
|
44
47
|
roomVersion: string;
|
|
45
48
|
}): void;
|
|
46
|
-
notifyAuthorityChanged(
|
|
49
|
+
notifyAuthorityChanged(locators?: readonly string[]): void;
|
|
47
50
|
notifyConversation(event: ConversationEvent): void;
|
|
48
51
|
notifyServiceMode(mode: ServiceMode): void;
|
|
49
52
|
heldRooms(): readonly string[];
|
|
50
53
|
replicatedConversations(): readonly string[];
|
|
54
|
+
heldConversationCursor(): string | null;
|
|
51
55
|
};
|
|
52
56
|
export declare function createMemoryAdapter(options?: MemoryAdapterOptions): MemoryAdapter;
|
|
53
57
|
//# sourceMappingURL=memory.d.ts.map
|
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,YA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