@agentshouse/mdruntime 0.1.0-cf08ada271a7f → 0.1.0-cf08df9b663d8
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 +21 -19
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +57 -38
- package/dist/act-lanes.d.ts +30 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +225 -0
- package/dist/actions.d.ts +8 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +173 -83
- package/dist/adapter.d.ts +210 -30
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +0 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -7
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.d.ts +0 -2
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +2 -4
- package/dist/client.d.ts +29 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +49 -64
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +4 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +88 -44
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +32 -17
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -11
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +24 -11
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +45 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +337 -203
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +46 -48
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +7 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- package/dist/expectation.d.ts +25 -14
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +51 -20
- package/dist/failure.d.ts +2 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -2
- package/dist/holdings.d.ts.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +94 -30
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +27 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -9
- package/dist/install.d.ts +10 -5
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -55
- package/dist/lifecycle.d.ts +2 -2
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +74 -51
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +27 -20
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +68 -69
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +8 -20
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +181 -34
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +99 -37
- package/dist/messages.d.ts +21 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +48 -16
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +18 -35
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +29 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +206 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +6 -6
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +4 -4
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +22 -10
- package/dist/outcome.d.ts +33 -13
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +36 -6
- package/dist/overlay.d.ts +21 -7
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +112 -39
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +5 -9
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -15
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +207 -96
- package/dist/presence.d.ts +58 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +231 -0
- package/dist/queries.d.ts +2 -2
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +137 -79
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -8
- package/dist/queue.d.ts +2 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +76 -49
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +196 -37
- package/dist/react.d.ts +17 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +23 -4
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +5 -3
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +26 -14
- package/dist/recovery.d.ts +4 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +31 -8
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +2 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +31 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +262 -36
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- 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/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -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 +11 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +120 -135
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +116 -65
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- 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 +8 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +95 -67
- package/dist/socket/lanes.d.ts +12 -4
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +34 -8
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +9 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +17 -16
- package/dist/source.d.ts +42 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +31 -7
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +70 -24
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +24 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +49 -17
- package/dist/stored.d.ts +41 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +215 -57
- package/dist/surface.d.ts +20 -8
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +66 -32
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +109 -82
- package/dist/tables.d.ts +40 -52
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +109 -326
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +3 -4
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +68 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +28 -11
- package/package.json +4 -4
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
- package/dist/job.d.ts +0 -5
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -7
- package/dist/log.d.ts +0 -6
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -14
- package/dist/socket/rooms.d.ts +0 -41
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAGrE,eAAO,MAAM,OAAO,YAAY,CAAC;AAOjC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAenF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAIjE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { turnCounts } from '@agentshouse/session-content';
|
|
2
2
|
import { excerpt } from './read.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export const WORKING = 'Working';
|
|
4
|
+
function said(count, one, many) {
|
|
5
|
+
if (count === 0)
|
|
6
|
+
return null;
|
|
7
|
+
return count === 1 ? one : many(count);
|
|
8
|
+
}
|
|
9
|
+
export function linesWords(added, removed) {
|
|
10
|
+
return `+${added} −${removed}`;
|
|
11
|
+
}
|
|
12
|
+
export function capitalized(words) {
|
|
13
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
14
|
+
}
|
|
15
|
+
export function turnLine(parts, lead) {
|
|
16
|
+
const counts = turnCounts(parts);
|
|
17
|
+
const kinds = [
|
|
18
|
+
said(counts.commands, 'ran 1 command', (count) => `ran ${count} commands`),
|
|
19
|
+
said(counts.edited, 'edited 1 file', (count) => `edited ${count} files`),
|
|
20
|
+
said(counts.other, 'made 1 other call', (count) => `made ${count} other calls`),
|
|
21
|
+
].filter((one) => one !== null);
|
|
22
|
+
if (kinds.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const changed = counts.added === 0 && counts.removed === 0 ? null : linesWords(counts.added, counts.removed);
|
|
25
|
+
const failed = counts.failed === 0 ? null : `${counts.failed} failed`;
|
|
26
|
+
const words = kinds.join(' · ');
|
|
27
|
+
return [lead === null ? capitalized(words) : `${lead} · ${words}`, changed, failed]
|
|
28
|
+
.filter((one) => one !== null)
|
|
29
|
+
.join(' · ');
|
|
5
30
|
}
|
|
6
31
|
export function runningLine(parts) {
|
|
7
|
-
const
|
|
8
|
-
const note = newest.find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
32
|
+
const note = [...parts].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
9
33
|
if (note?.type === 'text')
|
|
10
34
|
return excerpt(note.text);
|
|
11
|
-
|
|
12
|
-
return call?.type === 'call' && call.line !== '' ? call.line : null;
|
|
13
|
-
}
|
|
14
|
-
export function workOf(state) {
|
|
15
|
-
return (state?.running ?? []).map(({ kind, label, progress, next }) => ({
|
|
16
|
-
kind: kind === 'subagent' || kind === 'schedule' ? kind : 'job',
|
|
17
|
-
title: label,
|
|
18
|
-
next,
|
|
19
|
-
activity: progress,
|
|
20
|
-
}));
|
|
35
|
+
return turnLine(parts, null);
|
|
21
36
|
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function documentAt(patterns: readonly string[], path: string): boolean;
|
|
5
5
|
export declare function ancestors(path: string): readonly string[];
|
|
6
6
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.js
CHANGED
|
@@ -41,7 +41,7 @@ function matched(pattern, path) {
|
|
|
41
41
|
return ((open ? names.length > fixed.length : names.length === fixed.length) &&
|
|
42
42
|
fixed.every((one, at) => named(one, names[at])));
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
44
|
+
export function documentAt(patterns, path) {
|
|
45
45
|
return patterns.some((pattern) => matched(pattern, path));
|
|
46
46
|
}
|
|
47
47
|
export function ancestors(path) {
|
package/dist/preparation.d.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type InstallShare } from './install.js';
|
|
2
|
+
import { type ReadinessChange } from './observation.js';
|
|
2
3
|
import { type PortReach } from './reach.js';
|
|
3
|
-
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import { type CodeAvailability, type ConnectionAvailability, type FirstTier, type Readiness, type RoomCoverage } from './readiness.js';
|
|
4
5
|
import type { Runtime } from './runtime.js';
|
|
5
6
|
export type ReadinessPort = {
|
|
6
7
|
readonly target: string;
|
|
7
8
|
readonly code: CodeAvailability;
|
|
9
|
+
readonly first: FirstTier | null;
|
|
10
|
+
readonly inboxed: readonly string[] | null;
|
|
8
11
|
};
|
|
12
|
+
export type ReadinessMessage = Readiness | ReadinessChange;
|
|
9
13
|
export type ReadinessWatch = {
|
|
10
14
|
readonly port: ReadinessPort;
|
|
11
15
|
readonly reach: PortReach | null;
|
|
12
|
-
readonly deliver: (readiness:
|
|
16
|
+
readonly deliver: (readiness: ReadinessMessage) => void;
|
|
17
|
+
};
|
|
18
|
+
type Share = InstallShare & {
|
|
19
|
+
readonly coverage: RoomCoverage;
|
|
20
|
+
};
|
|
21
|
+
type Settled = {
|
|
22
|
+
acquiring: number;
|
|
23
|
+
unsettled: number;
|
|
24
|
+
};
|
|
25
|
+
type Totals = Settled & {
|
|
26
|
+
installing: number;
|
|
27
|
+
downloading: number;
|
|
28
|
+
done: number;
|
|
29
|
+
total: number;
|
|
30
|
+
};
|
|
31
|
+
export type ReadinessShowing = {
|
|
32
|
+
readonly listing: number;
|
|
33
|
+
readonly roomsListed: boolean;
|
|
34
|
+
readonly named: ReadonlySet<string> | null;
|
|
35
|
+
readonly rooms: Map<string, Share>;
|
|
36
|
+
readonly first: Map<string, string>;
|
|
37
|
+
readonly totals: Totals;
|
|
38
|
+
shown: string;
|
|
13
39
|
};
|
|
14
40
|
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
-
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
41
|
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
-
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
-
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness:
|
|
19
|
-
export declare function filled(
|
|
42
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[], touched: ReadonlySet<string> | null): Promise<void>;
|
|
43
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
44
|
+
export declare function filled({ store, socket }: Runtime): void;
|
|
45
|
+
export {};
|
|
20
46
|
//# sourceMappingURL=preparation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EACd,KAAK,SAAS,EAEd,KAAK,YAAY,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,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C;AAwCF,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,GAAE,SAAS,MAAM,EAAO,QA4BzE;AAqGD,wBAAsB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAOrF;AA8MD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,SAAS,cAAc,EAAE,EAC/B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,iBAKpC;AAED,wBAAgB,cAAc,CAC5B,EAAE,KAAK,EAAE,EAAE,OAAO,EAClB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,OAAO,EAAE,CAAC,SAAS,EAAE,gBAAgB,KAAK,IAAI,GAC7C,MAAM,IAAI,CAWZ;AAED,wBAAgB,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,QAGhD"}
|
package/dist/preparation.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { changeSet } from './change-set.js';
|
|
2
2
|
import { uncaught } from './failure.js';
|
|
3
|
-
import { installationOf } from './install.js';
|
|
4
|
-
import { listedLocators } from './listing.js';
|
|
3
|
+
import { installationOf, installShare } from './install.js';
|
|
4
|
+
import { listedLocators, listedOrHeld } from './listing.js';
|
|
5
|
+
import { keyedAt, keyedChange, unchanged, } from './observation.js';
|
|
5
6
|
import { planReach } from './reach.js';
|
|
6
|
-
import { readinessOf, } from './readiness.js';
|
|
7
|
-
import {
|
|
7
|
+
import { COMPLETE_ROOMS, readinessOf, } from './readiness.js';
|
|
8
|
+
import { roomsOfReach } from './rows.js';
|
|
8
9
|
import { recoverReads } from './shown.js';
|
|
9
10
|
import { yielded } from './turn.js';
|
|
10
11
|
async function prepareReplica(runtime, locator) {
|
|
@@ -23,22 +24,23 @@ async function prepareReplica(runtime, locator) {
|
|
|
23
24
|
if ((await store.rooms([locator])).get(locator)?.record.key !== key)
|
|
24
25
|
continue;
|
|
25
26
|
store.changed(changeSet(locator, { documents: null }));
|
|
26
|
-
recoverReads(runtime);
|
|
27
|
-
store.readiness.queue();
|
|
27
|
+
recoverReads(runtime, [locator]);
|
|
28
|
+
store.readiness.queue([locator]);
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
async function unprepared({ store
|
|
32
|
+
async function unprepared({ store }) {
|
|
32
33
|
const held = (await store.covering()).rooms;
|
|
33
|
-
|
|
34
|
+
const { unpreparedDemand, unpreparable } = store.device.now();
|
|
35
|
+
return [...unpreparedDemand, ...held.keys()].find((locator) => !(held.get(locator)?.indexed ?? false) && !unpreparable.has(locator));
|
|
34
36
|
}
|
|
35
|
-
function unpreparedBy({ store
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
store.readiness.queue();
|
|
37
|
+
function unpreparedBy({ store }, locator) {
|
|
38
|
+
const { unpreparable } = store.device.now();
|
|
39
|
+
store.device.set({ unpreparable: new Set([...unpreparable, locator]) });
|
|
40
|
+
store.readiness.queue([locator]);
|
|
39
41
|
}
|
|
40
42
|
export function prepare(runtime, locators = []) {
|
|
41
|
-
const { store, socket
|
|
43
|
+
const { store, socket } = runtime;
|
|
42
44
|
const { device } = store;
|
|
43
45
|
if (locators.length > 0) {
|
|
44
46
|
device.set({ unpreparedDemand: new Set([...device.now().unpreparedDemand, ...locators]) });
|
|
@@ -55,11 +57,10 @@ export function prepare(runtime, locators = []) {
|
|
|
55
57
|
const demand = new Set(device.now().unpreparedDemand);
|
|
56
58
|
demand.delete(waiting);
|
|
57
59
|
device.set({ unpreparedDemand: demand });
|
|
58
|
-
await prepareReplica(runtime, waiting).catch((
|
|
60
|
+
await prepareReplica(runtime, waiting).catch(() => unpreparedBy(runtime, waiting));
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
catch (error) {
|
|
62
|
-
journal.record('preparation failed');
|
|
63
64
|
uncaught(error);
|
|
64
65
|
}
|
|
65
66
|
finally {
|
|
@@ -67,26 +68,20 @@ export function prepare(runtime, locators = []) {
|
|
|
67
68
|
}
|
|
68
69
|
})();
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return { listed: named.every((room) => held.has(room)), rooms: named };
|
|
83
|
-
}
|
|
84
|
-
function roomState({ socket }, locator, held) {
|
|
85
|
-
const listedRoom = socket.rooms.discovered(locator);
|
|
71
|
+
function requires(runtime, named, held, room) {
|
|
72
|
+
const listed = listedOrHeld(runtime, held, room);
|
|
73
|
+
if (named === null)
|
|
74
|
+
return listed;
|
|
75
|
+
return named.has(room) && (!runtime.socket.session.now().roomsListed || listed);
|
|
76
|
+
}
|
|
77
|
+
function requiredRooms(runtime, named, held) {
|
|
78
|
+
return [...(named ?? listedLocators(runtime, held))]
|
|
79
|
+
.filter((room) => requires(runtime, named, held, room))
|
|
80
|
+
.sort();
|
|
81
|
+
}
|
|
82
|
+
function roomState({ socket, presence }, locator, held) {
|
|
86
83
|
if (socket.session.now().roomsListed &&
|
|
87
|
-
(
|
|
88
|
-
listedRoom.replica.admission !== 'admitted' ||
|
|
89
|
-
socket.rooms.standing(locator).unreadable))
|
|
84
|
+
(presence.room(locator) === undefined || !presence.available(locator)))
|
|
90
85
|
return 'unadmitted';
|
|
91
86
|
const stored = held.get(locator);
|
|
92
87
|
if (stored === undefined)
|
|
@@ -103,6 +98,41 @@ function conversationCoverage({ socket, conversations }, reach) {
|
|
|
103
98
|
return 'acquiring';
|
|
104
99
|
return 'complete';
|
|
105
100
|
}
|
|
101
|
+
function listCoverage({ socket, conversations }, first) {
|
|
102
|
+
if (!first.conversations || socket.conversations() === undefined)
|
|
103
|
+
return 'undeclared';
|
|
104
|
+
return conversations.listHeld() ? 'complete' : 'acquiring';
|
|
105
|
+
}
|
|
106
|
+
function tierOf(roomsListed, named, { acquiring, unsettled }, conversations) {
|
|
107
|
+
return { listed: roomsListed || (named && acquiring === 0), unsettled, conversations };
|
|
108
|
+
}
|
|
109
|
+
function placed({ presence }, tier, first, room, held) {
|
|
110
|
+
if (tier === null)
|
|
111
|
+
return;
|
|
112
|
+
const handle = presence.room(room)?.handle ?? held.get(room)?.handle;
|
|
113
|
+
if (handle !== undefined && tier.handles.includes(handle))
|
|
114
|
+
first.set(handle, room);
|
|
115
|
+
}
|
|
116
|
+
function firstOf(runtime, tier, inboxed, { roomsListed, rooms, first }) {
|
|
117
|
+
const settled = { acquiring: 0, unsettled: 0 };
|
|
118
|
+
const counted = (room) => {
|
|
119
|
+
const share = room === undefined ? undefined : rooms.get(room);
|
|
120
|
+
if (share !== undefined)
|
|
121
|
+
settledBy(settled, share.coverage.state, 1);
|
|
122
|
+
else if (!roomsListed)
|
|
123
|
+
settledBy(settled, 'acquiring', 1);
|
|
124
|
+
};
|
|
125
|
+
for (const handle of tier.handles)
|
|
126
|
+
counted(first.get(handle));
|
|
127
|
+
if (tier.inboxes) {
|
|
128
|
+
if (inboxed === null)
|
|
129
|
+
settledBy(settled, 'acquiring', 1);
|
|
130
|
+
else
|
|
131
|
+
for (const room of inboxed)
|
|
132
|
+
counted(room);
|
|
133
|
+
}
|
|
134
|
+
return tierOf(roomsListed, true, settled, listCoverage(runtime, tier));
|
|
135
|
+
}
|
|
106
136
|
function connectionOf({ socket }, lastCompleted) {
|
|
107
137
|
if (socket.isOpen())
|
|
108
138
|
return 'connected';
|
|
@@ -115,30 +145,103 @@ export async function connectionNow(runtime) {
|
|
|
115
145
|
if (socket.isOpen() || socket.session.now().moving.providerUnreachable || socket.streamed) {
|
|
116
146
|
return connectionOf(runtime, null);
|
|
117
147
|
}
|
|
118
|
-
|
|
148
|
+
if (!store.needed())
|
|
149
|
+
return connectionOf(runtime, socket.session.now().lastCompleted);
|
|
150
|
+
return connectionOf(runtime, (await (await store.open()).facts(['lastCompleted'])).lastCompleted);
|
|
119
151
|
}
|
|
120
|
-
async function readinessHeld({ store }) {
|
|
152
|
+
async function readinessHeld({ store, socket }) {
|
|
153
|
+
if (!store.needed()) {
|
|
154
|
+
return {
|
|
155
|
+
held: new Map(),
|
|
156
|
+
facts: { lastCompleted: socket.session.now().lastCompleted, targets: {} },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
121
159
|
const local = await store.open();
|
|
122
|
-
const [held, facts] = await Promise.all([
|
|
160
|
+
const [held, facts] = await Promise.all([
|
|
161
|
+
store.covering(),
|
|
162
|
+
local.facts(['lastCompleted', 'targets']),
|
|
163
|
+
]);
|
|
123
164
|
return { held: held.rooms, facts };
|
|
124
165
|
}
|
|
125
|
-
function
|
|
126
|
-
const {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
166
|
+
function shareOf(runtime, room, held) {
|
|
167
|
+
const coverage = Object.freeze({ room, state: roomState(runtime, room, held) });
|
|
168
|
+
return { ...installShare(runtime.store, coverage, held), coverage };
|
|
169
|
+
}
|
|
170
|
+
function sameState(was, now) {
|
|
171
|
+
return was.coverage.state === now.coverage.state;
|
|
172
|
+
}
|
|
173
|
+
function coverageOf(change) {
|
|
174
|
+
return {
|
|
175
|
+
...change,
|
|
176
|
+
changed: change.changed.map(([room, share]) => [room, share.coverage]),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function settledBy(settled, state, sign) {
|
|
180
|
+
settled.acquiring += state === 'acquiring' ? sign : 0;
|
|
181
|
+
settled.unsettled += COMPLETE_ROOMS.has(state) ? 0 : sign;
|
|
182
|
+
}
|
|
183
|
+
function counted(totals, share, sign) {
|
|
184
|
+
totals.installing += share.installing ? sign : 0;
|
|
185
|
+
totals.downloading += share.downloading ? sign : 0;
|
|
186
|
+
settledBy(totals, share.coverage.state, sign);
|
|
187
|
+
totals.done += sign * share.bytes.done;
|
|
188
|
+
totals.total += sign * share.bytes.total;
|
|
189
|
+
}
|
|
190
|
+
function showingOf(runtime, { port, reach }, held) {
|
|
191
|
+
const planned = planReach(reach);
|
|
192
|
+
const named = planned === null ? null : roomsOfReach(planned);
|
|
193
|
+
const totals = { installing: 0, downloading: 0, acquiring: 0, unsettled: 0, done: 0, total: 0 };
|
|
194
|
+
const rooms = new Map();
|
|
195
|
+
const first = new Map();
|
|
196
|
+
for (const room of requiredRooms(runtime, named, held)) {
|
|
197
|
+
const share = shareOf(runtime, room, held);
|
|
198
|
+
rooms.set(room, share);
|
|
199
|
+
placed(runtime, port.first, first, room, held);
|
|
200
|
+
counted(totals, share, 1);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
listing: runtime.presence.listing(),
|
|
204
|
+
roomsListed: runtime.socket.session.now().roomsListed,
|
|
205
|
+
named,
|
|
206
|
+
rooms,
|
|
207
|
+
first,
|
|
208
|
+
totals,
|
|
209
|
+
shown: '',
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function moved(runtime, { port }, showing, held, touched) {
|
|
213
|
+
const at = new Map();
|
|
214
|
+
for (const room of touched) {
|
|
215
|
+
at.set(room, requires(runtime, showing.named, held, room) ? shareOf(runtime, room, held) : null);
|
|
216
|
+
}
|
|
217
|
+
const change = keyedAt(showing.rooms, at, sameState);
|
|
218
|
+
if (change === null || change.removed.length > 0)
|
|
219
|
+
return null;
|
|
220
|
+
for (const [room, share] of at) {
|
|
221
|
+
if (share === null)
|
|
222
|
+
continue;
|
|
223
|
+
counted(showing.totals, showing.rooms.get(room), -1);
|
|
224
|
+
counted(showing.totals, share, 1);
|
|
225
|
+
showing.rooms.set(room, share);
|
|
226
|
+
placed(runtime, port.first, showing.first, room, held);
|
|
227
|
+
}
|
|
228
|
+
return change;
|
|
229
|
+
}
|
|
230
|
+
function preparingIn(runtime, showing, rooms) {
|
|
231
|
+
const { unpreparable } = runtime.store.device.now();
|
|
232
|
+
const preparing = [...rooms].filter((room) => showing.rooms.get(room)?.coverage.state === 'preparing' && !unpreparable.has(room));
|
|
132
233
|
if (preparing.length > 0)
|
|
133
234
|
prepare(runtime, preparing);
|
|
134
|
-
|
|
235
|
+
}
|
|
236
|
+
function shownOf(runtime, { port, reach }, showing, { facts }) {
|
|
237
|
+
const { store, socket } = runtime;
|
|
238
|
+
const { persistence, storageLoss } = store.device.now();
|
|
239
|
+
const { named, totals, roomsListed } = showing;
|
|
240
|
+
const coverage = tierOf(roomsListed, named !== null, totals, conversationCoverage(runtime, reach));
|
|
135
241
|
return readinessOf({
|
|
136
242
|
code: port.code,
|
|
137
|
-
coverage
|
|
138
|
-
|
|
139
|
-
rooms: coverage,
|
|
140
|
-
conversations: conversationCoverage(runtime, reach),
|
|
141
|
-
},
|
|
243
|
+
coverage,
|
|
244
|
+
first: port.first === null ? coverage : firstOf(runtime, port.first, port.inboxed, showing),
|
|
142
245
|
persistence,
|
|
143
246
|
connection: connectionOf(runtime, facts.lastCompleted),
|
|
144
247
|
house: socket.session.now().refusal !== null
|
|
@@ -147,87 +250,95 @@ function readinessFor(runtime, port, reach, { held, facts }) {
|
|
|
147
250
|
? 'write-halted'
|
|
148
251
|
: 'open',
|
|
149
252
|
space: store.space.full() ? 'full' : null,
|
|
150
|
-
installation: installationOf(
|
|
253
|
+
installation: installationOf(totals.installing, totals.downloading, {
|
|
254
|
+
done: totals.done,
|
|
255
|
+
total: totals.total,
|
|
256
|
+
}),
|
|
151
257
|
lost: storageLoss !== null,
|
|
152
|
-
established: facts.targets[port.target]?.established === true
|
|
153
|
-
(heldWhenOpened && usableWhenHeld.includes(port.target)),
|
|
258
|
+
established: facts.targets[port.target]?.established === true,
|
|
154
259
|
});
|
|
155
260
|
}
|
|
156
|
-
function establish(
|
|
157
|
-
const { store, journal } = runtime;
|
|
261
|
+
function establish({ store }, name) {
|
|
158
262
|
const { device } = store;
|
|
159
|
-
if (device.now().establishing.has(name))
|
|
263
|
+
if (device.now().establishing.has(name) || !store.needed())
|
|
160
264
|
return;
|
|
161
265
|
device.set({ establishing: new Set([...device.now().establishing, name]) });
|
|
162
266
|
void store
|
|
163
267
|
.durably(async (local) => {
|
|
164
|
-
const { targets } = await local.facts();
|
|
268
|
+
const { targets } = await local.facts(['targets']);
|
|
165
269
|
await local.fact('targets', { ...targets, [name]: { established: true } });
|
|
166
270
|
})
|
|
167
|
-
.then(() =>
|
|
168
|
-
store.readiness.queue();
|
|
169
|
-
void probeEachMinute(runtime);
|
|
170
|
-
}, (error) => {
|
|
171
|
-
journal.record(`target record failed ${name}`);
|
|
172
|
-
uncaught(error);
|
|
173
|
-
})
|
|
271
|
+
.then(() => store.readiness.queue([]), uncaught)
|
|
174
272
|
.finally(() => {
|
|
175
273
|
const establishing = new Set(device.now().establishing);
|
|
176
274
|
establishing.delete(name);
|
|
177
275
|
device.set({ establishing });
|
|
178
276
|
});
|
|
179
277
|
}
|
|
180
|
-
function deliverReadiness(runtime, watch, held) {
|
|
181
|
-
|
|
278
|
+
function deliverReadiness(runtime, watch, held, touched) {
|
|
279
|
+
const { readiness } = runtime.store;
|
|
280
|
+
if (!readiness.held(watch))
|
|
182
281
|
return;
|
|
183
|
-
const
|
|
184
|
-
|
|
282
|
+
const kept = readiness.kept(watch);
|
|
283
|
+
const patched = kept === undefined ||
|
|
284
|
+
touched === null ||
|
|
285
|
+
kept.listing !== runtime.presence.listing() ||
|
|
286
|
+
kept.roomsListed !== runtime.socket.session.now().roomsListed
|
|
287
|
+
? null
|
|
288
|
+
: moved(runtime, watch, kept, held.held, touched);
|
|
289
|
+
const showing = patched === null ? showingOf(runtime, watch, held.held) : kept;
|
|
290
|
+
preparingIn(runtime, showing, patched === null ? showing.rooms.keys() : touched);
|
|
291
|
+
const shown = shownOf(runtime, watch, showing, held);
|
|
292
|
+
if (shown.usable)
|
|
293
|
+
probeEachMinute(runtime);
|
|
294
|
+
if (shown.ready && held.facts.targets[watch.port.target]?.established !== true) {
|
|
185
295
|
establish(runtime, watch.port.target);
|
|
186
296
|
}
|
|
187
|
-
|
|
297
|
+
const text = JSON.stringify(shown);
|
|
298
|
+
const before = kept?.shown;
|
|
299
|
+
showing.shown = text;
|
|
300
|
+
readiness.keep(watch, showing);
|
|
301
|
+
if (kept === undefined) {
|
|
302
|
+
watch.deliver({
|
|
303
|
+
...shown,
|
|
304
|
+
coverage: {
|
|
305
|
+
...shown.coverage,
|
|
306
|
+
rooms: [...showing.rooms.values()].map(({ coverage }) => coverage),
|
|
307
|
+
},
|
|
308
|
+
});
|
|
188
309
|
return;
|
|
189
|
-
|
|
310
|
+
}
|
|
311
|
+
const rooms = coverageOf(patched ??
|
|
312
|
+
keyedChange(kept.rooms, [...showing.rooms.keys()], [...showing.rooms.values()], sameState));
|
|
313
|
+
if (text === before && unchanged(rooms))
|
|
314
|
+
return;
|
|
315
|
+
watch.deliver({ shown, rooms });
|
|
190
316
|
}
|
|
191
|
-
export async function deliverOwedReadiness(runtime, owed) {
|
|
317
|
+
export async function deliverOwedReadiness(runtime, owed, touched) {
|
|
192
318
|
const held = await readinessHeld(runtime);
|
|
193
319
|
if (runtime.socket.closed())
|
|
194
320
|
return;
|
|
195
321
|
for (const watch of owed)
|
|
196
|
-
deliverReadiness(runtime, watch, held);
|
|
322
|
+
deliverReadiness(runtime, watch, held, touched);
|
|
197
323
|
}
|
|
198
324
|
export function watchReadiness({ store }, port, reach, deliver) {
|
|
199
325
|
const watch = { port, reach, deliver };
|
|
200
326
|
const stop = store.readiness.add(watch);
|
|
201
|
-
|
|
327
|
+
if (!store.needed())
|
|
328
|
+
store.readiness.owe([watch]);
|
|
329
|
+
else {
|
|
330
|
+
void store.open().then(() => store.readiness.owe([watch]), () => store.readiness.owe([watch]));
|
|
331
|
+
}
|
|
202
332
|
return stop;
|
|
203
333
|
}
|
|
204
|
-
export function filled(
|
|
205
|
-
const { store, socket, journal } = runtime;
|
|
334
|
+
export function filled({ store, socket }) {
|
|
206
335
|
if (socket.closed() || !store.space.fill())
|
|
207
336
|
return;
|
|
208
|
-
|
|
209
|
-
store.readiness.queue();
|
|
210
|
-
void probeEachMinute(runtime);
|
|
211
|
-
}
|
|
212
|
-
async function installedTarget({ store }) {
|
|
213
|
-
if (store.device.now().heldWhenOpened)
|
|
214
|
-
return true;
|
|
215
|
-
const { targets } = await (await store.open()).facts();
|
|
216
|
-
return Object.values(targets).some((target) => target.established);
|
|
337
|
+
store.readiness.queue([]);
|
|
217
338
|
}
|
|
218
|
-
|
|
219
|
-
const { store, socket } = runtime;
|
|
339
|
+
function probeEachMinute({ store, socket }) {
|
|
220
340
|
const { space } = store;
|
|
221
|
-
|
|
222
|
-
if (idle())
|
|
223
|
-
return;
|
|
224
|
-
const installed = await installedTarget(runtime).catch((error) => {
|
|
225
|
-
uncaught(error);
|
|
226
|
-
return false;
|
|
227
|
-
});
|
|
228
|
-
if (!installed)
|
|
229
|
-
return;
|
|
230
|
-
if (idle())
|
|
341
|
+
if (!space.full() || space.probing() || socket.closed())
|
|
231
342
|
return;
|
|
232
343
|
space.probeEachMinute();
|
|
233
344
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { DiscoveredRoom, ProviderRefusal, ScopedRefusal } from './adapter.js';
|
|
2
|
+
import type { ModelState } from './model.js';
|
|
3
|
+
type Repairable = {
|
|
4
|
+
readonly reset: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
type Standing = {
|
|
7
|
+
readonly stale: boolean;
|
|
8
|
+
readonly repairable: Repairable | null;
|
|
9
|
+
readonly repairing: boolean;
|
|
10
|
+
readonly reloadDue: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare function lockingMode(mode: string | undefined): boolean;
|
|
13
|
+
type Listing = {
|
|
14
|
+
readonly whole: boolean;
|
|
15
|
+
readonly live: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type Presence = {
|
|
18
|
+
list(found: readonly DiscoveredRoom[], how: Listing): readonly DiscoveredRoom[];
|
|
19
|
+
room(locator: string): DiscoveredRoom | undefined;
|
|
20
|
+
rooms(): readonly DiscoveredRoom[];
|
|
21
|
+
available(locator: string, selection?: string): boolean;
|
|
22
|
+
refusal(locator: string): ProviderRefusal | null;
|
|
23
|
+
unheldModel(locator: string): ModelState | null;
|
|
24
|
+
refused(locator: string, refusal: ScopedRefusal | null): void;
|
|
25
|
+
readable(locator: string): boolean;
|
|
26
|
+
modelled(locator: string, model: ModelState | null): void;
|
|
27
|
+
installed(locator: string, bootstrapped: boolean): void;
|
|
28
|
+
locked(locator: string, stored: () => Promise<string | null>): Promise<boolean>;
|
|
29
|
+
lockedAmong(stored: ReadonlyMap<string, {
|
|
30
|
+
readonly offline: string;
|
|
31
|
+
}>, locking: ReadonlySet<string>): readonly string[];
|
|
32
|
+
lockedAs(locator: string, mode: string | undefined): boolean;
|
|
33
|
+
connectionLost(lapsed: () => void): void;
|
|
34
|
+
connectionLive(): void;
|
|
35
|
+
lapse(): void;
|
|
36
|
+
stood(locator: string, stale: boolean, repairable?: Repairable | null): void;
|
|
37
|
+
repairing(locator: string, running: boolean): void;
|
|
38
|
+
reload(locator: string, due: boolean): void;
|
|
39
|
+
standing(locator: string): Standing;
|
|
40
|
+
settled(): boolean;
|
|
41
|
+
repairsOwed(): readonly string[];
|
|
42
|
+
askAgain(locator: string, ask: () => void): void;
|
|
43
|
+
stopAsking(locator?: string): void;
|
|
44
|
+
lose(locator: string, during: number): boolean;
|
|
45
|
+
writing(locator: string): boolean;
|
|
46
|
+
unwritten(locator: string): void;
|
|
47
|
+
lost(locator: string): boolean;
|
|
48
|
+
losing(): boolean;
|
|
49
|
+
listing(): number;
|
|
50
|
+
losses(): number;
|
|
51
|
+
lostSince(locator: string, losses: number): boolean;
|
|
52
|
+
liftable(locator: string, discovery: number): boolean;
|
|
53
|
+
lift(locator: string, discovery: number, unfenced: boolean): void;
|
|
54
|
+
close(): void;
|
|
55
|
+
};
|
|
56
|
+
export declare function createPresence(notReadyWaitMs: (asked: number) => number): Presence;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=presence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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