@agentshouse/mdruntime 0.1.0-cd26b960b7262 → 0.1.0-cd30853a1b15e
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 +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +72 -158
- 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 +118 -67
- package/dist/adapter.d.ts +81 -56
- 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 +0 -5
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -19
- 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 +4 -0
- 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 +0 -2
- package/dist/client.d.ts +10 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +30 -18
- package/dist/collection.d.ts +25 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +19 -2
- 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 +2 -0
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +17 -5
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +31 -24
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +26 -12
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +23 -12
- package/dist/conversation-row.d.ts +8 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +20 -7
- package/dist/conversation.d.ts +32 -10
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +317 -232
- 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 +19 -44
- package/dist/durability.d.ts +4 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +4 -0
- package/dist/entry.js +1 -1
- 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 +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +4 -2
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +2 -1
- package/dist/host.d.ts +18 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +55 -15
- package/dist/index.d.ts +15 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -7
- package/dist/install.d.ts +10 -6
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +92 -109
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +54 -40
- package/dist/listing.d.ts +11 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +48 -72
- package/dist/live.d.ts +5 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +74 -31
- package/dist/loaded.d.ts +5 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +40 -0
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -39
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +11 -23
- package/dist/media.d.ts +5 -0
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +65 -14
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +56 -26
- package/dist/messages.d.ts +12 -6
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +25 -27
- 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 -139
- package/dist/observation.d.ts +27 -12
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +173 -69
- package/dist/opened.d.ts +1 -1
- 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 +5 -9
- package/dist/outcome.d.ts +7 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +23 -2
- package/dist/overlay.d.ts +6 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +37 -24
- 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 -59
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +10 -123
- package/dist/preparation.d.ts +27 -6
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +154 -66
- 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 +66 -30
- package/dist/questions.d.ts +1 -5
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +1 -7
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +480 -0
- package/dist/reach.d.ts +2 -3
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +83 -25
- package/dist/react.d.ts +8 -5
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +28 -5
- package/dist/readiness.d.ts +9 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +3 -5
- package/dist/reads.d.ts +4 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +11 -4
- package/dist/recovery.d.ts +3 -1
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +29 -7
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -5
- package/dist/replica.d.ts +5 -11
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +14 -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 +30 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +270 -63
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +8 -5
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +45 -0
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +9 -10
- package/dist/runtime.d.ts +9 -18
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +42 -90
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +314 -223
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +124 -703
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +4 -4
- package/dist/shown.d.ts +7 -5
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +75 -58
- 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.d.ts +3 -6
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +3 -14
- package/dist/source.d.ts +5 -7
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +13 -2
- 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 +17 -6
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +56 -22
- 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 +23 -14
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +46 -17
- package/dist/stored.d.ts +24 -13
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +80 -29
- package/dist/surface.d.ts +5 -3
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +23 -21
- package/dist/sync.d.ts +1 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +89 -85
- package/dist/tables.d.ts +16 -56
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +86 -327
- package/dist/tallies.d.ts.map +1 -1
- package/dist/tallies.js +1 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +4 -10
- package/dist/wire.d.ts +45 -7
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +15 -4
- 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/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 -44
- 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,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,"file":"presence.d.ts","sourceRoot":"","sources":["../src/presence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEzD,KAAK,QAAQ,GAAG;IACd,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAUF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAE7D;AAgBD,KAAK,OAAO,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CA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C;IAClE,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAKF,wBAAgB,cAAc,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,QAAQ,CAqNlF"}
|
package/dist/presence.js
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
export function lockingMode(mode) {
|
|
2
|
+
return mode === 'locked';
|
|
3
|
+
}
|
|
4
|
+
const UNANSWERED = {
|
|
5
|
+
stale: false,
|
|
6
|
+
repairable: null,
|
|
7
|
+
repairing: false,
|
|
8
|
+
reloadDue: false,
|
|
9
|
+
refusal: null,
|
|
10
|
+
unreading: false,
|
|
11
|
+
unreadable: false,
|
|
12
|
+
unheldModel: null,
|
|
13
|
+
confirmed: false,
|
|
14
|
+
};
|
|
15
|
+
// A Room that locks offline stays readable this long after the connection drops, so a laptop waking or changing network keeps working while a disconnected device locks soon after.
|
|
16
|
+
const LOCK_GRACE_MS = 120_000;
|
|
17
|
+
export function createPresence(notReadyWaitMs) {
|
|
18
|
+
const listed = new Map();
|
|
19
|
+
const lockable = new Set();
|
|
20
|
+
let listings = 0;
|
|
21
|
+
const answered = new Map();
|
|
22
|
+
const marks = new Map();
|
|
23
|
+
const lastLost = new Map();
|
|
24
|
+
const unready = new Map();
|
|
25
|
+
let lossCount = 0;
|
|
26
|
+
let lockGrace = null;
|
|
27
|
+
function answer(locator) {
|
|
28
|
+
return answered.get(locator) ?? UNANSWERED;
|
|
29
|
+
}
|
|
30
|
+
function change(locator, next) {
|
|
31
|
+
answered.set(locator, { ...answer(locator), ...next });
|
|
32
|
+
}
|
|
33
|
+
function heard(locator, next) {
|
|
34
|
+
if (!marks.has(locator))
|
|
35
|
+
change(locator, next);
|
|
36
|
+
}
|
|
37
|
+
function readied(locator) {
|
|
38
|
+
const held = unready.get(locator);
|
|
39
|
+
if (held === undefined)
|
|
40
|
+
return;
|
|
41
|
+
if (held.timer !== null)
|
|
42
|
+
clearTimeout(held.timer);
|
|
43
|
+
unready.delete(locator);
|
|
44
|
+
}
|
|
45
|
+
function stopAsking(locator) {
|
|
46
|
+
for (const held of locator === undefined ? [...unready.keys()] : [locator])
|
|
47
|
+
readied(held);
|
|
48
|
+
}
|
|
49
|
+
function connectionLive() {
|
|
50
|
+
if (lockGrace !== null)
|
|
51
|
+
clearTimeout(lockGrace);
|
|
52
|
+
lockGrace = null;
|
|
53
|
+
}
|
|
54
|
+
function readable(locator) {
|
|
55
|
+
const { unreadable, unreading } = answer(locator);
|
|
56
|
+
if (!unreadable || marks.has(locator))
|
|
57
|
+
return false;
|
|
58
|
+
change(locator, {
|
|
59
|
+
unreadable: false,
|
|
60
|
+
...(unreading ? { refusal: null, unreading: false } : {}),
|
|
61
|
+
});
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
function locks(locator, mode) {
|
|
65
|
+
return lockingMode(mode) && !answer(locator).confirmed && !marks.has(locator);
|
|
66
|
+
}
|
|
67
|
+
function liftable(locator, discovery) {
|
|
68
|
+
const mark = marks.get(locator);
|
|
69
|
+
return mark === undefined || mark.during < discovery;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
list(found, { whole, live }) {
|
|
73
|
+
listings += 1;
|
|
74
|
+
const kept = found.filter(({ locator }) => !marks.has(locator));
|
|
75
|
+
if (whole) {
|
|
76
|
+
listed.clear();
|
|
77
|
+
lockable.clear();
|
|
78
|
+
}
|
|
79
|
+
for (const room of kept) {
|
|
80
|
+
listed.set(room.locator, room);
|
|
81
|
+
if (lockingMode(room.replica.offline))
|
|
82
|
+
lockable.add(room.locator);
|
|
83
|
+
else
|
|
84
|
+
lockable.delete(room.locator);
|
|
85
|
+
change(room.locator, {
|
|
86
|
+
refusal: null,
|
|
87
|
+
unreading: false,
|
|
88
|
+
...(live && room.replica.admission === 'admitted' ? { confirmed: true } : {}),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return kept;
|
|
92
|
+
},
|
|
93
|
+
room: (locator) => listed.get(locator),
|
|
94
|
+
rooms: () => [...listed.values()],
|
|
95
|
+
available(locator, selection) {
|
|
96
|
+
if (marks.has(locator))
|
|
97
|
+
return false;
|
|
98
|
+
const room = listed.get(locator);
|
|
99
|
+
if (room === undefined)
|
|
100
|
+
return true;
|
|
101
|
+
return ((selection === undefined || selection === room.replica.selection) &&
|
|
102
|
+
room.replica.admission === 'admitted' &&
|
|
103
|
+
!answer(locator).unreadable);
|
|
104
|
+
},
|
|
105
|
+
refusal: (locator) => answer(locator).refusal,
|
|
106
|
+
unheldModel: (locator) => answer(locator).unheldModel,
|
|
107
|
+
refused(locator, refusal) {
|
|
108
|
+
if (refusal === null) {
|
|
109
|
+
heard(locator, { unreadable: true });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const unreading = refusal.scope !== 'operation' && refusal.scope !== 'model';
|
|
113
|
+
heard(locator, {
|
|
114
|
+
refusal: { code: refusal.code, fields: refusal.fields, retryable: refusal.retryable },
|
|
115
|
+
unreading,
|
|
116
|
+
...(unreading ? { unreadable: true } : {}),
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
readable,
|
|
120
|
+
modelled(locator, model) {
|
|
121
|
+
heard(locator, { unheldModel: model });
|
|
122
|
+
},
|
|
123
|
+
installed(locator, bootstrapped) {
|
|
124
|
+
if (marks.has(locator))
|
|
125
|
+
return;
|
|
126
|
+
if (bootstrapped) {
|
|
127
|
+
readied(locator);
|
|
128
|
+
change(locator, { unheldModel: null });
|
|
129
|
+
}
|
|
130
|
+
change(locator, { stale: false });
|
|
131
|
+
readable(locator);
|
|
132
|
+
},
|
|
133
|
+
async locked(locator, stored) {
|
|
134
|
+
if (marks.has(locator) || answer(locator).confirmed)
|
|
135
|
+
return false;
|
|
136
|
+
return locks(locator, (await stored()) ?? listed.get(locator)?.replica.offline);
|
|
137
|
+
},
|
|
138
|
+
lockedAs: locks,
|
|
139
|
+
lockedAmong(stored, locking) {
|
|
140
|
+
return [...new Set([...lockable, ...locking])]
|
|
141
|
+
.filter((locator) => locks(locator, stored.get(locator)?.offline ?? listed.get(locator)?.replica.offline))
|
|
142
|
+
.sort();
|
|
143
|
+
},
|
|
144
|
+
connectionLost(lapsed) {
|
|
145
|
+
if (lockGrace !== null)
|
|
146
|
+
return;
|
|
147
|
+
lockGrace = setTimeout(() => {
|
|
148
|
+
lockGrace = null;
|
|
149
|
+
lapsed();
|
|
150
|
+
}, LOCK_GRACE_MS);
|
|
151
|
+
},
|
|
152
|
+
connectionLive,
|
|
153
|
+
lapse() {
|
|
154
|
+
for (const [locator, held] of answered) {
|
|
155
|
+
if (held.confirmed)
|
|
156
|
+
answered.set(locator, { ...held, confirmed: false });
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
stood(locator, stale, repairable) {
|
|
160
|
+
heard(locator, { stale, ...(repairable === undefined ? {} : { repairable }) });
|
|
161
|
+
},
|
|
162
|
+
repairing(locator, running) {
|
|
163
|
+
change(locator, { repairing: running });
|
|
164
|
+
},
|
|
165
|
+
reload(locator, due) {
|
|
166
|
+
change(locator, { reloadDue: due });
|
|
167
|
+
},
|
|
168
|
+
standing(locator) {
|
|
169
|
+
const { stale, repairable, repairing, reloadDue } = answer(locator);
|
|
170
|
+
return { stale, repairable, repairing, reloadDue };
|
|
171
|
+
},
|
|
172
|
+
settled: () => ![...answered].some(([locator, { stale }]) => stale && !marks.has(locator)),
|
|
173
|
+
repairsOwed: () => [...answered]
|
|
174
|
+
.filter(([locator, { stale, repairable }]) => stale && repairable !== null && !marks.has(locator))
|
|
175
|
+
.map(([locator]) => locator),
|
|
176
|
+
askAgain(locator, ask) {
|
|
177
|
+
const held = unready.get(locator) ?? { tries: 0, timer: null };
|
|
178
|
+
unready.set(locator, held);
|
|
179
|
+
if (held.timer !== null)
|
|
180
|
+
return;
|
|
181
|
+
const wait = notReadyWaitMs(held.tries);
|
|
182
|
+
held.tries += 1;
|
|
183
|
+
held.timer = setTimeout(() => {
|
|
184
|
+
held.timer = null;
|
|
185
|
+
ask();
|
|
186
|
+
}, wait);
|
|
187
|
+
},
|
|
188
|
+
stopAsking,
|
|
189
|
+
lose(locator, during) {
|
|
190
|
+
if (marks.has(locator))
|
|
191
|
+
return false;
|
|
192
|
+
marks.set(locator, { during, written: false });
|
|
193
|
+
lastLost.set(locator, ++lossCount);
|
|
194
|
+
listings += 1;
|
|
195
|
+
listed.delete(locator);
|
|
196
|
+
lockable.delete(locator);
|
|
197
|
+
readied(locator);
|
|
198
|
+
const { repairing, reloadDue } = answer(locator);
|
|
199
|
+
answered.set(locator, { ...UNANSWERED, repairing, reloadDue });
|
|
200
|
+
return true;
|
|
201
|
+
},
|
|
202
|
+
writing(locator) {
|
|
203
|
+
const mark = marks.get(locator);
|
|
204
|
+
if (mark === undefined || mark.written)
|
|
205
|
+
return false;
|
|
206
|
+
marks.set(locator, { ...mark, written: true });
|
|
207
|
+
return true;
|
|
208
|
+
},
|
|
209
|
+
unwritten(locator) {
|
|
210
|
+
const mark = marks.get(locator);
|
|
211
|
+
if (mark !== undefined)
|
|
212
|
+
marks.set(locator, { ...mark, written: false });
|
|
213
|
+
},
|
|
214
|
+
lost: (locator) => marks.has(locator),
|
|
215
|
+
losing: () => marks.size > 0,
|
|
216
|
+
listing: () => listings,
|
|
217
|
+
losses: () => lossCount,
|
|
218
|
+
lostSince: (locator, losses) => marks.has(locator) || (lastLost.get(locator) ?? 0) > losses,
|
|
219
|
+
liftable,
|
|
220
|
+
lift(locator, discovery, unfenced) {
|
|
221
|
+
const mark = marks.get(locator);
|
|
222
|
+
if (mark !== undefined && liftable(locator, discovery) && (unfenced || !mark.written)) {
|
|
223
|
+
marks.delete(locator);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
close() {
|
|
227
|
+
stopAsking();
|
|
228
|
+
connectionLive();
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
}
|
package/dist/queries.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FiguresCover } from './figures.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type Cover, type Ran } from './live.js';
|
|
3
3
|
import { type Plan, type QueryResult } from './query.js';
|
|
4
4
|
import { type Deliver, type Fail, type PortReach } from './reach.js';
|
|
5
5
|
import type { Runtime } from './runtime.js';
|
|
@@ -9,7 +9,7 @@ export declare function figuresCover(runtime: Runtime): Promise<FiguresCover>;
|
|
|
9
9
|
export declare function answeredPlan(runtime: Runtime, plan: Plan, cover: () => Promise<Cover>): Promise<Ran>;
|
|
10
10
|
export declare function rowsQuery(runtime: Runtime, plan: Plan): Promise<QueryResult>;
|
|
11
11
|
export declare function planned(runtime: Runtime, input: unknown, reach: PortReach | null): Promise<Plan>;
|
|
12
|
-
export declare function roomTallies(runtime: Runtime, rooms: readonly QueryRoom[], since: string): Promise<readonly import("./tallies.
|
|
12
|
+
export declare function roomTallies(runtime: Runtime, rooms: readonly QueryRoom[], since: string): Promise<readonly import("./tallies.ts").RoomTally[]>;
|
|
13
13
|
export declare function watchPlan(runtime: Runtime, plan: Plan, deliver: Deliver, fail: Fail): () => void;
|
|
14
14
|
export declare function watchPlanned(runtime: Runtime, planning: Promise<Plan>, deliver: Deliver, fail: Fail): () => void;
|
|
15
15
|
export declare function searched(runtime: Runtime, input: unknown, reach: PortReach | null): Promise<SearchResult>;
|
package/dist/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAY,KAAK,KAAK,EAAE,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAK3D,OAAO,EAKL,KAAK,IAAI,EACT,KA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AAO,EAChB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,YAAY,CAAC,CAkDvB"}
|
package/dist/queries.js
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
import { identityOf } from '@agentshouse/mdmodel';
|
|
2
2
|
import { ROOM_TOTALS } from './figures.js';
|
|
3
3
|
import { roomInFlight } from './install.js';
|
|
4
|
-
import {
|
|
4
|
+
import { readerOf } from './live.js';
|
|
5
|
+
import { compositionFor, roomFacts } from './listing.js';
|
|
5
6
|
import { lockedRooms } from './locks.js';
|
|
6
7
|
import { OFFLINE, UNCERTAIN, failure } from './outcome.js';
|
|
7
|
-
import { connectionNow, prepare
|
|
8
|
+
import { connectionNow, prepare } from './preparation.js';
|
|
8
9
|
import { planWithin, } from './query.js';
|
|
9
10
|
import { planReach } from './reach.js';
|
|
10
11
|
import { refuse } from './refusal.js';
|
|
11
|
-
import { documentKey } from './rows.js';
|
|
12
|
+
import { documentKey, roomsOfReach } from './rows.js';
|
|
12
13
|
import { searchPlanOf } from './search.js';
|
|
13
14
|
import { seedApplies, seededResult, watchSeeded } from './seed.js';
|
|
14
15
|
import { capped, MAXIMUM_WINDOW } from './windows.js';
|
|
15
16
|
const QUERY_BYTES = 1 << 20;
|
|
16
|
-
function everyRoom({
|
|
17
|
+
function everyRoom({ presence }, held) {
|
|
17
18
|
return [
|
|
18
19
|
...new Set([
|
|
19
|
-
...
|
|
20
|
+
...presence.rooms().map(({ locator }) => locator),
|
|
20
21
|
...held.rooms.keys(),
|
|
21
22
|
...held.queues.keys(),
|
|
22
23
|
]),
|
|
23
24
|
];
|
|
24
25
|
}
|
|
26
|
+
function anyHeld({ presence }, held, locator) {
|
|
27
|
+
return (presence.room(locator) !== undefined || held.rooms.has(locator) || held.queues.has(locator));
|
|
28
|
+
}
|
|
29
|
+
function anyRoom(plan) {
|
|
30
|
+
return plan.rooms === null && plan.reach === null;
|
|
31
|
+
}
|
|
32
|
+
function reaching(runtime, plan, reads, held) {
|
|
33
|
+
if (!anyRoom(plan))
|
|
34
|
+
return reads;
|
|
35
|
+
return (locator) => reads(locator) && anyHeld(runtime, held, locator);
|
|
36
|
+
}
|
|
25
37
|
function reachedRooms(runtime, plan, held) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
const named = plan.rooms ?? (plan.reach === null ? everyRoom(runtime, held) : roomsOfReach(plan.reach));
|
|
39
|
+
return [...new Set(named)].filter(reaching(runtime, plan, readerOf(plan), held)).sort();
|
|
40
|
+
}
|
|
41
|
+
function awaited({ socket, presence }, locator) {
|
|
42
|
+
return (!socket.session.now().roomsListed || presence.room(locator)?.replica.admission === 'admitted');
|
|
31
43
|
}
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
function awaitsOf(runtime, locator, held) {
|
|
45
|
+
const replica = held.rooms.get(locator);
|
|
46
|
+
if (replica === undefined)
|
|
47
|
+
return awaited(runtime, locator) ? 'acquisition' : null;
|
|
48
|
+
return replica.indexed ? null : 'preparation';
|
|
36
49
|
}
|
|
37
50
|
function coveredRooms(runtime, locators, whole, held) {
|
|
38
51
|
const { store, socket } = runtime;
|
|
@@ -43,16 +56,12 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
43
56
|
const overlay = [];
|
|
44
57
|
const read = [];
|
|
45
58
|
for (const locator of locators) {
|
|
59
|
+
const awaits = awaitsOf(runtime, locator, held);
|
|
60
|
+
if (awaits !== null)
|
|
61
|
+
pending.push({ room: locator, awaits });
|
|
46
62
|
const replica = held.rooms.get(locator);
|
|
47
|
-
if (replica === undefined)
|
|
48
|
-
if (awaited(runtime, locator))
|
|
49
|
-
pending.push({ room: locator, awaits: 'acquisition' });
|
|
63
|
+
if (awaits !== null || replica === undefined)
|
|
50
64
|
continue;
|
|
51
|
-
}
|
|
52
|
-
if (!replica.indexed) {
|
|
53
|
-
pending.push({ room: locator, awaits: 'preparation' });
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
65
|
coverage.push({
|
|
57
66
|
room: locator,
|
|
58
67
|
generation: replica.transfer,
|
|
@@ -67,7 +76,19 @@ function coveredRooms(runtime, locators, whole, held) {
|
|
|
67
76
|
return { coverage: { rooms: coverage, overlay }, rooms: read };
|
|
68
77
|
}
|
|
69
78
|
function covered(runtime, plan, held) {
|
|
70
|
-
return coveredRooms(runtime, reachedRooms(runtime, plan, held), plan
|
|
79
|
+
return coveredRooms(runtime, reachedRooms(runtime, plan, held), anyRoom(plan), held);
|
|
80
|
+
}
|
|
81
|
+
function pendingAt(runtime, plan, reads, held, rooms) {
|
|
82
|
+
const reached = reaching(runtime, plan, reads, held);
|
|
83
|
+
const at = new Map();
|
|
84
|
+
for (const room of rooms) {
|
|
85
|
+
const awaits = reached(room) ? awaitsOf(runtime, room, held) : null;
|
|
86
|
+
at.set(room, awaits === null ? null : { room, awaits });
|
|
87
|
+
}
|
|
88
|
+
awaitPreparation(runtime, {
|
|
89
|
+
pending: [...at.values()].filter((room) => room !== null),
|
|
90
|
+
});
|
|
91
|
+
return at;
|
|
71
92
|
}
|
|
72
93
|
function awaitPreparation(runtime, cover) {
|
|
73
94
|
if (!('pending' in cover))
|
|
@@ -119,7 +140,22 @@ async function windowRows(local, plan, rooms, unchanged) {
|
|
|
119
140
|
}
|
|
120
141
|
return null;
|
|
121
142
|
}
|
|
122
|
-
|
|
143
|
+
function freeTextAsked(plan) {
|
|
144
|
+
return plan.shape.kind === 'documents' && (plan.shape.sections !== null || plan.shape.preamble);
|
|
145
|
+
}
|
|
146
|
+
async function composedRooms(runtime, plan, rooms) {
|
|
147
|
+
if (!freeTextAsked(plan))
|
|
148
|
+
return rooms;
|
|
149
|
+
const held = await runtime.store.rooms(rooms.map(({ locator }) => locator));
|
|
150
|
+
return rooms.map((room) => {
|
|
151
|
+
const stored = held.get(room.locator);
|
|
152
|
+
return stored === undefined
|
|
153
|
+
? room
|
|
154
|
+
: { ...room, composition: compositionFor(runtime, stored.record) };
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
async function coveredRows(runtime, plan, cover) {
|
|
158
|
+
const { store } = runtime;
|
|
123
159
|
for (;;) {
|
|
124
160
|
const before = await cover();
|
|
125
161
|
if ('pending' in before)
|
|
@@ -128,7 +164,7 @@ async function coveredRows({ store }, plan, cover) {
|
|
|
128
164
|
const keys = before.rooms.map(({ key }) => key);
|
|
129
165
|
const changes = local.changes(keys);
|
|
130
166
|
const current = () => local.changes(keys) === changes;
|
|
131
|
-
const rows = await windowRows(local, plan, before.rooms, current);
|
|
167
|
+
const rows = await windowRows(local, plan, await composedRooms(runtime, plan, before.rooms), current);
|
|
132
168
|
const after = await cover();
|
|
133
169
|
if (rows !== null && sameCover(before, after))
|
|
134
170
|
return { rows, cover: before, current };
|
|
@@ -191,11 +227,14 @@ export async function roomTallies(runtime, rooms, since) {
|
|
|
191
227
|
});
|
|
192
228
|
}
|
|
193
229
|
export function watchPlan(runtime, plan, deliver, fail) {
|
|
230
|
+
const reads = readerOf(plan);
|
|
194
231
|
return watchSeeded(runtime, plan, deliver, (behind, answered) => runtime.liveQueries.watch(plan, identityOf(plan), (held) => {
|
|
195
232
|
const cover = covered(runtime, plan, held);
|
|
196
233
|
awaitPreparation(runtime, cover);
|
|
197
234
|
return behind(cover, held);
|
|
198
|
-
},
|
|
235
|
+
}, (held, rooms) => runtime.store.seeds.of(plan.key) === undefined
|
|
236
|
+
? pendingAt(runtime, plan, reads, held, rooms)
|
|
237
|
+
: null, answered, fail));
|
|
199
238
|
}
|
|
200
239
|
export function watchPlanned(runtime, planning, deliver, fail) {
|
|
201
240
|
let stop = null;
|
|
@@ -213,7 +252,7 @@ export function watchPlanned(runtime, planning, deliver, fail) {
|
|
|
213
252
|
};
|
|
214
253
|
}
|
|
215
254
|
export async function searched(runtime, input, reach) {
|
|
216
|
-
const { store, socket
|
|
255
|
+
const { store, socket } = runtime;
|
|
217
256
|
const { session } = socket;
|
|
218
257
|
const asked = searchPlanOf(input);
|
|
219
258
|
await socket.ready;
|
|
@@ -249,12 +288,10 @@ export async function searched(runtime, input, reach) {
|
|
|
249
288
|
const { closed, authorization, refusal } = session.now();
|
|
250
289
|
if (closed || authorization === undefined || refusal !== null)
|
|
251
290
|
return UNCERTAIN;
|
|
252
|
-
journal.record('transfer search');
|
|
253
291
|
try {
|
|
254
292
|
const result = await search(authorization, { text: asked.text, rooms });
|
|
255
293
|
if (result.kind === 'revoked-authorization')
|
|
256
294
|
await refuse(runtime, 'revoked-authorization');
|
|
257
|
-
journal.record(`outcome search ${result.kind}`);
|
|
258
295
|
if (result.kind === 'rejected')
|
|
259
296
|
return result;
|
|
260
297
|
if (result.kind !== 'found')
|
|
@@ -266,7 +303,6 @@ export async function searched(runtime, input, reach) {
|
|
|
266
303
|
};
|
|
267
304
|
}
|
|
268
305
|
catch {
|
|
269
|
-
journal.record('outcome search transport-uncertainty');
|
|
270
306
|
return UNCERTAIN;
|
|
271
307
|
}
|
|
272
308
|
}
|
package/dist/questions.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type ChatQuestion = {
|
|
|
16
16
|
readonly interaction: string;
|
|
17
17
|
readonly asked: string | null;
|
|
18
18
|
readonly secret: boolean;
|
|
19
|
+
readonly page: string | null;
|
|
19
20
|
readonly message: string;
|
|
20
21
|
readonly fields: readonly ChatField[];
|
|
21
22
|
readonly undelivered: boolean;
|
|
@@ -26,9 +27,4 @@ export declare function entered(field: ChatField): boolean;
|
|
|
26
27
|
export declare function questionsOf(view: Pick<ConversationView, 'questions'> | null): readonly ChatQuestion[];
|
|
27
28
|
export declare function openQuestion(questions: readonly unknown[]): string | null;
|
|
28
29
|
export declare function questionAsked(questions: readonly unknown[]): string | null;
|
|
29
|
-
export type ChatLone = {
|
|
30
|
-
readonly question: ChatQuestion;
|
|
31
|
-
readonly field: ChatField;
|
|
32
|
-
};
|
|
33
|
-
export declare function loneOf(questions: readonly ChatQuestion[]): ChatLone | null;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C;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAuCF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAEjD;AA2DD,wBAAgB,WAAW,CACzB,IAAI,EAAE,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,IAAI,GAC/C,SAAS,YAAY,EAAE,CAkBzB;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,GAAG,IAAI,CAE1E"}
|
package/dist/questions.js
CHANGED
|
@@ -97,6 +97,7 @@ export function questionsOf(view) {
|
|
|
97
97
|
interaction,
|
|
98
98
|
asked: text(one, 'asked_at'),
|
|
99
99
|
secret: one.secret === true,
|
|
100
|
+
page: one.secret === true ? text(one, 'page') : null,
|
|
100
101
|
undelivered: one.telegram_undelivered === true,
|
|
101
102
|
...asked,
|
|
102
103
|
},
|
|
@@ -113,10 +114,3 @@ export function openQuestion(questions) {
|
|
|
113
114
|
export function questionAsked(questions) {
|
|
114
115
|
return questionsOf({ questions })[0]?.asked ?? null;
|
|
115
116
|
}
|
|
116
|
-
export function loneOf(questions) {
|
|
117
|
-
const asked = questions.length === 1 && !questions[0].secret ? questions[0] : undefined;
|
|
118
|
-
const only = asked?.fields.length === 1 ? asked.fields[0] : undefined;
|
|
119
|
-
return asked !== undefined && only !== undefined && entered(only)
|
|
120
|
-
? { question: asked, field: only }
|
|
121
|
-
: null;
|
|
122
|
-
}
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { MutationResult } from './adapter.js';
|
|
2
|
+
import { type ChangeBatch } from './change.js';
|
|
3
|
+
import { type HeldReplica, type ReplicaRecord, type Returned, type Slice } from './replica.js';
|
|
4
|
+
import type { Runtime } from './runtime.js';
|
|
5
|
+
import type { SavePlan } from './save.js';
|
|
6
|
+
import type { SaveResult } from './saves.js';
|
|
7
|
+
import type { PendingState, RoomCommit, Store, StoredFile, View, Work } from './store.js';
|
|
8
|
+
export type Queueing = Pick<Runtime, 'store' | 'localSaves'> & {
|
|
9
|
+
readonly socket: Pick<Runtime['socket'], 'continuing'>;
|
|
10
|
+
readonly presence: Pick<Runtime['presence'], 'lost' | 'unheldModel' | 'room'>;
|
|
11
|
+
};
|
|
12
|
+
export type Restand = {
|
|
13
|
+
readonly locator: string;
|
|
14
|
+
readonly record: ReplicaRecord;
|
|
15
|
+
readonly accepted?: string;
|
|
16
|
+
readonly adopted?: Returned;
|
|
17
|
+
readonly installed?: Pick<RoomCommit, 'published' | 'refreshed'>;
|
|
18
|
+
readonly refused?: true;
|
|
19
|
+
readonly after?: () => void;
|
|
20
|
+
};
|
|
21
|
+
export type Appending = {
|
|
22
|
+
readonly plan: SavePlan;
|
|
23
|
+
readonly files: readonly StoredFile[];
|
|
24
|
+
readonly held: ReadonlyMap<string, {
|
|
25
|
+
readonly replica: HeldReplica;
|
|
26
|
+
readonly confirmed: Slice;
|
|
27
|
+
}>;
|
|
28
|
+
readonly after?: () => Promise<void>;
|
|
29
|
+
};
|
|
30
|
+
type Answer = Extract<MutationResult, {
|
|
31
|
+
kind: 'conflicted' | 'rejected';
|
|
32
|
+
}>;
|
|
33
|
+
export declare function withdrawable(states: ReadonlyMap<string, PendingState>): (batch: ChangeBatch) => boolean;
|
|
34
|
+
export declare function sliceAt(store: Store, record: ReplicaRecord, view: View, queue: readonly ChangeBatch[], extra?: Iterable<string>, moved?: Iterable<string>): Promise<Slice>;
|
|
35
|
+
export declare function settle(runtime: Queueing, locators: readonly string[], decide: (held: ReadonlyMap<string, Work>) => Promise<readonly Restand[]>): Promise<void>;
|
|
36
|
+
export declare function answered(runtime: Queueing, locator: string, head: ChangeBatch, answer: Answer): Promise<void>;
|
|
37
|
+
export declare function unpair(runtime: Queueing): Promise<void>;
|
|
38
|
+
export declare function append(runtime: Queueing, appending: Appending): Promise<SaveResult>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAmC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAKhF,OAAO,EAUL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,QAAQ,EACb,KAAK,KAAK,EAEX,MAAM,cAAc,CAAC;AAUtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAGV,YAAY,EACZ,UAAU,EAEV,KAAK,EACL,UAAU,EACV,IAAI,EACJ,IAAI,EACL,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,GAAG;IAC7D,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;IACvD,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC,CAAC;CAC/E,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAC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