@agentshouse/mdruntime 0.1.0-cefbc8bb8a1c0 → 0.1.0-cf08ada271a7f
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 +10 -10
- package/dist/acceptance.d.ts +3 -0
- package/dist/acceptance.d.ts.map +1 -0
- package/dist/acceptance.js +309 -0
- package/dist/actions.d.ts +20 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +251 -0
- package/dist/adapter.d.ts +95 -104
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -56
- package/dist/bootstrap.d.ts +11 -10
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +205 -88
- package/dist/cell.d.ts +6 -0
- package/dist/cell.d.ts.map +1 -0
- package/dist/cell.js +9 -0
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- 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 +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +5 -0
- package/dist/chat-types.d.ts.map +1 -0
- package/dist/chat-types.js +13 -0
- package/dist/client.d.ts +24 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -5
- package/dist/collection.d.ts +23 -7
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +13 -19
- package/dist/compile.d.ts +6 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +272 -334
- package/dist/connection.d.ts +5 -143
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +101 -5310
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-live.d.ts +135 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +247 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +53 -0
- package/dist/conversation.d.ts +41 -47
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +873 -912
- 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 +10 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +177 -0
- package/dist/durability.d.ts +15 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +17 -7
- 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 +1 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -0
- package/dist/figures.d.ts +49 -0
- package/dist/figures.d.ts.map +1 -0
- package/dist/figures.js +197 -0
- 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 +20 -8
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +38 -33
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +27 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/install.d.ts +55 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +543 -0
- package/dist/job.d.ts +5 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +7 -0
- package/dist/lifecycle.d.ts +7 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +271 -0
- package/dist/listing.d.ts +53 -0
- package/dist/listing.d.ts.map +1 -0
- package/dist/listing.js +169 -0
- package/dist/live.d.ts +5 -4
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +64 -23
- package/dist/locks.d.ts +9 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +62 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/lost.d.ts +5 -0
- package/dist/lost.d.ts.map +1 -0
- package/dist/lost.js +61 -0
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +3 -3
- package/dist/memory.d.ts +14 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +177 -85
- package/dist/messages.d.ts +24 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +89 -31
- package/dist/model.d.ts +2 -11
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -23
- package/dist/models.d.ts +10 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +170 -0
- package/dist/observation.d.ts +2 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +14 -14
- package/dist/opened.js +3 -3
- package/dist/opening.d.ts +4 -0
- package/dist/opening.d.ts.map +1 -0
- package/dist/opening.js +59 -0
- package/dist/outcome.d.ts +4 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -0
- package/dist/overlay.d.ts +3 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +43 -21
- package/dist/parts.d.ts +11 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +21 -0
- 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 +20 -0
- package/dist/preparation.d.ts.map +1 -0
- package/dist/preparation.js +233 -0
- package/dist/queries.d.ts +16 -0
- package/dist/queries.d.ts.map +1 -0
- package/dist/queries.js +272 -0
- package/dist/query.d.ts +14 -210
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/questions.d.ts +34 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +122 -0
- package/dist/queue.d.ts +39 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts +15 -13
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +187 -140
- package/dist/react.d.ts +14 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +10 -1
- package/dist/read.d.ts +7 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +17 -0
- package/dist/readiness.d.ts +2 -16
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/reads.d.ts +36 -10
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +160 -77
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +9 -1
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +35 -7
- package/dist/refusal.d.ts +5 -0
- package/dist/refusal.d.ts.map +1 -0
- package/dist/refusal.js +57 -0
- package/dist/replica.d.ts +11 -17
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +64 -34
- package/dist/room-draft.d.ts +7 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +100 -103
- package/dist/room-drafts.d.ts +24 -0
- package/dist/room-drafts.d.ts.map +1 -0
- package/dist/room-drafts.js +217 -0
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +49 -186
- package/dist/runtime.d.ts +32 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +239 -116
- package/dist/saves.d.ts +32 -0
- package/dist/saves.d.ts.map +1 -0
- package/dist/saves.js +413 -0
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/seed.d.ts +11 -2
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +71 -1
- package/dist/shared.d.ts +1 -7
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -105
- package/dist/shown.d.ts +32 -0
- package/dist/shown.d.ts.map +1 -0
- package/dist/shown.js +299 -0
- package/dist/socket/admission.d.ts +7 -0
- package/dist/socket/admission.d.ts.map +1 -0
- package/dist/socket/admission.js +39 -0
- package/dist/socket/answers.d.ts +6 -0
- package/dist/socket/answers.d.ts.map +1 -0
- package/dist/socket/answers.js +20 -0
- package/dist/socket/lanes.d.ts +20 -0
- package/dist/socket/lanes.d.ts.map +1 -0
- package/dist/socket/lanes.js +77 -0
- package/dist/socket/reads.d.ts +10 -0
- package/dist/socket/reads.d.ts.map +1 -0
- package/dist/socket/reads.js +31 -0
- package/dist/socket/rooms.d.ts +41 -0
- package/dist/socket/rooms.d.ts.map +1 -0
- package/dist/socket/rooms.js +90 -0
- package/dist/socket/session.d.ts +38 -0
- package/dist/socket/session.d.ts.map +1 -0
- package/dist/socket/session.js +23 -0
- package/dist/socket.d.ts +69 -0
- package/dist/socket.d.ts.map +1 -0
- package/dist/socket.js +175 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +82 -0
- package/dist/status.d.ts +0 -6
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +0 -6
- package/dist/store/fences.d.ts +16 -0
- package/dist/store/fences.d.ts.map +1 -0
- package/dist/store/fences.js +26 -0
- package/dist/store/installs.d.ts +30 -0
- package/dist/store/installs.d.ts.map +1 -0
- package/dist/store/installs.js +34 -0
- package/dist/store/readiness.d.ts +10 -0
- package/dist/store/readiness.d.ts.map +1 -0
- package/dist/store/readiness.js +52 -0
- package/dist/store/records.d.ts +210 -0
- package/dist/store/records.d.ts.map +1 -0
- package/dist/store/records.js +428 -0
- package/dist/store/room-held.d.ts +8 -0
- package/dist/store/room-held.d.ts.map +1 -0
- package/dist/store/room-held.js +17 -0
- package/dist/store/space.d.ts +11 -0
- package/dist/store/space.d.ts.map +1 -0
- package/dist/store/space.js +41 -0
- package/dist/store/watchers.d.ts +17 -0
- package/dist/store/watchers.d.ts.map +1 -0
- package/dist/store/watchers.js +56 -0
- package/dist/store/writes.d.ts +24 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +125 -0
- package/dist/store.d.ts +107 -157
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +143 -395
- package/dist/stored.d.ts +59 -38
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +279 -210
- package/dist/surface.d.ts +88 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +224 -0
- package/dist/sync.d.ts +19 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +530 -0
- package/dist/tables.d.ts +116 -56
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +214 -98
- package/dist/tallies.d.ts +18 -0
- package/dist/tallies.d.ts.map +1 -0
- package/dist/tallies.js +129 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +21 -9
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +10 -4
- package/package.json +3 -2
- package/dist/fence.d.ts +0 -6
- package/dist/fence.d.ts.map +0 -1
- package/dist/fence.js +0 -10
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -370
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -156
package/dist/figures.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { instantKey } from '@agentshouse/mdmodel';
|
|
2
|
+
export const HOUSE_DIRECTORY = 'house';
|
|
3
|
+
export const ROOM_TOTALS = {
|
|
4
|
+
outside: [HOUSE_DIRECTORY],
|
|
5
|
+
groupBy: ['room'],
|
|
6
|
+
select: { size: true },
|
|
7
|
+
};
|
|
8
|
+
// Today's Last 24 hours is the day that ends as the read answers.
|
|
9
|
+
export const FIGURES_DAY_MS = 86_400_000;
|
|
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
|
+
const SETTLED_MS = 1_000;
|
|
12
|
+
// Changes that never rest, such as an Agent writing all afternoon, still reach the figures this long after the first of them.
|
|
13
|
+
const LONGEST_UNSETTLED_MS = 5_000;
|
|
14
|
+
function dayOf(tally, since) {
|
|
15
|
+
const after = (at) => at !== null && at >= since;
|
|
16
|
+
return {
|
|
17
|
+
created: tally.documentTimes.filter(([created]) => after(created)).length,
|
|
18
|
+
changed: tally.documentTimes.filter(([created, changed]) => !after(created) && after(changed))
|
|
19
|
+
.length,
|
|
20
|
+
chats: tally.chatTimes.filter(after).length,
|
|
21
|
+
messages: tally.messageTimes.filter(after).length,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function figuresOf(rooms, held, since) {
|
|
25
|
+
return {
|
|
26
|
+
rooms: rooms.map(({ locator }) => {
|
|
27
|
+
const tally = held.rooms.get(locator);
|
|
28
|
+
return {
|
|
29
|
+
room: locator,
|
|
30
|
+
day: dayOf(tally, since),
|
|
31
|
+
total: { documents: tally.documents, files: tally.files },
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
agentMessages: [...held.said.values()].reduce((sum, said) => sum + said.filter((at) => at >= since).length, 0),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function unheld() {
|
|
38
|
+
return {
|
|
39
|
+
rooms: new Map(),
|
|
40
|
+
said: new Map(),
|
|
41
|
+
staleRooms: new Set(),
|
|
42
|
+
staleConversations: new Set(),
|
|
43
|
+
everyConversation: true,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function createFigures(sources) {
|
|
47
|
+
const listeners = new Map();
|
|
48
|
+
const answered = new Set();
|
|
49
|
+
let held = unheld();
|
|
50
|
+
let shown = null;
|
|
51
|
+
let running = false;
|
|
52
|
+
let again = false;
|
|
53
|
+
let quiet = null;
|
|
54
|
+
let longest = null;
|
|
55
|
+
let closed = false;
|
|
56
|
+
function unscheduled() {
|
|
57
|
+
if (quiet !== null)
|
|
58
|
+
clearTimeout(quiet);
|
|
59
|
+
if (longest !== null)
|
|
60
|
+
clearTimeout(longest);
|
|
61
|
+
quiet = null;
|
|
62
|
+
longest = null;
|
|
63
|
+
}
|
|
64
|
+
function deliver(answer) {
|
|
65
|
+
const text = JSON.stringify(answer);
|
|
66
|
+
const changed = text !== shown;
|
|
67
|
+
shown = text;
|
|
68
|
+
for (const listener of listeners.keys()) {
|
|
69
|
+
if (changed || !answered.has(listener))
|
|
70
|
+
listener(structuredClone(answer));
|
|
71
|
+
answered.add(listener);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function tallied(rooms, since) {
|
|
75
|
+
for (const locator of held.rooms.keys()) {
|
|
76
|
+
if (!rooms.some((room) => room.locator === locator))
|
|
77
|
+
held.rooms.delete(locator);
|
|
78
|
+
}
|
|
79
|
+
const asked = rooms.filter(({ locator, key }) => held.staleRooms.has(locator) || held.rooms.get(locator)?.key !== key);
|
|
80
|
+
for (const { locator } of asked)
|
|
81
|
+
held.staleRooms.delete(locator);
|
|
82
|
+
const every = held.everyConversation;
|
|
83
|
+
const conversations = every ? null : [...held.staleConversations];
|
|
84
|
+
held.everyConversation = false;
|
|
85
|
+
held.staleConversations.clear();
|
|
86
|
+
const kept = held;
|
|
87
|
+
const [roomTallies, said] = await Promise.all([
|
|
88
|
+
asked.length === 0 ? [] : sources.rooms(asked, since),
|
|
89
|
+
conversations?.length === 0 ? [] : sources.conversations(conversations, since),
|
|
90
|
+
]);
|
|
91
|
+
if (kept !== held)
|
|
92
|
+
return false;
|
|
93
|
+
for (const tally of roomTallies) {
|
|
94
|
+
const room = asked.find(({ key }) => key === tally.key);
|
|
95
|
+
if (room !== undefined)
|
|
96
|
+
held.rooms.set(room.locator, tally);
|
|
97
|
+
}
|
|
98
|
+
if (every)
|
|
99
|
+
held.said.clear();
|
|
100
|
+
for (const { conversation, said: times } of said) {
|
|
101
|
+
if (times.length === 0)
|
|
102
|
+
held.said.delete(conversation);
|
|
103
|
+
else
|
|
104
|
+
held.said.set(conversation, times);
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
async function answer() {
|
|
109
|
+
const window = new Date(Date.now() - FIGURES_DAY_MS).toISOString();
|
|
110
|
+
const cover = await sources.cover();
|
|
111
|
+
if ('pending' in cover)
|
|
112
|
+
return cover;
|
|
113
|
+
if (!(await tallied(cover.rooms, window)))
|
|
114
|
+
return null;
|
|
115
|
+
return figuresOf(cover.rooms, held, instantKey(window));
|
|
116
|
+
}
|
|
117
|
+
async function run() {
|
|
118
|
+
if (running) {
|
|
119
|
+
again = true;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
running = true;
|
|
123
|
+
try {
|
|
124
|
+
do {
|
|
125
|
+
again = false;
|
|
126
|
+
const result = await answer();
|
|
127
|
+
if (closed || listeners.size === 0)
|
|
128
|
+
return;
|
|
129
|
+
if (result === null)
|
|
130
|
+
again = true;
|
|
131
|
+
else
|
|
132
|
+
deliver(result);
|
|
133
|
+
} while (again && !closed && listeners.size > 0);
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
for (const [listener, failed] of listeners) {
|
|
137
|
+
if (!answered.has(listener))
|
|
138
|
+
failed(error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
running = false;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function stop(listener) {
|
|
146
|
+
return () => {
|
|
147
|
+
listeners.delete(listener);
|
|
148
|
+
answered.delete(listener);
|
|
149
|
+
if (listeners.size > 0)
|
|
150
|
+
return;
|
|
151
|
+
unscheduled();
|
|
152
|
+
held = unheld();
|
|
153
|
+
shown = null;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function settle() {
|
|
157
|
+
if (closed || listeners.size === 0)
|
|
158
|
+
return;
|
|
159
|
+
const now = () => {
|
|
160
|
+
unscheduled();
|
|
161
|
+
void run();
|
|
162
|
+
};
|
|
163
|
+
if (quiet !== null)
|
|
164
|
+
clearTimeout(quiet);
|
|
165
|
+
quiet = setTimeout(now, SETTLED_MS);
|
|
166
|
+
longest ??= setTimeout(now, LONGEST_UNSETTLED_MS);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
watch(listener, failed) {
|
|
170
|
+
listeners.set(listener, failed);
|
|
171
|
+
void run();
|
|
172
|
+
return stop(listener);
|
|
173
|
+
},
|
|
174
|
+
touched(set) {
|
|
175
|
+
if (listeners.size === 0)
|
|
176
|
+
return;
|
|
177
|
+
for (const { locator } of set.documents)
|
|
178
|
+
held.staleRooms.add(locator);
|
|
179
|
+
for (const locator of set.rooms)
|
|
180
|
+
held.staleRooms.add(locator);
|
|
181
|
+
for (const conversation of set.conversations)
|
|
182
|
+
held.staleConversations.add(conversation);
|
|
183
|
+
if (set.documents.length + set.rooms.length + set.conversations.length > 0)
|
|
184
|
+
settle();
|
|
185
|
+
},
|
|
186
|
+
recover() {
|
|
187
|
+
if (listeners.size > 0)
|
|
188
|
+
settle();
|
|
189
|
+
},
|
|
190
|
+
close() {
|
|
191
|
+
closed = true;
|
|
192
|
+
unscheduled();
|
|
193
|
+
listeners.clear();
|
|
194
|
+
answered.clear();
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
@@ -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,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,OAAO,GACf,CAAC;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,GAChE;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC;AAEnE,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,GAAG,aAAa,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG;QAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,CAAC;IACxE,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAIF,eAAO,MAAM,aAAa,YAAY,CAAC;AA6CvC,wBAAgB,aAAa,CAC3B,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAClC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,GACT,MAAM,IAAI,CA4DZ"}
|
package/dist/holdings.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const NO_CODE = { house: 0, apps: [] };
|
|
2
|
+
export const CLEANED_TOPIC = '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
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
2
|
import type { PortReach } from './reach.js';
|
|
3
|
-
import type { CodeAvailability, Persistence, Readiness
|
|
3
|
+
import type { CodeAvailability, Persistence, Readiness } 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;
|
|
12
26
|
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
27
|
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
|
-
code(code: CodeAvailability, space: Space | null): void;
|
|
15
|
-
search(search: SearchObligation): void;
|
|
16
28
|
};
|
|
17
29
|
export type MdRuntimeHost = {
|
|
18
|
-
attach(port: RuntimePort,
|
|
30
|
+
attach(port: RuntimePort, options: AttachOptions): AttachedPort;
|
|
31
|
+
present(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
19
32
|
seed(entry: EntrySeed): void;
|
|
20
33
|
persisted(answer: Persistence): void;
|
|
21
|
-
shown(onScreen: boolean): void;
|
|
22
34
|
endAuthorization(holder?: string): Promise<void>;
|
|
23
|
-
lose(locators: readonly string[]): Promise<void>;
|
|
24
35
|
stop(): Promise<void>;
|
|
25
36
|
};
|
|
26
37
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
27
38
|
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
28
39
|
export type { PortReach, ReachedDocument } from './reach.js';
|
|
29
|
-
export type { CodeAvailability, Persistence,
|
|
40
|
+
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
30
41
|
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
31
|
-
export
|
|
42
|
+
export { undeclared } from './outcome.js';
|
|
43
|
+
export { wireAnswer, wireRequest, type RuntimePort, type WireAnswer, type WireRequest, } from './wire.js';
|
|
32
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":"
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAIxE,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,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC/B,SAAS,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;CAC/D,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,YAAY,CAAC;IAChE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAsIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA4L3E;AAED,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,UAAU,EACV,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { queryKey } from '@agentshouse/mdmodel';
|
|
2
|
+
import { composeRuntime } from './connection.js';
|
|
3
3
|
import { untilAnswered } from './recovery.js';
|
|
4
4
|
import { described } from './failure.js';
|
|
5
|
-
import {
|
|
5
|
+
import { answeredResult } from './outcome.js';
|
|
6
|
+
import { AUTHORIZATION_ENDED, WIRE, wireRequest, } from './wire.js';
|
|
6
7
|
const NARROWED = new Set(['within', 'whole']);
|
|
7
8
|
function answered(md, app, writtenBy, member, input) {
|
|
8
9
|
switch (member) {
|
|
@@ -40,6 +41,12 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
40
41
|
return md.log();
|
|
41
42
|
case 'cleanUp':
|
|
42
43
|
return md.cleanUp();
|
|
44
|
+
case 'unsent':
|
|
45
|
+
return md.unsent();
|
|
46
|
+
case 'reset':
|
|
47
|
+
return md.reset();
|
|
48
|
+
case 'readAgain':
|
|
49
|
+
return md.readAgain();
|
|
43
50
|
case 'persistence':
|
|
44
51
|
return md.persistence();
|
|
45
52
|
case 'retry':
|
|
@@ -74,8 +81,6 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
74
81
|
return md.conversation.interrupt(input[0]);
|
|
75
82
|
case 'conversation.kill':
|
|
76
83
|
return md.conversation.kill(input[0]);
|
|
77
|
-
case 'conversation.cancel':
|
|
78
|
-
return md.conversation.cancel(input[0], input[1]);
|
|
79
84
|
case 'conversation.delete':
|
|
80
85
|
return md.conversation.delete(input[0]);
|
|
81
86
|
case 'chatDraft.write':
|
|
@@ -94,9 +99,6 @@ function attempted(work) {
|
|
|
94
99
|
return Promise.reject(error);
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
|
-
function answeredResult(value) {
|
|
98
|
-
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
99
|
-
}
|
|
100
102
|
function answeredMessage(value) {
|
|
101
103
|
if (typeof value !== 'object' || value === null)
|
|
102
104
|
return false;
|
|
@@ -121,12 +123,12 @@ export function serveMdRuntime(options) {
|
|
|
121
123
|
deliver(structuredClone(deploymentFacts));
|
|
122
124
|
return () => { };
|
|
123
125
|
};
|
|
124
|
-
function attach(port,
|
|
126
|
+
function attach(port, options) {
|
|
125
127
|
if (!authorized)
|
|
126
128
|
throw new Error(AUTHORIZATION_ENDED);
|
|
129
|
+
const { app, release, reach, admission, code = 'stored' } = options;
|
|
127
130
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
128
|
-
|
|
129
|
-
const view = runtime.within(reach ?? null, facts);
|
|
131
|
+
const view = runtime.within(reach ?? null, { target: app, code });
|
|
130
132
|
const observations = new Map();
|
|
131
133
|
const followed = new Set();
|
|
132
134
|
const answeredKeys = new Set();
|
|
@@ -164,9 +166,16 @@ export function serveMdRuntime(options) {
|
|
|
164
166
|
if (topic === 'query' && answeredMessage(value))
|
|
165
167
|
answeredQuery(input[0]);
|
|
166
168
|
};
|
|
169
|
+
const fail = (error) => {
|
|
170
|
+
if (!serving || resolved)
|
|
171
|
+
return;
|
|
172
|
+
observations.get(id)?.();
|
|
173
|
+
observations.delete(id);
|
|
174
|
+
send({ kind: 'failure', id, ...described(error) });
|
|
175
|
+
};
|
|
167
176
|
observations.set(id, topic === 'deployment-facts'
|
|
168
177
|
? watchFacts(deliver)
|
|
169
|
-
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver));
|
|
178
|
+
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver, fail));
|
|
170
179
|
};
|
|
171
180
|
const reply = async (id, query, pending) => {
|
|
172
181
|
try {
|
|
@@ -182,6 +191,15 @@ export function serveMdRuntime(options) {
|
|
|
182
191
|
send({ kind: 'failure', id, ...described(error) });
|
|
183
192
|
}
|
|
184
193
|
};
|
|
194
|
+
const admitted = admission === undefined
|
|
195
|
+
? view.md
|
|
196
|
+
: {
|
|
197
|
+
...view.md,
|
|
198
|
+
async call(name, input) {
|
|
199
|
+
const decided = await admission(name, input);
|
|
200
|
+
return 'refused' in decided ? decided.refused : view.md.call(name, decided.admitted);
|
|
201
|
+
},
|
|
202
|
+
};
|
|
185
203
|
const serve = async (message) => {
|
|
186
204
|
if (message.kind === 'hello')
|
|
187
205
|
return;
|
|
@@ -207,13 +225,13 @@ export function serveMdRuntime(options) {
|
|
|
207
225
|
return;
|
|
208
226
|
}
|
|
209
227
|
const { id, member, input } = message;
|
|
210
|
-
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ?
|
|
228
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? admitted : md, app, writtenBy, member, input));
|
|
211
229
|
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
212
230
|
};
|
|
213
231
|
port.addEventListener('message', (event) => {
|
|
214
232
|
if (!serving)
|
|
215
233
|
return;
|
|
216
|
-
const message =
|
|
234
|
+
const message = wireRequest(event.data);
|
|
217
235
|
if (message === null)
|
|
218
236
|
return;
|
|
219
237
|
void serve(message);
|
|
@@ -227,18 +245,6 @@ export function serveMdRuntime(options) {
|
|
|
227
245
|
if (serving)
|
|
228
246
|
view.narrow(next);
|
|
229
247
|
},
|
|
230
|
-
code(next, space) {
|
|
231
|
-
if (!serving)
|
|
232
|
-
return;
|
|
233
|
-
facts = { ...facts, code: next, space };
|
|
234
|
-
view.facts(facts);
|
|
235
|
-
},
|
|
236
|
-
search(next) {
|
|
237
|
-
if (!serving)
|
|
238
|
-
return;
|
|
239
|
-
facts = { ...facts, search: next };
|
|
240
|
-
view.facts(facts);
|
|
241
|
-
},
|
|
242
248
|
answered(queries, done) {
|
|
243
249
|
const keys = queries.map(queryKey);
|
|
244
250
|
if (keys.every((key) => answeredKeys.has(key)))
|
|
@@ -252,7 +258,7 @@ export function serveMdRuntime(options) {
|
|
|
252
258
|
const stop = view.watch('readiness', [], (value) => {
|
|
253
259
|
if (serving)
|
|
254
260
|
deliver(value);
|
|
255
|
-
});
|
|
261
|
+
}, () => { });
|
|
256
262
|
const end = () => {
|
|
257
263
|
followed.delete(end);
|
|
258
264
|
stop();
|
|
@@ -264,15 +270,15 @@ export function serveMdRuntime(options) {
|
|
|
264
270
|
}
|
|
265
271
|
return {
|
|
266
272
|
attach,
|
|
273
|
+
present(app, members) {
|
|
274
|
+
return md.presentation.edit(app, members);
|
|
275
|
+
},
|
|
267
276
|
seed(entry) {
|
|
268
277
|
runtime.seed(entry);
|
|
269
278
|
},
|
|
270
279
|
persisted(answer) {
|
|
271
280
|
runtime.persisted(answer);
|
|
272
281
|
},
|
|
273
|
-
shown(onScreen) {
|
|
274
|
-
runtime.shown(onScreen);
|
|
275
|
-
},
|
|
276
282
|
async endAuthorization(holder) {
|
|
277
283
|
authorized = false;
|
|
278
284
|
for (const [detach, send] of [...attachments]) {
|
|
@@ -284,9 +290,6 @@ export function serveMdRuntime(options) {
|
|
|
284
290
|
await options.shell.dropGeneration();
|
|
285
291
|
}
|
|
286
292
|
},
|
|
287
|
-
lose(locators) {
|
|
288
|
-
return runtime.lose(locators);
|
|
289
|
-
},
|
|
290
293
|
stop() {
|
|
291
294
|
return runtime.stop();
|
|
292
295
|
},
|
|
@@ -294,3 +297,5 @@ export function serveMdRuntime(options) {
|
|
|
294
297
|
}
|
|
295
298
|
export { entrySeedOf } from './seed.js';
|
|
296
299
|
export { createRecovery, retryDelay, } from './recovery.js';
|
|
300
|
+
export { undeclared } from './outcome.js';
|
|
301
|
+
export { wireAnswer, wireRequest, } from './wire.js';
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
|
-
export declare function identityTime(identity: string): number;
|
|
3
2
|
export declare function roomDraftRevision(): string;
|
|
4
3
|
export declare function chatDraftRevision(): string;
|
|
5
4
|
export declare function transferIdentity(): string;
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/identity.js
CHANGED
|
@@ -10,9 +10,6 @@ export function changeBatchIdentity(at = Date.now()) {
|
|
|
10
10
|
const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
11
11
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
12
12
|
}
|
|
13
|
-
export function identityTime(identity) {
|
|
14
|
-
return Number.parseInt(identity.replaceAll('-', '').slice(0, 12), 16);
|
|
15
|
-
}
|
|
16
13
|
function randomIdentity() {
|
|
17
14
|
const bytes = new Uint8Array(16);
|
|
18
15
|
crypto.getRandomValues(bytes);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,47 @@
|
|
|
1
|
-
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, AttachRequest, AttachResult, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction,
|
|
1
|
+
export type { AcceptedMessage, AcceptedRoom, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, AttachRequest, AttachResult, AuthorityChange, Authorization, BinaryFile, BinaryLinkResult, BinaryRequest, BinaryResult, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, SavedFacts, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, BootstrapPart, NotReady, HeldRoom, ListedAgent, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomChange, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, SearchAnswer, SearchAsk, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnOperation, TypedPath, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
3
|
-
export
|
|
4
|
-
export type {
|
|
3
|
+
export { heldFacts } from './conversation-row.js';
|
|
4
|
+
export type { ConversationAsk, ConversationHeld, ConversationLast, ConversationStart, } from './conversation-row.js';
|
|
5
|
+
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
6
|
+
export type { MdRuntimeOptions } from './connection.js';
|
|
7
|
+
export { writeRule, type WriteRefusal } from './declaration.js';
|
|
8
|
+
export type { HistoryQuery } from './actions.js';
|
|
9
|
+
export type { AppRoom, AppTypedSelection } from './listing.js';
|
|
10
|
+
export type { ConnectionRefusal, ConnectionRefusalCode } from './socket.js';
|
|
11
|
+
export type { MdRuntime, RoomSchemas } from './surface.js';
|
|
12
|
+
export type { BinaryFileSurface, SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
|
|
5
13
|
export type { Observation } from './observation.js';
|
|
14
|
+
export type { DayFigures, Figures, FiguresResult, RoomFigures } from './figures.js';
|
|
15
|
+
export type { HeldApp, Holdings, RoomDocuments } from './holdings.js';
|
|
16
|
+
export type { PresentationSurface, RoomDraftSurface } from './room-drafts.js';
|
|
6
17
|
export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
7
18
|
export type { BinaryFileRecord } from './binary.js';
|
|
8
19
|
export type { RuntimeError } from './failure.js';
|
|
9
20
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
10
21
|
export type { SaveRefusal } from './save.js';
|
|
11
|
-
export type {
|
|
22
|
+
export type { SearchFound, SearchHit, SearchRequest, SearchResult } from './search.js';
|
|
23
|
+
export { CHAT_MESSAGE_TYPE, CHAT_TYPE, keptFile, keptLines } from './chat-types.js';
|
|
24
|
+
export { FIGURES_DAY_MS } from './figures.js';
|
|
12
25
|
export { departure } from './change.js';
|
|
13
|
-
export {
|
|
26
|
+
export { definitionsIn, selected } from './collection.js';
|
|
27
|
+
export { lineEnded, partsAfter, partsChanges } from './room-draft.js';
|
|
14
28
|
export { cutName, nameFrom, transliterated } from './name.js';
|
|
15
29
|
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
30
|
+
export { contextFigure } from './context.js';
|
|
31
|
+
export { sessionEnded, type RunningJob } from './job.js';
|
|
16
32
|
export { changeBatchIdentity } from './identity.js';
|
|
17
33
|
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
34
|
+
export { authoredAt, covered } from './paths.js';
|
|
18
35
|
export { untilAnswered } from './recovery.js';
|
|
19
36
|
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
20
37
|
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
21
38
|
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
22
|
-
export type { RuntimeShell } from './durability.js';
|
|
23
|
-
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount,
|
|
39
|
+
export type { AppCode, HeldCode, RuntimeShell, UnsentKind, UnsentWork } from './durability.js';
|
|
40
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationStep, Persistence, Readiness, ReadinessStatus, RoomCoverage, RoomPreparation, Space, TargetCoverage, } from './readiness.js';
|
|
41
|
+
export type { ObservedRead } from './reads.js';
|
|
24
42
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
25
|
-
export type {
|
|
43
|
+
export type { Direction, DocumentQuery, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, Key, LocalQuery, OrderOptions, Predicate, Related, Select, Value, Where, } from '@agentshouse/mdmodel';
|
|
44
|
+
export type { Awaits, Backlink, CoveredRoom, DocumentResult, GroupResult, GroupTotal, PendingResult, PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, } from './query.js';
|
|
26
45
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
27
46
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
28
47
|
//# sourceMappingURL=index.d.ts.map
|