@agentshouse/mdruntime 0.1.0-c5e756efec46e → 0.1.0-c5f0bd46f6eca
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/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +31 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +25 -5
- package/dist/adapter.d.ts +92 -14
- package/dist/adapter.d.ts.map +1 -1
- package/dist/{binary.d.ts → attachment.d.ts} +3 -3
- package/dist/attachment.d.ts.map +1 -0
- package/dist/{binary.js → attachment.js} +1 -1
- package/dist/authored.d.ts.map +1 -1
- package/dist/authored.js +0 -2
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/client.d.ts +8 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -3
- 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 -37
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +7 -2
- package/dist/conversation-live.d.ts +1 -0
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +2 -1
- package/dist/conversation-row.d.ts +16 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +17 -1
- package/dist/conversation.d.ts +12 -4
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +44 -36
- package/dist/declaration.js +2 -2
- package/dist/download.d.ts +2 -2
- package/dist/download.d.ts.map +1 -1
- package/dist/entry.d.ts +12 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +86 -25
- 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.map +1 -1
- package/dist/host.js +2 -2
- package/dist/house-query.d.ts +8 -2
- package/dist/house-query.d.ts.map +1 -1
- package/dist/house-query.js +53 -5
- 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 +12 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +2 -0
- package/dist/live.d.ts +14 -0
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +29 -12
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +16 -3
- package/dist/memory.js +4 -4
- package/dist/messages.d.ts +5 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -3
- package/dist/model.d.ts +6 -5
- package/dist/model.d.ts.map +1 -1
- 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 +2 -0
- package/dist/outcome.d.ts +16 -16
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +4 -4
- package/dist/overlay.d.ts +17 -6
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +108 -37
- package/dist/parts.d.ts +1 -0
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +1 -1
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +56 -13
- package/dist/query.d.ts +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +4 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +22 -6
- package/dist/react.d.ts +6 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +4 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +15 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +2 -2
- package/dist/room-draft.d.ts +1 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +4 -4
- package/dist/room-drafts.js +2 -2
- package/dist/room-list.d.ts.map +1 -1
- package/dist/room-list.js +2 -0
- package/dist/rows.d.ts +9 -2
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +17 -4
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +3 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +6 -6
- package/dist/saves.d.ts +3 -3
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +53 -46
- 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 +1 -1
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +13 -12
- package/dist/socket.d.ts +3 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +7 -0
- package/dist/source.d.ts +35 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +61 -7
- package/dist/store/records.d.ts +12 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +10 -4
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/stored.d.ts +9 -2
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +33 -11
- package/dist/surface.d.ts +7 -1
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +3 -0
- package/dist/tables.d.ts +26 -3
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +24 -4
- 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 +2 -1
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -1
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/reference-forms.d.ts +0 -4
- package/dist/reference-forms.d.ts.map +0 -1
- package/dist/reference-forms.js +0 -74
package/dist/conversation.js
CHANGED
|
@@ -293,16 +293,16 @@ async function slide(alive, local, conversation, arriving) {
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
function stateOf(
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
function stateOf({ activity }) {
|
|
297
|
+
if (activity === null)
|
|
298
|
+
return 'idle';
|
|
299
|
+
if (activity.turn === 'asking')
|
|
299
300
|
return 'asking';
|
|
300
|
-
return
|
|
301
|
+
return activity.turn === 'running' || activity.background !== false ? 'working' : 'idle';
|
|
301
302
|
}
|
|
302
303
|
function rowOf(alive, conversation) {
|
|
303
304
|
const { turn, questions, deliveryWaiting } = alive.liveOf(conversation);
|
|
304
305
|
return {
|
|
305
|
-
state: stateOf(alive, conversation),
|
|
306
306
|
started: turn?.started ?? null,
|
|
307
307
|
line: turn === null ? null : runningLine(turn.parts),
|
|
308
308
|
question: openQuestion(questions),
|
|
@@ -332,6 +332,10 @@ async function entries(alive) {
|
|
|
332
332
|
outcome: entry.outcome,
|
|
333
333
|
waiting: entry.waiting,
|
|
334
334
|
subject: entry.subject,
|
|
335
|
+
room: entry.room,
|
|
336
|
+
model: entry.model,
|
|
337
|
+
effort: entry.effort,
|
|
338
|
+
state: stateOf(entry),
|
|
335
339
|
...rowOf(alive, entry.conversation),
|
|
336
340
|
...heldFacts(rows.get(entry.conversation), entry),
|
|
337
341
|
jobs: standing(alive.liveOf(entry.conversation), rows.get(entry.conversation)?.saved ?? null, entry.processEnded)?.running ?? [],
|
|
@@ -357,35 +361,39 @@ function upserted(kept, set, key) {
|
|
|
357
361
|
held.set(key(one), { ...one });
|
|
358
362
|
return held;
|
|
359
363
|
}
|
|
364
|
+
async function listStored(alive, local, change) {
|
|
365
|
+
const { conversationList, agentList, conversationCursor, readUntil } = await local.facts();
|
|
366
|
+
if (readUntil === null)
|
|
367
|
+
await local.fact('readUntil', new Date().toISOString());
|
|
368
|
+
const held = upserted(change.replacing ? [] : (conversationList ?? []), change.set, (entry) => entry.conversation);
|
|
369
|
+
for (const entry of change.set)
|
|
370
|
+
alive.created(entry.conversation);
|
|
371
|
+
if (change.gone !== null)
|
|
372
|
+
held.delete(change.gone);
|
|
373
|
+
const list = [...held.values()];
|
|
374
|
+
const agents = [
|
|
375
|
+
...upserted(change.replacing ? [] : (agentList ?? []), change.agents, (agent) => agent.id).values(),
|
|
376
|
+
];
|
|
377
|
+
if (JSON.stringify(list) !== JSON.stringify(conversationList)) {
|
|
378
|
+
await local.fact('conversationList', list);
|
|
379
|
+
}
|
|
380
|
+
if (JSON.stringify(agents) !== JSON.stringify(agentList)) {
|
|
381
|
+
await local.fact('agentList', agents);
|
|
382
|
+
}
|
|
383
|
+
if (change.cursor !== undefined && !alive.held.now().listRefused) {
|
|
384
|
+
if (change.cursor !== conversationCursor) {
|
|
385
|
+
await local.fact('conversationCursor', change.cursor);
|
|
386
|
+
}
|
|
387
|
+
alive.deps.stream()?.hold(change.cursor);
|
|
388
|
+
}
|
|
389
|
+
return { conversations: list, agents };
|
|
390
|
+
}
|
|
360
391
|
function listChanged(alive, change) {
|
|
361
392
|
void alive.deps
|
|
362
|
-
.durably(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
const held = upserted(change.replacing ? [] : (conversationList ?? []), change.set, (entry) => entry.conversation);
|
|
367
|
-
for (const entry of change.set)
|
|
368
|
-
alive.created(entry.conversation);
|
|
369
|
-
if (change.gone !== null)
|
|
370
|
-
held.delete(change.gone);
|
|
371
|
-
const list = [...held.values()];
|
|
372
|
-
const agents = [
|
|
373
|
-
...upserted(change.replacing ? [] : (agentList ?? []), change.agents, (agent) => agent.id).values(),
|
|
374
|
-
];
|
|
375
|
-
if (JSON.stringify(list) !== JSON.stringify(conversationList)) {
|
|
376
|
-
await local.fact('conversationList', list);
|
|
377
|
-
}
|
|
378
|
-
if (JSON.stringify(agents) !== JSON.stringify(agentList)) {
|
|
379
|
-
await local.fact('agentList', agents);
|
|
380
|
-
}
|
|
381
|
-
if (change.cursor !== undefined) {
|
|
382
|
-
if (change.cursor !== conversationCursor) {
|
|
383
|
-
await local.fact('conversationCursor', change.cursor);
|
|
384
|
-
}
|
|
385
|
-
alive.deps.stream()?.hold(change.cursor);
|
|
386
|
-
}
|
|
387
|
-
return { conversations: list, agents };
|
|
388
|
-
})
|
|
393
|
+
.durably((local) => listStored(alive, local, change).catch((error) => {
|
|
394
|
+
alive.held.set({ listRefused: true });
|
|
395
|
+
throw error;
|
|
396
|
+
}))
|
|
389
397
|
.catch(async () => {
|
|
390
398
|
const { conversationList, agentList } = await (await alive.deps.local()).facts();
|
|
391
399
|
return { conversations: conversationList ?? [], agents: agentList ?? [] };
|
|
@@ -495,6 +503,7 @@ function agentsOf(listing) {
|
|
|
495
503
|
cli: agent.cli,
|
|
496
504
|
model: agent.model,
|
|
497
505
|
effort: agent.effort,
|
|
506
|
+
model_fixed: agent.model_fixed,
|
|
498
507
|
environment: {
|
|
499
508
|
identity: agent.environment,
|
|
500
509
|
name: agent.environment_name,
|
|
@@ -531,8 +540,7 @@ function setLive(alive, conversation, next) {
|
|
|
531
540
|
const before = rowOf(alive, conversation);
|
|
532
541
|
alive.holdLive(conversation, next);
|
|
533
542
|
const after = rowOf(alive, conversation);
|
|
534
|
-
if (after.
|
|
535
|
-
after.started !== before.started ||
|
|
543
|
+
if (after.started !== before.started ||
|
|
536
544
|
ran(alive.liveOf(conversation)) !== was ||
|
|
537
545
|
after.deliveryWaiting.join() !== before.deliveryWaiting.join())
|
|
538
546
|
emitList(alive);
|
|
@@ -1033,8 +1041,8 @@ export function conversationSurface(alive, files) {
|
|
|
1033
1041
|
rename(conversation, name, operation) {
|
|
1034
1042
|
return invoke(alive, 'conversations/rename', conversation, operation, { name });
|
|
1035
1043
|
},
|
|
1036
|
-
|
|
1037
|
-
return invoke(alive, 'conversations/
|
|
1044
|
+
set(conversation, settings, operation) {
|
|
1045
|
+
return invoke(alive, 'conversations/set', conversation, operation, settings);
|
|
1038
1046
|
},
|
|
1039
1047
|
retry(conversation, message, operation) {
|
|
1040
1048
|
return invoke(alive, 'conversations/retry', conversation, operation, {
|
package/dist/declaration.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
2
|
+
import { documentAt, covered, normalize } from './paths.js';
|
|
3
3
|
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
4
|
return declaration;
|
|
5
5
|
}
|
|
@@ -11,7 +11,7 @@ export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pa
|
|
|
11
11
|
const normalized = normalize(path.normalize('NFC'));
|
|
12
12
|
if (normalized === null || normalized === '')
|
|
13
13
|
return { code: 'room-root', path };
|
|
14
|
-
if (covered(providerOwnedPaths, normalized) || !
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !documentAt(authoredPaths, normalized)) {
|
|
15
15
|
return { code: 'provider-owned-path', path: normalized };
|
|
16
16
|
}
|
|
17
17
|
if (!pathRule(normalized))
|
package/dist/download.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AttachmentLinkAnswer, DownloadAnswer } from './outcome.js';
|
|
3
3
|
export declare function handedCopy(copy: Blob, name: string): DownloadAnswer;
|
|
4
|
-
export declare function handedLink(path: string, link: () => Promise<
|
|
4
|
+
export declare function handedLink(path: string, link: () => Promise<AttachmentLinkAnswer>): Promise<DownloadAnswer>;
|
|
5
5
|
export declare function downloadAttachment(client: MdRuntimeClient, link: string): Promise<DownloadAnswer>;
|
|
6
6
|
//# sourceMappingURL=download.d.ts.map
|
package/dist/download.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBzE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAKnE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAEjG"}
|
package/dist/entry.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { type VerifiedModel } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
|
+
import type { ChangeBatch } from './change.js';
|
|
4
|
+
import { type Written } from './overlay.js';
|
|
3
5
|
import { type QueryRows } from './query.js';
|
|
4
6
|
import { type ValuedEntry } from './stored.js';
|
|
5
7
|
import type { Connection } from './tables.js';
|
|
6
8
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
7
9
|
export { documentKey, pathOfKey } from './rows.js';
|
|
8
10
|
export type { ValuedEntry } from './stored.js';
|
|
11
|
+
export type EntryArea = {
|
|
12
|
+
readonly path: string;
|
|
13
|
+
readonly open: readonly string[];
|
|
14
|
+
};
|
|
9
15
|
export type EntryRoom = {
|
|
10
16
|
locator: string;
|
|
17
|
+
handle?: string;
|
|
18
|
+
readable?: readonly string[];
|
|
19
|
+
areas?: readonly EntryArea[];
|
|
11
20
|
schema: string | null;
|
|
12
21
|
documents: Readonly<Record<string, string>>;
|
|
13
22
|
revisions?: Readonly<Record<string, string>>;
|
|
@@ -20,6 +29,7 @@ export type EntryArguments = Readonly<Record<string, string>>;
|
|
|
20
29
|
export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
|
|
21
30
|
export declare function boundQuery(template: unknown, args: EntryArguments): unknown;
|
|
22
31
|
export declare function entryParameters(template: unknown): readonly string[];
|
|
32
|
+
export declare function localQueryRefusal(template: unknown): string | null;
|
|
23
33
|
export declare function entryRefusal(template: unknown): string | null;
|
|
24
34
|
export type EntryScope = {
|
|
25
35
|
results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
|
|
@@ -29,6 +39,7 @@ export type CountedRoom = {
|
|
|
29
39
|
schema: string | null;
|
|
30
40
|
documents: readonly ValuedEntry[];
|
|
31
41
|
};
|
|
32
|
-
export declare function
|
|
42
|
+
export declare function writtenIn(room: EntryRoom, roomTypes: VerifiedModel, batch: ChangeBatch): Written;
|
|
43
|
+
export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection, followed?: readonly EntryRoom[]): EntryScope;
|
|
33
44
|
export declare function countScope(room: CountedRoom, roomTypes: VerifiedModel, connection: Connection): EntryScope;
|
|
34
45
|
//# sourceMappingURL=entry.d.ts.map
|
package/dist/entry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.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U,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,EACtB,QAAQ,GAAE,SAAS,SAAS,EAAO,GAClC,UAAU,CAOZ;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,GACrB,UAAU,CAaZ"}
|
package/dist/entry.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { invalid, plain, QueryError, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { attachedModel } from './attached-model.js';
|
|
3
|
+
import { writtenDocuments } from './overlay.js';
|
|
3
4
|
import { answerQuery } from './compile.js';
|
|
4
5
|
import { planWithin } from './query.js';
|
|
5
|
-
import { writtenFacts } from './rows.js';
|
|
6
|
+
import { documentKey, writtenFacts } from './rows.js';
|
|
6
7
|
import { entered, enteredValues, REPLICA_TABLES, } from './stored.js';
|
|
7
8
|
export { QueryError } from '@agentshouse/mdmodel';
|
|
8
9
|
export { documentKey, pathOfKey } from './rows.js';
|
|
@@ -71,6 +72,12 @@ export function entryParameters(template) {
|
|
|
71
72
|
return [];
|
|
72
73
|
}
|
|
73
74
|
const SAMPLED = {
|
|
75
|
+
rooms: 'entry',
|
|
76
|
+
folder: 'entry',
|
|
77
|
+
outside: 'entry',
|
|
78
|
+
paths: 'entry',
|
|
79
|
+
fileIds: 'entry',
|
|
80
|
+
text: 'entry',
|
|
74
81
|
direction: 'asc',
|
|
75
82
|
nulls: 'last',
|
|
76
83
|
stringSort: 'lexical',
|
|
@@ -101,15 +108,16 @@ function sampled(template, key) {
|
|
|
101
108
|
}
|
|
102
109
|
return template;
|
|
103
110
|
}
|
|
104
|
-
function entryPlan(query, facts) {
|
|
105
|
-
const plan = planWithin(query, facts);
|
|
111
|
+
function entryPlan(query, facts, reach = null) {
|
|
112
|
+
const plan = planWithin(query, facts, reach);
|
|
106
113
|
if (plan.fileIds !== null)
|
|
107
114
|
invalid('fileIds', 'an entry Room holds no file IDs');
|
|
108
115
|
return plan;
|
|
109
116
|
}
|
|
110
|
-
|
|
117
|
+
const UNHELD = { listed: false, rooms: [] };
|
|
118
|
+
function refusalOf(plan) {
|
|
111
119
|
try {
|
|
112
|
-
|
|
120
|
+
plan();
|
|
113
121
|
return null;
|
|
114
122
|
}
|
|
115
123
|
catch (error) {
|
|
@@ -118,38 +126,88 @@ export function entryRefusal(template) {
|
|
|
118
126
|
throw error;
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
export function localQueryRefusal(template) {
|
|
130
|
+
return refusalOf(() => planWithin(sampled(template, ''), UNHELD));
|
|
131
|
+
}
|
|
132
|
+
export function entryRefusal(template) {
|
|
133
|
+
return refusalOf(() => entryPlan(sampled(template, ''), UNHELD));
|
|
134
|
+
}
|
|
135
|
+
function composedRoom(room, roomTypes) {
|
|
136
|
+
const model = attachedModel({
|
|
137
|
+
kind: 'model',
|
|
138
|
+
snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
|
|
139
|
+
}, roomTypes);
|
|
140
|
+
return { model, selection: null, typedPaths: [] };
|
|
141
|
+
}
|
|
142
|
+
export function writtenIn(room, roomTypes, batch) {
|
|
143
|
+
const written = writtenDocuments({
|
|
144
|
+
documents: room.documents,
|
|
145
|
+
binaries: {},
|
|
146
|
+
revisions: room.revisions ?? {},
|
|
147
|
+
fileIds: {},
|
|
148
|
+
created: {},
|
|
149
|
+
changes: {},
|
|
150
|
+
}, batch, composedRoom(room, roomTypes));
|
|
151
|
+
for (;;) {
|
|
152
|
+
const step = written.next();
|
|
153
|
+
if (step.done === true)
|
|
154
|
+
return step.value;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function enteredRoom(room, roomTypes, connection) {
|
|
158
|
+
const composition = composedRoom(room, roomTypes);
|
|
159
|
+
const { model } = composition;
|
|
160
|
+
const key = room.enter(composition);
|
|
161
|
+
if (room.handle !== undefined)
|
|
162
|
+
connection.run("INSERT INTO replica_rooms (locator, key, record) VALUES (?, ?, json_object('declaration', json_object('handle', ?)))", [room.locator, key, room.handle]);
|
|
163
|
+
return {
|
|
164
|
+
locator: room.locator,
|
|
165
|
+
key,
|
|
166
|
+
composition,
|
|
167
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
168
|
+
facts: {
|
|
131
169
|
locator: room.locator,
|
|
132
170
|
available: model.status !== 'unavailable',
|
|
133
171
|
types: model.status === 'unavailable' ? [] : Object.values(model.types),
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function reachOf(rooms, followed) {
|
|
176
|
+
if (followed.every(({ readable, areas }) => readable === undefined && areas === undefined))
|
|
177
|
+
return null;
|
|
178
|
+
return {
|
|
179
|
+
rooms: [...rooms, ...followed.filter(({ readable }) => readable === undefined)].map(({ locator }) => locator),
|
|
180
|
+
documents: followed.flatMap(({ locator, readable }) => (readable ?? []).map((path) => documentKey(locator, path))),
|
|
181
|
+
areas: followed.flatMap(({ locator, areas }) => (areas ?? []).map(({ path, open }) => ({ room: locator, path, open }))),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function scope(rooms, roomTypes, connection, followed = []) {
|
|
185
|
+
for (const table of REPLICA_TABLES)
|
|
186
|
+
connection.run(table);
|
|
187
|
+
const keys = rooms.map((room) => enteredRoom(room, roomTypes, connection));
|
|
188
|
+
const follows = [
|
|
189
|
+
...keys,
|
|
190
|
+
...followed.map((room) => enteredRoom(room, roomTypes, connection)),
|
|
191
|
+
].filter(({ handle }) => handle !== undefined);
|
|
192
|
+
const planned = { listed: true, rooms: keys.map(({ facts }) => facts) };
|
|
193
|
+
const reach = reachOf(rooms, followed);
|
|
139
194
|
return {
|
|
140
195
|
async results(queries) {
|
|
141
196
|
const results = {};
|
|
142
197
|
for (const [name, query] of Object.entries(queries)) {
|
|
143
|
-
const plan = entryPlan(query, planned);
|
|
144
|
-
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
|
|
198
|
+
const plan = entryPlan(query, planned, reach);
|
|
199
|
+
results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)), null, follows);
|
|
145
200
|
}
|
|
146
201
|
return results;
|
|
147
202
|
},
|
|
148
203
|
};
|
|
149
204
|
}
|
|
150
|
-
|
|
151
|
-
return
|
|
205
|
+
function scopedRoom(room, connection) {
|
|
206
|
+
return {
|
|
152
207
|
locator: room.locator,
|
|
208
|
+
...(room.handle === undefined ? {} : { handle: room.handle }),
|
|
209
|
+
...(room.readable === undefined ? {} : { readable: room.readable }),
|
|
210
|
+
...(room.areas === undefined ? {} : { areas: room.areas }),
|
|
153
211
|
schema: room.schema,
|
|
154
212
|
enter(composition) {
|
|
155
213
|
const heads = (path) => ({
|
|
@@ -177,7 +235,10 @@ export function entryScope(rooms, roomTypes, connection) {
|
|
|
177
235
|
];
|
|
178
236
|
return entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
|
|
179
237
|
},
|
|
180
|
-
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export function entryScope(rooms, roomTypes, connection, followed = []) {
|
|
241
|
+
return scope(rooms.map((room) => scopedRoom(room, connection)), roomTypes, connection, followed.map((room) => scopedRoom(room, connection)));
|
|
181
242
|
}
|
|
182
243
|
export function countScope(room, roomTypes, connection) {
|
|
183
244
|
return scope([
|
package/dist/figures.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { GroupTotal, PendingResult } from './query.js';
|
|
|
3
3
|
import type { Deliver, Fail } from './reach.js';
|
|
4
4
|
import type { ConversationTally, RoomTally } from './tallies.js';
|
|
5
5
|
import type { QueryRoom } from './tables.js';
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const HOUSE_FOLDER = "house";
|
|
7
7
|
export declare const ROOM_TOTALS: {
|
|
8
8
|
readonly outside: readonly ["house"];
|
|
9
9
|
readonly groupBy: readonly ["room"];
|
package/dist/figures.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figures.d.ts","sourceRoot":"","sources":["../src/figures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"figures.d.ts","sourceRoot":"","sources":["../src/figures.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;iBAGZ,IAAI;;CACe,CAAC;AAGhC,eAAO,MAAM,cAAc,WAAa,CAAC;AAQzC,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;I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,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAgDF,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAwIlE"}
|
package/dist/figures.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { instantKey } from '@agentshouse/mdmodel';
|
|
2
|
-
export const
|
|
2
|
+
export const HOUSE_FOLDER = 'house';
|
|
3
3
|
export const ROOM_TOTALS = {
|
|
4
|
-
outside: [
|
|
4
|
+
outside: [HOUSE_FOLDER],
|
|
5
5
|
groupBy: ['room'],
|
|
6
6
|
select: { size: true },
|
|
7
7
|
};
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAWxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG1F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAEL,KAAK,WAAW,EAQjB,MAAM,WAAW,CAAC;AAgBnB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,CAAC;AAE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AI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAiLF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAsN3E;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACtF,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,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -108,8 +108,8 @@ function answered(md, app, writtenBy, member, input, said) {
|
|
|
108
108
|
return md.conversation.decide(input[0], input[1], input[2]);
|
|
109
109
|
case 'conversation.rename':
|
|
110
110
|
return md.conversation.rename(input[0], input[1], input[2]);
|
|
111
|
-
case 'conversation.
|
|
112
|
-
return md.conversation.
|
|
111
|
+
case 'conversation.set':
|
|
112
|
+
return md.conversation.set(input[0], input[1], input[2]);
|
|
113
113
|
case 'conversation.retry':
|
|
114
114
|
return md.conversation.retry(input[0], input[1], input[2]);
|
|
115
115
|
case 'conversation.pin':
|
package/dist/house-query.d.ts
CHANGED
|
@@ -3,9 +3,14 @@ import type { HouseQueryGroups, HouseQueryRows, ProviderRefusal } from './adapte
|
|
|
3
3
|
import { type Failure, type Offline } from './outcome.js';
|
|
4
4
|
import { type PortReach } from './reach.js';
|
|
5
5
|
import type { Runtime } from './runtime.js';
|
|
6
|
-
|
|
7
|
-
rooms: readonly [string];
|
|
6
|
+
type HouseViewQuery = {
|
|
7
|
+
readonly rooms: readonly [string];
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly after?: string;
|
|
8
10
|
};
|
|
11
|
+
export type HouseQuery = ((DocumentQuery | GroupQuery) & {
|
|
12
|
+
rooms: readonly [string];
|
|
13
|
+
}) | HouseViewQuery;
|
|
9
14
|
export type HouseQueryOptions = {
|
|
10
15
|
readonly fresh?: boolean;
|
|
11
16
|
};
|
|
@@ -15,4 +20,5 @@ export type HouseQueryResult = HouseQueryRows | HouseQueryGroups | Offline | (Pr
|
|
|
15
20
|
kind: 'undeclared';
|
|
16
21
|
}) | Failure;
|
|
17
22
|
export declare function queriedHouse(runtime: Runtime, input: unknown, reach: PortReach | null, options: unknown): Promise<HouseQueryResult>;
|
|
23
|
+
export {};
|
|
18
24
|
//# sourceMappingURL=house-query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"house-query.d.ts","sourceRoot":"","sources":["../src/house-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"house-query.d.ts","sourceRoot":"","sources":["../src/house-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,KAAK,EAGV,gBAAgB,EAChB,cAAc,EACd,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAA2C,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,CAAC,CAAC,aAAa,GAAG,UAAU,CAAC,GAAG;IAAE,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,GAC7D,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAAG;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7D,MAAM,MAAM,gBAAgB,GACxB,cAAc,GACd,gBAAgB,GAChB,OAAO,GACP,CAAC,eAAe,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GACxC,CAAC,eAAe,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,GAC1C,OAAO,CAAC;AAgFZ,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,gBAAgB,CAAC,CAiB3B"}
|
package/dist/house-query.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { invalid, known, plain } from '@agentshouse/mdmodel';
|
|
2
2
|
import { listedOrHeld } from './listing.js';
|
|
3
|
+
import { normalize } from './paths.js';
|
|
3
4
|
import { failure, OFFLINE, UNCERTAIN, undeclared } from './outcome.js';
|
|
4
5
|
import { askedOnline, offline } from './online.js';
|
|
5
6
|
import { holds, queriedOnly } from './reach.js';
|
|
7
|
+
import { documentKey } from './rows.js';
|
|
6
8
|
const HELD_ON_DEVICE = {
|
|
7
9
|
kind: 'rejected',
|
|
8
10
|
code: 'held-on-device',
|
|
@@ -20,25 +22,71 @@ function freshOf(options) {
|
|
|
20
22
|
invalid('fresh', 'expects true or false');
|
|
21
23
|
return fresh;
|
|
22
24
|
}
|
|
23
|
-
function
|
|
25
|
+
function viewOf(query) {
|
|
26
|
+
known(query, ['path', 'after'], '');
|
|
27
|
+
const { path, after } = query;
|
|
28
|
+
if (typeof path !== 'string' || path === '' || normalize(path) !== path)
|
|
29
|
+
invalid('path', 'names a View by its Path in the Room');
|
|
30
|
+
if (after === undefined)
|
|
31
|
+
return { path };
|
|
32
|
+
if (typeof after !== 'string')
|
|
33
|
+
invalid('after', 'expects the next an earlier page answered');
|
|
34
|
+
return { path, after };
|
|
35
|
+
}
|
|
36
|
+
function followedOf(reach) {
|
|
37
|
+
if (reach === null)
|
|
38
|
+
return {};
|
|
39
|
+
const whole = new Set([
|
|
40
|
+
...reach.rooms,
|
|
41
|
+
...(reach.queriesOnly ?? []).map(({ locator }) => locator),
|
|
42
|
+
]);
|
|
43
|
+
const documents = new Map(reach.documents
|
|
44
|
+
.filter(({ room }) => !whole.has(room))
|
|
45
|
+
.map(({ room, path }) => [documentKey(room, path), { room, path }]));
|
|
46
|
+
const followed = new Set([...whole, ...[...documents.values()].map(({ room }) => room)]);
|
|
47
|
+
const areas = new Map((reach.areas ?? [])
|
|
48
|
+
.filter(({ room }) => followed.has(room))
|
|
49
|
+
.map(({ room, path, open }) => [
|
|
50
|
+
documentKey(room, path),
|
|
51
|
+
{ room, path, open: [...new Set(open)].sort() },
|
|
52
|
+
]));
|
|
53
|
+
return {
|
|
54
|
+
follows: [
|
|
55
|
+
...[...whole].sort(),
|
|
56
|
+
...[...documents.keys()].sort().map((key) => documents.get(key)),
|
|
57
|
+
...[...areas.keys()].sort().map((key) => areas.get(key)),
|
|
58
|
+
],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function houseQueryOf(input, options, reach) {
|
|
24
62
|
if (!plain(input))
|
|
25
63
|
invalid('query', 'expects a query object');
|
|
26
64
|
const { rooms, ...query } = input;
|
|
27
65
|
if (!Array.isArray(rooms) || rooms.length !== 1 || typeof rooms[0] !== 'string')
|
|
28
66
|
invalid('rooms', 'names the one Room House answers');
|
|
29
|
-
|
|
67
|
+
const asked = { room: rooms[0], fresh: freshOf(options), ...followedOf(reach) };
|
|
68
|
+
return query.path === undefined ? { ...asked, query } : { ...asked, ...viewOf(query) };
|
|
30
69
|
}
|
|
31
70
|
async function heldHere(runtime, reach, room) {
|
|
32
71
|
return holds(reach, room) && listedOrHeld(runtime, await runtime.store.rooms([room]), room);
|
|
33
72
|
}
|
|
73
|
+
async function searchListed(runtime, room) {
|
|
74
|
+
const { roomList } = await (await runtime.store.open()).facts(['roomList']);
|
|
75
|
+
return roomList?.rooms.some((one) => one.room_ref === room && one.level === 'search') === true;
|
|
76
|
+
}
|
|
77
|
+
async function queriedHere(runtime, reach, room) {
|
|
78
|
+
if (queriedOnly(reach, runtime.socket.session.now().queriesOnly, room))
|
|
79
|
+
return true;
|
|
80
|
+
return reach === null && (await searchListed(runtime, room));
|
|
81
|
+
}
|
|
34
82
|
export async function queriedHouse(runtime, input, reach, options) {
|
|
35
83
|
const { socket } = runtime;
|
|
36
|
-
const asked = houseQueryOf(input, options);
|
|
37
|
-
await socket.ready;
|
|
38
84
|
const query = socket.queryHouse();
|
|
39
85
|
if (query === undefined)
|
|
40
86
|
return undeclared('queryHouse');
|
|
41
|
-
|
|
87
|
+
const asked = houseQueryOf(input, options, reach);
|
|
88
|
+
await socket.ready;
|
|
89
|
+
if (!(await queriedHere(runtime, reach, asked.room))) {
|
|
42
90
|
return (await heldHere(runtime, reach, asked.room))
|
|
43
91
|
? HELD_ON_DEVICE
|
|
44
92
|
: failure({ kind: 'room-not-readable', locator: asked.room });
|
package/dist/identity.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export declare function changeBatchIdentity(at?: number): string;
|
|
|
2
2
|
export declare function roomDraftRevision(): string;
|
|
3
3
|
export declare function chatDraftRevision(): string;
|
|
4
4
|
export declare function transferIdentity(): string;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function attachmentLocalId(): string;
|
|
6
6
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|