@agentshouse/mdruntime 0.1.0-c8c4b020a3ec7 → 0.1.0-c99e5271060cd
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 +94 -33
- package/README.md +10 -10
- package/dist/adapter.d.ts +92 -46
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +1 -9
- package/dist/attached-model.d.ts +11 -0
- package/dist/attached-model.d.ts.map +1 -0
- package/dist/attached-model.js +47 -0
- package/dist/bootstrap.d.ts +20 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +89 -35
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +13 -7
- package/dist/change.d.ts +4 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/client.d.ts +8 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +57 -24
- package/dist/collection.d.ts +6 -11
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +56 -19
- package/dist/connection.d.ts +20 -16
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +699 -578
- package/dist/conversation.d.ts +23 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +252 -106
- package/dist/failure.d.ts +13 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +19 -0
- package/dist/host.d.ts +8 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +38 -38
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +7 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +12 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +108 -36
- package/dist/model.d.ts +13 -12
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -3
- package/dist/observation.d.ts +2 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +24 -14
- package/dist/open.d.ts +2 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +1 -0
- package/dist/outcome.d.ts +22 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +35 -1
- package/dist/overlay.d.ts +1 -1
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +19 -15
- package/dist/paths.d.ts +0 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +0 -16
- package/dist/query.d.ts +10 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +78 -36
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +272 -0
- package/dist/react.d.ts +40 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +64 -0
- package/dist/read-side.d.ts +4 -0
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +116 -54
- package/dist/refresh.d.ts +12 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +35 -22
- package/dist/replica.d.ts +6 -6
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +53 -39
- package/dist/room-draft.d.ts +11 -8
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +19 -26
- package/dist/rows.d.ts +4 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +82 -39
- package/dist/save.d.ts +4 -3
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +127 -68
- package/dist/search.d.ts +3 -2
- package/dist/search.d.ts.map +1 -1
- package/dist/status.d.ts +2 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +25 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +206 -90
- package/dist/wire.d.ts +55 -19
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +62 -61
- package/package.json +14 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { verify } from '@agentshouse/mdmodel';
|
|
2
|
+
import { MD_MODEL } from './collection.js';
|
|
3
|
+
import { sameModel } from './model.js';
|
|
4
|
+
const EMPTY_SCHEMA = { verdict: 'accept', model: { types: {} } };
|
|
5
|
+
export function attachedModel(answer, previous) {
|
|
6
|
+
if (answer.kind === 'model-unavailable') {
|
|
7
|
+
return { state: { status: 'unavailable', reason: answer.reason }, refused: null };
|
|
8
|
+
}
|
|
9
|
+
if (previous.status !== 'unavailable' &&
|
|
10
|
+
sameModel(previous.snapshot, answer.snapshot) &&
|
|
11
|
+
previous.snapshot.schema !== answer.snapshot.schema) {
|
|
12
|
+
return {
|
|
13
|
+
state: {
|
|
14
|
+
status: 'unavailable',
|
|
15
|
+
reason: 'invalid',
|
|
16
|
+
schema: answer.snapshot.schema,
|
|
17
|
+
revision: answer.snapshot.revision,
|
|
18
|
+
},
|
|
19
|
+
refused: null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const verified = answer.snapshot.schema === null ? EMPTY_SCHEMA : verify(answer.snapshot.schema);
|
|
23
|
+
if (verified.verdict === 'refuse') {
|
|
24
|
+
return {
|
|
25
|
+
state: {
|
|
26
|
+
status: 'unavailable',
|
|
27
|
+
reason: 'invalid',
|
|
28
|
+
schema: answer.snapshot.schema,
|
|
29
|
+
revision: answer.snapshot.revision,
|
|
30
|
+
},
|
|
31
|
+
refused: {
|
|
32
|
+
identity: answer.snapshot.identity,
|
|
33
|
+
rule: verified.rule,
|
|
34
|
+
...(verified.location === undefined ? {} : { location: verified.location }),
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
state: {
|
|
40
|
+
status: 'current',
|
|
41
|
+
snapshot: structuredClone(answer.snapshot),
|
|
42
|
+
verifiedWith: MD_MODEL,
|
|
43
|
+
types: verified.model.types,
|
|
44
|
+
},
|
|
45
|
+
refused: null,
|
|
46
|
+
};
|
|
47
|
+
}
|
package/dist/bootstrap.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import type { ModelState } from './model.js';
|
|
2
|
-
import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom } from './adapter.js';
|
|
3
|
-
import { type
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export
|
|
2
|
+
import type { Adapter, AdapterFailure, Authorization, DiscoveredRoom, RetryableRefusal, RoomModels } from './adapter.js';
|
|
3
|
+
import { type ConfirmedLayer } from './replica.js';
|
|
4
|
+
import type { StagedLayer, TransferRecord } from './store.js';
|
|
5
|
+
import { type Refused, type Unconfirmed } from './transfer.js';
|
|
6
|
+
export type Bootstrapped = {
|
|
7
|
+
kind: 'staged';
|
|
8
|
+
confirmed: ConfirmedLayer;
|
|
9
|
+
stored: StagedLayer;
|
|
10
|
+
};
|
|
11
|
+
export type BootstrapOutcome = Bootstrapped | Refused | Unconfirmed | RetryableRefusal | AdapterFailure;
|
|
12
|
+
export type HeldModels = {
|
|
7
13
|
collection: ModelState;
|
|
8
14
|
selection: ModelState;
|
|
9
|
-
}
|
|
15
|
+
};
|
|
16
|
+
export type Remodel = (models: RoomModels | undefined, held: HeldModels) => HeldModels;
|
|
17
|
+
export type Staging = {
|
|
18
|
+
held(locator: string): TransferRecord | null;
|
|
19
|
+
staged(record: TransferRecord): Promise<StagedLayer>;
|
|
20
|
+
stage(record: TransferRecord, page: StagedLayer): Promise<boolean>;
|
|
21
|
+
abandon(locator: string): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export declare function bootstrapRoom(adapter: Adapter, authorization: Authorization, room: DiscoveredRoom, held: HeldModels, remodel: Remodel, continuing: () => boolean, staging: Staging): Promise<BootstrapOutcome>;
|
|
10
24
|
//# sourceMappingURL=bootstrap.d.ts.map
|
package/dist/bootstrap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,
|
|
1
|
+
{"version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AAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,OAAO,EACzB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,gBAAgB,CAAC,CA4E3B"}
|
package/dist/bootstrap.js
CHANGED
|
@@ -1,56 +1,110 @@
|
|
|
1
1
|
import { declaredAttachments } from './attachment.js';
|
|
2
|
+
import { transferIdentity } from './identity.js';
|
|
3
|
+
import { advancement } from './refresh.js';
|
|
2
4
|
import { readStaged } from './replica.js';
|
|
3
5
|
import { unconfirmed } from './transfer.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
const RESUMABLE = new Set([
|
|
7
|
+
'transport-uncertainty',
|
|
8
|
+
'retryable-refusal',
|
|
9
|
+
'unconfirmed',
|
|
10
|
+
]);
|
|
11
|
+
function pageLayer(page) {
|
|
12
|
+
return {
|
|
13
|
+
documents: page.documents,
|
|
14
|
+
revisions: page.revisions,
|
|
15
|
+
changes: page.changes,
|
|
16
|
+
written: Object.fromEntries(Object.keys(page.documents).map((path) => [path, page.roomVersion])),
|
|
17
|
+
binaryTargets: page.binaryTargets,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
async function heldTransfer(staging, room) {
|
|
21
|
+
const record = staging.held(room.locator);
|
|
22
|
+
if (record === null)
|
|
23
|
+
return null;
|
|
24
|
+
if (record.selection === room.replica.selection) {
|
|
25
|
+
return { record, layer: await staging.staged(record) };
|
|
26
|
+
}
|
|
27
|
+
await staging.abandon(room.locator);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export async function bootstrapRoom(adapter, authorization, room, held, remodel, continuing, staging) {
|
|
31
|
+
const locator = room.locator;
|
|
32
|
+
const selection = room.replica.selection;
|
|
33
|
+
const kept = await heldTransfer(staging, room);
|
|
34
|
+
const documents = { ...kept?.layer.documents };
|
|
35
|
+
const revisions = { ...kept?.layer.revisions };
|
|
36
|
+
const changes = { ...kept?.layer.changes };
|
|
37
|
+
const written = { ...kept?.layer.written };
|
|
38
|
+
const binaryTargets = new Set(kept?.layer.binaryTargets);
|
|
39
|
+
let transfer = kept?.record ?? null;
|
|
40
|
+
while (transfer === null || transfer.pageToken !== null) {
|
|
19
41
|
if (!continuing())
|
|
20
42
|
return unconfirmed;
|
|
21
43
|
const page = await adapter.bootstrap(authorization, {
|
|
22
|
-
locator
|
|
23
|
-
selection
|
|
24
|
-
pageToken,
|
|
44
|
+
locator,
|
|
45
|
+
selection,
|
|
46
|
+
...(transfer?.pageToken == null ? {} : { pageToken: transfer.pageToken }),
|
|
25
47
|
});
|
|
26
|
-
if (page.kind !== 'bootstrap')
|
|
48
|
+
if (page.kind !== 'bootstrap') {
|
|
49
|
+
if (!RESUMABLE.has(page.kind))
|
|
50
|
+
await staging.abandon(locator);
|
|
27
51
|
return page;
|
|
28
|
-
|
|
52
|
+
}
|
|
53
|
+
transfer = {
|
|
54
|
+
locator,
|
|
55
|
+
transfer: transfer?.transfer ?? transferIdentity(),
|
|
56
|
+
selection,
|
|
57
|
+
from: transfer?.from ?? page.roomVersion,
|
|
58
|
+
last: page.roomVersion,
|
|
59
|
+
pageToken: page.pageToken ?? null,
|
|
60
|
+
models: remodel(page.models, transfer?.models ?? held),
|
|
61
|
+
attachments: [...(transfer?.attachments ?? []), page.attachments ?? []],
|
|
62
|
+
};
|
|
63
|
+
const staged = pageLayer(page);
|
|
64
|
+
if (!(await staging.stage(transfer, staged)))
|
|
29
65
|
return unconfirmed;
|
|
30
|
-
Object.assign(documents,
|
|
31
|
-
Object.assign(revisions,
|
|
32
|
-
Object.assign(changes,
|
|
33
|
-
|
|
66
|
+
Object.assign(documents, staged.documents);
|
|
67
|
+
Object.assign(revisions, staged.revisions);
|
|
68
|
+
Object.assign(changes, staged.changes);
|
|
69
|
+
Object.assign(written, staged.written);
|
|
70
|
+
for (const target of staged.binaryTargets)
|
|
34
71
|
binaryTargets.add(target);
|
|
35
|
-
attachments.push(page.attachments ?? []);
|
|
36
|
-
pageToken = page.pageToken;
|
|
37
72
|
}
|
|
38
|
-
|
|
39
|
-
locator
|
|
73
|
+
const record = {
|
|
74
|
+
locator,
|
|
40
75
|
name: room.name,
|
|
76
|
+
handle: room.handle,
|
|
41
77
|
operations: room.operations,
|
|
42
78
|
replica: room.replica,
|
|
43
|
-
|
|
44
|
-
model: models.collection,
|
|
79
|
+
model: transfer.models.collection,
|
|
45
80
|
typedSelection: room.typedSelection ?? null,
|
|
46
|
-
selectionModel: models.selection,
|
|
81
|
+
selectionModel: transfer.models.selection,
|
|
47
82
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
48
|
-
roomVersion,
|
|
83
|
+
roomVersion: transfer.from,
|
|
84
|
+
transfer: transfer.transfer,
|
|
49
85
|
documents,
|
|
50
86
|
binaryTargets: [...binaryTargets].sort(),
|
|
51
87
|
revisions,
|
|
52
88
|
changes,
|
|
53
|
-
written
|
|
54
|
-
attachments: declaredAttachments(attachments),
|
|
55
|
-
}
|
|
89
|
+
written,
|
|
90
|
+
attachments: declaredAttachments(transfer.attachments),
|
|
91
|
+
};
|
|
92
|
+
const reconciled = transfer.last === transfer.from
|
|
93
|
+
? { kind: 'still-current' }
|
|
94
|
+
: await advancement(adapter, authorization, record, remodel, continuing);
|
|
95
|
+
if (reconciled.kind === 'advanced' || reconciled.kind === 'still-current') {
|
|
96
|
+
const read = readStaged(reconciled.kind === 'advanced' ? reconciled.record : record);
|
|
97
|
+
if (read.kind === 'refused') {
|
|
98
|
+
await staging.abandon(locator);
|
|
99
|
+
return read;
|
|
100
|
+
}
|
|
101
|
+
return { kind: 'staged', confirmed: read.confirmed, stored: record };
|
|
102
|
+
}
|
|
103
|
+
if (reconciled.kind === 'beyond-horizon') {
|
|
104
|
+
await staging.abandon(locator);
|
|
105
|
+
return unconfirmed;
|
|
106
|
+
}
|
|
107
|
+
if (!RESUMABLE.has(reconciled.kind))
|
|
108
|
+
await staging.abandon(locator);
|
|
109
|
+
return reconciled;
|
|
56
110
|
}
|
package/dist/change-set.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"change-set.d.ts","sourceRoot":"","sources":["../src/change-set.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAwB,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAE3D,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;AAqBF,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,CAqDX;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"}
|
package/dist/change-set.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import { passingDocument } from './collection.js';
|
|
1
2
|
import { sameChange } from './overlay.js';
|
|
2
3
|
import { beneath } from './paths.js';
|
|
3
4
|
import { compositionOf, sameMembership } from './replica.js';
|
|
4
|
-
import { rowsOf } from './rows.js';
|
|
5
|
+
import { markdownPath, rowsOf } from './rows.js';
|
|
5
6
|
function rowsAt(locator, replica, path) {
|
|
6
7
|
if (replica === null)
|
|
7
8
|
return [];
|
|
8
|
-
const
|
|
9
|
-
|
|
9
|
+
const visible = replica.visible;
|
|
10
|
+
const document = markdownPath(path) ? passingDocument(visible.collection, path) : null;
|
|
11
|
+
const held = visible.documents[path] !== undefined && document !== undefined;
|
|
12
|
+
if (!held && !visible.binaryTargets.includes(path))
|
|
10
13
|
return [];
|
|
11
|
-
|
|
12
|
-
return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record), replica.visible.changes[path] ?? null);
|
|
14
|
+
return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record), visible.changes[path] ?? null);
|
|
13
15
|
}
|
|
14
16
|
function modelShape(model) {
|
|
15
17
|
return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
|
|
@@ -45,8 +47,12 @@ export function changeSet(locator, before, after, changed = {}) {
|
|
|
45
47
|
documents.push({
|
|
46
48
|
locator,
|
|
47
49
|
path,
|
|
48
|
-
before
|
|
49
|
-
|
|
50
|
+
get before() {
|
|
51
|
+
return rowsAt(locator, before, path);
|
|
52
|
+
},
|
|
53
|
+
get after() {
|
|
54
|
+
return rowsAt(locator, after, path);
|
|
55
|
+
},
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
return {
|
package/dist/change.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export type Precondition = {
|
|
|
51
51
|
readonly kind: 'revision';
|
|
52
52
|
readonly path: string;
|
|
53
53
|
readonly revision: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: 'content';
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly content: string;
|
|
54
58
|
} | {
|
|
55
59
|
readonly kind: 'present';
|
|
56
60
|
readonly path: string;
|
package/dist/change.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC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E,iBAAiB,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,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/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { AppRoom, ConnectionRefusal, HistoryQuery,
|
|
2
|
-
import type {
|
|
1
|
+
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
|
+
import type { Member, ServiceMode } from './adapter.js';
|
|
3
3
|
import type { ChatDraft, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
4
|
import { type Observation } from './observation.js';
|
|
5
|
-
import type { CallResult, QueueEntry } from './outcome.js';
|
|
5
|
+
import type { CallResult, HistoryAnswer, QueueEntry } from './outcome.js';
|
|
6
6
|
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
|
|
7
7
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
8
8
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
@@ -15,7 +15,7 @@ export type MdRuntimeClient = {
|
|
|
15
15
|
(query: GroupQuery): Promise<GroupResult>;
|
|
16
16
|
};
|
|
17
17
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
18
|
-
types(locator: string): Promise<
|
|
18
|
+
types(locator: string): Promise<RoomSchemas>;
|
|
19
19
|
roomDraft: {
|
|
20
20
|
list(): Promise<readonly RoomDraft[]>;
|
|
21
21
|
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
@@ -42,7 +42,7 @@ export type MdRuntimeClient = {
|
|
|
42
42
|
write(conversation: string, draft: ChatDraft): Promise<void>;
|
|
43
43
|
discard(conversation: string): Promise<void>;
|
|
44
44
|
};
|
|
45
|
-
history(locator: string, path: string, query?: HistoryQuery): Promise<
|
|
45
|
+
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
46
46
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
47
47
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
48
48
|
log(): Promise<string>;
|
|
@@ -54,14 +54,17 @@ export type MdRuntimeClient = {
|
|
|
54
54
|
(topic: 'storage-loss'): Promise<Observation<string | null>>;
|
|
55
55
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
56
56
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
57
|
+
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
57
58
|
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
|
|
58
59
|
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
|
|
59
60
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
60
61
|
(topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
|
|
61
62
|
(topic: 'presentation'): Promise<Observation<unknown>>;
|
|
62
63
|
(topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
|
|
64
|
+
(topic: 'conversations'): Promise<Observation<readonly ConversationEntry[]>>;
|
|
63
65
|
};
|
|
64
66
|
reauthorize(): Promise<void>;
|
|
67
|
+
settled(): Promise<void>;
|
|
65
68
|
};
|
|
66
69
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
67
70
|
export type { Observation } from './observation.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,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AI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAMF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CA6MnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { observed } from './observation.js';
|
|
2
|
-
import {
|
|
2
|
+
import { runtimeError } from './failure.js';
|
|
3
|
+
import { answer, AUTHORIZATION_ENDED, PORT_CLOSED, } from './wire.js';
|
|
4
|
+
function refused(refusal) {
|
|
5
|
+
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
6
|
+
}
|
|
3
7
|
export function connectMdRuntime(port) {
|
|
4
8
|
let sequence = 0;
|
|
5
9
|
let refusal = null;
|
|
@@ -7,8 +11,10 @@ export function connectMdRuntime(port) {
|
|
|
7
11
|
const calls = new Map();
|
|
8
12
|
const opening = new Map();
|
|
9
13
|
const observations = new Map();
|
|
14
|
+
let drawing = null;
|
|
15
|
+
let settling = null;
|
|
10
16
|
const send = (message) => {
|
|
11
|
-
port.postMessage(
|
|
17
|
+
port.postMessage(message);
|
|
12
18
|
};
|
|
13
19
|
function begin(id, topic, first) {
|
|
14
20
|
const handle = observed(first, () => {
|
|
@@ -25,7 +31,7 @@ export function connectMdRuntime(port) {
|
|
|
25
31
|
if (topic === 'connection-refusal')
|
|
26
32
|
handle.receive(reported);
|
|
27
33
|
}
|
|
28
|
-
const failure =
|
|
34
|
+
const failure = refused(reported);
|
|
29
35
|
for (const [id, waiting] of opening) {
|
|
30
36
|
if (waiting.topic === 'connection-refusal')
|
|
31
37
|
waiting.settle(begin(id, waiting.topic, reported));
|
|
@@ -36,12 +42,12 @@ export function connectMdRuntime(port) {
|
|
|
36
42
|
for (const waiting of calls.values())
|
|
37
43
|
waiting.fail(failure);
|
|
38
44
|
calls.clear();
|
|
45
|
+
drawing?.();
|
|
39
46
|
}
|
|
40
|
-
function end(
|
|
47
|
+
function end(failure) {
|
|
41
48
|
if (ended !== null)
|
|
42
49
|
return;
|
|
43
|
-
ended =
|
|
44
|
-
const failure = new Error(reason);
|
|
50
|
+
ended = failure;
|
|
45
51
|
for (const waiting of opening.values())
|
|
46
52
|
waiting.fail(failure);
|
|
47
53
|
opening.clear();
|
|
@@ -51,16 +57,10 @@ export function connectMdRuntime(port) {
|
|
|
51
57
|
for (const { handle } of observations.values())
|
|
52
58
|
handle.end();
|
|
53
59
|
observations.clear();
|
|
60
|
+
drawing?.();
|
|
54
61
|
}
|
|
55
62
|
port.addEventListener('message', (event) => {
|
|
56
|
-
const
|
|
57
|
-
if (wire === null)
|
|
58
|
-
return;
|
|
59
|
-
if (!wire.matching) {
|
|
60
|
-
refuse(PROTOCOL_MISMATCH);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const message = answer(wire.message);
|
|
63
|
+
const message = answer(event.data);
|
|
64
64
|
if (message === null)
|
|
65
65
|
return;
|
|
66
66
|
if (message.kind === 'refusal') {
|
|
@@ -68,7 +68,11 @@ export function connectMdRuntime(port) {
|
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
70
|
if (message.kind === 'ended') {
|
|
71
|
-
|
|
71
|
+
for (const { topic, handle } of observations.values()) {
|
|
72
|
+
if (topic === 'member')
|
|
73
|
+
handle.receive(null);
|
|
74
|
+
}
|
|
75
|
+
end(runtimeError('authorization-ended', AUTHORIZATION_ENDED));
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
74
78
|
if (message.kind === 'event') {
|
|
@@ -78,31 +82,34 @@ export function connectMdRuntime(port) {
|
|
|
78
82
|
const waiting = opening.get(message.id);
|
|
79
83
|
if (waiting !== undefined) {
|
|
80
84
|
opening.delete(message.id);
|
|
81
|
-
if (message.kind === 'failure')
|
|
82
|
-
waiting.fail(
|
|
85
|
+
if (message.kind === 'failure') {
|
|
86
|
+
waiting.fail(runtimeError(message.code, message.message, message.retryable));
|
|
87
|
+
}
|
|
83
88
|
else
|
|
84
89
|
waiting.settle(begin(message.id, waiting.topic, message.value));
|
|
90
|
+
drawing?.();
|
|
85
91
|
return;
|
|
86
92
|
}
|
|
87
93
|
const called = calls.get(message.id);
|
|
88
94
|
if (called === undefined)
|
|
89
95
|
return;
|
|
90
96
|
calls.delete(message.id);
|
|
91
|
-
if (message.kind === 'failure')
|
|
92
|
-
called.fail(
|
|
97
|
+
if (message.kind === 'failure') {
|
|
98
|
+
called.fail(runtimeError(message.code, message.message, message.retryable));
|
|
99
|
+
}
|
|
93
100
|
else
|
|
94
101
|
called.settle(message.value);
|
|
95
102
|
});
|
|
96
103
|
port.addEventListener('close', () => {
|
|
97
|
-
end(PORT_CLOSED);
|
|
104
|
+
end(runtimeError('port-closed', PORT_CLOSED));
|
|
98
105
|
});
|
|
99
106
|
port.start();
|
|
100
107
|
send({ kind: 'hello' });
|
|
101
108
|
function ask(member, input) {
|
|
102
109
|
if (ended !== null)
|
|
103
|
-
return Promise.reject(
|
|
110
|
+
return Promise.reject(ended);
|
|
104
111
|
if (refusal !== null)
|
|
105
|
-
return Promise.reject(
|
|
112
|
+
return Promise.reject(refused(refusal));
|
|
106
113
|
const id = (sequence += 1);
|
|
107
114
|
return new Promise((settle, fail) => {
|
|
108
115
|
calls.set(id, { settle: settle, fail });
|
|
@@ -111,17 +118,42 @@ export function connectMdRuntime(port) {
|
|
|
111
118
|
}
|
|
112
119
|
function watch(topic, input) {
|
|
113
120
|
if (ended !== null)
|
|
114
|
-
return Promise.reject(
|
|
121
|
+
return Promise.reject(ended);
|
|
115
122
|
const id = (sequence += 1);
|
|
116
123
|
if (refusal !== null) {
|
|
117
124
|
return topic === 'connection-refusal'
|
|
118
125
|
? Promise.resolve(begin(id, topic, refusal))
|
|
119
|
-
: Promise.reject(
|
|
126
|
+
: Promise.reject(refused(refusal));
|
|
120
127
|
}
|
|
121
128
|
return new Promise((settle, fail) => {
|
|
122
129
|
opening.set(id, { topic, settle, fail });
|
|
123
130
|
send({ kind: 'observe', id, topic, input });
|
|
131
|
+
drawing?.();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function settled() {
|
|
135
|
+
if (settling !== null)
|
|
136
|
+
return settling;
|
|
137
|
+
settling = new Promise((resolve) => {
|
|
138
|
+
let moved = 0;
|
|
139
|
+
const check = () => {
|
|
140
|
+
moved += 1;
|
|
141
|
+
if (opening.size > 0)
|
|
142
|
+
return;
|
|
143
|
+
const at = moved;
|
|
144
|
+
requestAnimationFrame(() => {
|
|
145
|
+
requestAnimationFrame(() => {
|
|
146
|
+
if (moved !== at || opening.size > 0)
|
|
147
|
+
return;
|
|
148
|
+
drawing = null;
|
|
149
|
+
resolve();
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
drawing = check;
|
|
154
|
+
check();
|
|
124
155
|
});
|
|
156
|
+
return settling;
|
|
125
157
|
}
|
|
126
158
|
return {
|
|
127
159
|
rooms: () => ask('rooms', []),
|
|
@@ -161,5 +193,6 @@ export function connectMdRuntime(port) {
|
|
|
161
193
|
persistence: () => ask('persistence', []),
|
|
162
194
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
163
195
|
reauthorize: () => ask('reauthorize', []),
|
|
196
|
+
settled,
|
|
164
197
|
};
|
|
165
198
|
}
|
package/dist/collection.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { MdModelIdentity } from './adapter.js';
|
|
|
4
4
|
import type { Refused } from './transfer.js';
|
|
5
5
|
export declare const MD_MODEL: MdModelIdentity;
|
|
6
6
|
export type Collection = {
|
|
7
|
-
|
|
7
|
+
text: Readonly<Record<string, string>>;
|
|
8
8
|
composition: Composition;
|
|
9
|
+
document(path: string): Document | undefined;
|
|
9
10
|
};
|
|
10
11
|
export type Composition = {
|
|
11
12
|
model: ModelState;
|
|
@@ -15,16 +16,10 @@ export type Composition = {
|
|
|
15
16
|
} | null;
|
|
16
17
|
};
|
|
17
18
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export declare function parseCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: Previous): Collection;
|
|
23
|
-
export declare function readCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: Previous): {
|
|
24
|
-
kind: 'read';
|
|
25
|
-
collection: Collection;
|
|
26
|
-
} | Refused;
|
|
19
|
+
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition, previous?: Collection): Collection;
|
|
20
|
+
export declare function passingDocument(collection: Collection, path: string): Document | undefined;
|
|
21
|
+
export declare function documentsOf(collection: Collection): Generator<readonly [string, Document]>;
|
|
22
|
+
export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
|
|
27
23
|
export declare function validRoot(root: unknown): root is string;
|
|
28
24
|
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
|
|
29
|
-
export {};
|
|
30
25
|
//# 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,EAIL,KAAK,QAAQ,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAIhG,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,E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