@agentshouse/mdruntime 0.1.0-c3903a68dcbbf → 0.1.0-c3a5b012b4a8c
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 +26 -13
- package/dist/adapter.d.ts +244 -88
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +8 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +46 -0
- package/dist/attempt.d.ts +16 -0
- package/dist/attempt.d.ts.map +1 -0
- package/dist/attempt.js +70 -0
- package/dist/binary.d.ts +18 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts +40 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +336 -52
- package/dist/chain.d.ts +12 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -14
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -60
- package/dist/change.d.ts +46 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +34 -0
- package/dist/client.d.ts +44 -24
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +161 -36
- package/dist/collection.d.ts +13 -16
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +52 -66
- package/dist/compile.d.ts +11 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +717 -0
- package/dist/connection.d.ts +69 -44
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +4581 -1472
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation-row.d.ts +33 -0
- package/dist/conversation-row.d.ts.map +1 -0
- package/dist/conversation-row.js +47 -0
- package/dist/conversation.d.ts +76 -27
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +1052 -273
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +10 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +20 -0
- package/dist/entry.d.ts.map +1 -0
- package/dist/entry.js +161 -0
- package/dist/expectation.d.ts +21 -0
- package/dist/expectation.d.ts.map +1 -0
- package/dist/expectation.js +70 -0
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/file.d.ts +2 -19
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +7 -122
- package/dist/host.d.ts +17 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +163 -75
- package/dist/identity.d.ts +3 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +13 -1
- package/dist/index.d.ts +26 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/job.d.ts +33 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +54 -0
- package/dist/live.d.ts +23 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +165 -0
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +30 -9
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +337 -87
- package/dist/messages.d.ts +52 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +168 -0
- package/dist/model.d.ts +17 -16
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +9 -9
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +22 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +133 -17
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +72 -21
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +81 -1
- package/dist/overlay.d.ts +16 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +147 -180
- package/dist/parts.d.ts +59 -0
- package/dist/parts.d.ts.map +1 -0
- package/dist/parts.js +118 -0
- package/dist/paths.d.ts +1 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -16
- package/dist/query.d.ts +56 -180
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -422
- package/dist/questions.d.ts +32 -0
- package/dist/questions.d.ts.map +1 -0
- package/dist/questions.js +118 -0
- package/dist/reach.d.ts +54 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +483 -0
- package/dist/react.d.ts +45 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +54 -0
- 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 +50 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +27 -0
- package/dist/recovery.d.ts +26 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +232 -0
- package/dist/refresh.d.ts +21 -7
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +155 -55
- package/dist/replica.d.ts +61 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +355 -162
- package/dist/room-draft.d.ts +62 -11
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +281 -83
- package/dist/rows.d.ts +32 -34
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +65 -87
- package/dist/save.d.ts +74 -6
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +902 -183
- package/dist/search.d.ts +15 -54
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +10 -121
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +15 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +421 -0
- package/dist/source.d.ts +61 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +81 -0
- package/dist/status.d.ts +7 -4
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -15
- package/dist/store.d.ts +178 -80
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +372 -381
- package/dist/stored.d.ts +156 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +637 -0
- package/dist/tables.d.ts +388 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +706 -0
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/turn.d.ts +9 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +75 -0
- package/dist/validation.d.ts +29 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +104 -0
- package/dist/windows.d.ts +11 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +16 -0
- package/dist/wire.d.ts +199 -19
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +92 -67
- package/package.json +33 -10
- package/AGENTS.md +0 -210
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
- package/dist/read-side.d.ts +0 -14
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -371
package/dist/host.d.ts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { type MdRuntimeOptions } from './connection.js';
|
|
2
|
+
import type { PortReach } from './reach.js';
|
|
3
|
+
import type { CodeAvailability, Persistence, Readiness } from './readiness.js';
|
|
4
|
+
import type { EntrySeed } from './seed.js';
|
|
2
5
|
import { type RuntimePort } from './wire.js';
|
|
3
6
|
export type MdRuntimeHostOptions = MdRuntimeOptions & {
|
|
4
7
|
deploymentFacts?: unknown;
|
|
5
8
|
};
|
|
9
|
+
export type AttachedPort = {
|
|
10
|
+
detach(): void;
|
|
11
|
+
narrow(reach: PortReach): void;
|
|
12
|
+
readiness(deliver: (readiness: Readiness) => void): () => void;
|
|
13
|
+
answered(queries: readonly unknown[], done: () => void): void;
|
|
14
|
+
};
|
|
6
15
|
export type MdRuntimeHost = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
16
|
+
attach(port: RuntimePort, app: string, release?: string, reach?: PortReach, code?: CodeAvailability): AttachedPort;
|
|
17
|
+
seed(entry: EntrySeed): void;
|
|
18
|
+
persisted(answer: Persistence): void;
|
|
19
|
+
endAuthorization(holder?: string): Promise<void>;
|
|
10
20
|
stop(): Promise<void>;
|
|
11
21
|
};
|
|
12
22
|
export declare function serveMdRuntime(options: MdRuntimeHostOptions): MdRuntimeHost;
|
|
23
|
+
export { entrySeedOf, type EntrySeed } from './seed.js';
|
|
24
|
+
export type { PortReach, ReachedDocument } from './reach.js';
|
|
25
|
+
export type { CodeAvailability, Persistence, Space } from './readiness.js';
|
|
26
|
+
export { createRecovery, retryDelay, type Attempt, type Attempted, type AttemptOptions, type Recovery, type RecoveryOptions, } from './recovery.js';
|
|
13
27
|
export type { RuntimePort } from './wire.js';
|
|
14
28
|
//# 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":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAEzB,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,EAGL,KAAK,WAAW,EAOjB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AK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -1,40 +1,53 @@
|
|
|
1
|
+
import { queryKey } from '@agentshouse/mdmodel';
|
|
1
2
|
import { composeRuntime, } from './connection.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { untilAnswered } from './recovery.js';
|
|
4
|
+
import { described } from './failure.js';
|
|
5
|
+
import { AUTHORIZATION_ENDED, request, WIRE, } from './wire.js';
|
|
6
|
+
const NARROWED = new Set(['within', 'whole']);
|
|
7
|
+
function answered(md, app, writtenBy, member, input) {
|
|
5
8
|
switch (member) {
|
|
6
9
|
case 'rooms':
|
|
7
10
|
return md.rooms();
|
|
8
|
-
case 'slots':
|
|
9
|
-
return md.slots();
|
|
10
11
|
case 'query':
|
|
11
12
|
return md.query(input[0]);
|
|
12
13
|
case 'search':
|
|
13
14
|
return md.search(input[0]);
|
|
14
15
|
case 'types':
|
|
15
16
|
return md.types(input[0]);
|
|
16
|
-
case 'syncStatus':
|
|
17
|
-
return md.syncStatus();
|
|
18
|
-
case 'serviceMode':
|
|
19
|
-
return md.serviceMode();
|
|
20
17
|
case 'save':
|
|
21
18
|
return md.save(input[0], input[1], writtenBy);
|
|
22
|
-
case '
|
|
23
|
-
return md.
|
|
19
|
+
case 'saveParts':
|
|
20
|
+
return md.saveParts(input[0], input[1], writtenBy);
|
|
24
21
|
case 'history':
|
|
25
22
|
return md.history(input[0], input[1], input[2]);
|
|
23
|
+
case 'resolve':
|
|
24
|
+
return md.resolve(input[0], input[1], input[2]);
|
|
25
|
+
case 'binaryFile.read':
|
|
26
|
+
return md.binaryFile.read(input[0], input[1], input[2]);
|
|
27
|
+
case 'binaryFile.link':
|
|
28
|
+
return md.binaryFile.link(input[0], input[1], input[2]);
|
|
29
|
+
case 'binaryFile.show':
|
|
30
|
+
return md.binaryFile.show(input[0], input[1], input[2]);
|
|
31
|
+
case 'binaryFile.attach':
|
|
32
|
+
return md.binaryFile.attach(input[0], input[1]);
|
|
33
|
+
case 'binaryFile.part':
|
|
34
|
+
return md.binaryFile.part(input[0], input[1]);
|
|
26
35
|
case 'call':
|
|
27
36
|
return md.call(input[0], input[1]);
|
|
28
37
|
case 'reached':
|
|
29
38
|
return md.reached(input[0], input[1], input[2]);
|
|
30
39
|
case 'log':
|
|
31
40
|
return md.log();
|
|
32
|
-
case '
|
|
33
|
-
return md.
|
|
34
|
-
case '
|
|
35
|
-
return
|
|
41
|
+
case 'cleanUp':
|
|
42
|
+
return md.cleanUp();
|
|
43
|
+
case 'unsent':
|
|
44
|
+
return md.unsent();
|
|
45
|
+
case 'reset':
|
|
46
|
+
return md.reset();
|
|
36
47
|
case 'persistence':
|
|
37
48
|
return md.persistence();
|
|
49
|
+
case 'retry':
|
|
50
|
+
return md.retry();
|
|
38
51
|
case 'reauthorize':
|
|
39
52
|
return md.reauthorize();
|
|
40
53
|
case 'roomDraft.list':
|
|
@@ -42,13 +55,15 @@ function answered(md, app, writtenBy, member, input, deploymentFacts) {
|
|
|
42
55
|
case 'roomDraft.read':
|
|
43
56
|
return md.roomDraft.read(input[0], input[1]);
|
|
44
57
|
case 'roomDraft.write':
|
|
45
|
-
return md.roomDraft.write(input[0], input[1], input[2], input[3]);
|
|
58
|
+
return md.roomDraft.write(input[0], input[1], input[2], input[3], input[4]);
|
|
46
59
|
case 'roomDraft.discard':
|
|
47
60
|
return md.roomDraft.discard(input[0], input[1], input[2]);
|
|
48
61
|
case 'presentation.read':
|
|
49
62
|
return md.presentation.read(app);
|
|
50
63
|
case 'presentation.write':
|
|
51
64
|
return md.presentation.write(app, input[0]);
|
|
65
|
+
case 'presentation.edit':
|
|
66
|
+
return md.presentation.edit(app, input[0]);
|
|
52
67
|
case 'conversation.list':
|
|
53
68
|
return md.conversation.list();
|
|
54
69
|
case 'conversation.read':
|
|
@@ -56,25 +71,41 @@ function answered(md, app, writtenBy, member, input, deploymentFacts) {
|
|
|
56
71
|
case 'conversation.create':
|
|
57
72
|
return md.conversation.create(input[0]);
|
|
58
73
|
case 'conversation.send':
|
|
59
|
-
return md.conversation.send(input[0]);
|
|
74
|
+
return md.conversation.send(input[0], input[1], input[2]);
|
|
60
75
|
case 'conversation.answer':
|
|
61
76
|
return md.conversation.answer(input[0], input[1]);
|
|
62
77
|
case 'conversation.interrupt':
|
|
63
78
|
return md.conversation.interrupt(input[0]);
|
|
64
79
|
case 'conversation.kill':
|
|
65
80
|
return md.conversation.kill(input[0]);
|
|
66
|
-
case 'conversation.cancel':
|
|
67
|
-
return md.conversation.cancel(input[0], input[1]);
|
|
68
81
|
case 'conversation.delete':
|
|
69
82
|
return md.conversation.delete(input[0]);
|
|
70
83
|
case 'chatDraft.write':
|
|
71
|
-
return md.chatDraft.write(input[0], input[1]);
|
|
84
|
+
return md.chatDraft.write(input[0], input[1], input[2]);
|
|
85
|
+
case 'chatDraft.prepend':
|
|
86
|
+
return md.chatDraft.prepend(input[0], input[1]);
|
|
72
87
|
case 'chatDraft.discard':
|
|
73
88
|
return md.chatDraft.discard(input[0]);
|
|
74
89
|
}
|
|
75
90
|
}
|
|
91
|
+
function attempted(work) {
|
|
92
|
+
try {
|
|
93
|
+
return Promise.resolve(work());
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return Promise.reject(error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function answeredResult(value) {
|
|
100
|
+
return typeof value === 'object' && value !== null && !('pending' in value);
|
|
101
|
+
}
|
|
102
|
+
function answeredMessage(value) {
|
|
103
|
+
if (typeof value !== 'object' || value === null)
|
|
104
|
+
return false;
|
|
105
|
+
return !('result' in value) || answeredResult(value.result);
|
|
106
|
+
}
|
|
76
107
|
export function serveMdRuntime(options) {
|
|
77
|
-
|
|
108
|
+
const deploymentFacts = structuredClone(options.deploymentFacts);
|
|
78
109
|
const closing = new AbortController();
|
|
79
110
|
const close = () => {
|
|
80
111
|
closing.abort();
|
|
@@ -83,86 +114,114 @@ export function serveMdRuntime(options) {
|
|
|
83
114
|
if (options.signal?.aborted === true)
|
|
84
115
|
close();
|
|
85
116
|
const runtime = composeRuntime({ ...options, signal: closing.signal });
|
|
86
|
-
const { md
|
|
117
|
+
const { md } = runtime;
|
|
87
118
|
const attachments = new Map();
|
|
88
119
|
let authorized = true;
|
|
89
|
-
|
|
120
|
+
let opening = null;
|
|
121
|
+
const opened = () => (opening ??= untilAnswered(() => md.loaded(), closing.signal));
|
|
90
122
|
const watchFacts = (deliver) => {
|
|
91
|
-
factsObservers.add(deliver);
|
|
92
123
|
deliver(structuredClone(deploymentFacts));
|
|
93
|
-
return () => {
|
|
94
|
-
factsObservers.delete(deliver);
|
|
95
|
-
};
|
|
124
|
+
return () => { };
|
|
96
125
|
};
|
|
97
|
-
function attach(port, app, release) {
|
|
126
|
+
function attach(port, app, release, reach, code = 'stored') {
|
|
98
127
|
if (!authorized)
|
|
99
128
|
throw new Error(AUTHORIZATION_ENDED);
|
|
100
129
|
const writtenBy = release === undefined ? undefined : { app, release };
|
|
101
|
-
const
|
|
130
|
+
const view = runtime.within(reach ?? null, { target: app, code });
|
|
131
|
+
const observations = new Map();
|
|
132
|
+
const followed = new Set();
|
|
133
|
+
const answeredKeys = new Set();
|
|
134
|
+
let awaited = null;
|
|
102
135
|
let serving = true;
|
|
136
|
+
const answeredQuery = (query) => {
|
|
137
|
+
answeredKeys.add(queryKey(query));
|
|
138
|
+
if (awaited === null || !awaited.keys.every((key) => answeredKeys.has(key)))
|
|
139
|
+
return;
|
|
140
|
+
const { done } = awaited;
|
|
141
|
+
awaited = null;
|
|
142
|
+
done();
|
|
143
|
+
};
|
|
103
144
|
const send = (message) => {
|
|
104
|
-
port.postMessage(
|
|
145
|
+
port.postMessage(message);
|
|
105
146
|
};
|
|
106
147
|
const detach = () => {
|
|
107
148
|
if (!serving)
|
|
108
149
|
return;
|
|
109
150
|
serving = false;
|
|
110
|
-
for (const end of
|
|
151
|
+
for (const end of observations.values())
|
|
152
|
+
end();
|
|
153
|
+
observations.clear();
|
|
154
|
+
for (const end of [...followed])
|
|
111
155
|
end();
|
|
112
|
-
subscriptions.clear();
|
|
113
156
|
attachments.delete(detach);
|
|
114
157
|
};
|
|
158
|
+
const observe = (id, topic, input) => {
|
|
159
|
+
let resolved = false;
|
|
160
|
+
const deliver = (value) => {
|
|
161
|
+
if (!serving)
|
|
162
|
+
return;
|
|
163
|
+
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
164
|
+
resolved = true;
|
|
165
|
+
if (topic === 'query' && answeredMessage(value))
|
|
166
|
+
answeredQuery(input[0]);
|
|
167
|
+
};
|
|
168
|
+
const fail = (error) => {
|
|
169
|
+
if (!serving || resolved)
|
|
170
|
+
return;
|
|
171
|
+
observations.get(id)?.();
|
|
172
|
+
observations.delete(id);
|
|
173
|
+
send({ kind: 'failure', id, ...described(error) });
|
|
174
|
+
};
|
|
175
|
+
observations.set(id, topic === 'deployment-facts'
|
|
176
|
+
? watchFacts(deliver)
|
|
177
|
+
: (NARROWED.has(WIRE.topics[topic]) ? view : runtime).watch(topic, topic === 'presentation' ? [app] : input, deliver, fail));
|
|
178
|
+
};
|
|
179
|
+
const reply = async (id, query, pending) => {
|
|
180
|
+
try {
|
|
181
|
+
const value = await pending;
|
|
182
|
+
if (!serving)
|
|
183
|
+
return;
|
|
184
|
+
send({ kind: 'result', id, value });
|
|
185
|
+
if (query !== undefined && answeredResult(value))
|
|
186
|
+
answeredQuery(query);
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
if (serving)
|
|
190
|
+
send({ kind: 'failure', id, ...described(error) });
|
|
191
|
+
}
|
|
192
|
+
};
|
|
115
193
|
const serve = async (message) => {
|
|
116
194
|
if (message.kind === 'hello')
|
|
117
195
|
return;
|
|
118
196
|
if (message.kind === 'stop') {
|
|
119
|
-
|
|
120
|
-
|
|
197
|
+
observations.get(message.id)?.();
|
|
198
|
+
observations.delete(message.id);
|
|
121
199
|
return;
|
|
122
200
|
}
|
|
123
201
|
try {
|
|
124
|
-
if (message.kind !== 'observe'
|
|
202
|
+
if (message.kind !== 'observe')
|
|
125
203
|
await md.loaded();
|
|
204
|
+
else if (message.topic !== 'room-drafts')
|
|
205
|
+
await opened();
|
|
126
206
|
if (message.kind === 'observe') {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const deliver = (value) => {
|
|
130
|
-
if (!serving)
|
|
131
|
-
return;
|
|
132
|
-
send(resolved ? { kind: 'event', id, value } : { kind: 'result', id, value });
|
|
133
|
-
resolved = true;
|
|
134
|
-
};
|
|
135
|
-
subscriptions.set(id, topic === 'deployment-facts'
|
|
136
|
-
? watchFacts(deliver)
|
|
137
|
-
: watch(topic, topic === 'presentation' ? [app] : message.input, deliver));
|
|
207
|
+
if (serving)
|
|
208
|
+
observe(message.id, message.topic, message.input);
|
|
138
209
|
return;
|
|
139
210
|
}
|
|
140
|
-
const value = await answered(md, app, writtenBy, message.member, message.input, deploymentFacts);
|
|
141
|
-
if (serving)
|
|
142
|
-
send({ kind: 'result', id: message.id, value });
|
|
143
211
|
}
|
|
144
212
|
catch (error) {
|
|
145
|
-
if (serving)
|
|
146
|
-
send({
|
|
147
|
-
|
|
148
|
-
id: message.id,
|
|
149
|
-
message: error instanceof Error ? error.message : String(error),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
213
|
+
if (serving)
|
|
214
|
+
send({ kind: 'failure', id: message.id, ...described(error) });
|
|
215
|
+
return;
|
|
152
216
|
}
|
|
217
|
+
const { id, member, input } = message;
|
|
218
|
+
const pending = attempted(() => answered(NARROWED.has(WIRE.members[member].reach) ? view.md : md, app, writtenBy, member, input));
|
|
219
|
+
return reply(id, member === 'query' ? input[0] : undefined, pending);
|
|
153
220
|
};
|
|
154
221
|
port.addEventListener('message', (event) => {
|
|
155
222
|
if (!serving)
|
|
156
223
|
return;
|
|
157
|
-
const
|
|
158
|
-
if (wire === null)
|
|
159
|
-
return;
|
|
160
|
-
if (!wire.matching) {
|
|
161
|
-
send({ kind: 'refusal', refusal: PROTOCOL_MISMATCH });
|
|
162
|
-
detach();
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
const message = request(wire.message);
|
|
224
|
+
const message = request(event.data);
|
|
166
225
|
if (message === null)
|
|
167
226
|
return;
|
|
168
227
|
void serve(message);
|
|
@@ -170,29 +229,58 @@ export function serveMdRuntime(options) {
|
|
|
170
229
|
port.addEventListener('close', detach);
|
|
171
230
|
port.start();
|
|
172
231
|
attachments.set(detach, send);
|
|
173
|
-
return
|
|
232
|
+
return {
|
|
233
|
+
detach,
|
|
234
|
+
narrow(next) {
|
|
235
|
+
if (serving)
|
|
236
|
+
view.narrow(next);
|
|
237
|
+
},
|
|
238
|
+
answered(queries, done) {
|
|
239
|
+
const keys = queries.map(queryKey);
|
|
240
|
+
if (keys.every((key) => answeredKeys.has(key)))
|
|
241
|
+
done();
|
|
242
|
+
else
|
|
243
|
+
awaited = { keys, done };
|
|
244
|
+
},
|
|
245
|
+
readiness(deliver) {
|
|
246
|
+
if (!serving)
|
|
247
|
+
return () => { };
|
|
248
|
+
const stop = view.watch('readiness', [], (value) => {
|
|
249
|
+
if (serving)
|
|
250
|
+
deliver(value);
|
|
251
|
+
}, () => { });
|
|
252
|
+
const end = () => {
|
|
253
|
+
followed.delete(end);
|
|
254
|
+
stop();
|
|
255
|
+
};
|
|
256
|
+
followed.add(end);
|
|
257
|
+
return end;
|
|
258
|
+
},
|
|
259
|
+
};
|
|
174
260
|
}
|
|
175
261
|
return {
|
|
176
262
|
attach,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
deliver(structuredClone(deploymentFacts));
|
|
263
|
+
seed(entry) {
|
|
264
|
+
runtime.seed(entry);
|
|
265
|
+
},
|
|
266
|
+
persisted(answer) {
|
|
267
|
+
runtime.persisted(answer);
|
|
183
268
|
},
|
|
184
|
-
async endAuthorization() {
|
|
269
|
+
async endAuthorization(holder) {
|
|
185
270
|
authorized = false;
|
|
186
271
|
for (const [detach, send] of [...attachments]) {
|
|
187
272
|
send({ kind: 'ended' });
|
|
188
273
|
detach();
|
|
189
274
|
}
|
|
190
275
|
close();
|
|
191
|
-
await
|
|
192
|
-
|
|
276
|
+
if (!(await options.database.ask({ kind: 'authored.end', holder: holder ?? null }))) {
|
|
277
|
+
await options.shell.dropGeneration();
|
|
278
|
+
}
|
|
193
279
|
},
|
|
194
280
|
stop() {
|
|
195
281
|
return runtime.stop();
|
|
196
282
|
},
|
|
197
283
|
};
|
|
198
284
|
}
|
|
285
|
+
export { entrySeedOf } from './seed.js';
|
|
286
|
+
export { createRecovery, retryDelay, } from './recovery.js';
|
package/dist/identity.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare function changeBatchIdentity(at?: number): string;
|
|
2
2
|
export declare function roomDraftRevision(): string;
|
|
3
|
+
export declare function chatDraftRevision(): string;
|
|
4
|
+
export declare function transferIdentity(): string;
|
|
5
|
+
export declare function binaryLocalId(): string;
|
|
3
6
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAED,wBAAgB,iBAAiB,IAAI,MAAM,
|
|
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,8 +10,20 @@ 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
|
-
|
|
13
|
+
function randomIdentity() {
|
|
14
14
|
const bytes = new Uint8Array(16);
|
|
15
15
|
crypto.getRandomValues(bytes);
|
|
16
16
|
return [...bytes].map((byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
17
17
|
}
|
|
18
|
+
export function roomDraftRevision() {
|
|
19
|
+
return randomIdentity();
|
|
20
|
+
}
|
|
21
|
+
export function chatDraftRevision() {
|
|
22
|
+
return randomIdentity();
|
|
23
|
+
}
|
|
24
|
+
export function transferIdentity() {
|
|
25
|
+
return randomIdentity();
|
|
26
|
+
}
|
|
27
|
+
export function binaryLocalId() {
|
|
28
|
+
return randomIdentity();
|
|
29
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,33 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction,
|
|
2
|
-
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
|
-
export
|
|
4
|
-
export type {
|
|
5
|
-
export type {
|
|
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, TurnContext, TurnOperation, TypedPath, TypedSelection, } from './adapter.js';
|
|
2
|
+
export type { Change, ChangeBatch, Precondition, RoomMove, WrittenBy } from './change.js';
|
|
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 { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
7
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type {
|
|
8
|
-
export type {
|
|
8
|
+
export type { AttachAnswer, BinaryAnswer, BinaryLinkAnswer, CallResult, DownloadAnswer, Failure, HistoryAnswer, Offline, QueueEntry, Resolution, Submission, } from './outcome.js';
|
|
9
|
+
export type { BinaryFileRecord } from './binary.js';
|
|
10
|
+
export type { RuntimeError } from './failure.js';
|
|
11
|
+
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, TextParts, } from './room-draft.js';
|
|
9
12
|
export type { SaveRefusal } from './save.js';
|
|
10
|
-
export type {
|
|
13
|
+
export type { SearchFound, SearchHit, SearchRequest, SearchResult } from './search.js';
|
|
14
|
+
export { departure } from './change.js';
|
|
15
|
+
export { lineEnded, partsAfter, partsChanges } from './room-draft.js';
|
|
16
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
17
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
18
|
+
export { contextFigure } from './context.js';
|
|
19
|
+
export { jobsRunning, openJobs, sessionEnded, type OpenJob, type RunningJob } from './job.js';
|
|
11
20
|
export { changeBatchIdentity } from './identity.js';
|
|
12
|
-
export {
|
|
13
|
-
export
|
|
21
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
22
|
+
export { untilAnswered } from './recovery.js';
|
|
23
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
24
|
+
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
25
|
+
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
|
26
|
+
export type { RuntimeShell, UnsentKind, UnsentWork } from './durability.js';
|
|
27
|
+
export type { CodeAvailability, ConnectionAvailability, ConversationCoverage, Durability, HouseOutcome, Installation, InstallationAmount, InstallationStep, Persistence, Readiness, ReadinessStatus, RoomCoverage, RoomPreparation, Space, TargetCoverage, } from './readiness.js';
|
|
14
28
|
export type { AttentionEntry, SyncStatus } from './status.js';
|
|
15
|
-
export type {
|
|
29
|
+
export type { Direction, DocumentQuery, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, Key, LocalQuery, OrderOptions, Predicate, Related, Select, Value, Where, } from '@agentshouse/mdmodel';
|
|
30
|
+
export type { Awaits, Backlink, CoveredRoom, DocumentResult, GroupResult, GroupTotal, PendingResult, PendingRoom, QueryCoverage, QueryDocument, QueryGroup, QueryResult, QueryRows, } from './query.js';
|
|
16
31
|
export type { MdType, ModelIdentity, ModelSnapshot, ModelState, ModelResult, TypesResult, ValidationReceipt, } from './model.js';
|
|
17
32
|
export type { OperationScopes, ReplicaAdmission, ScopedRefusal } from './adapter.js';
|
|
18
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,YAAY,EACZ,eAAe,EACf,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,UAAU,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,U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Z,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,eAAe,EACf,YAAY,EACZ,eAAe,EACf,KAAK,EACL,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EACV,SAAS,EACT,aAAa,EACb,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,GAAG,EACH,UAAU,EACV,YAAY,EACZ,SAAS,EACT,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,MAAM,EACN,QAAQ,EACR,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
+
export { heldFacts } from './conversation-row.js';
|
|
2
|
+
export { departure } from './change.js';
|
|
3
|
+
export { lineEnded, partsAfter, partsChanges } from './room-draft.js';
|
|
4
|
+
export { cutName, nameFrom, transliterated } from './name.js';
|
|
5
|
+
export { HISTORY_CONVERSATIONS, SESSION_STARTED } from './conversation.js';
|
|
6
|
+
export { contextFigure } from './context.js';
|
|
7
|
+
export { jobsRunning, openJobs, sessionEnded } from './job.js';
|
|
1
8
|
export { changeBatchIdentity } from './identity.js';
|
|
2
|
-
export {
|
|
9
|
+
export { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
10
|
+
export { untilAnswered } from './recovery.js';
|
|
11
|
+
export { entriesIn, patching, sortedKeys } from './shared.js';
|
|
12
|
+
export { attempts, identities, intentOf, } from './attempt.js';
|
|
13
|
+
export { expectedList, expecting } from './expectation.js';
|
package/dist/job.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
type Job = {
|
|
2
|
+
readonly label: string;
|
|
3
|
+
readonly kind: 'started' | 'scheduled' | 'ended';
|
|
4
|
+
readonly state: string;
|
|
5
|
+
readonly next: string | null;
|
|
6
|
+
};
|
|
7
|
+
export type RunningJob = {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly running_since: string;
|
|
10
|
+
};
|
|
11
|
+
export type JobMarker = {
|
|
12
|
+
readonly said: string;
|
|
13
|
+
readonly at: string;
|
|
14
|
+
};
|
|
15
|
+
export type OpenJob<At = string | null> = {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly started: At;
|
|
18
|
+
};
|
|
19
|
+
export declare function jobOf(said: string): Job;
|
|
20
|
+
export declare function closeLast(open: {
|
|
21
|
+
readonly key: string;
|
|
22
|
+
}[], key: string): void;
|
|
23
|
+
export declare function markerMoved<Kept extends {
|
|
24
|
+
readonly key: string;
|
|
25
|
+
}>(open: Kept[], said: string, opened: (job: Job, key: string) => Kept | null): void;
|
|
26
|
+
export declare function openJobs<At>(markers: readonly {
|
|
27
|
+
readonly said: string;
|
|
28
|
+
readonly at: At;
|
|
29
|
+
}[]): readonly OpenJob<At>[];
|
|
30
|
+
export declare function jobsRunning(jobs: readonly RunningJob[], now: number): string[];
|
|
31
|
+
export declare function sessionEnded(jobs: readonly RunningJob[], now: number): string;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=job.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../src/job.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG;IACT,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CA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AAE,CAQxB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAI7E"}
|
package/dist/job.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const NEXT_RUN = 'next run ';
|
|
2
|
+
const MINUTE = 60_000;
|
|
3
|
+
const ENDED = 'Session ended.';
|
|
4
|
+
export function jobOf(said) {
|
|
5
|
+
const at = said.lastIndexOf(': ');
|
|
6
|
+
const label = at === -1 ? said : said.slice(0, at);
|
|
7
|
+
const state = at === -1 ? '' : said.slice(at + 2);
|
|
8
|
+
if (state === 'running')
|
|
9
|
+
return { label, kind: 'started', state, next: null };
|
|
10
|
+
if (state === 'scheduled')
|
|
11
|
+
return { label, kind: 'scheduled', state, next: null };
|
|
12
|
+
return state.startsWith(NEXT_RUN)
|
|
13
|
+
? { label, kind: 'scheduled', state, next: state.slice(NEXT_RUN.length) }
|
|
14
|
+
: { label, kind: 'ended', state, next: null };
|
|
15
|
+
}
|
|
16
|
+
export function closeLast(open, key) {
|
|
17
|
+
const at = open.map((one) => one.key).lastIndexOf(key);
|
|
18
|
+
if (at !== -1)
|
|
19
|
+
open.splice(at, 1);
|
|
20
|
+
}
|
|
21
|
+
export function markerMoved(open, said, opened) {
|
|
22
|
+
const job = jobOf(said);
|
|
23
|
+
const started = `job\u0000${job.label}`;
|
|
24
|
+
const schedule = `schedule\u0000${job.label}`;
|
|
25
|
+
if (job.kind === 'ended')
|
|
26
|
+
closeLast(open, started);
|
|
27
|
+
if (job.kind !== 'started')
|
|
28
|
+
closeLast(open, schedule);
|
|
29
|
+
if (job.kind === 'ended')
|
|
30
|
+
return;
|
|
31
|
+
const kept = opened(job, job.kind === 'started' ? started : schedule);
|
|
32
|
+
if (kept !== null)
|
|
33
|
+
open.push(kept);
|
|
34
|
+
}
|
|
35
|
+
export function openJobs(markers) {
|
|
36
|
+
const open = [];
|
|
37
|
+
for (const { said, at } of markers) {
|
|
38
|
+
markerMoved(open, said, (job, key) => job.kind === 'started' ? { key, name: job.label, started: at } : null);
|
|
39
|
+
}
|
|
40
|
+
return open.map(({ name, started }) => ({ name, started }));
|
|
41
|
+
}
|
|
42
|
+
export function jobsRunning(jobs, now) {
|
|
43
|
+
return jobs.map((job) => {
|
|
44
|
+
const since = Date.parse(job.running_since);
|
|
45
|
+
const ran = Number.isNaN(since) ? 0 : Math.floor((now - since) / MINUTE);
|
|
46
|
+
return ran >= 1 ? `${job.name} (${ran} min)` : job.name;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function sessionEnded(jobs, now) {
|
|
50
|
+
if (jobs.length === 0)
|
|
51
|
+
return ENDED;
|
|
52
|
+
const counted = jobs.length === 1 ? '1 background job' : `${jobs.length} background jobs`;
|
|
53
|
+
return `${ENDED} ${counted} stopped: ${jobsRunning(jobs, now).join(', ')}`;
|
|
54
|
+
}
|
package/dist/live.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ChangeSet } from './change-set.js';
|
|
2
|
+
import { type KeyedResult, type QueryMessage } from './observation.js';
|
|
3
|
+
import type { PendingResult, Plan, QueryCoverage } from './query.js';
|
|
4
|
+
import type { Fail } from './reach.js';
|
|
5
|
+
import type { QueryRoom } from './tables.js';
|
|
6
|
+
export type Cover = {
|
|
7
|
+
coverage: QueryCoverage;
|
|
8
|
+
rooms: readonly QueryRoom[];
|
|
9
|
+
} | PendingResult;
|
|
10
|
+
export type Ran = KeyedResult & {
|
|
11
|
+
readonly current: () => boolean;
|
|
12
|
+
};
|
|
13
|
+
export type Run = (plan: Plan, cover: () => Promise<Cover>) => Promise<Ran>;
|
|
14
|
+
type Listener = (message: QueryMessage) => void;
|
|
15
|
+
export type LiveQueries<H> = {
|
|
16
|
+
touched(set: ChangeSet): void;
|
|
17
|
+
recover(): void;
|
|
18
|
+
watch(plan: Plan, identity: string, cover: (held: H) => Cover, deliver: Listener, failed: Fail): () => void;
|
|
19
|
+
close(): void;
|
|
20
|
+
};
|
|
21
|
+
export declare function createLiveQueries<H>(run: Run, holding: () => Promise<H>): LiveQueries<H>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=live.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../src/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,GAAG,aAAa,CAAC;AAE7F,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE5E,KAAK,QAAQ,GAAG,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;AAchD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,OAAO,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,OAAO,IAAI,IAAI,CAAC;IAChB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