@agentshouse/mdruntime 0.1.0-c3903a68dcbbf → 0.1.0-c5b50992a4193
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 +75 -41
- package/README.md +11 -11
- package/dist/adapter.d.ts +81 -51
- 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 +5 -3
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +3 -3
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +2 -6
- package/dist/client.d.ts +4 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3 -16
- package/dist/collection.d.ts +0 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +2 -12
- package/dist/connection.d.ts +11 -28
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +535 -643
- package/dist/conversation.d.ts +22 -11
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +250 -105
- package/dist/host.d.ts +7 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +37 -57
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/memory.d.ts +11 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +84 -27
- package/dist/model.d.ts +11 -11
- 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/outcome.d.ts +5 -21
- package/dist/outcome.d.ts.map +1 -1
- 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 +8 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +75 -36
- package/dist/reach.d.ts +40 -0
- package/dist/reach.d.ts.map +1 -0
- package/dist/reach.js +270 -0
- package/dist/react.d.ts +32 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +62 -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 +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +7 -3
- package/dist/replica.d.ts +5 -5
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +16 -21
- package/dist/room-draft.d.ts +3 -0
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +6 -4
- package/dist/rows.d.ts +2 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +75 -38
- package/dist/save.d.ts +1 -2
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +92 -51
- package/dist/store.d.ts +6 -16
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +10 -32
- package/dist/wire.d.ts +51 -16
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +50 -65
- package/package.json +14 -2
package/dist/save.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { definitionOf } from './model.js';
|
|
2
|
-
import { apply, links, parse, retarget, serialize, target, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { apply, ATTACHMENT, links, parse, pointerSegments, references, relative, relativize, retarget, serialize, target, } from '@agentshouse/mdmodel';
|
|
3
3
|
import { immutable, } from './change.js';
|
|
4
|
-
import { governing,
|
|
4
|
+
import { governing, parseCollection, validateCollection, } from './collection.js';
|
|
5
5
|
import { changeBatchIdentity } from './identity.js';
|
|
6
6
|
import { overlay } from './overlay.js';
|
|
7
|
-
import { covered, normalize
|
|
7
|
+
import { covered, normalize } from './paths.js';
|
|
8
8
|
function refuse(rule, file, location) {
|
|
9
9
|
return {
|
|
10
10
|
kind: 'refused',
|
|
@@ -15,21 +15,34 @@ function refuse(rule, file, location) {
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
function repointed(document, definition, from, to, moves, settled) {
|
|
19
|
+
const parsed = parse(document.content, from);
|
|
20
|
+
if (!parsed.ok)
|
|
21
|
+
return [];
|
|
22
|
+
let next = parsed.document;
|
|
23
|
+
const names = new Set();
|
|
24
|
+
for (const { pointer, value } of definition === undefined
|
|
25
|
+
? []
|
|
26
|
+
: references(document, definition)) {
|
|
27
|
+
const [name = ''] = pointerSegments(pointer);
|
|
28
|
+
const named = target(from, value);
|
|
29
|
+
if (named === null || settled.has(`${from} ${name}`))
|
|
30
|
+
continue;
|
|
31
|
+
const destination = moves.get(named) ?? named;
|
|
32
|
+
if (target(to, value) === destination)
|
|
33
|
+
continue;
|
|
34
|
+
const applied = apply(next, {
|
|
35
|
+
kind: 'reference',
|
|
36
|
+
pointer,
|
|
37
|
+
value: retarget(value, relative(to, destination)),
|
|
38
|
+
prior: value,
|
|
39
|
+
});
|
|
40
|
+
if (applied.outcome !== 'applied')
|
|
41
|
+
continue;
|
|
42
|
+
next = applied.document;
|
|
43
|
+
names.add(name);
|
|
25
44
|
}
|
|
26
|
-
|
|
27
|
-
return undefined;
|
|
28
|
-
const named = target(from, value);
|
|
29
|
-
if (named === null)
|
|
30
|
-
return undefined;
|
|
31
|
-
const destination = moves.get(named) ?? named;
|
|
32
|
-
return target(to, value) === destination ? undefined : retarget(value, relative(to, destination));
|
|
45
|
+
return [...names].map((name) => ({ kind: 'field', path: from, name, value: next.fields[name] }));
|
|
33
46
|
}
|
|
34
47
|
function edited(document, path, changes) {
|
|
35
48
|
let next = document;
|
|
@@ -122,14 +135,7 @@ function rewrites(changes, visible) {
|
|
|
122
135
|
continue;
|
|
123
136
|
const moved = moves.get(path) ?? path;
|
|
124
137
|
const definition = definitionOf(governing(visible.collection.composition, path), document.type);
|
|
125
|
-
|
|
126
|
-
if (!referenceField(spec) || settled.has(`${path} ${name}`))
|
|
127
|
-
continue;
|
|
128
|
-
const value = repointed(document.fields[name], path, moved, moves);
|
|
129
|
-
if (value === undefined)
|
|
130
|
-
continue;
|
|
131
|
-
added.push({ kind: 'field', path, name, value });
|
|
132
|
-
}
|
|
138
|
+
added.push(...repointed(document, definition, path, moved, moves, settled));
|
|
133
139
|
const relinked = relinks(path, moved, edited(document, path, merged), moves);
|
|
134
140
|
if (relinked.kind === 'refused')
|
|
135
141
|
return relinked;
|
|
@@ -166,18 +172,6 @@ export function providerRewritten(batch, visible) {
|
|
|
166
172
|
...anticipated(batch.changes, batch.preconditions, rewritten.changes, visible),
|
|
167
173
|
};
|
|
168
174
|
}
|
|
169
|
-
function targets(value, from) {
|
|
170
|
-
const values = Array.isArray(value) ? value : [value];
|
|
171
|
-
const resolved = [];
|
|
172
|
-
for (const item of values) {
|
|
173
|
-
if (typeof item !== 'string')
|
|
174
|
-
continue;
|
|
175
|
-
const named = target(from, item);
|
|
176
|
-
if (named !== null)
|
|
177
|
-
resolved.push(named);
|
|
178
|
-
}
|
|
179
|
-
return resolved;
|
|
180
|
-
}
|
|
181
175
|
function incoming(collection, removed) {
|
|
182
176
|
const found = new Map();
|
|
183
177
|
const note = (target, file) => {
|
|
@@ -189,14 +183,13 @@ function incoming(collection, removed) {
|
|
|
189
183
|
};
|
|
190
184
|
for (const [path, document] of Object.entries(collection.documents)) {
|
|
191
185
|
const definition = definitionOf(governing(collection.composition, path), document.type);
|
|
192
|
-
for (const
|
|
193
|
-
if (
|
|
186
|
+
for (const { value, to } of definition === undefined ? [] : references(document, definition)) {
|
|
187
|
+
if (to.includes(ATTACHMENT))
|
|
194
188
|
continue;
|
|
195
|
-
|
|
189
|
+
const named = target(path, value);
|
|
190
|
+
if (named !== null)
|
|
196
191
|
note(named, path);
|
|
197
192
|
}
|
|
198
|
-
for (const link of links(document, path))
|
|
199
|
-
note(link.target, path);
|
|
200
193
|
}
|
|
201
194
|
const [first] = [...found.keys()].sort();
|
|
202
195
|
if (first === undefined)
|
|
@@ -368,26 +361,75 @@ function exceeded(limits, changes, resulting) {
|
|
|
368
361
|
}
|
|
369
362
|
return null;
|
|
370
363
|
}
|
|
364
|
+
function shellRelative(text, path, handle, definition) {
|
|
365
|
+
if (!text.includes(`/rooms/${handle}/`))
|
|
366
|
+
return null;
|
|
367
|
+
const parsed = parse(text, path);
|
|
368
|
+
if (!parsed.ok)
|
|
369
|
+
return null;
|
|
370
|
+
const result = relativize(parsed.document, path, handle, definition(parsed.document.type));
|
|
371
|
+
return result.outcome === 'applied' && result.document.content !== text ? result.document : null;
|
|
372
|
+
}
|
|
373
|
+
function relativeField(path, name, value, handle, definition) {
|
|
374
|
+
const opened = parse('---\n---\n');
|
|
375
|
+
if (definition === undefined ||
|
|
376
|
+
!opened.ok ||
|
|
377
|
+
!JSON.stringify(value ?? null).includes(`/rooms/${handle}/`))
|
|
378
|
+
return value;
|
|
379
|
+
const held = apply(opened.document, { kind: 'field', name, value, prior: undefined });
|
|
380
|
+
if (held.outcome !== 'applied')
|
|
381
|
+
return value;
|
|
382
|
+
const result = relativize(held.document, path, handle, definition);
|
|
383
|
+
return result.outcome === 'applied' ? result.document.fields[name] : value;
|
|
384
|
+
}
|
|
385
|
+
function relativeChanges(input) {
|
|
386
|
+
const { handle, composition, visible } = input;
|
|
387
|
+
const typed = (path) => (type) => definitionOf(governing(composition, path), type);
|
|
388
|
+
const body = (path, text) => shellRelative(text, path, handle, () => undefined)?.content ?? text;
|
|
389
|
+
return input.changes.map((change) => {
|
|
390
|
+
const definition = typed(change.path);
|
|
391
|
+
if (change.kind === 'field') {
|
|
392
|
+
const type = visible.collection.documents[change.path]?.type;
|
|
393
|
+
const value = relativeField(change.path, change.name, change.value, handle, definition(type));
|
|
394
|
+
return value === change.value ? change : { ...change, value };
|
|
395
|
+
}
|
|
396
|
+
if (change.kind === 'section' || change.kind === 'preamble') {
|
|
397
|
+
const value = body(change.path, change.value);
|
|
398
|
+
return value === change.value ? change : { ...change, value };
|
|
399
|
+
}
|
|
400
|
+
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
401
|
+
const content = shellRelative(change.content, change.path, handle, definition)?.content ?? change.content;
|
|
402
|
+
return content === change.content ? change : { ...change, content };
|
|
403
|
+
}
|
|
404
|
+
if (change.kind !== 'create')
|
|
405
|
+
return change;
|
|
406
|
+
const type = typeof change.fields.type === 'string' ? change.fields.type : undefined;
|
|
407
|
+
const fields = Object.fromEntries(Object.entries(change.fields).map(([name, value]) => [
|
|
408
|
+
name,
|
|
409
|
+
relativeField(change.path, name, value, handle, definition(type)),
|
|
410
|
+
]));
|
|
411
|
+
const sections = Object.fromEntries(Object.entries(change.sections).map(([name, value]) => [name, body(change.path, value)]));
|
|
412
|
+
return { ...change, fields, sections };
|
|
413
|
+
});
|
|
414
|
+
}
|
|
371
415
|
export function buildBatch(input) {
|
|
372
|
-
const
|
|
416
|
+
const changes = relativeChanges(input);
|
|
417
|
+
const structural = changes.find((change) => change.kind === 'move' || change.kind === 'remove');
|
|
373
418
|
if (structural !== undefined &&
|
|
374
419
|
Object.entries(input.visible.collection.documents).some(([path, document]) => document.type !== undefined &&
|
|
375
420
|
document.type !== 'any' &&
|
|
376
421
|
governing(input.composition, path).status === 'unavailable'))
|
|
377
422
|
return refuse('model-unavailable', structural.path);
|
|
378
|
-
if (
|
|
423
|
+
if (changes.length === 0)
|
|
379
424
|
return refuse('no-change');
|
|
380
|
-
const rewritten = rewrites(
|
|
425
|
+
const rewritten = rewrites(changes, input.visible);
|
|
381
426
|
if (rewritten.kind === 'refused')
|
|
382
427
|
return rewritten;
|
|
383
|
-
const changes = input.rewriting === 'provider' ? input.changes : rewritten.changes;
|
|
384
428
|
const refusal = guard(changes, input);
|
|
385
429
|
if (refusal !== null)
|
|
386
430
|
return refusal;
|
|
387
431
|
const preconditions = preconditionsOf(changes, input.visible, input.bases);
|
|
388
|
-
const predicted = input.
|
|
389
|
-
? anticipated(changes, preconditions, rewritten.changes, input.visible)
|
|
390
|
-
: { changes, preconditions };
|
|
432
|
+
const predicted = anticipated(changes, preconditions, rewritten.changes, input.visible);
|
|
391
433
|
const resulting = overlay(input.visible, [
|
|
392
434
|
{ id: '', baseRoomVersion: input.baseRoomVersion, ...predicted },
|
|
393
435
|
]);
|
|
@@ -403,8 +445,7 @@ export function buildBatch(input) {
|
|
|
403
445
|
const parsed = parse(content);
|
|
404
446
|
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
405
447
|
};
|
|
406
|
-
const typedPaths = [...new Set(predicted.changes.flatMap(affected))].filter((path) =>
|
|
407
|
-
(typed(input.visible.documents[path]) || typed(resulting.documents[path])));
|
|
448
|
+
const typedPaths = [...new Set(predicted.changes.flatMap(affected))].filter((path) => typed(input.visible.documents[path]) || typed(resulting.documents[path]));
|
|
408
449
|
const needsModel = typedPaths.length > 0;
|
|
409
450
|
const withoutModel = typedPaths.find((path) => governing(input.composition, path).status === 'unavailable');
|
|
410
451
|
if (withoutModel !== undefined)
|
package/dist/store.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { ModelState } from './model.js';
|
|
2
|
-
import type { Capability,
|
|
2
|
+
import type { Capability, HeadChange, OperationScopes, ProviderLimit, ReplicaAdmission, RoomAttachment, TypedSelection } from './adapter.js';
|
|
3
3
|
import type { AcceptedMessage } from './adapter.js';
|
|
4
4
|
import type { ChangeBatch } from './change.js';
|
|
5
5
|
import type { ChatDraftFile } from './file.js';
|
|
6
|
-
import type { Submission
|
|
6
|
+
import type { Submission } from './outcome.js';
|
|
7
7
|
import type { RoomDraftRecord, SavedDraft } from './room-draft.js';
|
|
8
8
|
export type ReplicaRecord = {
|
|
9
9
|
locator: string;
|
|
10
10
|
name: string;
|
|
11
|
+
handle: string;
|
|
11
12
|
operations: OperationScopes;
|
|
12
13
|
replica: ReplicaAdmission;
|
|
13
14
|
model: ModelState;
|
|
14
|
-
attachedModel: import('./model.js').ModelIdentity | null;
|
|
15
15
|
typedSelection: TypedSelection | null;
|
|
16
16
|
selectionModel: ModelState;
|
|
17
|
-
untypedFolders: readonly string[];
|
|
18
17
|
providerOwnedPaths: readonly string[];
|
|
19
18
|
roomVersion: string;
|
|
20
19
|
documents: Readonly<Record<string, string>>;
|
|
@@ -29,11 +28,7 @@ export type PendingState = {
|
|
|
29
28
|
readonly submission: Submission;
|
|
30
29
|
readonly lost: boolean;
|
|
31
30
|
readonly upload?: unknown;
|
|
32
|
-
|
|
33
|
-
export type OutcomeRecord = {
|
|
34
|
-
locator: string;
|
|
35
|
-
id: string;
|
|
36
|
-
outcome: SubmissionOutcome;
|
|
31
|
+
readonly accepted?: string;
|
|
37
32
|
};
|
|
38
33
|
export type QueueRecord = {
|
|
39
34
|
locator: string;
|
|
@@ -69,10 +64,6 @@ export type RecordWrite = {
|
|
|
69
64
|
queue: readonly ChangeBatch[];
|
|
70
65
|
previousQueue?: readonly ChangeBatch[];
|
|
71
66
|
saved?: readonly SavedDraft[];
|
|
72
|
-
outcomes?: readonly {
|
|
73
|
-
id: string;
|
|
74
|
-
outcome: SubmissionOutcome | null;
|
|
75
|
-
}[];
|
|
76
67
|
roomDrafts?: readonly RoomDraftRecord[];
|
|
77
68
|
consumedRoomDrafts?: readonly string[];
|
|
78
69
|
};
|
|
@@ -87,11 +78,10 @@ export type RuntimeStore = {
|
|
|
87
78
|
complete(at: string): Promise<void>;
|
|
88
79
|
providerLimits(): Promise<readonly ProviderLimit[]>;
|
|
89
80
|
capabilities(): Promise<readonly Capability[]>;
|
|
90
|
-
|
|
91
|
-
declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[], slots: NonNullable<Discovery['slots']>): Promise<void>;
|
|
81
|
+
declare(limits: readonly ProviderLimit[], capabilities: readonly Capability[]): Promise<void>;
|
|
92
82
|
queues(): Promise<readonly QueueRecord[]>;
|
|
93
|
-
outcomes(): Promise<readonly OutcomeRecord[]>;
|
|
94
83
|
submit(locator: string, id: string, submission: Submission, lost: boolean): Promise<void>;
|
|
84
|
+
accept(locator: string, id: string, roomVersion: string): Promise<void>;
|
|
95
85
|
keepUpload(locator: string, id: string, upload: unknown): Promise<void>;
|
|
96
86
|
roomDrafts(): Promise<readonly RoomDraftRecord[]>;
|
|
97
87
|
presentation(): Promise<readonly PresentationRecord[]>;
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiBnE,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,eAAe,CAAC;IAC5B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,cAAc,EAAE,UAAU,CAAC;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AAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,SAAS,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrC,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AA6EF,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMlD;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CA6T9D"}
|
package/dist/store.js
CHANGED
|
@@ -5,7 +5,6 @@ const DOCUMENTS = 'documents';
|
|
|
5
5
|
const BINARY_TARGETS = 'binaryTargets';
|
|
6
6
|
const ATTACHMENTS = 'attachments';
|
|
7
7
|
const PENDING_CHANGES = 'pendingChanges';
|
|
8
|
-
const OUTCOMES = 'outcomes';
|
|
9
8
|
const DECLARATIONS = 'declarations';
|
|
10
9
|
const ROOM_DRAFTS = 'roomDrafts';
|
|
11
10
|
const PRESENTATION = 'presentation';
|
|
@@ -13,7 +12,7 @@ const CONVERSATIONS = 'conversations';
|
|
|
13
12
|
const MESSAGES = 'messages';
|
|
14
13
|
const CHAT_DRAFTS = 'chatDrafts';
|
|
15
14
|
const CURRENT = 'current';
|
|
16
|
-
const SCHEMA =
|
|
15
|
+
const SCHEMA = 20;
|
|
17
16
|
function settled(request) {
|
|
18
17
|
return new Promise((resolve, reject) => {
|
|
19
18
|
request.onsuccess = () => resolve(request.result);
|
|
@@ -32,7 +31,6 @@ const EMPTY_DECLARATIONS = {
|
|
|
32
31
|
generation: null,
|
|
33
32
|
providerLimits: [],
|
|
34
33
|
capabilities: [],
|
|
35
|
-
slots: [],
|
|
36
34
|
};
|
|
37
35
|
function declaration(database) {
|
|
38
36
|
const transaction = database.transaction(DECLARATIONS, 'readonly');
|
|
@@ -89,8 +87,6 @@ export async function openRuntimeStore() {
|
|
|
89
87
|
database.createObjectStore(BINARY_TARGETS, { keyPath: ['locator', 'path'] });
|
|
90
88
|
database.createObjectStore(ATTACHMENTS, { keyPath: ['locator', 'reference'] });
|
|
91
89
|
database.createObjectStore(PENDING_CHANGES, { keyPath: ['locator', 'id'] });
|
|
92
|
-
const outcomes = database.createObjectStore(OUTCOMES, { keyPath: 'id' });
|
|
93
|
-
outcomes.createIndex('locator', 'locator');
|
|
94
90
|
database.createObjectStore(DECLARATIONS);
|
|
95
91
|
database.createObjectStore(ROOM_DRAFTS, { keyPath: ['locator', 'path'] });
|
|
96
92
|
database.createObjectStore(PRESENTATION, { keyPath: 'app' });
|
|
@@ -156,8 +152,8 @@ export async function openRuntimeStore() {
|
|
|
156
152
|
}
|
|
157
153
|
return [...byRoom.values()];
|
|
158
154
|
},
|
|
159
|
-
async write({ next, previous, queue, previousQueue, saved,
|
|
160
|
-
const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS, ATTACHMENTS, PENDING_CHANGES,
|
|
155
|
+
async write({ next, previous, queue, previousQueue, saved, roomDrafts, consumedRoomDrafts }) {
|
|
156
|
+
const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS, ATTACHMENTS, PENDING_CHANGES, ROOM_DRAFTS], 'readwrite');
|
|
161
157
|
transaction.objectStore(ROOMS).put(roomRecord(next, queue));
|
|
162
158
|
const documents = transaction.objectStore(DOCUMENTS);
|
|
163
159
|
for (const path of Object.keys(previous?.documents ?? {})) {
|
|
@@ -231,13 +227,6 @@ export async function openRuntimeStore() {
|
|
|
231
227
|
}
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
|
-
const outcomeStore = transaction.objectStore(OUTCOMES);
|
|
235
|
-
for (const entry of outcomes ?? []) {
|
|
236
|
-
if (entry.outcome === null)
|
|
237
|
-
outcomeStore.delete(entry.id);
|
|
238
|
-
else
|
|
239
|
-
outcomeStore.put({ locator: next.locator, id: entry.id, outcome: entry.outcome });
|
|
240
|
-
}
|
|
241
230
|
const draftStore = transaction.objectStore(ROOM_DRAFTS);
|
|
242
231
|
for (const path of consumedRoomDrafts ?? [])
|
|
243
232
|
draftStore.delete([next.locator, path]);
|
|
@@ -266,15 +255,11 @@ export async function openRuntimeStore() {
|
|
|
266
255
|
async capabilities() {
|
|
267
256
|
return (await declaration(database)).capabilities;
|
|
268
257
|
},
|
|
269
|
-
|
|
270
|
-
return (await declaration(database)).slots;
|
|
271
|
-
},
|
|
272
|
-
declare(limits, capabilities, slots) {
|
|
258
|
+
declare(limits, capabilities) {
|
|
273
259
|
return updateDeclaration(database, (record) => ({
|
|
274
260
|
...record,
|
|
275
261
|
providerLimits: limits,
|
|
276
262
|
capabilities,
|
|
277
|
-
slots,
|
|
278
263
|
}));
|
|
279
264
|
},
|
|
280
265
|
async queues() {
|
|
@@ -290,18 +275,17 @@ export async function openRuntimeStore() {
|
|
|
290
275
|
const record = byId.get(`${room.locator}\0${id}`);
|
|
291
276
|
if (record === undefined)
|
|
292
277
|
throw new Error(`Missing Pending Change ${room.locator}/${id}`);
|
|
293
|
-
const { batch, drafts, submission, lost, upload } = record;
|
|
294
|
-
return { batch, state: { drafts, submission, lost, upload } };
|
|
278
|
+
const { batch, drafts, submission, lost, upload, accepted } = record;
|
|
279
|
+
return { batch, state: { drafts, submission, lost, upload, accepted } };
|
|
295
280
|
}),
|
|
296
281
|
}));
|
|
297
282
|
},
|
|
298
|
-
async outcomes() {
|
|
299
|
-
const transaction = database.transaction(OUTCOMES, 'readonly');
|
|
300
|
-
return settled(transaction.objectStore(OUTCOMES).getAll());
|
|
301
|
-
},
|
|
302
283
|
submit(locator, id, submission, lost) {
|
|
303
284
|
return amendPending(database, locator, id, { submission, lost });
|
|
304
285
|
},
|
|
286
|
+
accept(locator, id, roomVersion) {
|
|
287
|
+
return amendPending(database, locator, id, { accepted: roomVersion });
|
|
288
|
+
},
|
|
305
289
|
keepUpload(locator, id, upload) {
|
|
306
290
|
return amendPending(database, locator, id, { upload });
|
|
307
291
|
},
|
|
@@ -389,18 +373,12 @@ export async function openRuntimeStore() {
|
|
|
389
373
|
await completed(transaction);
|
|
390
374
|
},
|
|
391
375
|
async dropRooms(locators) {
|
|
392
|
-
const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS, ATTACHMENTS, PENDING_CHANGES,
|
|
376
|
+
const transaction = database.transaction([ROOMS, DOCUMENTS, BINARY_TARGETS, ATTACHMENTS, PENDING_CHANGES, ROOM_DRAFTS], 'readwrite');
|
|
393
377
|
for (const locator of locators) {
|
|
394
378
|
transaction.objectStore(ROOMS).delete(locator);
|
|
395
379
|
for (const name of [DOCUMENTS, BINARY_TARGETS, ATTACHMENTS, PENDING_CHANGES, ROOM_DRAFTS]) {
|
|
396
380
|
removeRoomEntries(transaction.objectStore(name), locator);
|
|
397
381
|
}
|
|
398
|
-
const outcomes = transaction.objectStore(OUTCOMES);
|
|
399
|
-
const ids = outcomes.index('locator').getAllKeys(locator);
|
|
400
|
-
ids.onsuccess = () => {
|
|
401
|
-
for (const id of ids.result)
|
|
402
|
-
outcomes.delete(id);
|
|
403
|
-
};
|
|
404
382
|
}
|
|
405
383
|
await completed(transaction);
|
|
406
384
|
},
|
package/dist/wire.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { ConnectionRefusal } from './connection.js';
|
|
2
|
-
export declare const RUNTIME_WIRE_PROTOCOL = 8;
|
|
3
|
-
export declare const PROTOCOL_MISMATCH: ConnectionRefusal;
|
|
4
2
|
export type RuntimePort = {
|
|
5
3
|
postMessage(message: unknown): void;
|
|
6
4
|
addEventListener(type: 'message' | 'close', listener: (event: {
|
|
@@ -8,10 +6,57 @@ export type RuntimePort = {
|
|
|
8
6
|
}) => void): void;
|
|
9
7
|
start(): void;
|
|
10
8
|
};
|
|
11
|
-
|
|
12
|
-
declare const
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
export type WireReach = 'within' | 'app' | 'runtime' | 'actions' | 'whole';
|
|
10
|
+
declare const MEMBERS: {
|
|
11
|
+
readonly rooms: 'within';
|
|
12
|
+
readonly query: 'within';
|
|
13
|
+
readonly search: 'within';
|
|
14
|
+
readonly types: 'within';
|
|
15
|
+
readonly save: 'within';
|
|
16
|
+
readonly history: 'within';
|
|
17
|
+
readonly call: 'actions';
|
|
18
|
+
readonly reached: 'within';
|
|
19
|
+
readonly log: 'whole';
|
|
20
|
+
readonly persistence: 'runtime';
|
|
21
|
+
readonly reauthorize: 'runtime';
|
|
22
|
+
readonly 'roomDraft.list': 'within';
|
|
23
|
+
readonly 'roomDraft.read': 'within';
|
|
24
|
+
readonly 'roomDraft.write': 'within';
|
|
25
|
+
readonly 'roomDraft.discard': 'within';
|
|
26
|
+
readonly 'presentation.read': 'app';
|
|
27
|
+
readonly 'presentation.write': 'app';
|
|
28
|
+
readonly 'conversation.list': 'within';
|
|
29
|
+
readonly 'conversation.read': 'within';
|
|
30
|
+
readonly 'conversation.create': 'within';
|
|
31
|
+
readonly 'conversation.send': 'within';
|
|
32
|
+
readonly 'conversation.answer': 'within';
|
|
33
|
+
readonly 'conversation.interrupt': 'within';
|
|
34
|
+
readonly 'conversation.kill': 'within';
|
|
35
|
+
readonly 'conversation.cancel': 'within';
|
|
36
|
+
readonly 'conversation.delete': 'within';
|
|
37
|
+
readonly 'chatDraft.write': 'within';
|
|
38
|
+
readonly 'chatDraft.discard': 'within';
|
|
39
|
+
};
|
|
40
|
+
declare const TOPICS: {
|
|
41
|
+
readonly rooms: 'within';
|
|
42
|
+
readonly 'connection-refusal': 'runtime';
|
|
43
|
+
readonly 'storage-loss': 'runtime';
|
|
44
|
+
readonly 'deployment-facts': 'runtime';
|
|
45
|
+
readonly 'sync-status': 'within';
|
|
46
|
+
readonly 'service-mode': 'runtime';
|
|
47
|
+
readonly query: 'within';
|
|
48
|
+
readonly queue: 'within';
|
|
49
|
+
readonly 'room-drafts': 'within';
|
|
50
|
+
readonly presentation: 'app';
|
|
51
|
+
readonly conversation: 'within';
|
|
52
|
+
readonly conversations: 'within';
|
|
53
|
+
};
|
|
54
|
+
export declare const WIRE_REACH: {
|
|
55
|
+
readonly members: Readonly<Record<string, WireReach>>;
|
|
56
|
+
readonly topics: Readonly<Record<string, WireReach>>;
|
|
57
|
+
};
|
|
58
|
+
export type WireMember = keyof typeof MEMBERS;
|
|
59
|
+
export type WireTopic = keyof typeof TOPICS;
|
|
15
60
|
export type WireRequest = {
|
|
16
61
|
kind: 'hello';
|
|
17
62
|
} | {
|
|
@@ -48,16 +93,6 @@ export type WireAnswer = {
|
|
|
48
93
|
};
|
|
49
94
|
export declare const AUTHORIZATION_ENDED = "the host authorization ended";
|
|
50
95
|
export declare const PORT_CLOSED = "the port closed";
|
|
51
|
-
export type WireEnvelope = {
|
|
52
|
-
mdRuntime: number;
|
|
53
|
-
message: WireRequest | WireAnswer;
|
|
54
|
-
};
|
|
55
|
-
export type Carried = {
|
|
56
|
-
matching: boolean;
|
|
57
|
-
message: unknown;
|
|
58
|
-
};
|
|
59
|
-
export declare function envelope(message: WireRequest | WireAnswer): WireEnvelope;
|
|
60
|
-
export declare function carried(data: unknown): Carried | null;
|
|
61
96
|
export declare function request(message: unknown): WireRequest | null;
|
|
62
97
|
export declare function answer(message: unknown): WireAnswer | null;
|
|
63
98
|
export {};
|
package/dist/wire.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":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AED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAe1D"}
|
package/dist/wire.js
CHANGED
|
@@ -1,69 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const MEMBERS = {
|
|
2
|
+
rooms: 'within',
|
|
3
|
+
query: 'within',
|
|
4
|
+
search: 'within',
|
|
5
|
+
types: 'within',
|
|
6
|
+
save: 'within',
|
|
7
|
+
history: 'within',
|
|
8
|
+
call: 'actions',
|
|
9
|
+
reached: 'within',
|
|
10
|
+
log: 'whole',
|
|
11
|
+
persistence: 'runtime',
|
|
12
|
+
reauthorize: 'runtime',
|
|
13
|
+
'roomDraft.list': 'within',
|
|
14
|
+
'roomDraft.read': 'within',
|
|
15
|
+
'roomDraft.write': 'within',
|
|
16
|
+
'roomDraft.discard': 'within',
|
|
17
|
+
'presentation.read': 'app',
|
|
18
|
+
'presentation.write': 'app',
|
|
19
|
+
'conversation.list': 'within',
|
|
20
|
+
'conversation.read': 'within',
|
|
21
|
+
'conversation.create': 'within',
|
|
22
|
+
'conversation.send': 'within',
|
|
23
|
+
'conversation.answer': 'within',
|
|
24
|
+
'conversation.interrupt': 'within',
|
|
25
|
+
'conversation.kill': 'within',
|
|
26
|
+
'conversation.cancel': 'within',
|
|
27
|
+
'conversation.delete': 'within',
|
|
28
|
+
'chatDraft.write': 'within',
|
|
29
|
+
'chatDraft.discard': 'within',
|
|
6
30
|
};
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'persistence',
|
|
23
|
-
'deploymentFacts',
|
|
24
|
-
'reauthorize',
|
|
25
|
-
'roomDraft.list',
|
|
26
|
-
'roomDraft.read',
|
|
27
|
-
'roomDraft.write',
|
|
28
|
-
'roomDraft.discard',
|
|
29
|
-
'presentation.read',
|
|
30
|
-
'presentation.write',
|
|
31
|
-
'conversation.list',
|
|
32
|
-
'conversation.read',
|
|
33
|
-
'conversation.create',
|
|
34
|
-
'conversation.send',
|
|
35
|
-
'conversation.answer',
|
|
36
|
-
'conversation.interrupt',
|
|
37
|
-
'conversation.kill',
|
|
38
|
-
'conversation.cancel',
|
|
39
|
-
'conversation.delete',
|
|
40
|
-
'chatDraft.write',
|
|
41
|
-
'chatDraft.discard',
|
|
42
|
-
];
|
|
43
|
-
const TOPICS = [
|
|
44
|
-
'rooms',
|
|
45
|
-
'connection-refusal',
|
|
46
|
-
'storage-loss',
|
|
47
|
-
'deployment-facts',
|
|
48
|
-
'sync-status',
|
|
49
|
-
'service-mode',
|
|
50
|
-
'query',
|
|
51
|
-
'queue',
|
|
52
|
-
'room-drafts',
|
|
53
|
-
'presentation',
|
|
54
|
-
'conversation',
|
|
55
|
-
];
|
|
31
|
+
const TOPICS = {
|
|
32
|
+
rooms: 'within',
|
|
33
|
+
'connection-refusal': 'runtime',
|
|
34
|
+
'storage-loss': 'runtime',
|
|
35
|
+
'deployment-facts': 'runtime',
|
|
36
|
+
'sync-status': 'within',
|
|
37
|
+
'service-mode': 'runtime',
|
|
38
|
+
query: 'within',
|
|
39
|
+
queue: 'within',
|
|
40
|
+
'room-drafts': 'within',
|
|
41
|
+
presentation: 'app',
|
|
42
|
+
conversation: 'within',
|
|
43
|
+
conversations: 'within',
|
|
44
|
+
};
|
|
45
|
+
export const WIRE_REACH = { members: MEMBERS, topics: TOPICS };
|
|
56
46
|
export const AUTHORIZATION_ENDED = 'the host authorization ended';
|
|
57
47
|
export const PORT_CLOSED = 'the port closed';
|
|
58
|
-
export function envelope(message) {
|
|
59
|
-
return { mdRuntime: RUNTIME_WIRE_PROTOCOL, message };
|
|
60
|
-
}
|
|
61
|
-
export function carried(data) {
|
|
62
|
-
if (typeof data !== 'object' || data === null || !('mdRuntime' in data))
|
|
63
|
-
return null;
|
|
64
|
-
const record = data;
|
|
65
|
-
return { matching: record.mdRuntime === RUNTIME_WIRE_PROTOCOL, message: record.message };
|
|
66
|
-
}
|
|
67
48
|
function body(message) {
|
|
68
49
|
if (typeof message !== 'object' || message === null)
|
|
69
50
|
return null;
|
|
@@ -83,7 +64,9 @@ export function request(message) {
|
|
|
83
64
|
return { kind: 'stop', id: shape.id };
|
|
84
65
|
if (!Array.isArray(record.input))
|
|
85
66
|
return null;
|
|
86
|
-
if (shape.kind === 'call' &&
|
|
67
|
+
if (shape.kind === 'call' &&
|
|
68
|
+
typeof record.member === 'string' &&
|
|
69
|
+
Object.hasOwn(MEMBERS, record.member)) {
|
|
87
70
|
return {
|
|
88
71
|
kind: 'call',
|
|
89
72
|
id: shape.id,
|
|
@@ -91,7 +74,9 @@ export function request(message) {
|
|
|
91
74
|
input: record.input,
|
|
92
75
|
};
|
|
93
76
|
}
|
|
94
|
-
if (shape.kind === 'observe' &&
|
|
77
|
+
if (shape.kind === 'observe' &&
|
|
78
|
+
typeof record.topic === 'string' &&
|
|
79
|
+
Object.hasOwn(TOPICS, record.topic)) {
|
|
95
80
|
return {
|
|
96
81
|
kind: 'observe',
|
|
97
82
|
id: shape.id,
|