@agentshouse/mdruntime 0.1.0-c0136de3edfbe → 0.1.0-c014edb0e9d9b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/dist/acceptance.d.ts +0 -3
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +74 -145
- package/dist/act-lanes.d.ts +33 -0
- package/dist/act-lanes.d.ts.map +1 -0
- package/dist/act-lanes.js +177 -0
- package/dist/actions.d.ts +7 -2
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +44 -31
- package/dist/adapter.d.ts +30 -44
- package/dist/adapter.d.ts.map +1 -1
- package/dist/bootstrap.d.ts +1 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +6 -18
- package/dist/change-set.d.ts +4 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +6 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +4 -2
- package/dist/chat-types.d.ts +2 -0
- package/dist/chat-types.d.ts.map +1 -1
- package/dist/chat-types.js +11 -0
- package/dist/client.d.ts +9 -12
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -14
- package/dist/collection.d.ts +22 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +12 -2
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +15 -21
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +30 -17
- package/dist/conversation-live.d.ts +138 -0
- package/dist/conversation-live.d.ts.map +1 -0
- package/dist/conversation-live.js +249 -0
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +7 -1
- package/dist/conversation.d.ts +44 -44
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +904 -1024
- package/dist/declaration.d.ts +10 -0
- package/dist/declaration.d.ts.map +1 -0
- package/dist/declaration.js +24 -0
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +18 -40
- package/dist/durability.d.ts +12 -0
- package/dist/durability.d.ts.map +1 -1
- package/dist/expectation.d.ts +4 -2
- package/dist/expectation.d.ts.map +1 -1
- package/dist/expectation.js +33 -11
- package/dist/failure.d.ts +3 -0
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +6 -0
- package/dist/figures.d.ts +1 -0
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +2 -2
- package/dist/holdings.d.ts +29 -0
- package/dist/holdings.d.ts.map +1 -0
- package/dist/holdings.js +95 -0
- package/dist/host.d.ts +17 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +38 -8
- package/dist/index.d.ts +13 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/install.d.ts +1 -3
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +49 -70
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +42 -30
- package/dist/listing.d.ts +6 -11
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +25 -61
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +3 -3
- package/dist/locks.d.ts +2 -4
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +10 -38
- package/dist/lost.d.ts.map +1 -1
- package/dist/lost.js +10 -21
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +4 -4
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +38 -20
- package/dist/messages.d.ts +1 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +14 -32
- package/dist/model.d.ts +0 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +0 -5
- package/dist/models.d.ts +4 -8
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +97 -134
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +12 -17
- package/dist/opened.d.ts +1 -1
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +5 -5
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +8 -5
- package/dist/outcome.d.ts +6 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +15 -0
- package/dist/overlay.d.ts +2 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +32 -21
- package/dist/page-metadata.d.ts +8 -0
- package/dist/page-metadata.d.ts.map +1 -0
- package/dist/page-metadata.js +19 -0
- package/dist/parts.d.ts +3 -51
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +14 -111
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +22 -0
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +22 -15
- package/dist/presence.d.ts +52 -0
- package/dist/presence.d.ts.map +1 -0
- package/dist/presence.js +220 -0
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +5 -7
- package/dist/query.d.ts +0 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +2 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +5 -1
- package/dist/queue.d.ts +40 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +455 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +28 -9
- package/dist/react.d.ts +15 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +15 -1
- package/dist/readiness.d.ts +0 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +4 -1
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +47 -5
- package/dist/refresh.js +2 -2
- package/dist/refusal.d.ts.map +1 -1
- package/dist/refusal.js +5 -4
- package/dist/replica.d.ts +5 -10
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +15 -16
- package/dist/retried.d.ts +30 -0
- package/dist/retried.d.ts.map +1 -0
- package/dist/retried.js +72 -0
- package/dist/room-draft.d.ts +4 -6
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +36 -52
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +17 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -4
- package/dist/runtime.d.ts +11 -17
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +41 -86
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +232 -112
- package/dist/saves.d.ts +2 -40
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +107 -698
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -3
- package/dist/shared.d.ts +1 -6
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +13 -95
- package/dist/shown.d.ts +4 -3
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +29 -33
- package/dist/socket/lanes.d.ts +2 -1
- package/dist/socket/lanes.d.ts.map +1 -1
- package/dist/socket/lanes.js +5 -2
- package/dist/socket/session.d.ts +0 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket.d.ts +2 -4
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +4 -8
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +5 -4
- package/dist/store/records.d.ts +4 -4
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +33 -11
- package/dist/store/space.d.ts +1 -1
- package/dist/store/space.d.ts.map +1 -1
- package/dist/store/space.js +0 -2
- package/dist/store/watchers.js +1 -2
- package/dist/store.d.ts +11 -6
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +38 -13
- package/dist/stored.d.ts +1 -1
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +22 -10
- package/dist/surface.d.ts +4 -2
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +20 -14
- package/dist/sync.d.ts +0 -1
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +91 -82
- package/dist/tables.d.ts +13 -8
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +25 -12
- package/dist/tallies.js +5 -5
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +2 -2
- package/dist/wire.d.ts +41 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +13 -3
- package/package.json +3 -2
- package/dist/attempt.d.ts +0 -16
- package/dist/attempt.d.ts.map +0 -1
- package/dist/attempt.js +0 -70
- package/dist/job.d.ts +0 -33
- package/dist/job.d.ts.map +0 -1
- package/dist/job.js +0 -54
- package/dist/socket/rooms.d.ts +0 -43
- package/dist/socket/rooms.d.ts.map +0 -1
- package/dist/socket/rooms.js +0 -90
- package/dist/store/fences.d.ts +0 -16
- package/dist/store/fences.d.ts.map +0 -1
- package/dist/store/fences.js +0 -26
package/dist/change.js
CHANGED
|
@@ -22,7 +22,8 @@ export function leaving(batch, locator) {
|
|
|
22
22
|
}
|
|
23
23
|
export function landing(changes, index, path) {
|
|
24
24
|
let at = path;
|
|
25
|
-
for (
|
|
25
|
+
for (let next = index + 1; next < changes.length; next += 1) {
|
|
26
|
+
const change = changes[next];
|
|
26
27
|
if (change.path !== at)
|
|
27
28
|
continue;
|
|
28
29
|
if (change.kind === 'remove')
|
|
@@ -34,7 +35,8 @@ export function landing(changes, index, path) {
|
|
|
34
35
|
}
|
|
35
36
|
export function departure(changes, index) {
|
|
36
37
|
let at = changes[index].path;
|
|
37
|
-
for (
|
|
38
|
+
for (let earlier = index - 1; earlier >= 0; earlier -= 1) {
|
|
39
|
+
const change = changes[earlier];
|
|
38
40
|
if (change.kind === 'move' && change.to === at)
|
|
39
41
|
at = change.path;
|
|
40
42
|
}
|
package/dist/chat-types.d.ts
CHANGED
package/dist/chat-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-types.d.ts","sourceRoot":"","sources":["../src/chat-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"chat-types.d.ts","sourceRoot":"","sources":["../src/chat-types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAMhD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEpD;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKhD"}
|
package/dist/chat-types.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
export const CHAT_TYPE = 'chat';
|
|
2
2
|
export const CHAT_MESSAGE_TYPE = 'chat-message';
|
|
3
|
+
const KEPT_LINE = /^\[([^\]\n]+)\]\(\1\)$/u;
|
|
4
|
+
const TOO_BIG_LINE = /^\[too big to keep: [^\n]*\]$/u;
|
|
5
|
+
export function keptFile(line) {
|
|
6
|
+
return KEPT_LINE.exec(line)?.[1] ?? null;
|
|
7
|
+
}
|
|
8
|
+
export function keptLines(body) {
|
|
9
|
+
const trimmed = body.replace(/\n+$/u, '');
|
|
10
|
+
const at = trimmed.lastIndexOf('\n\n');
|
|
11
|
+
const lines = (at === -1 ? trimmed : trimmed.slice(at + 2)).split('\n');
|
|
12
|
+
return lines.every((line) => keptFile(line) !== null || TOO_BIG_LINE.test(line)) ? lines : [];
|
|
13
|
+
}
|
package/dist/client.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ import type { RoomSchemas } from './surface.js';
|
|
|
6
6
|
import type { SavedParts, SavedRoomDraft, SaveResult } from './saves.js';
|
|
7
7
|
import type { Member, ServiceMode } from './adapter.js';
|
|
8
8
|
import type { UnsentWork } from './durability.js';
|
|
9
|
-
import type { ChatDraft, ConversationAgent,
|
|
9
|
+
import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationSurface, ConversationView } from './conversation.js';
|
|
10
10
|
import { type Observation } from './observation.js';
|
|
11
|
-
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer,
|
|
11
|
+
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, QueueEntry, Resolution } from './outcome.js';
|
|
12
12
|
import type { FiguresResult } from './figures.js';
|
|
13
|
+
import type { Holdings } from './holdings.js';
|
|
13
14
|
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
14
15
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
15
16
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
@@ -17,7 +18,9 @@ import type { Readiness } from './readiness.js';
|
|
|
17
18
|
import type { ObservedRead } from './reads.js';
|
|
18
19
|
import type { SyncStatus } from './status.js';
|
|
19
20
|
import { type RuntimePort } from './wire.js';
|
|
21
|
+
export type BuildFile = (name: string) => Promise<Blob | null>;
|
|
20
22
|
export type MdRuntimeClient = {
|
|
23
|
+
buildFile(name: string): Promise<Blob | null>;
|
|
21
24
|
rooms(): Promise<readonly AppRoom[]>;
|
|
22
25
|
query: {
|
|
23
26
|
(query: DocumentQuery): Promise<DocumentResult | PendingResult>;
|
|
@@ -38,15 +41,8 @@ export type MdRuntimeClient = {
|
|
|
38
41
|
write(value: unknown): Promise<void>;
|
|
39
42
|
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
40
43
|
};
|
|
41
|
-
conversation: {
|
|
42
|
-
|
|
43
|
-
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
44
|
-
create(input: unknown): Promise<CallResult>;
|
|
45
|
-
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
46
|
-
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
47
|
-
interrupt(conversation: string): Promise<CallResult>;
|
|
48
|
-
kill(conversation: string): Promise<CallResult>;
|
|
49
|
-
delete(conversation: string): Promise<CallResult>;
|
|
44
|
+
conversation: ConversationSurface & {
|
|
45
|
+
pageMetadata(app: string, address: string): Promise<string>;
|
|
50
46
|
};
|
|
51
47
|
chatDraft: {
|
|
52
48
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
@@ -88,12 +84,13 @@ export type MdRuntimeClient = {
|
|
|
88
84
|
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
89
85
|
(topic: 'agents'): Promise<Observation<readonly ConversationAgent[]>>;
|
|
90
86
|
(topic: 'figures'): Promise<Observation<FiguresResult>>;
|
|
87
|
+
(topic: 'holdings'): Promise<Observation<Holdings>>;
|
|
91
88
|
(topic: 'read', name: string, input: unknown): Promise<Observation<ObservedRead>>;
|
|
92
89
|
};
|
|
93
90
|
reauthorize(): Promise<void>;
|
|
94
91
|
settled(): Promise<void>;
|
|
95
92
|
};
|
|
96
|
-
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
93
|
+
export declare function connectMdRuntime(port: RuntimePort, buildFile?: BuildFile): MdRuntimeClient;
|
|
97
94
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
98
95
|
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
99
96
|
export { roomDraftRevision } from './identity.js';
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,O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e,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { shownBy } from './media.js';
|
|
2
|
+
import { pageMetadataBlock } from './page-metadata.js';
|
|
2
3
|
import { observed } from './observation.js';
|
|
3
4
|
import { runtimeError } from './failure.js';
|
|
4
|
-
import {
|
|
5
|
+
import { AUTHORIZATION_ENDED, PORT_CLOSED, wireAnswer, } from './wire.js';
|
|
5
6
|
// React renders an arrived value in a later task and opens what that render observes as it commits, so this many frames opening nothing mean the page drew what it observes.
|
|
6
7
|
const SETTLED_FRAMES = 2;
|
|
7
8
|
// A browser reads a download's address only after the click that hands it returns, so a copy's address is released a minute later.
|
|
@@ -21,9 +22,10 @@ function handed(url, name) {
|
|
|
21
22
|
anchor.click();
|
|
22
23
|
}
|
|
23
24
|
function refused(refusal) {
|
|
24
|
-
return runtimeError(refusal.code
|
|
25
|
+
return runtimeError(refusal.code);
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
const UNBUILT = () => Promise.resolve(null);
|
|
28
|
+
export function connectMdRuntime(port, buildFile = UNBUILT) {
|
|
27
29
|
let sequence = 0;
|
|
28
30
|
let refusal = null;
|
|
29
31
|
let ended = null;
|
|
@@ -35,13 +37,13 @@ export function connectMdRuntime(port) {
|
|
|
35
37
|
const send = (message) => {
|
|
36
38
|
port.postMessage(message);
|
|
37
39
|
};
|
|
38
|
-
function begin(id, topic, first) {
|
|
40
|
+
function begin(id, topic, input, first) {
|
|
39
41
|
const handle = observed(first, () => {
|
|
40
42
|
observations.delete(id);
|
|
41
43
|
if (refusal === null)
|
|
42
44
|
send({ kind: 'stop', id });
|
|
43
45
|
}, topic === 'query');
|
|
44
|
-
observations.set(id, { topic, handle });
|
|
46
|
+
observations.set(id, { topic, input, handle });
|
|
45
47
|
return handle.observation;
|
|
46
48
|
}
|
|
47
49
|
function refuse(reported) {
|
|
@@ -53,7 +55,7 @@ export function connectMdRuntime(port) {
|
|
|
53
55
|
const failure = refused(reported);
|
|
54
56
|
for (const [id, waiting] of opening) {
|
|
55
57
|
if (waiting.topic === 'connection-refusal')
|
|
56
|
-
waiting.settle(begin(id, waiting.topic, reported));
|
|
58
|
+
waiting.settle(begin(id, waiting.topic, waiting.input, reported));
|
|
57
59
|
else
|
|
58
60
|
waiting.fail(failure);
|
|
59
61
|
}
|
|
@@ -79,7 +81,7 @@ export function connectMdRuntime(port) {
|
|
|
79
81
|
drawing?.();
|
|
80
82
|
}
|
|
81
83
|
port.addEventListener('message', (event) => {
|
|
82
|
-
const message =
|
|
84
|
+
const message = wireAnswer(event.data);
|
|
83
85
|
if (message === null)
|
|
84
86
|
return;
|
|
85
87
|
if (message.kind === 'refusal') {
|
|
@@ -105,7 +107,7 @@ export function connectMdRuntime(port) {
|
|
|
105
107
|
waiting.fail(runtimeError(message.code, message.message, message.retryable));
|
|
106
108
|
}
|
|
107
109
|
else
|
|
108
|
-
waiting.settle(begin(message.id, waiting.topic, message.value));
|
|
110
|
+
waiting.settle(begin(message.id, waiting.topic, waiting.input, message.value));
|
|
109
111
|
drawing?.();
|
|
110
112
|
return;
|
|
111
113
|
}
|
|
@@ -141,11 +143,11 @@ export function connectMdRuntime(port) {
|
|
|
141
143
|
const id = (sequence += 1);
|
|
142
144
|
if (refusal !== null) {
|
|
143
145
|
return topic === 'connection-refusal'
|
|
144
|
-
? Promise.resolve(begin(id, topic, refusal))
|
|
146
|
+
? Promise.resolve(begin(id, topic, input, refusal))
|
|
145
147
|
: Promise.reject(refused(refusal));
|
|
146
148
|
}
|
|
147
149
|
return new Promise((settle, fail) => {
|
|
148
|
-
opening.set(id, { topic, settle, fail });
|
|
150
|
+
opening.set(id, { topic, input, settle, fail });
|
|
149
151
|
send({ kind: 'observe', id, topic, input });
|
|
150
152
|
drawing?.();
|
|
151
153
|
});
|
|
@@ -232,6 +234,7 @@ export function connectMdRuntime(port) {
|
|
|
232
234
|
}
|
|
233
235
|
const show = (room, path, revision) => ask('binaryFile.show', [room, path, revision]).then((shown) => streamed(shown));
|
|
234
236
|
return shownBy(show, {
|
|
237
|
+
buildFile,
|
|
235
238
|
rooms: () => ask('rooms', []),
|
|
236
239
|
query: ((query) => ask('query', [query])),
|
|
237
240
|
search: (request) => ask('search', [request]),
|
|
@@ -254,10 +257,22 @@ export function connectMdRuntime(port) {
|
|
|
254
257
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
255
258
|
create: (input) => ask('conversation.create', [input]),
|
|
256
259
|
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
257
|
-
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
258
|
-
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
259
|
-
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
260
|
-
delete: (conversation) => ask('conversation.delete', [conversation]),
|
|
260
|
+
answer: (conversation, answer, operation) => ask('conversation.answer', [conversation, answer, operation]),
|
|
261
|
+
interrupt: (conversation, operation) => ask('conversation.interrupt', [conversation, operation]),
|
|
262
|
+
kill: (conversation, operation) => ask('conversation.kill', [conversation, operation]),
|
|
263
|
+
delete: (conversation, operation) => ask('conversation.delete', [conversation, operation]),
|
|
264
|
+
takeOut: (conversation, message, operation) => ask('conversation.takeOut', [conversation, message, operation]),
|
|
265
|
+
decide: (request, decision, operation) => ask('conversation.decide', [request, decision, operation]),
|
|
266
|
+
rename: (conversation, name, operation) => ask('conversation.rename', [conversation, name, operation]),
|
|
267
|
+
option: (conversation, option, value, operation) => ask('conversation.option', [conversation, option, value, operation]),
|
|
268
|
+
retry: (conversation, message, operation) => ask('conversation.retry', [conversation, message, operation]),
|
|
269
|
+
pins: () => ask('conversation.pins', []),
|
|
270
|
+
pin: (figures) => ask('conversation.pin', [figures]),
|
|
271
|
+
openedTurns: () => ask('conversation.openedTurns', []),
|
|
272
|
+
openTurn: (conversation, turn) => ask('conversation.openTurn', [conversation, turn]),
|
|
273
|
+
pageMetadata: async (app, address) => pageMetadataBlock(app, address, [...observations]
|
|
274
|
+
.sort(([left], [right]) => left - right)
|
|
275
|
+
.flatMap(([, { topic, input }]) => (topic === 'query' ? [input[0]] : []))),
|
|
261
276
|
},
|
|
262
277
|
chatDraft: {
|
|
263
278
|
write: (conversation, draft, revision) => ask('chatDraft.write', [conversation, draft, revision]),
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Document, type TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
-
import type { ModelState } from './model.js';
|
|
1
|
+
import { type DefinitionOf, type Document, type TypedPath } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { ModelState, TypesResult } from './model.js';
|
|
3
|
+
import type { AppTypedSelection } from './listing.js';
|
|
3
4
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
5
|
export declare const MD_MODEL: MdModelIdentity;
|
|
5
6
|
export type Collection = {
|
|
@@ -20,10 +21,27 @@ export type Composed = {
|
|
|
20
21
|
readonly fingerprint: string;
|
|
21
22
|
};
|
|
22
23
|
export declare function composedOf(composition: Composition): Composed;
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
type Selecting<M> = {
|
|
25
|
+
readonly model: M;
|
|
26
|
+
readonly selection: {
|
|
27
|
+
readonly roots: readonly string[];
|
|
28
|
+
readonly model: M;
|
|
29
|
+
} | null;
|
|
30
|
+
};
|
|
31
|
+
export declare function selected(composition: {
|
|
32
|
+
readonly selection: {
|
|
33
|
+
readonly roots: readonly string[];
|
|
34
|
+
} | null;
|
|
35
|
+
}, path: string): boolean;
|
|
36
|
+
export declare function governing<M>(composition: Selecting<M>, path: string): M;
|
|
37
|
+
export declare function definitionsAt(composition: Composition, path: string): DefinitionOf;
|
|
38
|
+
export declare function definitionsIn(room: {
|
|
39
|
+
readonly model: TypesResult;
|
|
40
|
+
readonly typedSelection: AppTypedSelection | null;
|
|
41
|
+
}, path: string, typedPaths: readonly TypedPath[]): DefinitionOf;
|
|
25
42
|
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
26
43
|
export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
|
|
27
44
|
export declare function validRoot(root: unknown): root is string;
|
|
28
45
|
export declare function available(composition: Composition): boolean;
|
|
46
|
+
export {};
|
|
29
47
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,SAAS,EAEf,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAEhG,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,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AgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,UAAU,CAcZ;AAED,wBAAiB,WAAW,CAC1B,UAAU,EAAE,UAAU,GACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAQhE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEvD;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAE3D"}
|
package/dist/collection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
1
|
+
import { definitionAt, parse, VERSION, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
3
|
import { hashed } from './observation.js';
|
|
4
4
|
import { sortedKeys } from './shared.js';
|
|
@@ -33,6 +33,16 @@ export function governing(composition, path) {
|
|
|
33
33
|
? composition.selection.model
|
|
34
34
|
: composition.model;
|
|
35
35
|
}
|
|
36
|
+
function definitionsUnder(composition, path, typedPaths, typesOf) {
|
|
37
|
+
const types = typesOf(governing(composition, path));
|
|
38
|
+
return types === null ? () => undefined : definitionAt({ types }, path, typedPaths);
|
|
39
|
+
}
|
|
40
|
+
export function definitionsAt(composition, path) {
|
|
41
|
+
return definitionsUnder(composition, path, composition.typedPaths, (model) => model.status === 'unavailable' ? null : model.types);
|
|
42
|
+
}
|
|
43
|
+
export function definitionsIn(room, path, typedPaths) {
|
|
44
|
+
return definitionsUnder({ model: room.model, selection: room.typedSelection }, path, typedPaths, ({ types }) => types === null ? null : Object.fromEntries(types.map((type) => [type.name, type])));
|
|
45
|
+
}
|
|
36
46
|
export function collectionOf(text, composition) {
|
|
37
47
|
const parsed = new Map();
|
|
38
48
|
return {
|
|
@@ -44,7 +54,7 @@ export function collectionOf(text, composition) {
|
|
|
44
54
|
const content = text[path];
|
|
45
55
|
if (content === undefined)
|
|
46
56
|
return undefined;
|
|
47
|
-
const read = parse(content, path);
|
|
57
|
+
const read = parse(content, path, definitionsAt(composition, path));
|
|
48
58
|
parsed.set(path, read.ok ? read.document : null);
|
|
49
59
|
return read.ok ? read.document : undefined;
|
|
50
60
|
},
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,GAAG,EAOJ,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,IAAI,EAAuC,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,KAAK,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAI7B,eAAO,MAAM,OAAO,UAAW,MAAM,KAAG,MACkC,CAAC;AAa3E,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAM5D;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,GAAG,EAOJ,MAAM,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,IAAI,EAAuC,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,KAAK,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;AAI7B,eAAO,MAAM,OAAO,UAAW,MAAM,KAAG,MACkC,CAAC;AAa3E,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAM5D;AA2cD,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA6ZjE,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}
|
package/dist/compile.js
CHANGED
|
@@ -313,8 +313,8 @@ function sectionsOf(sections, names) {
|
|
|
313
313
|
function documentOf(shape, room, row, linked) {
|
|
314
314
|
const path = row.path;
|
|
315
315
|
const type = row.type;
|
|
316
|
-
const fileId = row.file_id
|
|
317
|
-
const revision = row.revision
|
|
316
|
+
const fileId = row.file_id;
|
|
317
|
+
const revision = row.revision;
|
|
318
318
|
if (type === null) {
|
|
319
319
|
const binary = row.binary === null ? null : JSON.parse(row.binary);
|
|
320
320
|
const content = row.content ?? null;
|
|
@@ -333,7 +333,7 @@ function documentOf(shape, room, row, linked) {
|
|
|
333
333
|
...heldFacts(shape, row),
|
|
334
334
|
};
|
|
335
335
|
}
|
|
336
|
-
const read =
|
|
336
|
+
const read = shape.sections !== null || shape.preamble ? parse(row.content, path) : null;
|
|
337
337
|
const body = read?.ok === true ? read.document : null;
|
|
338
338
|
const fields = JSON.parse(row.fields ?? '{}');
|
|
339
339
|
return {
|
|
@@ -365,7 +365,7 @@ function changeOf(row) {
|
|
|
365
365
|
function heldFacts(shape, row) {
|
|
366
366
|
return {
|
|
367
367
|
...(shape.size ? { size: row.bytes === null ? null : Number(row.bytes) } : {}),
|
|
368
|
-
...(shape.created ? { created: row.created
|
|
368
|
+
...(shape.created ? { created: row.created } : {}),
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
371
|
function backlinksOf(connection, bound, rows) {
|
|
@@ -377,8 +377,8 @@ function backlinksOf(connection, bound, rows) {
|
|
|
377
377
|
held.push(row.path);
|
|
378
378
|
byKey.set(key, held);
|
|
379
379
|
}
|
|
380
|
+
const reach = reached(bound, 's');
|
|
380
381
|
for (const [key, targets] of byKey) {
|
|
381
|
-
const reach = reached(bound, 's');
|
|
382
382
|
const room = bound.rooms.find((one) => one.key === key).locator;
|
|
383
383
|
const found = connection.rows(`SELECT target, path, type, field FROM (SELECT l.target, s.path, s.type, l.field, ROW_NUMBER() OVER (PARTITION BY l.target ORDER BY s.path, l.field) AS rank FROM (SELECT DISTINCT doc, target, field FROM replica_links WHERE key = ? AND kind = 'field' AND target IN (SELECT value FROM json_each(?))) l JOIN replica_entries s ON s.id = l.doc AND ${VISIBLE('s')} WHERE ${reach.sql}) WHERE rank <= ? ORDER BY target, path, field`, [key, JSON.stringify(targets), ...reach.bind, MAXIMUM_WINDOW]);
|
|
384
384
|
for (const row of found) {
|
|
@@ -395,22 +395,19 @@ function documents(connection, bound, plan, shape, budget) {
|
|
|
395
395
|
const filter = filtered(bound, plan);
|
|
396
396
|
const cursor = plan.after?.values ?? null;
|
|
397
397
|
const room = located('d');
|
|
398
|
-
const
|
|
398
|
+
const after = cursor === null
|
|
399
399
|
? null
|
|
400
400
|
: (() => {
|
|
401
401
|
const key = cursor[shape.orderBy.length];
|
|
402
|
-
return any([
|
|
402
|
+
return sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), any([
|
|
403
403
|
fragment(`${room.sql} > ?`, [...room.bind, roomOfKey(key)]),
|
|
404
404
|
fragment(`${room.sql} = ? AND d.path > ?`, [
|
|
405
405
|
...room.bind,
|
|
406
406
|
roomOfKey(key),
|
|
407
407
|
pathOfKey(key),
|
|
408
408
|
]),
|
|
409
|
-
]);
|
|
409
|
+
]));
|
|
410
410
|
})();
|
|
411
|
-
const after = cursor === null || tie === null
|
|
412
|
-
? null
|
|
413
|
-
: sql.following(terms.map(({ term }, index) => sql.beyond(bound.collate, term, cursor[index])), tie);
|
|
414
411
|
const selected = joined([
|
|
415
412
|
fragment('SELECT d.id, d.key, d.path, d.type, d.binary, d.revision, d.fields, d.change, d.file_id, d.bytes, d.created'),
|
|
416
413
|
...terms.map(({ term }, index) => joined([
|
|
@@ -645,17 +642,14 @@ function groups(connection, bound, plan, shape) {
|
|
|
645
642
|
{ ordering: GROUP_TIES, kind: fragment("'string'"), value: fragment(`k${index}`) },
|
|
646
643
|
]);
|
|
647
644
|
const cursor = plan.after?.values ?? null;
|
|
648
|
-
const
|
|
649
|
-
? null
|
|
650
|
-
: cursor[shape.orderBy.length].flatMap((value) => [
|
|
651
|
-
value,
|
|
652
|
-
heldKind(value ?? null),
|
|
653
|
-
]);
|
|
654
|
-
const after = cursor === null || tieValues === null
|
|
645
|
+
const after = cursor === null
|
|
655
646
|
? null
|
|
656
|
-
:
|
|
657
|
-
.
|
|
658
|
-
.map((term, index) => sql.beyond(bound.collate, term,
|
|
647
|
+
: (() => {
|
|
648
|
+
const tieValues = cursor[shape.orderBy.length].flatMap((value) => [value, heldKind(value ?? null)]);
|
|
649
|
+
return sql.following(ordered.map((term, index) => sql.beyond(bound.collate, term, cursor[index])), sql.following(ties
|
|
650
|
+
.slice(0, -1)
|
|
651
|
+
.map((term, index) => sql.beyond(bound.collate, term, tieValues[index])), sql.beyond(bound.collate, ties.at(-1), tieValues.at(-1)).beyond));
|
|
652
|
+
})();
|
|
659
653
|
const grouping = joined([fragment(`SELECT ${columns} FROM (`), ranked, fragment(`) GROUP BY ${held}`)], '');
|
|
660
654
|
const windowed = joined([
|
|
661
655
|
fragment('SELECT * FROM ('),
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAI/E,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAWrE,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9D,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAErE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAIF,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAwGzE"}
|
package/dist/connection.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { submitLater
|
|
1
|
+
import { submitLater } from './acceptance.js';
|
|
2
2
|
import { invokeAction, called, readConversationHistory, resendLater } from './actions.js';
|
|
3
3
|
import { builtInModel, roomTypesOf } from './attached-model.js';
|
|
4
|
-
import {
|
|
4
|
+
import { createLiveConversations } from './conversation-live.js';
|
|
5
|
+
import { writeRule } from './declaration.js';
|
|
5
6
|
import { refusedForSpace } from './durability.js';
|
|
7
|
+
import { uncaught } from './failure.js';
|
|
6
8
|
import { createFigures } from './figures.js';
|
|
7
9
|
import { scheduleCurrency, spaceFreed, start } from './lifecycle.js';
|
|
8
10
|
import { createLiveQueries } from './live.js';
|
|
9
11
|
import { createLog } from './log.js';
|
|
10
|
-
import { scoped } from './models.js';
|
|
11
12
|
import { open } from './opening.js';
|
|
12
|
-
import { deliverOwedReadiness, filled } from './preparation.js';
|
|
13
|
+
import { deliverOwedReadiness, filled, prepare } from './preparation.js';
|
|
14
|
+
import { createPresence } from './presence.js';
|
|
13
15
|
import { answeredPlan, figuresCover, roomTallies } from './queries.js';
|
|
14
16
|
import { readAnswers } from './reads.js';
|
|
15
17
|
import { createRecovery } from './recovery.js';
|
|
16
|
-
import {
|
|
18
|
+
import { createRetries } from './retried.js';
|
|
17
19
|
import { publishChangeSet, show } from './shown.js';
|
|
18
20
|
import { createSocket } from './socket.js';
|
|
19
21
|
import { createStore } from './store.js';
|
|
20
22
|
import { composedRuntime } from './surface.js';
|
|
21
|
-
import { advanced, withhold } from './sync.js';
|
|
22
23
|
const ROOM_ATTEMPTS = 16;
|
|
23
24
|
export function composeRuntime(options) {
|
|
24
25
|
const { adapter, shell } = options;
|
|
@@ -26,8 +27,11 @@ export function composeRuntime(options) {
|
|
|
26
27
|
const builtIn = builtInModel(roomTypes);
|
|
27
28
|
const typedPaths = adapter.typedPaths ?? [];
|
|
28
29
|
const journal = createLog();
|
|
29
|
-
const
|
|
30
|
+
const retries = createRetries(shell);
|
|
31
|
+
const socket = createSocket(adapter, journal, retries, options.authorization);
|
|
32
|
+
const presence = createPresence();
|
|
30
33
|
const store = createStore({
|
|
34
|
+
retries,
|
|
31
35
|
database: {
|
|
32
36
|
async ask(request) {
|
|
33
37
|
try {
|
|
@@ -44,11 +48,19 @@ export function composeRuntime(options) {
|
|
|
44
48
|
builtIn,
|
|
45
49
|
typedPaths,
|
|
46
50
|
persistence: shell.persistence,
|
|
51
|
+
lost: presence.lost,
|
|
47
52
|
opening: (local) => open(runtime, local),
|
|
48
53
|
unpublished(error) {
|
|
49
54
|
journal.record(`publication failed ${error instanceof Error ? error.name : 'unknown'}`);
|
|
55
|
+
uncaught(error);
|
|
56
|
+
},
|
|
57
|
+
changed(set) {
|
|
58
|
+
if (set.unindexed.length > 0)
|
|
59
|
+
prepare(runtime, set.unindexed);
|
|
60
|
+
for (const locator of set.due)
|
|
61
|
+
submitLater(runtime, locator);
|
|
62
|
+
return publishChangeSet(runtime, set);
|
|
50
63
|
},
|
|
51
|
-
changed: (set) => publishChangeSet(runtime, set),
|
|
52
64
|
deliverReadiness: (owed) => deliverOwedReadiness(runtime, owed),
|
|
53
65
|
spaceFreed: () => spaceFreed(runtime),
|
|
54
66
|
});
|
|
@@ -56,17 +68,20 @@ export function composeRuntime(options) {
|
|
|
56
68
|
const runtime = {
|
|
57
69
|
store,
|
|
58
70
|
socket,
|
|
71
|
+
presence,
|
|
59
72
|
journal,
|
|
60
73
|
recovery,
|
|
74
|
+
retries,
|
|
61
75
|
shell,
|
|
62
76
|
localSaves: adapter.localSaves === true,
|
|
63
77
|
roomTypes,
|
|
64
78
|
builtIn,
|
|
65
79
|
typedPaths,
|
|
80
|
+
writeRule: (declaration) => writeRule(declaration, adapter.pathRule ?? (() => true), adapter.localSaves === true),
|
|
66
81
|
usableWhenHeld: options.usableWhenHeld ?? [],
|
|
67
82
|
build: options.build ?? '',
|
|
68
|
-
conversations:
|
|
69
|
-
call: (name, input) => invokeAction(runtime, name, input),
|
|
83
|
+
conversations: createLiveConversations({
|
|
84
|
+
call: (name, input, attempt) => invokeAction(runtime, name, input, { attempt }),
|
|
70
85
|
history: (request) => readConversationHistory(runtime, request),
|
|
71
86
|
durably: store.durably,
|
|
72
87
|
local: store.open,
|
|
@@ -82,6 +97,8 @@ export function composeRuntime(options) {
|
|
|
82
97
|
full: store.space.full,
|
|
83
98
|
closed: socket.closed,
|
|
84
99
|
unanswered: () => resendLater(runtime),
|
|
100
|
+
recovery: recovery.scope(),
|
|
101
|
+
retries,
|
|
85
102
|
}),
|
|
86
103
|
liveQueries: createLiveQueries((plan, cover) => answeredPlan(runtime, plan, cover), store.covering),
|
|
87
104
|
figures: createFigures({
|
|
@@ -95,18 +112,14 @@ export function composeRuntime(options) {
|
|
|
95
112
|
unkept: adapter.unkeptReads ?? [],
|
|
96
113
|
leading: adapter.leadingReads ?? [],
|
|
97
114
|
recovery: recovery.scope(),
|
|
98
|
-
|
|
115
|
+
retries,
|
|
116
|
+
call: (name, input, attempt) => called(runtime, name, input, attempt),
|
|
99
117
|
online: socket.reached,
|
|
118
|
+
streaming: socket.isOpen,
|
|
100
119
|
closed: socket.closed,
|
|
101
120
|
full: store.space.full,
|
|
102
121
|
filled: () => filled(runtime),
|
|
103
122
|
}),
|
|
104
|
-
settle: (...held) => settle(runtime, ...held),
|
|
105
|
-
scoped: (...held) => scoped(runtime, ...held),
|
|
106
|
-
submitLater: (locator) => submitLater(runtime, locator),
|
|
107
|
-
unpair: (local) => unpair(runtime, local),
|
|
108
|
-
advanced: (...held) => advanced(runtime, ...held),
|
|
109
|
-
withhold: (...held) => withhold(runtime, ...held),
|
|
110
123
|
};
|
|
111
124
|
start(runtime, options.signal);
|
|
112
125
|
return composedRuntime(runtime);
|