@agentshouse/mdruntime 0.1.0-alpha.4 → 0.1.0-alpha.41
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/AGENTS.md +191 -0
- package/README.md +44 -0
- package/dist/adapter.d.ts +174 -18
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +2 -1
- package/dist/adapter.js.map +1 -1
- package/dist/bootstrap.d.ts +7 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +14 -9
- package/dist/bootstrap.js.map +1 -1
- package/dist/change-set.d.ts +33 -0
- package/dist/change-set.d.ts.map +1 -0
- package/dist/change-set.js +89 -0
- package/dist/change-set.js.map +1 -0
- package/dist/change.d.ts +10 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js.map +1 -1
- package/dist/client.d.ts +74 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +232 -0
- package/dist/client.js.map +1 -0
- package/dist/collection.d.ts +25 -12
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +113 -31
- package/dist/collection.js.map +1 -1
- package/dist/connection.d.ts +84 -27
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1685 -336
- package/dist/connection.js.map +1 -1
- package/dist/conversation.d.ts +79 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +593 -0
- package/dist/conversation.js.map +1 -0
- package/dist/durability.d.ts +9 -0
- package/dist/durability.d.ts.map +1 -0
- package/dist/durability.js +11 -0
- package/dist/durability.js.map +1 -0
- package/dist/file.d.ts +20 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +149 -0
- package/dist/file.js.map +1 -0
- package/dist/host.d.ts +14 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +211 -0
- package/dist/host.js.map +1 -0
- package/dist/identity.d.ts +3 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +23 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +17 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +201 -15
- package/dist/memory.js.map +1 -1
- package/dist/model.d.ts +55 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +36 -0
- package/dist/model.js.map +1 -0
- package/dist/observation.d.ts +25 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +92 -0
- package/dist/observation.js.map +1 -0
- package/dist/outcome.d.ts +22 -18
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +1 -11
- package/dist/outcome.js.map +1 -1
- package/dist/overlay.d.ts +2 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +107 -1
- package/dist/overlay.js.map +1 -1
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -4
- package/dist/paths.js.map +1 -1
- package/dist/query.d.ts +209 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +467 -0
- package/dist/query.js.map +1 -0
- package/dist/read-side.d.ts +14 -0
- package/dist/read-side.d.ts.map +1 -0
- package/dist/read-side.js +451 -0
- package/dist/read-side.js.map +1 -0
- package/dist/refresh.d.ts +3 -3
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +10 -7
- package/dist/refresh.js.map +1 -1
- package/dist/replica.d.ts +23 -4
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +224 -13
- package/dist/replica.js.map +1 -1
- package/dist/room-draft.d.ts +124 -0
- package/dist/room-draft.d.ts.map +1 -0
- package/dist/room-draft.js +406 -0
- package/dist/room-draft.js.map +1 -0
- package/dist/rows.d.ts +39 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +100 -0
- package/dist/rows.js.map +1 -0
- package/dist/save.d.ts +11 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +116 -128
- package/dist/save.js.map +1 -1
- package/dist/search.d.ts +61 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +155 -0
- package/dist/search.js.map +1 -0
- package/dist/status.d.ts +9 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +5 -4
- package/dist/status.js.map +1 -1
- package/dist/store.d.ts +89 -18
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +445 -57
- package/dist/store.js.map +1 -1
- package/dist/transfer.d.ts +5 -0
- package/dist/transfer.d.ts.map +1 -1
- package/dist/transfer.js.map +1 -1
- package/dist/wire.d.ts +64 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +144 -0
- package/dist/wire.js.map +1 -0
- package/package.json +15 -13
package/dist/bootstrap.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readStaged } from './replica.js';
|
|
2
2
|
import { unconfirmed } from './transfer.js';
|
|
3
|
-
export async function bootstrapRoom(adapter, authorization, room) {
|
|
3
|
+
export async function bootstrapRoom(adapter, authorization, room, models, continuing) {
|
|
4
4
|
const first = await adapter.bootstrap(authorization, {
|
|
5
|
-
locator: room.locator
|
|
5
|
+
locator: room.locator,
|
|
6
|
+
selection: room.replica.selection
|
|
6
7
|
});
|
|
7
8
|
if (first.kind !== 'bootstrap') return first;
|
|
8
9
|
const roomVersion = first.roomVersion;
|
|
@@ -15,8 +16,10 @@ export async function bootstrapRoom(adapter, authorization, room) {
|
|
|
15
16
|
const binaryTargets = new Set(first.binaryTargets);
|
|
16
17
|
let pageToken = first.pageToken;
|
|
17
18
|
while(pageToken !== undefined){
|
|
19
|
+
if (!continuing()) return unconfirmed;
|
|
18
20
|
const page = await adapter.bootstrap(authorization, {
|
|
19
21
|
locator: room.locator,
|
|
22
|
+
selection: room.replica.selection,
|
|
20
23
|
pageToken
|
|
21
24
|
});
|
|
22
25
|
if (page.kind !== 'bootstrap') return page;
|
|
@@ -26,10 +29,16 @@ export async function bootstrapRoom(adapter, authorization, room) {
|
|
|
26
29
|
for (const target of page.binaryTargets)binaryTargets.add(target);
|
|
27
30
|
pageToken = page.pageToken;
|
|
28
31
|
}
|
|
29
|
-
|
|
32
|
+
return readStaged({
|
|
30
33
|
locator: room.locator,
|
|
34
|
+
collectionRoot: room.collectionRoot,
|
|
31
35
|
name: room.name,
|
|
32
|
-
|
|
36
|
+
operations: room.operations,
|
|
37
|
+
replica: room.replica,
|
|
38
|
+
attachedModel: room.attachedModel,
|
|
39
|
+
model: models.collection,
|
|
40
|
+
typedSelection: room.typedSelection ?? null,
|
|
41
|
+
selectionModel: models.selection,
|
|
33
42
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
34
43
|
roomVersion,
|
|
35
44
|
documents,
|
|
@@ -38,10 +47,6 @@ export async function bootstrapRoom(adapter, authorization, room) {
|
|
|
38
47
|
].sort(),
|
|
39
48
|
revisions
|
|
40
49
|
});
|
|
41
|
-
return confirmed === null ? unconfirmed : {
|
|
42
|
-
kind: 'staged',
|
|
43
|
-
confirmed
|
|
44
|
-
};
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
//# sourceMappingURL=bootstrap.js.map
|
package/dist/bootstrap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport {
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/bootstrap.ts"],"sourcesContent":["import type { ModelState } from './model.js';\nimport type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';\nimport { readStaged, type Staged } from './replica.js';\nimport { unconfirmed } from './transfer.js';\n\nexport type BootstrapOutcome = Staged | AdapterFailure;\n\nexport async function bootstrapRoom(\n adapter: Adapter,\n authorization: Authorization,\n room: DiscoveredRoom,\n models: { collection: ModelState; selection: ModelState },\n continuing: () => boolean,\n): Promise<BootstrapOutcome> {\n const first = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n });\n if (first.kind !== 'bootstrap') return first;\n const roomVersion = first.roomVersion;\n const documents: Record<string, string> = { ...first.documents };\n const revisions: Record<string, string> = { ...first.revisions };\n const binaryTargets = new Set(first.binaryTargets);\n let pageToken = first.pageToken;\n while (pageToken !== undefined) {\n if (!continuing()) return unconfirmed;\n const page = await adapter.bootstrap(authorization, {\n locator: room.locator,\n selection: room.replica.selection,\n pageToken,\n });\n if (page.kind !== 'bootstrap') return page;\n if (page.roomVersion !== roomVersion) return unconfirmed;\n Object.assign(documents, page.documents);\n Object.assign(revisions, page.revisions);\n for (const target of page.binaryTargets) binaryTargets.add(target);\n pageToken = page.pageToken;\n }\n return readStaged({\n locator: room.locator,\n collectionRoot: room.collectionRoot,\n name: room.name,\n operations: room.operations,\n replica: room.replica,\n attachedModel: room.attachedModel,\n model: models.collection,\n typedSelection: room.typedSelection ?? null,\n selectionModel: models.selection,\n providerOwnedPaths: room.providerOwnedPaths,\n roomVersion,\n documents,\n binaryTargets: [...binaryTargets].sort(),\n revisions,\n });\n}\n"],"names":["readStaged","unconfirmed","bootstrapRoom","adapter","authorization","room","models","continuing","first","bootstrap","locator","selection","replica","kind","roomVersion","documents","revisions","binaryTargets","Set","pageToken","undefined","page","Object","assign","target","add","collectionRoot","name","operations","attachedModel","model","collection","typedSelection","selectionModel","providerOwnedPaths","sort"],"mappings":"AAEA,SAASA,UAAU,QAAqB,eAAe;AACvD,SAASC,WAAW,QAAQ,gBAAgB;AAI5C,OAAO,eAAeC,cACpBC,OAAgB,EAChBC,aAA4B,EAC5BC,IAAoB,EACpBC,MAAyD,EACzDC,UAAyB;IAEzB,MAAMC,QAAQ,MAAML,QAAQM,SAAS,CAACL,eAAe;QACnDM,SAASL,KAAKK,OAAO;QACrBC,WAAWN,KAAKO,OAAO,CAACD,SAAS;IACnC;IACA,IAAIH,MAAMK,IAAI,KAAK,aAAa,OAAOL;IACvC,MAAMM,cAAcN,MAAMM,WAAW;IACrC,MAAMC,YAAoC;QAAE,GAAGP,MAAMO,SAAS;IAAC;IAC/D,MAAMC,YAAoC;QAAE,GAAGR,MAAMQ,SAAS;IAAC;IAC/D,MAAMC,gBAAgB,IAAIC,IAAIV,MAAMS,aAAa;IACjD,IAAIE,YAAYX,MAAMW,SAAS;IAC/B,MAAOA,cAAcC,UAAW;QAC9B,IAAI,CAACb,cAAc,OAAON;QAC1B,MAAMoB,OAAO,MAAMlB,QAAQM,SAAS,CAACL,eAAe;YAClDM,SAASL,KAAKK,OAAO;YACrBC,WAAWN,KAAKO,OAAO,CAACD,SAAS;YACjCQ;QACF;QACA,IAAIE,KAAKR,IAAI,KAAK,aAAa,OAAOQ;QACtC,IAAIA,KAAKP,WAAW,KAAKA,aAAa,OAAOb;QAC7CqB,OAAOC,MAAM,CAACR,WAAWM,KAAKN,SAAS;QACvCO,OAAOC,MAAM,CAACP,WAAWK,KAAKL,SAAS;QACvC,KAAK,MAAMQ,UAAUH,KAAKJ,aAAa,CAAEA,cAAcQ,GAAG,CAACD;QAC3DL,YAAYE,KAAKF,SAAS;IAC5B;IACA,OAAOnB,WAAW;QAChBU,SAASL,KAAKK,OAAO;QACrBgB,gBAAgBrB,KAAKqB,cAAc;QACnCC,MAAMtB,KAAKsB,IAAI;QACfC,YAAYvB,KAAKuB,UAAU;QAC3BhB,SAASP,KAAKO,OAAO;QACrBiB,eAAexB,KAAKwB,aAAa;QACjCC,OAAOxB,OAAOyB,UAAU;QACxBC,gBAAgB3B,KAAK2B,cAAc,IAAI;QACvCC,gBAAgB3B,OAAOK,SAAS;QAChCuB,oBAAoB7B,KAAK6B,kBAAkB;QAC3CpB;QACAC;QACAE,eAAe;eAAIA;SAAc,CAACkB,IAAI;QACtCnB;IACF;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Replica } from './replica.js';
|
|
2
|
+
import { type Row } from './rows.js';
|
|
3
|
+
export type DocumentChange = {
|
|
4
|
+
locator: string;
|
|
5
|
+
path: string;
|
|
6
|
+
before: readonly Row[];
|
|
7
|
+
after: readonly Row[];
|
|
8
|
+
};
|
|
9
|
+
export type MessageChange = {
|
|
10
|
+
conversation: string;
|
|
11
|
+
identity: string;
|
|
12
|
+
};
|
|
13
|
+
export type ChangeSet = {
|
|
14
|
+
documents: readonly DocumentChange[];
|
|
15
|
+
drafts: readonly {
|
|
16
|
+
locator: string;
|
|
17
|
+
path: string;
|
|
18
|
+
}[];
|
|
19
|
+
rooms: readonly string[];
|
|
20
|
+
queues: readonly string[];
|
|
21
|
+
presentations: readonly string[];
|
|
22
|
+
messages: readonly MessageChange[];
|
|
23
|
+
conversations: readonly string[];
|
|
24
|
+
};
|
|
25
|
+
export declare function changeSet(locator: string, before: Replica | null, after: Replica | null, changed?: {
|
|
26
|
+
drafts?: readonly string[];
|
|
27
|
+
room?: boolean;
|
|
28
|
+
queue?: boolean;
|
|
29
|
+
presentation?: string;
|
|
30
|
+
}): ChangeSet;
|
|
31
|
+
export declare function conversationChangeSet(messages: readonly MessageChange[], conversations: readonly string[]): ChangeSet;
|
|
32
|
+
export declare function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet;
|
|
33
|
+
//# sourceMappingURL=change-set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAU,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,EAAE,CAAC;IACvB,KAAK,EAAE,SAAS,GAAG,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IACrC,MAAM,EAAE,SAAS;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACrD,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAaF,wBAAgB,SAAS,CACvB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,GAAG,IAAI,EACtB,KAAK,EAAE,OAAO,GAAG,IAAI,EACrB,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CAClB,GACL,SAAS,CAgDX;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,aAAa,EAAE,SAAS,MAAM,EAAE,GAC/B,SAAS,CAUX;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAUrE"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { beneath } from './paths.js';
|
|
2
|
+
import { compositionOf } from './replica.js';
|
|
3
|
+
import { rowsOf } from './rows.js';
|
|
4
|
+
function rowsAt(locator, replica, path) {
|
|
5
|
+
const document = replica?.visible.collection.documents[path];
|
|
6
|
+
if (replica === null) return [];
|
|
7
|
+
if (document === undefined && !replica.visible.binaryTargets.includes(path)) return [];
|
|
8
|
+
return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record));
|
|
9
|
+
}
|
|
10
|
+
function modelShape(model) {
|
|
11
|
+
return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
|
|
12
|
+
}
|
|
13
|
+
export function changeSet(locator, before, after, changed = {}) {
|
|
14
|
+
const paths = new Set([
|
|
15
|
+
...Object.keys(before?.visible.documents ?? {}),
|
|
16
|
+
...Object.keys(after?.visible.documents ?? {}),
|
|
17
|
+
...before?.visible.binaryTargets ?? [],
|
|
18
|
+
...after?.visible.binaryTargets ?? []
|
|
19
|
+
]);
|
|
20
|
+
const documents = [];
|
|
21
|
+
const oldRoom = before?.confirmed.record;
|
|
22
|
+
const newRoom = after?.confirmed.record;
|
|
23
|
+
const collectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.model) !== modelShape(newRoom.model);
|
|
24
|
+
const selectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
|
|
25
|
+
for (const path of paths){
|
|
26
|
+
const selected = newRoom?.typedSelection?.roots.some((root)=>beneath(root, path)) ?? false;
|
|
27
|
+
const inCollection = newRoom !== undefined && (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));
|
|
28
|
+
const retyped = selected ? selectionChanged : inCollection && collectionChanged;
|
|
29
|
+
if (before?.visible.documents[path] === after?.visible.documents[path] && before?.visible.binaryTargets.includes(path) === after?.visible.binaryTargets.includes(path) && before?.visible.revisions[path] === after?.visible.revisions[path] && !retyped) continue;
|
|
30
|
+
documents.push({
|
|
31
|
+
locator,
|
|
32
|
+
path,
|
|
33
|
+
before: rowsAt(locator, before, path),
|
|
34
|
+
after: rowsAt(locator, after, path)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
documents,
|
|
39
|
+
drafts: (changed.drafts ?? []).map((path)=>({
|
|
40
|
+
locator,
|
|
41
|
+
path
|
|
42
|
+
})),
|
|
43
|
+
rooms: changed.room ? [
|
|
44
|
+
locator
|
|
45
|
+
] : [],
|
|
46
|
+
queues: changed.queue ? [
|
|
47
|
+
locator
|
|
48
|
+
] : [],
|
|
49
|
+
presentations: changed.presentation === undefined ? [] : [
|
|
50
|
+
changed.presentation
|
|
51
|
+
],
|
|
52
|
+
messages: [],
|
|
53
|
+
conversations: []
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export function conversationChangeSet(messages, conversations) {
|
|
57
|
+
return {
|
|
58
|
+
documents: [],
|
|
59
|
+
drafts: [],
|
|
60
|
+
rooms: [],
|
|
61
|
+
queues: [],
|
|
62
|
+
presentations: [],
|
|
63
|
+
messages,
|
|
64
|
+
conversations: [
|
|
65
|
+
...new Set(conversations)
|
|
66
|
+
]
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export function mergeChangeSets(sets) {
|
|
70
|
+
return {
|
|
71
|
+
documents: sets.flatMap((set)=>set.documents),
|
|
72
|
+
drafts: sets.flatMap((set)=>set.drafts),
|
|
73
|
+
rooms: [
|
|
74
|
+
...new Set(sets.flatMap((set)=>set.rooms))
|
|
75
|
+
],
|
|
76
|
+
queues: [
|
|
77
|
+
...new Set(sets.flatMap((set)=>set.queues))
|
|
78
|
+
],
|
|
79
|
+
presentations: [
|
|
80
|
+
...new Set(sets.flatMap((set)=>set.presentations))
|
|
81
|
+
],
|
|
82
|
+
messages: sets.flatMap((set)=>set.messages),
|
|
83
|
+
conversations: [
|
|
84
|
+
...new Set(sets.flatMap((set)=>set.conversations))
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=change-set.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/change-set.ts"],"sourcesContent":["import { beneath } from './paths.js';\nimport { compositionOf, type Replica } from './replica.js';\nimport { rowsOf, type Row } from './rows.js';\n\nexport type DocumentChange = {\n locator: string;\n path: string;\n before: readonly Row[];\n after: readonly Row[];\n};\n\nexport type MessageChange = { conversation: string; identity: string };\n\nexport type ChangeSet = {\n documents: readonly DocumentChange[];\n drafts: readonly { locator: string; path: string }[];\n rooms: readonly string[];\n queues: readonly string[];\n presentations: readonly string[];\n messages: readonly MessageChange[];\n conversations: readonly string[];\n};\n\nfunction rowsAt(locator: string, replica: Replica | null, path: string): readonly Row[] {\n const document = replica?.visible.collection.documents[path];\n if (replica === null) return [];\n if (document === undefined && !replica.visible.binaryTargets.includes(path)) return [];\n return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record));\n}\n\nfunction modelShape(model: Replica['confirmed']['record']['model']): string {\n return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);\n}\n\nexport function changeSet(\n locator: string,\n before: Replica | null,\n after: Replica | null,\n changed: {\n drafts?: readonly string[];\n room?: boolean;\n queue?: boolean;\n presentation?: string;\n } = {},\n): ChangeSet {\n const paths = new Set([\n ...Object.keys(before?.visible.documents ?? {}),\n ...Object.keys(after?.visible.documents ?? {}),\n ...(before?.visible.binaryTargets ?? []),\n ...(after?.visible.binaryTargets ?? []),\n ]);\n const documents: DocumentChange[] = [];\n const oldRoom = before?.confirmed.record;\n const newRoom = after?.confirmed.record;\n const collectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.model) !== modelShape(newRoom.model);\n const selectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);\n for (const path of paths) {\n const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;\n const inCollection =\n newRoom !== undefined &&\n (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));\n const retyped = selected ? selectionChanged : inCollection && collectionChanged;\n if (\n before?.visible.documents[path] === after?.visible.documents[path] &&\n before?.visible.binaryTargets.includes(path) ===\n after?.visible.binaryTargets.includes(path) &&\n before?.visible.revisions[path] === after?.visible.revisions[path] &&\n !retyped\n )\n continue;\n documents.push({\n locator,\n path,\n before: rowsAt(locator, before, path),\n after: rowsAt(locator, after, path),\n });\n }\n return {\n documents,\n drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),\n rooms: changed.room ? [locator] : [],\n queues: changed.queue ? [locator] : [],\n presentations: changed.presentation === undefined ? [] : [changed.presentation],\n messages: [],\n conversations: [],\n };\n}\n\nexport function conversationChangeSet(\n messages: readonly MessageChange[],\n conversations: readonly string[],\n): ChangeSet {\n return {\n documents: [],\n drafts: [],\n rooms: [],\n queues: [],\n presentations: [],\n messages,\n conversations: [...new Set(conversations)],\n };\n}\n\nexport function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet {\n return {\n documents: sets.flatMap((set) => set.documents),\n drafts: sets.flatMap((set) => set.drafts),\n rooms: [...new Set(sets.flatMap((set) => set.rooms))],\n queues: [...new Set(sets.flatMap((set) => set.queues))],\n presentations: [...new Set(sets.flatMap((set) => set.presentations))],\n messages: sets.flatMap((set) => set.messages),\n conversations: [...new Set(sets.flatMap((set) => set.conversations))],\n };\n}\n"],"names":["beneath","compositionOf","rowsOf","rowsAt","locator","replica","path","document","visible","collection","documents","undefined","binaryTargets","includes","confirmed","record","modelShape","model","status","JSON","stringify","types","changeSet","before","after","changed","paths","Set","Object","keys","oldRoom","newRoom","collectionChanged","selectionChanged","selectionModel","selected","typedSelection","roots","some","root","inCollection","collectionRoot","retyped","revisions","push","drafts","map","rooms","room","queues","queue","presentations","presentation","messages","conversations","conversationChangeSet","mergeChangeSets","sets","flatMap","set"],"mappings":"AAAA,SAASA,OAAO,QAAQ,aAAa;AACrC,SAASC,aAAa,QAAsB,eAAe;AAC3D,SAASC,MAAM,QAAkB,YAAY;AAqB7C,SAASC,OAAOC,OAAe,EAAEC,OAAuB,EAAEC,IAAY;IACpE,MAAMC,WAAWF,SAASG,QAAQC,WAAWC,SAAS,CAACJ,KAAK;IAC5D,IAAID,YAAY,MAAM,OAAO,EAAE;IAC/B,IAAIE,aAAaI,aAAa,CA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B,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIV,MAAM;SAAG;QACvDE,eAAe;eAAI,IAAIxB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIR,aAAa;SAAG;QACrEE,UAAUI,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIN,QAAQ;QAC5CC,eAAe;eAAI,IAAI3B,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIL,aAAa;SAAG;IACvE;AACF"}
|
package/dist/change.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export type Change = {
|
|
|
17
17
|
readonly path: string;
|
|
18
18
|
readonly fields: Readonly<Record<string, unknown>>;
|
|
19
19
|
readonly sections: Readonly<Record<string, string>>;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'create';
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly content: string;
|
|
20
24
|
} | {
|
|
21
25
|
readonly kind: 'replace';
|
|
22
26
|
readonly path: string;
|
|
@@ -54,11 +58,17 @@ export type Precondition = {
|
|
|
54
58
|
readonly kind: 'absent';
|
|
55
59
|
readonly path: string;
|
|
56
60
|
};
|
|
61
|
+
export type WrittenBy = {
|
|
62
|
+
readonly app: string;
|
|
63
|
+
readonly release: string;
|
|
64
|
+
};
|
|
57
65
|
export type ChangeBatch = {
|
|
66
|
+
validation?: import('./model.js').ValidationReceipt;
|
|
58
67
|
readonly id: string;
|
|
59
68
|
readonly baseRoomVersion: string;
|
|
60
69
|
readonly changes: readonly Change[];
|
|
61
70
|
readonly preconditions: readonly Precondition[];
|
|
71
|
+
readonly writtenBy?: WrittenBy;
|
|
62
72
|
};
|
|
63
73
|
export declare function immutable(batch: ChangeBatch): ChangeBatch;
|
|
64
74
|
//# sourceMappingURL=change.d.ts.map
|
package/dist/change.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAA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ACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC,CAAC;AAUF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAEzD"}
|
package/dist/change.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/change.ts"],"sourcesContent":["export type Change =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | {\n readonly kind: 'create';\n readonly path: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly sections: Readonly<Record<string, string>>;\n }\n | { readonly kind: 'replace'; readonly path: string; readonly content: string }\n | { readonly kind: 'move'; readonly path: string; readonly to: string }\n | { readonly kind: 'remove'; readonly path: string };\n\nexport type Precondition =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | { readonly kind: 'revision'; readonly path: string; readonly revision: string }\n | { readonly kind: 'present'; readonly path: string }\n | { readonly kind: 'absent'; readonly path: string };\n\nexport type ChangeBatch = {\n readonly id: string;\n readonly baseRoomVersion: string;\n readonly changes: readonly Change[];\n readonly preconditions: readonly Precondition[];\n};\n\nfunction frozen<T>(value: T): T {\n if (Array.isArray(value)) return Object.freeze(value.map((item) => frozen(item))) as T;\n if (value === null || typeof value !== 'object') return value;\n const copy: Record<string, unknown> = {};\n for (const [name, item] of Object.entries(value)) copy[name] = frozen(item);\n return Object.freeze(copy) as T;\n}\n\nexport function immutable(batch: ChangeBatch): ChangeBatch {\n return frozen(batch);\n}\n"],"names":["frozen","value","Array","isArray","Object","freeze","map","item","copy","name","entries","immutable","batch"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/change.ts"],"sourcesContent":["export type Change =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | {\n readonly kind: 'create';\n readonly path: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly sections: Readonly<Record<string, string>>;\n }\n | { readonly kind: 'create'; readonly path: string; readonly content: string }\n | { readonly kind: 'replace'; readonly path: string; readonly content: string }\n | { readonly kind: 'move'; readonly path: string; readonly to: string }\n | { readonly kind: 'remove'; readonly path: string };\n\nexport type Precondition =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | { readonly kind: 'revision'; readonly path: string; readonly revision: string }\n | { readonly kind: 'present'; readonly path: string }\n | { readonly kind: 'absent'; readonly path: string };\n\nexport type WrittenBy = { readonly app: string; readonly release: string };\n\nexport type ChangeBatch = {\n validation?: import('./model.js').ValidationReceipt;\n readonly id: string;\n readonly baseRoomVersion: string;\n readonly changes: readonly Change[];\n readonly preconditions: readonly Precondition[];\n readonly writtenBy?: WrittenBy;\n};\n\nfunction frozen<T>(value: T): T {\n if (Array.isArray(value)) return Object.freeze(value.map((item) => frozen(item))) as T;\n if (value === null || typeof value !== 'object') return value;\n const copy: Record<string, unknown> = {};\n for (const [name, item] of Object.entries(value)) copy[name] = frozen(item);\n return Object.freeze(copy) as T;\n}\n\nexport function immutable(batch: ChangeBatch): ChangeBatch {\n return frozen(batch);\n}\n"],"names":["frozen","value","Array","isArray","Object","freeze","map","item","copy","name","entries","immutable","batch"],"mappings":"AAsDA,SAASA,OAAUC,KAAQ;IACzB,IAAIC,MAAMC,OAAO,CAACF,QAAQ,OAAOG,OAAOC,MAAM,CAACJ,MAAMK,GAAG,CAAC,CAACC,OAASP,OAAOO;IAC1E,IAAIN,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOA;IACxD,MAAMO,OAAgC,CAAC;IACvC,KAAK,MAAM,CAACC,MAAMF,KAAK,IAAIH,OAAOM,OAAO,CAACT,OAAQO,IAAI,CAACC,KAAK,GAAGT,OAAOO;IACtE,OAAOH,OAAOC,MAAM,CAACG;AACvB;AAEA,OAAO,SAASG,UAAUC,KAAkB;IAC1C,OAAOZ,OAAOY;AAChB"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { AppRoom, AppSlot, ConnectionRefusal, HistoryQuery, RoomTypes, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
|
+
import type { HistoryResult, ServiceMode } from './adapter.js';
|
|
3
|
+
import type { ChatDraft, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
|
+
import { type Observation } from './observation.js';
|
|
5
|
+
import type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';
|
|
6
|
+
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
7
|
+
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
8
|
+
import type { SearchRequest, SearchResult } from './search.js';
|
|
9
|
+
import type { SyncStatus } from './status.js';
|
|
10
|
+
import { type RuntimePort } from './wire.js';
|
|
11
|
+
export type MdRuntimeClient = {
|
|
12
|
+
rooms(): Promise<readonly AppRoom[]>;
|
|
13
|
+
slots(): Promise<readonly AppSlot[]>;
|
|
14
|
+
query: {
|
|
15
|
+
(query: DocumentQuery): Promise<DocumentResult>;
|
|
16
|
+
(query: GroupQuery): Promise<GroupResult>;
|
|
17
|
+
};
|
|
18
|
+
search(request: SearchRequest): Promise<SearchResult>;
|
|
19
|
+
types(locator: string): Promise<RoomTypes>;
|
|
20
|
+
syncStatus(): Promise<SyncStatus>;
|
|
21
|
+
serviceMode(): Promise<ServiceMode>;
|
|
22
|
+
roomDraft: {
|
|
23
|
+
list(): Promise<readonly RoomDraft[]>;
|
|
24
|
+
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
25
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
26
|
+
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
27
|
+
};
|
|
28
|
+
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
29
|
+
outcome(identifier: string): Promise<SubmissionOutcome | null>;
|
|
30
|
+
presentation: {
|
|
31
|
+
read(): Promise<unknown>;
|
|
32
|
+
write(value: unknown): Promise<void>;
|
|
33
|
+
};
|
|
34
|
+
conversation: {
|
|
35
|
+
list(): Promise<readonly ConversationEntry[]>;
|
|
36
|
+
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
37
|
+
create(input: unknown): Promise<CallResult>;
|
|
38
|
+
send(conversation: string): Promise<CallResult>;
|
|
39
|
+
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
40
|
+
interrupt(conversation: string): Promise<CallResult>;
|
|
41
|
+
kill(conversation: string): Promise<CallResult>;
|
|
42
|
+
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
43
|
+
delete(conversation: string): Promise<CallResult>;
|
|
44
|
+
};
|
|
45
|
+
chatDraft: {
|
|
46
|
+
write(conversation: string, draft: ChatDraft): Promise<void>;
|
|
47
|
+
discard(conversation: string): Promise<void>;
|
|
48
|
+
};
|
|
49
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;
|
|
50
|
+
call(name: string, input: unknown): Promise<CallResult>;
|
|
51
|
+
log(): Promise<string>;
|
|
52
|
+
storageLoss(): Promise<string | null>;
|
|
53
|
+
persistence(): Promise<boolean>;
|
|
54
|
+
deploymentFacts(): Promise<unknown>;
|
|
55
|
+
observe: {
|
|
56
|
+
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
57
|
+
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
58
|
+
(topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
|
|
59
|
+
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
60
|
+
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
61
|
+
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
62
|
+
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
63
|
+
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
64
|
+
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
65
|
+
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
66
|
+
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
67
|
+
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
68
|
+
};
|
|
69
|
+
reauthorize(): Promise<void>;
|
|
70
|
+
};
|
|
71
|
+
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
72
|
+
export type { Observation } from './observation.js';
|
|
73
|
+
export type { RuntimePort } from './wire.js';
|
|
74
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EACV,SAAS,EACT,iB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AC,CAAC,CAAC;QAC7D,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7E,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;QACvE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC,CAAC;QAC/E,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CACE,KAAK,EAAE,cAAc,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC3C,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAsLnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { observed } from './observation.js';
|
|
2
|
+
import { answer, AUTHORIZATION_ENDED, carried, envelope, PORT_CLOSED, PROTOCOL_MISMATCH } from './wire.js';
|
|
3
|
+
export function connectMdRuntime(port) {
|
|
4
|
+
let sequence = 0;
|
|
5
|
+
let refusal = null;
|
|
6
|
+
let ended = null;
|
|
7
|
+
const calls = new Map();
|
|
8
|
+
const opening = new Map();
|
|
9
|
+
const observations = new Map();
|
|
10
|
+
const send = (message)=>{
|
|
11
|
+
port.postMessage(envelope(message));
|
|
12
|
+
};
|
|
13
|
+
function begin(id, topic, first) {
|
|
14
|
+
const handle = observed(first, ()=>{
|
|
15
|
+
observations.delete(id);
|
|
16
|
+
if (refusal === null) send({
|
|
17
|
+
kind: 'stop',
|
|
18
|
+
id
|
|
19
|
+
});
|
|
20
|
+
}, topic === 'query');
|
|
21
|
+
observations.set(id, {
|
|
22
|
+
topic,
|
|
23
|
+
handle
|
|
24
|
+
});
|
|
25
|
+
return handle.observation;
|
|
26
|
+
}
|
|
27
|
+
function refuse(reported) {
|
|
28
|
+
refusal = reported;
|
|
29
|
+
for (const { topic, handle } of observations.values()){
|
|
30
|
+
if (topic === 'connection-refusal') handle.receive(reported);
|
|
31
|
+
}
|
|
32
|
+
const failure = new Error(reported.reason);
|
|
33
|
+
for (const [id, waiting] of opening){
|
|
34
|
+
if (waiting.topic === 'connection-refusal') waiting.settle(begin(id, waiting.topic, reported));
|
|
35
|
+
else waiting.fail(failure);
|
|
36
|
+
}
|
|
37
|
+
opening.clear();
|
|
38
|
+
for (const waiting of calls.values())waiting.fail(failure);
|
|
39
|
+
calls.clear();
|
|
40
|
+
}
|
|
41
|
+
function end(reason) {
|
|
42
|
+
if (ended !== null) return;
|
|
43
|
+
ended = reason;
|
|
44
|
+
const failure = new Error(reason);
|
|
45
|
+
for (const waiting of opening.values())waiting.fail(failure);
|
|
46
|
+
opening.clear();
|
|
47
|
+
for (const waiting of calls.values())waiting.fail(failure);
|
|
48
|
+
calls.clear();
|
|
49
|
+
for (const { handle } of observations.values())handle.end();
|
|
50
|
+
observations.clear();
|
|
51
|
+
}
|
|
52
|
+
port.addEventListener('message', (event)=>{
|
|
53
|
+
const wire = carried(event.data);
|
|
54
|
+
if (wire === null) return;
|
|
55
|
+
if (!wire.matching) {
|
|
56
|
+
refuse(PROTOCOL_MISMATCH);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const message = answer(wire.message);
|
|
60
|
+
if (message === null) return;
|
|
61
|
+
if (message.kind === 'refusal') {
|
|
62
|
+
refuse(message.refusal);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (message.kind === 'ended') {
|
|
66
|
+
end(AUTHORIZATION_ENDED);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (message.kind === 'event') {
|
|
70
|
+
observations.get(message.id)?.handle.receive(message.value);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const waiting = opening.get(message.id);
|
|
74
|
+
if (waiting !== undefined) {
|
|
75
|
+
opening.delete(message.id);
|
|
76
|
+
if (message.kind === 'failure') waiting.fail(new Error(message.message));
|
|
77
|
+
else waiting.settle(begin(message.id, waiting.topic, message.value));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const called = calls.get(message.id);
|
|
81
|
+
if (called === undefined) return;
|
|
82
|
+
calls.delete(message.id);
|
|
83
|
+
if (message.kind === 'failure') called.fail(new Error(message.message));
|
|
84
|
+
else called.settle(message.value);
|
|
85
|
+
});
|
|
86
|
+
port.addEventListener('close', ()=>{
|
|
87
|
+
end(PORT_CLOSED);
|
|
88
|
+
});
|
|
89
|
+
port.start();
|
|
90
|
+
send({
|
|
91
|
+
kind: 'hello'
|
|
92
|
+
});
|
|
93
|
+
function ask(member, input) {
|
|
94
|
+
if (ended !== null) return Promise.reject(new Error(ended));
|
|
95
|
+
if (refusal !== null) return Promise.reject(new Error(refusal.reason));
|
|
96
|
+
const id = sequence += 1;
|
|
97
|
+
return new Promise((settle, fail)=>{
|
|
98
|
+
calls.set(id, {
|
|
99
|
+
settle: settle,
|
|
100
|
+
fail
|
|
101
|
+
});
|
|
102
|
+
send({
|
|
103
|
+
kind: 'call',
|
|
104
|
+
id,
|
|
105
|
+
member,
|
|
106
|
+
input
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function watch(topic, input) {
|
|
111
|
+
if (ended !== null) return Promise.reject(new Error(ended));
|
|
112
|
+
const id = sequence += 1;
|
|
113
|
+
if (refusal !== null) {
|
|
114
|
+
return topic === 'connection-refusal' ? Promise.resolve(begin(id, topic, refusal)) : Promise.reject(new Error(refusal.reason));
|
|
115
|
+
}
|
|
116
|
+
return new Promise((settle, fail)=>{
|
|
117
|
+
opening.set(id, {
|
|
118
|
+
topic,
|
|
119
|
+
settle,
|
|
120
|
+
fail
|
|
121
|
+
});
|
|
122
|
+
send({
|
|
123
|
+
kind: 'observe',
|
|
124
|
+
id,
|
|
125
|
+
topic,
|
|
126
|
+
input
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
rooms: ()=>ask('rooms', []),
|
|
132
|
+
slots: ()=>ask('slots', []),
|
|
133
|
+
query: (query)=>ask('query', [
|
|
134
|
+
query
|
|
135
|
+
]),
|
|
136
|
+
search: (request)=>ask('search', [
|
|
137
|
+
request
|
|
138
|
+
]),
|
|
139
|
+
types: (locator)=>ask('types', [
|
|
140
|
+
locator
|
|
141
|
+
]),
|
|
142
|
+
syncStatus: ()=>ask('syncStatus', []),
|
|
143
|
+
serviceMode: ()=>ask('serviceMode', []),
|
|
144
|
+
roomDraft: {
|
|
145
|
+
list: ()=>ask('roomDraft.list', []),
|
|
146
|
+
read: (room, path)=>ask('roomDraft.read', [
|
|
147
|
+
room,
|
|
148
|
+
path
|
|
149
|
+
]),
|
|
150
|
+
write: (room, path, revision, parts)=>ask('roomDraft.write', [
|
|
151
|
+
room,
|
|
152
|
+
path,
|
|
153
|
+
revision,
|
|
154
|
+
parts
|
|
155
|
+
]),
|
|
156
|
+
discard: (room, path, revision)=>ask('roomDraft.discard', [
|
|
157
|
+
room,
|
|
158
|
+
path,
|
|
159
|
+
revision
|
|
160
|
+
])
|
|
161
|
+
},
|
|
162
|
+
save: (room, roomDrafts)=>ask('save', [
|
|
163
|
+
room,
|
|
164
|
+
roomDrafts
|
|
165
|
+
]),
|
|
166
|
+
outcome: (identifier)=>ask('outcome', [
|
|
167
|
+
identifier
|
|
168
|
+
]),
|
|
169
|
+
presentation: {
|
|
170
|
+
read: ()=>ask('presentation.read', []),
|
|
171
|
+
write: (value)=>ask('presentation.write', [
|
|
172
|
+
value
|
|
173
|
+
])
|
|
174
|
+
},
|
|
175
|
+
conversation: {
|
|
176
|
+
list: ()=>ask('conversation.list', []),
|
|
177
|
+
read: (conversation, options)=>ask('conversation.read', [
|
|
178
|
+
conversation,
|
|
179
|
+
options
|
|
180
|
+
]),
|
|
181
|
+
create: (input)=>ask('conversation.create', [
|
|
182
|
+
input
|
|
183
|
+
]),
|
|
184
|
+
send: (conversation)=>ask('conversation.send', [
|
|
185
|
+
conversation
|
|
186
|
+
]),
|
|
187
|
+
answer: (conversation, answer)=>ask('conversation.answer', [
|
|
188
|
+
conversation,
|
|
189
|
+
answer
|
|
190
|
+
]),
|
|
191
|
+
interrupt: (conversation)=>ask('conversation.interrupt', [
|
|
192
|
+
conversation
|
|
193
|
+
]),
|
|
194
|
+
kill: (conversation)=>ask('conversation.kill', [
|
|
195
|
+
conversation
|
|
196
|
+
]),
|
|
197
|
+
cancel: (conversation, turn)=>ask('conversation.cancel', [
|
|
198
|
+
conversation,
|
|
199
|
+
turn
|
|
200
|
+
]),
|
|
201
|
+
delete: (conversation)=>ask('conversation.delete', [
|
|
202
|
+
conversation
|
|
203
|
+
])
|
|
204
|
+
},
|
|
205
|
+
chatDraft: {
|
|
206
|
+
write: (conversation, draft)=>ask('chatDraft.write', [
|
|
207
|
+
conversation,
|
|
208
|
+
draft
|
|
209
|
+
]),
|
|
210
|
+
discard: (conversation)=>ask('chatDraft.discard', [
|
|
211
|
+
conversation
|
|
212
|
+
])
|
|
213
|
+
},
|
|
214
|
+
history: (locator, path, query)=>ask('history', [
|
|
215
|
+
locator,
|
|
216
|
+
path,
|
|
217
|
+
query
|
|
218
|
+
]),
|
|
219
|
+
call: (name, input)=>ask('call', [
|
|
220
|
+
name,
|
|
221
|
+
input
|
|
222
|
+
]),
|
|
223
|
+
log: ()=>ask('log', []),
|
|
224
|
+
storageLoss: ()=>ask('storageLoss', []),
|
|
225
|
+
persistence: ()=>ask('persistence', []),
|
|
226
|
+
deploymentFacts: ()=>ask('deploymentFacts', []),
|
|
227
|
+
observe: (topic, ...input)=>watch(topic, input),
|
|
228
|
+
reauthorize: ()=>ask('reauthorize', [])
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type {\n AppRoom,\n AppSlot,\n ConnectionRefusal,\n HistoryQuery,\n RoomTypes,\n SavedRoomDraft,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult, ServiceMode } from './adapter.js';\nimport type {\n ChatDraft,\n ConversationEntry,\n ConversationOptions,\n ConversationView,\n} from './conversation.js';\nimport { observed, type Observation, type Observed } from './observation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';\nimport type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';\nimport type { SearchRequest, SearchResult } from './search.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PORT_CLOSED,\n PROTOCOL_MISMATCH,\n type RuntimePort,\n type WireMember,\n type WireRequest,\n type WireTopic,\n} from './wire.js';\n\nexport type MdRuntimeClient = {\n rooms(): Promise<readonly AppRoom[]>;\n slots(): Promise<readonly AppSlot[]>;\n query: {\n (query: DocumentQuery): Promise<DocumentResult>;\n (query: GroupQuery): Promise<GroupResult>;\n };\n search(request: SearchRequest): Promise<SearchResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n serviceMode(): Promise<ServiceMode>;\n roomDraft: {\n list(): Promise<readonly RoomDraft[]>;\n read(room: string, path: string): Promise<RoomDraft | null>;\n write(\n room: string,\n path: string,\n revision: string | null,\n parts: RoomDraftParts,\n ): Promise<RoomDraftWrite>;\n discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;\n };\n save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;\n create(input: unknown): Promise<CallResult>;\n send(conversation: string): Promise<CallResult>;\n answer(conversation: string, answer: unknown): Promise<CallResult>;\n interrupt(conversation: string): Promise<CallResult>;\n kill(conversation: string): Promise<CallResult>;\n cancel(conversation: string, turn: string): Promise<CallResult>;\n delete(conversation: string): Promise<CallResult>;\n };\n chatDraft: {\n write(conversation: string, draft: ChatDraft): Promise<void>;\n discard(conversation: string): Promise<void>;\n };\n history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;\n call(name: string, input: unknown): Promise<CallResult>;\n log(): Promise<string>;\n storageLoss(): Promise<string | null>;\n persistence(): Promise<boolean>;\n deploymentFacts(): Promise<unknown>;\n observe: {\n (topic: 'deployment-facts'): Promise<Observation<unknown>>;\n (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;\n (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;\n (topic: 'storage-loss'): Promise<Observation<string | null>>;\n (topic: 'sync-status'): Promise<Observation<SyncStatus>>;\n (topic: 'service-mode'): Promise<Observation<ServiceMode>>;\n (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;\n (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;\n (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;\n (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;\n (topic: 'presentation'): Promise<Observation<unknown>>;\n (\n topic: 'conversation',\n conversation: string,\n options: ConversationOptions,\n ): Promise<Observation<ConversationView>>;\n };\n reauthorize(): Promise<void>;\n};\n\nexport function connectMdRuntime(port: RuntimePort): MdRuntimeClient {\n let sequence = 0;\n let refusal: ConnectionRefusal | null = null;\n let ended: string | null = null;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const opening = new Map<\n number,\n {\n topic: WireTopic;\n settle: (observation: Observation<unknown>) => void;\n fail: (error: Error) => void;\n }\n >();\n const observations = new Map<number, { topic: WireTopic; handle: Observed }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function begin(id: number, topic: WireTopic, first: unknown): Observation<unknown> {\n const handle = observed(\n first,\n () => {\n observations.delete(id);\n if (refusal === null) send({ kind: 'stop', id });\n },\n topic === 'query',\n );\n observations.set(id, { topic, handle });\n return handle.observation;\n }\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const { topic, handle } of observations.values()) {\n if (topic === 'connection-refusal') handle.receive(reported);\n }\n const failure = new Error(reported.reason);\n for (const [id, waiting] of opening) {\n if (waiting.topic === 'connection-refusal')\n waiting.settle(begin(id, waiting.topic, reported));\n else waiting.fail(failure);\n }\n opening.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n }\n\n function end(reason: string) {\n if (ended !== null) return;\n ended = reason;\n const failure = new Error(reason);\n for (const waiting of opening.values()) waiting.fail(failure);\n opening.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const { handle } of observations.values()) handle.end();\n observations.clear();\n }\n\n port.addEventListener('message', (event) => {\n const wire = carried(event.data);\n if (wire === null) return;\n if (!wire.matching) {\n refuse(PROTOCOL_MISMATCH);\n return;\n }\n const message = answer(wire.message);\n if (message === null) return;\n if (message.kind === 'refusal') {\n refuse(message.refusal);\n return;\n }\n if (message.kind === 'ended') {\n end(AUTHORIZATION_ENDED);\n return;\n }\n if (message.kind === 'event') {\n observations.get(message.id)?.handle.receive(message.value);\n return;\n }\n const waiting = opening.get(message.id);\n if (waiting !== undefined) {\n opening.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(begin(message.id, waiting.topic, message.value));\n return;\n }\n const called = calls.get(message.id);\n if (called === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') called.fail(new Error(message.message));\n else called.settle(message.value);\n });\n port.addEventListener('close', () => {\n end(PORT_CLOSED);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended !== null) return Promise.reject(new Error(ended));\n if (refusal !== null) return Promise.reject(new Error(refusal.reason));\n const id = (sequence += 1);\n return new Promise<T>((settle, fail) => {\n calls.set(id, { settle: settle as (value: unknown) => void, fail });\n send({ kind: 'call', id, member, input });\n });\n }\n\n function watch(topic: WireTopic, input: readonly unknown[]): Promise<Observation<unknown>> {\n if (ended !== null) return Promise.reject(new Error(ended));\n const id = (sequence += 1);\n if (refusal !== null) {\n return topic === 'connection-refusal'\n ? Promise.resolve(begin(id, topic, refusal))\n : Promise.reject(new Error(refusal.reason));\n }\n return new Promise((settle, fail) => {\n opening.set(id, { topic, settle, fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n slots: () => ask<readonly AppSlot[]>('slots', []),\n query: ((query: DocumentQuery | GroupQuery) =>\n ask('query', [query])) as MdRuntimeClient['query'],\n search: (request: SearchRequest) => ask<SearchResult>('search', [request]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n serviceMode: () => ask<ServiceMode>('serviceMode', []),\n roomDraft: {\n list: () => ask<readonly RoomDraft[]>('roomDraft.list', []),\n read: (room: string, path: string) => ask<RoomDraft | null>('roomDraft.read', [room, path]),\n write: (room: string, path: string, revision: string | null, parts: RoomDraftParts) =>\n ask<RoomDraftWrite>('roomDraft.write', [room, path, revision, parts]),\n discard: (room: string, path: string, revision: string) =>\n ask<RoomDraftWrite>('roomDraft.discard', [room, path, revision]),\n },\n save: (room: string, roomDrafts: readonly SavedRoomDraft[]) =>\n ask<SaveResult>('save', [room, roomDrafts]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\n presentation: {\n read: () => ask<unknown>('presentation.read', []),\n write: (value: unknown) => ask<void>('presentation.write', [value]),\n },\n conversation: {\n list: () => ask<readonly ConversationEntry[]>('conversation.list', []),\n read: (conversation: string, options?: ConversationOptions) =>\n ask<ConversationView>('conversation.read', [conversation, options]),\n create: (input: unknown) => ask<CallResult>('conversation.create', [input]),\n send: (conversation: string) => ask<CallResult>('conversation.send', [conversation]),\n answer: (conversation: string, answer: unknown) =>\n ask<CallResult>('conversation.answer', [conversation, answer]),\n interrupt: (conversation: string) =>\n ask<CallResult>('conversation.interrupt', [conversation]),\n kill: (conversation: string) => ask<CallResult>('conversation.kill', [conversation]),\n cancel: (conversation: string, turn: string) =>\n ask<CallResult>('conversation.cancel', [conversation, turn]),\n delete: (conversation: string) => ask<CallResult>('conversation.delete', [conversation]),\n },\n chatDraft: {\n write: (conversation: string, draft: ChatDraft) =>\n ask<void>('chatDraft.write', [conversation, draft]),\n discard: (conversation: string) => ask<void>('chatDraft.discard', [conversation]),\n },\n history: (locator: string, path: string, query?: HistoryQuery) =>\n ask<HistoryResult>('history', [locator, path, query]),\n call: (name: string, input: unknown) => ask<CallResult>('call', [name, input]),\n log: () => ask<string>('log', []),\n storageLoss: () => ask<string | null>('storageLoss', []),\n persistence: () => ask<boolean>('persistence', []),\n deploymentFacts: () => ask<unknown>('deploymentFacts', []),\n observe: ((topic: WireTopic, ...input: unknown[]) =>\n watch(topic, input)) as MdRuntimeClient['observe'],\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { Observation } from './observation.js';\nexport type { RuntimePort } from './wire.js';\n"],"names":["observed","answer","AUTHORIZATION_ENDED","carried","envelope","PORT_CLOSED","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","opening","observations","send","message","postMessage","begin","id","topic","first","handle","delete","kind","set","observation","refuse","reported","values","receive","failure","Error","reason","waiting","settle","fail","clear","end","addEventListener","event","wire","data","matching","get","value","undefined","called","start","ask","member","input","Promise","reject","watch","resolve","rooms","slots","query","search","request","types","locator","syncStatus","serviceMode","roomDraft","list","read","room","path","write","revision","parts","discard","save","roomDrafts","outcome","identifier","presentation","conversation","options","create","interrupt","kill","cancel","turn","chatDraft","draft","history","call","name","log","storageLoss","persistence","deploymentFacts","observe","reauthorize"],"mappings":"AAgBA,SAASA,QAAQ,QAAyC,mBAAmB;AAM7E,SACEC,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,iBAAiB,QAKZ,YAAY;AAwEnB,OAAO,SAASC,iBAAiBC,IAAiB;IAChD,IAAIC,WAAW;IACf,IAAIC,UAAoC;IACxC,IAAIC,QAAuB;IAC3B,MAAMC,QAAQ,IAAIC;IAIlB,MAAMC,UAAU,IAAID;IAQpB,MAAME,eAAe,IAAIF;IAEzB,MAAMG,OAAO,CAACC;QACZT,KAAKU,WAAW,CAACd,SAASa;IAC5B;IAEA,SAASE,MAAMC,EAAU,EAAEC,KAAgB,EAAEC,KAAc;QACzD,MAAMC,SAASvB,SACbsB,OACA;YACEP,aAAaS,MAAM,CAACJ;YACpB,IAAIV,YAAY,MAAMM,KAAK;gBAAES,MAAM;gBAAQL;YAAG;QAChD,GACAC,UAAU;QAEZN,aAAaW,GAAG,CAACN,IAAI;YAAEC;YAAOE;QAAO;QACrC,OAAOA,OAAOI,WAAW;IAC3B;IAEA,SAASC,OAAOC,QAA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