@agentshouse/mdruntime 0.1.0-c0136de3edfbe → 0.1.0-c014edb0e9d9b
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 +8 -8
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -145
- package/dist/act-lanes.d.ts +33 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +177 -0
- package/dist/actions.d.ts +7 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +44 -31
- package/dist/adapter.d.ts +30 -44
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +2 -0
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +9 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -14
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +15 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +30 -17
- package/dist/conversation-live.d.ts +138 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +249 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +44 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +904 -1024
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -40
- package/dist/durability.d.ts +12 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +17 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +38 -8
- package/dist/index.d.ts +13 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/install.d.ts +1 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -70
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +42 -30
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -61
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- 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 +10 -21
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -4
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -20
- package/dist/messages.d.ts +1 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -32
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -134
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +8 -5
- package/dist/outcome.d.ts +6 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +15 -0
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- 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 +3 -51
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +14 -111
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +22 -15
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +5 -7
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +5 -1
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +28 -9
- package/dist/react.d.ts +15 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -1
- package/dist/readiness.d.ts +0 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +4 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +47 -5
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -4
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- 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 +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +11 -17
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +232 -112
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -698
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +4 -3
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +29 -33
- package/dist/socket/lanes.d.ts +2 -1
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +5 -2
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +2 -4
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -8
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +4 -4
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +33 -11
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +11 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +22 -10
- package/dist/surface.d.ts +4 -2
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +20 -14
- package/dist/sync.d.ts +0 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +91 -82
- package/dist/tables.d.ts +13 -8
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +25 -12
- package/dist/tallies.js +5 -5
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +41 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +13 -3
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/socket/rooms.d.ts +0 -43
- 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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DiscoveredRoom, OperationScopes, PathRule, RoomDeclaration } from './adapter.js';
|
|
2
|
+
export type WriteRefusal = {
|
|
3
|
+
readonly code: 'room-root' | 'provider-owned-path' | 'invalid-path' | `${keyof OperationScopes}-grant`;
|
|
4
|
+
readonly path: string;
|
|
5
|
+
};
|
|
6
|
+
export type WriteRule = (path: string, needs: readonly (keyof OperationScopes)[]) => WriteRefusal | null;
|
|
7
|
+
export declare function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }: DiscoveredRoom): RoomDeclaration;
|
|
8
|
+
export declare function sameDeclaration(left: RoomDeclaration, right: RoomDeclaration): boolean;
|
|
9
|
+
export declare function writeRule({ operations, providerOwnedPaths, authoredPaths, }: Pick<RoomDeclaration, 'operations' | 'providerOwnedPaths' | 'authoredPaths'>, pathRule: PathRule, local: boolean): WriteRule;
|
|
10
|
+
//# sourceMappingURL=declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declaration.d.ts","sourceRoot":"","sources":["../src/declaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG/F,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EACT,WAAW,GACX,qBAAqB,GACrB,cAAc,GACd,GAAG,MAAM,eAAe,QAAQ,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,CACtB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,CAAC,MAAM,eAAe,CAAC,EAAE,KACtC,YAAY,GAAG,IAAI,CAAC;AAEzB,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EAAE,QAAQ,EACjB,WAAW,EAAE,YAAY,EACzB,GAAG,WAAW,EACf,EAAE,cAAc,GAAG,eAAe,CAElC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAEtF;AAED,wBAAgB,SAAS,CACvB,EACE,UAAU,EACV,kBAAkB,EAClB,aAAa,GACd,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,oBAAoB,GAAG,eAAe,CAAC,EAC/E,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAYX"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { equalValue } from '@agentshouse/mdmodel';
|
|
2
|
+
import { authoredAt, covered, normalize } from './paths.js';
|
|
3
|
+
export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
|
|
4
|
+
return declaration;
|
|
5
|
+
}
|
|
6
|
+
export function sameDeclaration(left, right) {
|
|
7
|
+
return equalValue(left, right);
|
|
8
|
+
}
|
|
9
|
+
export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
|
|
10
|
+
return (path, needs) => {
|
|
11
|
+
const normalized = normalize(path);
|
|
12
|
+
if (normalized === null || normalized === '')
|
|
13
|
+
return { code: 'room-root', path };
|
|
14
|
+
if (covered(providerOwnedPaths, normalized) || !authoredAt(authoredPaths, normalized)) {
|
|
15
|
+
return { code: 'provider-owned-path', path: normalized };
|
|
16
|
+
}
|
|
17
|
+
if (!pathRule(normalized))
|
|
18
|
+
return { code: 'invalid-path', path: normalized };
|
|
19
|
+
if (local)
|
|
20
|
+
return null;
|
|
21
|
+
const missing = needs.find((operation) => !covered(operations[operation], normalized));
|
|
22
|
+
return missing === undefined ? null : { code: `${missing}-grant`, path: normalized };
|
|
23
|
+
};
|
|
24
|
+
}
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB1E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CA0CpC;AAYD,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CAkE3C"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { validRoot } from './collection.js';
|
|
2
|
-
import {
|
|
3
|
-
import { confirmLocks, lockedRooms, relocked } from './locks.js';
|
|
2
|
+
import { lockedRooms, relocked } from './locks.js';
|
|
4
3
|
import { loseRooms } from './lost.js';
|
|
5
4
|
import { cachedModels } from './models.js';
|
|
6
5
|
import { beneath } from './paths.js';
|
|
@@ -11,7 +10,7 @@ function within(root, path) {
|
|
|
11
10
|
}
|
|
12
11
|
function declaredSelection(room) {
|
|
13
12
|
const selection = room.typedSelection;
|
|
14
|
-
if (selection ===
|
|
13
|
+
if (selection === null)
|
|
15
14
|
return true;
|
|
16
15
|
if (!Array.isArray(selection.roots) || selection.roots.length === 0)
|
|
17
16
|
return false;
|
|
@@ -37,60 +36,34 @@ export function malformed(listed) {
|
|
|
37
36
|
return null;
|
|
38
37
|
}
|
|
39
38
|
export async function applyDiscovery(runtime, found, started, left) {
|
|
40
|
-
const { store, socket } = runtime;
|
|
41
|
-
const { rooms } = socket;
|
|
39
|
+
const { store, socket, presence } = runtime;
|
|
42
40
|
const lockedBefore = await lockedRooms(runtime);
|
|
43
41
|
const local = await store.open();
|
|
44
|
-
const
|
|
42
|
+
const fenced = new Set(await local.fences());
|
|
45
43
|
const relisting = found
|
|
46
44
|
.map(({ locator }) => locator)
|
|
47
|
-
.filter((locator) =>
|
|
48
|
-
|
|
49
|
-
return stillFenced.has(locator) && (fence === undefined || fence.at < started);
|
|
50
|
-
});
|
|
51
|
-
const relisted = relisting.length === 0
|
|
45
|
+
.filter((locator) => fenced.has(locator) && presence.liftable(locator, started));
|
|
46
|
+
const unfenced = relisting.length === 0
|
|
52
47
|
? new Set()
|
|
53
48
|
: await store.durably((held) => held.unfence(relisting));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
continue;
|
|
58
|
-
if (relisted.has(locator) || (!stillFenced.has(locator) && !fence.written)) {
|
|
59
|
-
store.fences.lift(locator);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
49
|
+
const clear = found.filter(({ locator }) => !fenced.has(locator) || unfenced.has(locator));
|
|
50
|
+
for (const { locator } of clear)
|
|
51
|
+
presence.lift(locator, started, unfenced.has(locator));
|
|
62
52
|
const kept = await local.held();
|
|
63
53
|
await loseRooms(runtime, found
|
|
64
54
|
.filter((room) => room.replica.admission !== 'admitted' &&
|
|
65
55
|
(kept.held.has(room.locator) || store.installs.of(room.locator).transfer !== null))
|
|
66
56
|
.map((room) => room.locator));
|
|
67
|
-
const listed = found.filter(({ locator }) => !store.fences.has(locator) && (!stillFenced.has(locator) || relisted.has(locator)));
|
|
68
|
-
const listedLocatorsNow = new Set(listed.map((room) => room.locator));
|
|
69
|
-
for (const locator of listedLocatorsNow)
|
|
70
|
-
rooms.stand(locator, { refusal: null });
|
|
71
|
-
if (left === undefined)
|
|
72
|
-
rooms.undiscoverAll();
|
|
73
|
-
for (const room of listed)
|
|
74
|
-
rooms.discover(room);
|
|
75
57
|
const named = new Set(found.map((room) => room.locator));
|
|
76
58
|
await loseRooms(runtime, left ??
|
|
77
59
|
[
|
|
78
60
|
...new Set([
|
|
79
|
-
...rooms
|
|
61
|
+
...presence.rooms().map(({ locator }) => locator),
|
|
80
62
|
...kept.held,
|
|
81
63
|
...store.installs.transferring(),
|
|
82
64
|
]),
|
|
83
65
|
].filter((locator) => !named.has(locator)));
|
|
84
|
-
const
|
|
85
|
-
for (const room of listed) {
|
|
86
|
-
const record = held.get(room.locator)?.record;
|
|
87
|
-
if (record !== undefined && record.replica.selection !== room.replica.selection) {
|
|
88
|
-
listHeld(runtime, room.locator);
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
list(runtime, room, admitted(runtime, room));
|
|
92
|
-
}
|
|
93
|
-
confirmLocks(runtime, listed);
|
|
66
|
+
const listed = presence.list(clear, { whole: left === undefined, live: socket.isOpen() });
|
|
94
67
|
socket.session.set({ roomsListed: true });
|
|
95
68
|
emitRooms(runtime);
|
|
96
69
|
await relocked(runtime, lockedBefore);
|
|
@@ -100,10 +73,11 @@ async function asked({ socket }, authorized) {
|
|
|
100
73
|
try {
|
|
101
74
|
return (await socket.discover(authorized)) ?? { kind: 'transport-uncertainty' };
|
|
102
75
|
}
|
|
103
|
-
catch {
|
|
104
|
-
return { kind: 'transport-uncertainty' };
|
|
76
|
+
catch (failure) {
|
|
77
|
+
return { kind: 'transport-uncertainty', failure };
|
|
105
78
|
}
|
|
106
79
|
}
|
|
80
|
+
const DISCOVERY = 'discovery';
|
|
107
81
|
export async function signIn(runtime, local, signedIn) {
|
|
108
82
|
if (JSON.stringify(signedIn) === JSON.stringify((await local.facts()).member))
|
|
109
83
|
return;
|
|
@@ -130,6 +104,10 @@ export async function discoverRooms(runtime, local, progress, live, found) {
|
|
|
130
104
|
return null;
|
|
131
105
|
}
|
|
132
106
|
journal.record(`connection discover ${result.kind}`);
|
|
107
|
+
if (result.kind === 'transport-uncertainty')
|
|
108
|
+
runtime.retries.uncertain('connection', DISCOVERY, result);
|
|
109
|
+
if (result.kind === 'discovery')
|
|
110
|
+
runtime.retries.succeeded('connection', DISCOVERY);
|
|
133
111
|
if (result.kind === 'transport-uncertainty') {
|
|
134
112
|
await cachedModels(runtime, local);
|
|
135
113
|
progress.reachable = false;
|
package/dist/durability.d.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import type { Persistence } from './readiness.js';
|
|
2
|
+
import type { RetriedFailure, Step } from './retried.js';
|
|
2
3
|
export type UnsentKind = 'pending-change' | 'call' | 'room-draft' | 'chat-draft';
|
|
3
4
|
export type UnsentWork = {
|
|
4
5
|
readonly kind: UnsentKind;
|
|
5
6
|
readonly count: number;
|
|
6
7
|
};
|
|
8
|
+
export type AppCode = {
|
|
9
|
+
readonly running: number;
|
|
10
|
+
readonly older: number;
|
|
11
|
+
};
|
|
12
|
+
export type HeldCode = {
|
|
13
|
+
readonly house: number | null;
|
|
14
|
+
readonly apps: readonly string[];
|
|
15
|
+
};
|
|
7
16
|
export type RuntimeShell = {
|
|
8
17
|
persistence: Persistence;
|
|
9
18
|
generation: string | null;
|
|
10
19
|
keepGeneration(value: string): void | Promise<void>;
|
|
11
20
|
dropGeneration(): void | Promise<void>;
|
|
12
21
|
cleanUp?(): Promise<number>;
|
|
22
|
+
measure?(measured: (app: string, code: AppCode | null) => void): Promise<HeldCode>;
|
|
13
23
|
reset(): Promise<void>;
|
|
24
|
+
retried?(failure: RetriedFailure): void;
|
|
25
|
+
succeeded?(step: Step): void;
|
|
14
26
|
};
|
|
15
27
|
export declare function refusedForSpace(error: unknown): boolean;
|
|
16
28
|
export declare function detectStorageLoss(stored: string | null, reported: string | null): string | null;
|
package/dist/durability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"durability.d.ts","sourceRoot":"","sources":["../src/durability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAIzD,MAAM,MAAM,UAAU,GAAG,gBAAgB,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;AAEjF,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,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AAG,IAAI,GAAG,MAAM,CAGrF"}
|
package/dist/expectation.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export type Expecting<E extends {
|
|
|
7
7
|
subscribe(listener: () => void): () => void;
|
|
8
8
|
version(): number;
|
|
9
9
|
begin(): number;
|
|
10
|
-
expect(act: number, expected: ExpectedOf<E
|
|
10
|
+
expect(act: number, expected: ExpectedOf<E>): void;
|
|
11
11
|
drop(act: number): void;
|
|
12
|
-
|
|
12
|
+
reads(reader: string, asks: (one: E) => boolean): void;
|
|
13
|
+
heard(reader: string, shown: (one: E) => boolean): void;
|
|
14
|
+
left(reader: string): void;
|
|
13
15
|
drawn(): readonly E[];
|
|
14
16
|
};
|
|
15
17
|
export declare function expectedList<E extends {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expectation.d.ts","sourceRoot":"","sources":["../src/expectation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;AAErF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,OAAO,IAAI,MAAM,CAAC;IAClB,KAAK,IAAI,MAAM,CAAC;IAChB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"expectation.d.ts","sourceRoot":"","sources":["../src/expectation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,IAAI,CAAC;AAErF,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,IAAI;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,OAAO,IAAI,MAAM,CAAC;IAClB,KAAK,IAAI,MAAM,CAAC;IAChB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACnD,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;IACvD,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;IACxD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,IAAI,SAAS,CAAC,EAAE,CAAC;CACvB,CAAC;AAQF,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,EAC7D,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,GACtB,SAAS,CAAC,EAAE,CAGd;AAwBD,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,KAAK,SAAS,CAAC,CAAC,CAAC,CAmE5E"}
|
package/dist/expectation.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const NONE = () => false;
|
|
1
2
|
export function expectedList(expected) {
|
|
2
3
|
if (expected === null)
|
|
3
4
|
return [];
|
|
@@ -13,7 +14,7 @@ function unended(entries, ends) {
|
|
|
13
14
|
for (const one of [...entries].reverse()) {
|
|
14
15
|
if (ended.has(one.expectation.key))
|
|
15
16
|
continue;
|
|
16
|
-
if (ends(one
|
|
17
|
+
if (ends(one))
|
|
17
18
|
ended.add(one.expectation.key);
|
|
18
19
|
else
|
|
19
20
|
kept.unshift(one);
|
|
@@ -24,6 +25,7 @@ export function expecting() {
|
|
|
24
25
|
let entries = [];
|
|
25
26
|
let version = 0;
|
|
26
27
|
let acts = 0;
|
|
28
|
+
const readers = new Map();
|
|
27
29
|
const listeners = new Set();
|
|
28
30
|
const set = (next) => {
|
|
29
31
|
if (next.length === entries.length && next.every((one, at) => one === entries[at]))
|
|
@@ -33,6 +35,19 @@ export function expecting() {
|
|
|
33
35
|
for (const listener of listeners)
|
|
34
36
|
listener();
|
|
35
37
|
};
|
|
38
|
+
const settle = (next) => {
|
|
39
|
+
for (const entry of next)
|
|
40
|
+
for (const [id, reader] of readers)
|
|
41
|
+
if (reader.asks(entry.expectation) && reader.shown(entry.expectation))
|
|
42
|
+
entry.seen.add(id);
|
|
43
|
+
set(unended(next, (entry) => {
|
|
44
|
+
const asking = [...readers].filter(([, reader]) => reader.asks(entry.expectation));
|
|
45
|
+
const seen = asking.filter(([id]) => entry.seen.has(id));
|
|
46
|
+
return (seen.length > 0 &&
|
|
47
|
+
(seen.length === asking.length ||
|
|
48
|
+
seen.some(([, reader]) => !reader.shown(entry.expectation))));
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
36
51
|
return {
|
|
37
52
|
subscribe(listener) {
|
|
38
53
|
listeners.add(listener);
|
|
@@ -45,25 +60,32 @@ export function expecting() {
|
|
|
45
60
|
acts += 1;
|
|
46
61
|
return acts;
|
|
47
62
|
},
|
|
48
|
-
expect(act, expected
|
|
63
|
+
expect(act, expected) {
|
|
49
64
|
const fresh = expectedList(expected);
|
|
50
65
|
if (fresh.length === 0)
|
|
51
66
|
return;
|
|
52
67
|
const keys = new Set(fresh.map((one) => one.key));
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
...kept,
|
|
57
|
-
...fresh
|
|
58
|
-
.filter((one) => over.has(one.key) || !settled(one))
|
|
59
|
-
.map((expectation) => ({ act, expectation })),
|
|
68
|
+
settle([
|
|
69
|
+
...entries.filter((one) => one.act !== act || !keys.has(one.expectation.key)),
|
|
70
|
+
...fresh.map((expectation) => ({ act, expectation, seen: new Set() })),
|
|
60
71
|
]);
|
|
61
72
|
},
|
|
62
73
|
drop(act) {
|
|
63
74
|
set(entries.filter((one) => one.act !== act));
|
|
64
75
|
},
|
|
65
|
-
|
|
66
|
-
set(
|
|
76
|
+
reads(reader, asks) {
|
|
77
|
+
readers.set(reader, { asks, shown: readers.get(reader)?.shown ?? NONE });
|
|
78
|
+
settle(entries);
|
|
79
|
+
},
|
|
80
|
+
heard(reader, shown) {
|
|
81
|
+
readers.set(reader, { asks: readers.get(reader)?.asks ?? NONE, shown });
|
|
82
|
+
settle(entries);
|
|
83
|
+
},
|
|
84
|
+
left(reader) {
|
|
85
|
+
readers.delete(reader);
|
|
86
|
+
for (const entry of entries)
|
|
87
|
+
entry.seen.delete(reader);
|
|
88
|
+
settle(entries);
|
|
67
89
|
},
|
|
68
90
|
drawn: () => entries.flatMap((one, at) => (superseded(entries, at) ? [] : [one.expectation])),
|
|
69
91
|
};
|
package/dist/failure.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderRefusal } from './adapter.js';
|
|
1
2
|
export type RuntimeError = Error & {
|
|
2
3
|
readonly code: string;
|
|
3
4
|
readonly retryable: boolean;
|
|
@@ -8,6 +9,8 @@ export type Described = {
|
|
|
8
9
|
retryable: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare function runtimeError(code: string, message?: string, retryable?: boolean): RuntimeError;
|
|
12
|
+
export declare function refusalError(refusal: ProviderRefusal): RuntimeError;
|
|
11
13
|
export declare function failed(error: unknown): RuntimeError;
|
|
14
|
+
export declare function uncaught(error: unknown): void;
|
|
12
15
|
export declare function described(error: unknown): Described;
|
|
13
16
|
//# sourceMappingURL=failure.d.ts.map
|
package/dist/failure.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|
|
1
|
+
{"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1F,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,MAAa,EACtB,SAAS,UAAQ,GAChB,YAAY,CAEd;AAYD,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,YAAY,CAEnE;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,CAGnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAGnD"}
|
package/dist/failure.js
CHANGED
|
@@ -8,11 +8,17 @@ function coded(error) {
|
|
|
8
8
|
'retryable' in error &&
|
|
9
9
|
typeof error.retryable === 'boolean');
|
|
10
10
|
}
|
|
11
|
+
export function refusalError(refusal) {
|
|
12
|
+
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
13
|
+
}
|
|
11
14
|
export function failed(error) {
|
|
12
15
|
if (coded(error))
|
|
13
16
|
return error;
|
|
14
17
|
return runtimeError('runtime-failure', error instanceof Error ? error.message : String(error));
|
|
15
18
|
}
|
|
19
|
+
export function uncaught(error) {
|
|
20
|
+
reportError(error);
|
|
21
|
+
}
|
|
16
22
|
export function described(error) {
|
|
17
23
|
const { message, code, retryable } = failed(error);
|
|
18
24
|
return { message, code, retryable };
|
package/dist/figures.d.ts
CHANGED
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,eAAe,UAAU,CAAC;AAEvC,eAAO,MAAM,WAAW;;;;iBAGZ,IAAI;;CACe,CAAC;
|
|
1
|
+
{"version":3,"file":"figures.d.ts","sour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S,SAAS,EAAE,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,KAAK,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;IACjF,aAAa,CACX,aAAa,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,EACvC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,MAAM,IAAI,CAAC;IAChD,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAgDF,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,WAAW,CAsIlE"}
|
package/dist/figures.js
CHANGED
|
@@ -6,7 +6,7 @@ export const ROOM_TOTALS = {
|
|
|
6
6
|
select: { size: true },
|
|
7
7
|
};
|
|
8
8
|
// Today's Last 24 hours is the day that ends as the read answers.
|
|
9
|
-
const
|
|
9
|
+
export const FIGURES_DAY_MS = 86_400_000;
|
|
10
10
|
// An install or a catch-up commits many times a second, so the figures answer again once changes rest this long, never per commit.
|
|
11
11
|
const SETTLED_MS = 1_000;
|
|
12
12
|
// Changes that never rest, such as an Agent writing all afternoon, still reach the figures this long after the first of them.
|
|
@@ -106,7 +106,7 @@ export function createFigures(sources) {
|
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
108
|
async function answer() {
|
|
109
|
-
const window = new Date(Date.now() -
|
|
109
|
+
const window = new Date(Date.now() - FIGURES_DAY_MS).toISOString();
|
|
110
110
|
const cover = await sources.cover();
|
|
111
111
|
if ('pending' in cover)
|
|
112
112
|
return cover;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AppCode } from './durability.js';
|
|
2
|
+
import type { GroupTotal, PendingResult } from './query.js';
|
|
3
|
+
import type { Deliver, Fail } from './reach.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { OpenedRoom } from './tables.js';
|
|
6
|
+
export type RoomDocuments = {
|
|
7
|
+
readonly room: string;
|
|
8
|
+
readonly documents: GroupTotal;
|
|
9
|
+
};
|
|
10
|
+
export type HeldApp = ({
|
|
11
|
+
readonly app: string;
|
|
12
|
+
readonly state: 'measured';
|
|
13
|
+
} & AppCode) | {
|
|
14
|
+
readonly app: string;
|
|
15
|
+
readonly state: 'asking' | 'unknown';
|
|
16
|
+
};
|
|
17
|
+
export type Holdings = {
|
|
18
|
+
readonly rooms: readonly RoomDocuments[] | PendingResult;
|
|
19
|
+
readonly opened: GroupTotal & {
|
|
20
|
+
readonly rooms: readonly OpenedRoom[];
|
|
21
|
+
};
|
|
22
|
+
readonly apps: readonly HeldApp[];
|
|
23
|
+
readonly house: number | null;
|
|
24
|
+
readonly total: number | null;
|
|
25
|
+
readonly cleanUp: number | null;
|
|
26
|
+
};
|
|
27
|
+
export declare const CLEANED_TOPIC = "cleaned";
|
|
28
|
+
export declare function watchHoldings({ store, figures, shell }: Runtime, deliver: Deliver, fail: Fail): () => void;
|
|
29
|
+
//# sourceMappingURL=holdings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"holdings.d.ts","sourceRoot":"","sources":["../src/holdings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAY,MAAM,iBAAiB,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAA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PIC = 'cleaned';
|
|
3
|
+
function heldRooms(figures) {
|
|
4
|
+
if ('pending' in figures)
|
|
5
|
+
return figures;
|
|
6
|
+
return figures.rooms.map(({ room, total }) => ({ room, documents: total.documents }));
|
|
7
|
+
}
|
|
8
|
+
function heldApp(app, measured) {
|
|
9
|
+
if (!measured.has(app))
|
|
10
|
+
return { app, state: 'asking' };
|
|
11
|
+
const code = measured.get(app) ?? null;
|
|
12
|
+
return code === null ? { app, state: 'unknown' } : { app, state: 'measured', ...code };
|
|
13
|
+
}
|
|
14
|
+
function summed(values) {
|
|
15
|
+
return values.reduce((sum, value) => sum + value, 0);
|
|
16
|
+
}
|
|
17
|
+
function holdingsOf(rooms, opened, code, measured) {
|
|
18
|
+
const apps = code.apps.map((app) => heldApp(app, measured));
|
|
19
|
+
const known = apps.flatMap((app) => (app.state === 'measured' ? [app] : []));
|
|
20
|
+
const whole = known.length === apps.length;
|
|
21
|
+
const files = {
|
|
22
|
+
count: summed(opened.rooms.map(({ count }) => count)),
|
|
23
|
+
size: summed(opened.rooms.map(({ size }) => size)),
|
|
24
|
+
};
|
|
25
|
+
const documents = 'pending' in rooms ? null : summed(rooms.map(({ documents: d }) => d.size));
|
|
26
|
+
const older = whole ? summed(known.map((app) => app.older)) : null;
|
|
27
|
+
return {
|
|
28
|
+
rooms,
|
|
29
|
+
opened: { ...files, rooms: opened.rooms },
|
|
30
|
+
apps,
|
|
31
|
+
house: code.house,
|
|
32
|
+
total: documents === null || code.house === null || older === null
|
|
33
|
+
? null
|
|
34
|
+
: documents + files.size + summed(known.map((app) => app.running)) + older + code.house,
|
|
35
|
+
cleanUp: older === null ? null : opened.cleanable + older,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function watchHoldings({ store, figures, shell }, deliver, fail) {
|
|
39
|
+
let open = true;
|
|
40
|
+
let asked = 0;
|
|
41
|
+
let rooms = null;
|
|
42
|
+
let opened = null;
|
|
43
|
+
let code = null;
|
|
44
|
+
let measured = new Map();
|
|
45
|
+
function told() {
|
|
46
|
+
if (open && rooms !== null && opened !== null && code !== null) {
|
|
47
|
+
deliver(holdingsOf(rooms, opened, code, measured));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function failed(error) {
|
|
51
|
+
if (!open)
|
|
52
|
+
return;
|
|
53
|
+
stop();
|
|
54
|
+
fail(error);
|
|
55
|
+
}
|
|
56
|
+
function ask() {
|
|
57
|
+
asked += 1;
|
|
58
|
+
const at = asked;
|
|
59
|
+
const current = () => open && at === asked;
|
|
60
|
+
opened = null;
|
|
61
|
+
code = null;
|
|
62
|
+
measured = new Map();
|
|
63
|
+
store.ask({ kind: 'opened.held' }).then((held) => {
|
|
64
|
+
if (!current())
|
|
65
|
+
return;
|
|
66
|
+
opened = held;
|
|
67
|
+
told();
|
|
68
|
+
}, failed);
|
|
69
|
+
const answers = measured;
|
|
70
|
+
const measuring = shell.measure?.((app, answer) => {
|
|
71
|
+
if (!current())
|
|
72
|
+
return;
|
|
73
|
+
answers.set(app, answer);
|
|
74
|
+
told();
|
|
75
|
+
}) ?? Promise.resolve(NO_CODE);
|
|
76
|
+
measuring.then((held) => {
|
|
77
|
+
if (!current())
|
|
78
|
+
return;
|
|
79
|
+
code = held;
|
|
80
|
+
told();
|
|
81
|
+
}, failed);
|
|
82
|
+
}
|
|
83
|
+
const stopFigures = figures.watch((answer) => {
|
|
84
|
+
rooms = heldRooms(answer);
|
|
85
|
+
told();
|
|
86
|
+
}, failed);
|
|
87
|
+
const cleaned = store.watch(CLEANED_TOPIC, ask);
|
|
88
|
+
function stop() {
|
|
89
|
+
open = false;
|
|
90
|
+
stopFigures();
|
|
91
|
+
cleaned.stop();
|
|
92
|
+
}
|
|
93
|
+
ask();
|
|
94
|
+
return stop;
|
|
95
|
+
}
|
package/dist/host.d.ts
CHANGED
|
@@ -2,10 +2,24 @@ import { type MdRuntimeOptions } from './connection.js';
|
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
3
|
import type { CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
4
4
|
import type { EntrySeed } from './seed.js';
|
|
5
|
+
import { type CallResult } from './outcome.js';
|
|
5
6
|
import { type RuntimePort } from './wire.js';
|
|
6
7
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
7
8
|
deploymentFacts?: unknown;
|
|
8
9
|
};
|
|
10
|
+
export type Admitted = {
|
|
11
|
+
readonly admitted: unknown;
|
|
12
|
+
} | {
|
|
13
|
+
readonly refused: CallResult;
|
|
14
|
+
};
|
|
15
|
+
export type ActionAdmission = (name: string, input: unknown) => Promise<Admitted>;
|
|
16
|
+
export type AttachOptions = {
|
|
17
|
+
readonly app: string;
|
|
18
|
+
readonly release?: string;
|
|
19
|
+
readonly reach?: PortReach;
|
|
20
|
+
readonly admission?: ActionAdmission;
|
|
21
|
+
readonly code?: CodeAvailability;
|
|
22
|
+
};
|
|
9
23
|
export type AttachedPort = {
|
|
10
24
|
detach(): void;
|
|
11
25
|
narrow(reach: PortReach): void;
|
|
@@ -13,7 +27,7 @@ export type AttachedPort = {
|
|
|
13
27
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
28
|
};
|
|
15
29
|
export type MdRuntimeHost = {
|
|
16
|
-
attach(port: RuntimePort,
|
|
30
|
+
attach(port: RuntimePort, options: AttachOptions): AttachedPort;
|
|
17
31
|
present(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
18
32
|
seed(entry: EntrySeed): void;
|
|
19
33
|
persisted(answer: Persistence): void;
|
|
@@ -25,5 +39,6 @@ export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
|
25
39
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
26
40
|
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
27
41
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
28
|
-
export
|
|
42
|
+
export { undeclared } from './outcome.js';
|
|
43
|
+
export { wireAnswer, wireRequest, type RuntimePort, type WireAnswer, type WireRequest, } from './wire.js';
|
|
29
44
|
//# 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":"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;AAUxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAEL,KAAK,WAAW,EAQjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAEzF,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAElF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,Q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