@agentshouse/mdruntime 0.1.0-cd3486bd400ed → 0.1.0-cde2b99d2fcbc
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 +70 -42
- package/README.md +11 -2
- package/dist/adapter.d.ts +34 -11
- package/dist/adapter.d.ts.map +1 -1
- package/dist/binary.d.ts +23 -0
- package/dist/binary.d.ts.map +1 -0
- package/dist/binary.js +8 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +5 -8
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +8 -7
- package/dist/change.d.ts +11 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +26 -1
- package/dist/chat/context.d.ts +3 -0
- package/dist/chat/context.d.ts.map +1 -0
- package/dist/chat/context.js +10 -0
- package/dist/chat/input.d.ts +9 -0
- package/dist/chat/input.d.ts.map +1 -0
- package/dist/chat/input.js +99 -0
- package/dist/chat/kit.d.ts +60 -0
- package/dist/chat/kit.d.ts.map +1 -0
- package/dist/chat/kit.js +123 -0
- package/dist/chat/lasting.d.ts +6 -0
- package/dist/chat/lasting.d.ts.map +1 -0
- package/dist/chat/lasting.js +19 -0
- package/dist/chat/list.d.ts +20 -0
- package/dist/chat/list.d.ts.map +1 -0
- package/dist/chat/list.js +59 -0
- package/dist/chat/markdown.d.ts +19 -0
- package/dist/chat/markdown.d.ts.map +1 -0
- package/dist/chat/markdown.js +187 -0
- package/dist/chat/message.d.ts +6 -0
- package/dist/chat/message.d.ts.map +1 -0
- package/dist/chat/message.js +192 -0
- package/dist/chat/name.d.ts +6 -0
- package/dist/chat/name.d.ts.map +1 -0
- package/dist/chat/name.js +37 -0
- package/dist/chat/opened.d.ts +11 -0
- package/dist/chat/opened.d.ts.map +1 -0
- package/dist/chat/opened.js +17 -0
- package/dist/chat/provider.d.ts +6 -0
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +9 -1
- package/dist/chat/question.d.ts +9 -0
- package/dist/chat/question.d.ts.map +1 -0
- package/dist/chat/question.js +80 -0
- package/dist/chat/ready.d.ts +33 -0
- package/dist/chat/ready.d.ts.map +1 -0
- package/dist/chat/ready.js +91 -0
- package/dist/chat/style.d.ts +4 -0
- package/dist/chat/style.d.ts.map +1 -0
- package/dist/chat/style.js +302 -0
- package/dist/chat.d.ts +7 -0
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +6 -0
- package/dist/client.d.ts +7 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +10 -0
- package/dist/connection.d.ts +9 -4
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +184 -15
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +4 -0
- package/dist/identity.d.ts +1 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +3 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/memory.d.ts +3 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +31 -11
- package/dist/outcome.d.ts +7 -1
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +6 -0
- package/dist/overlay.d.ts +13 -2
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +56 -22
- package/dist/query.d.ts +2 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +2 -0
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +23 -1
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +9 -2
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +12 -17
- package/dist/replica.d.ts +5 -2
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +43 -27
- package/dist/room-draft.d.ts +19 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +119 -1
- package/dist/rows.d.ts +3 -1
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +3 -1
- package/dist/save.d.ts +24 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +304 -14
- package/dist/store.d.ts +6 -7
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +79 -91
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -0
- package/package.json +11 -3
- package/dist/attachment.d.ts +0 -3
- package/dist/attachment.d.ts.map +0 -1
- package/dist/attachment.js +0 -8
package/dist/connection.js
CHANGED
|
@@ -8,14 +8,16 @@ import { createSearchIndex, searchPlanOf, } from './search.js';
|
|
|
8
8
|
import { bootstrapRoom } from './bootstrap.js';
|
|
9
9
|
import { changeSet, mergeChangeSets } from './change-set.js';
|
|
10
10
|
import { createConversationStore, } from './conversation.js';
|
|
11
|
+
import { queuedFile } from './change.js';
|
|
11
12
|
import { validRoot } from './collection.js';
|
|
12
13
|
import { runtimeError } from './failure.js';
|
|
13
14
|
import { createLog } from './log.js';
|
|
14
|
-
import {
|
|
15
|
+
import { binaryRecord } from './binary.js';
|
|
16
|
+
import { absentBinary, binaryAnswer, calledResult, historyAnswer, undeclared, UNCERTAIN, } from './outcome.js';
|
|
15
17
|
import { refreshRoom } from './refresh.js';
|
|
16
|
-
import { buildBatch } from './save.js';
|
|
18
|
+
import { buildBatch, joined, limitedIn, requeued } from './save.js';
|
|
17
19
|
import { applyReturned, compositionOf, confirmedOf, landed, readReclassified, replicaOf, sameMembership, withdrawals, } from './replica.js';
|
|
18
|
-
import { changedParts, changesOf, held, readParts, returnedBy, returnedInto, staleWrite, underneath, } from './room-draft.js';
|
|
20
|
+
import { binaryBase, changedParts, changesOf, held, heldFile, joinedDraft, readParts, returnedBy, returnedInto, staleWrite, underneath, withdrawnDrafts, } from './room-draft.js';
|
|
19
21
|
import { same, saving, STARTING, transferring, } from './status.js';
|
|
20
22
|
import { detectStorageLoss, nextGeneration } from './durability.js';
|
|
21
23
|
import { roomDraftRevision } from './identity.js';
|
|
@@ -474,7 +476,6 @@ export function composeRuntime(options) {
|
|
|
474
476
|
},
|
|
475
477
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
476
478
|
roomVersion: replicas.get(room.locator)?.confirmed.record.roomVersion ?? null,
|
|
477
|
-
attachments: replicas.get(room.locator)?.confirmed.record.attachments ?? [],
|
|
478
479
|
synchronizationAvailable,
|
|
479
480
|
refusal: scopedRefusals.get(room.locator) ?? sourceRefusals.get(room.locator) ?? null,
|
|
480
481
|
});
|
|
@@ -602,7 +603,6 @@ export function composeRuntime(options) {
|
|
|
602
603
|
rooms.set(record.locator, {
|
|
603
604
|
...existing,
|
|
604
605
|
roomVersion: record.roomVersion,
|
|
605
|
-
attachments: record.attachments,
|
|
606
606
|
operations: record.operations,
|
|
607
607
|
replica: record.replica,
|
|
608
608
|
model: modelTypes(model),
|
|
@@ -810,7 +810,24 @@ export function composeRuntime(options) {
|
|
|
810
810
|
if (changed.length > 0)
|
|
811
811
|
return { outcome: 'refused', code: 'changed-underneath', retryable: false, parts: changed };
|
|
812
812
|
const parts = saved.map(({ path, parts }) => changesOf(path, parts));
|
|
813
|
-
const
|
|
813
|
+
const changes = parts.flatMap(({ changes }) => changes);
|
|
814
|
+
const requeue = requeued(replica.queue, changes, replica.visible, withdrawable, (queue) => replicaOf(replica.confirmed, queue, replica).visible);
|
|
815
|
+
if (requeue.kind === 'refused')
|
|
816
|
+
return { outcome: 'refused', ...requeue.refusal };
|
|
817
|
+
const foreign = [...requeue.withdrawn.keys()].some((origin) => {
|
|
818
|
+
const writer = replica.queue.find((batch) => batch.id === origin)?.writtenBy;
|
|
819
|
+
return writer?.app !== writtenBy?.app || writer?.release !== writtenBy?.release;
|
|
820
|
+
});
|
|
821
|
+
if (foreign) {
|
|
822
|
+
return {
|
|
823
|
+
outcome: 'refused',
|
|
824
|
+
code: 'unknown-revision',
|
|
825
|
+
retryable: false,
|
|
826
|
+
file: [...requeue.queued].at(-1),
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
const withdrawing = requeue.withdrawn.size > 0;
|
|
830
|
+
const input = {
|
|
814
831
|
local: localSaves,
|
|
815
832
|
baseRoomVersion: replica.confirmed.record.roomVersion,
|
|
816
833
|
composition: compositionFor(replica.confirmed.record),
|
|
@@ -819,13 +836,67 @@ export function composeRuntime(options) {
|
|
|
819
836
|
providerLimits: limits,
|
|
820
837
|
handle: room.handle,
|
|
821
838
|
visible: replica.visible,
|
|
822
|
-
changes
|
|
839
|
+
changes,
|
|
823
840
|
bases: parts.flatMap(({ bases }) => bases),
|
|
824
841
|
writtenBy,
|
|
842
|
+
};
|
|
843
|
+
const checked = withdrawing ? buildBatch({ ...input, queued: requeue.queued }) : null;
|
|
844
|
+
if (checked?.kind === 'refused')
|
|
845
|
+
return { outcome: 'refused', ...checked.refusal };
|
|
846
|
+
const owners = [...requeue.owners].flatMap((origin) => {
|
|
847
|
+
const batch = requeue.withdrawn.get(origin);
|
|
848
|
+
return batch === undefined || batch === null ? [] : [{ origin, batch }];
|
|
825
849
|
});
|
|
826
|
-
if (
|
|
850
|
+
if (owners.length > 1) {
|
|
851
|
+
return {
|
|
852
|
+
outcome: 'refused',
|
|
853
|
+
code: 'unknown-revision',
|
|
854
|
+
retryable: false,
|
|
855
|
+
file: [...requeue.queued].at(-1),
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
const built = !withdrawing
|
|
859
|
+
? buildBatch(input)
|
|
860
|
+
: requeue.changes.length === 0
|
|
861
|
+
? null
|
|
862
|
+
: buildBatch({
|
|
863
|
+
...input,
|
|
864
|
+
visible: replicaOf(replica.confirmed, requeue.queue, replica).visible,
|
|
865
|
+
changes: requeue.changes,
|
|
866
|
+
});
|
|
867
|
+
if (built?.kind === 'refused')
|
|
827
868
|
return { outcome: 'refused', ...built.refusal };
|
|
828
|
-
const
|
|
869
|
+
const [owner] = owners;
|
|
870
|
+
const join = built === null || owner === undefined
|
|
871
|
+
? null
|
|
872
|
+
: joined(requeue.queue, owner.batch, built.batch);
|
|
873
|
+
if (join?.kind === 'refused')
|
|
874
|
+
return { outcome: 'refused', ...join.refusal };
|
|
875
|
+
const withdrawn = new Map(requeue.withdrawn);
|
|
876
|
+
if (join !== null && owner !== undefined)
|
|
877
|
+
withdrawn.set(owner.origin, join.batch);
|
|
878
|
+
const drafted = new Map();
|
|
879
|
+
for (const [origin, replaced] of withdrawn) {
|
|
880
|
+
if (replaced === null)
|
|
881
|
+
continue;
|
|
882
|
+
const carried = withdrawnDrafts(pendings.get(origin)?.drafts ?? [], changes);
|
|
883
|
+
drafted.set(replaced.id, replaced === join?.batch
|
|
884
|
+
? [
|
|
885
|
+
...carried.map((held) => joinedDraft(held, saved)),
|
|
886
|
+
...saved.filter((draft) => !carried.some((held) => held.path === draft.path)),
|
|
887
|
+
]
|
|
888
|
+
: carried);
|
|
889
|
+
}
|
|
890
|
+
if (built !== null && join === null)
|
|
891
|
+
drafted.set(built.batch.id, saved);
|
|
892
|
+
const batches = join !== null ? join.queue : built === null ? requeue.queue : [...requeue.queue, built.batch];
|
|
893
|
+
for (const replaced of withdrawn.values()) {
|
|
894
|
+
if (replaced === null || !batches.includes(replaced))
|
|
895
|
+
continue;
|
|
896
|
+
const limited = limitedIn(batches, replaced, limits, (queue) => replicaOf(replica.confirmed, queue, replica).visible);
|
|
897
|
+
if (limited !== null)
|
|
898
|
+
return { outcome: 'refused', ...limited };
|
|
899
|
+
}
|
|
829
900
|
const consumed = saved.map(({ path }) => path);
|
|
830
901
|
try {
|
|
831
902
|
await local.write({
|
|
@@ -833,14 +904,18 @@ export function composeRuntime(options) {
|
|
|
833
904
|
previous: replica.confirmed.record,
|
|
834
905
|
queue: batches,
|
|
835
906
|
previousQueue: replica.queue,
|
|
836
|
-
saved,
|
|
907
|
+
saved: drafted,
|
|
837
908
|
consumedRoomDrafts: consumed,
|
|
838
909
|
});
|
|
839
910
|
}
|
|
840
911
|
catch {
|
|
841
912
|
return { outcome: 'refused', code: 'durable-write', retryable: true };
|
|
842
913
|
}
|
|
843
|
-
|
|
914
|
+
for (const origin of withdrawn.keys())
|
|
915
|
+
pendings.delete(origin);
|
|
916
|
+
for (const [id, drafts] of drafted) {
|
|
917
|
+
pendings.set(id, { drafts, submission: { state: 'waiting' }, lost: false });
|
|
918
|
+
}
|
|
844
919
|
if (!localSaves)
|
|
845
920
|
recorded = false;
|
|
846
921
|
for (const path of consumed)
|
|
@@ -852,7 +927,10 @@ export function composeRuntime(options) {
|
|
|
852
927
|
}));
|
|
853
928
|
moveTo({ ...(localSaves ? status : saving(status)), ...attention() });
|
|
854
929
|
submitLater(locator);
|
|
855
|
-
|
|
930
|
+
const identifier = join?.batch.id ??
|
|
931
|
+
built?.batch.id ??
|
|
932
|
+
[...requeue.withdrawn].map(([origin, replaced]) => replaced?.id ?? origin).at(-1);
|
|
933
|
+
return { outcome: 'saved', identifier };
|
|
856
934
|
}
|
|
857
935
|
async function mark(local, locator, identifier, submission, lost) {
|
|
858
936
|
const state = pendings.get(identifier);
|
|
@@ -915,6 +993,90 @@ export function composeRuntime(options) {
|
|
|
915
993
|
return UNCERTAIN;
|
|
916
994
|
}
|
|
917
995
|
}
|
|
996
|
+
function queuedBlob(locator, path, localId) {
|
|
997
|
+
for (const batch of replicas.get(locator)?.queue ?? []) {
|
|
998
|
+
const change = batch.changes[queuedFile(batch, path, localId)];
|
|
999
|
+
if (change?.kind === 'binary')
|
|
1000
|
+
return change.blob;
|
|
1001
|
+
}
|
|
1002
|
+
return null;
|
|
1003
|
+
}
|
|
1004
|
+
async function readBinary(request) {
|
|
1005
|
+
if (closed || refusal !== null)
|
|
1006
|
+
return UNCERTAIN;
|
|
1007
|
+
try {
|
|
1008
|
+
await ensureAuthorization();
|
|
1009
|
+
}
|
|
1010
|
+
catch {
|
|
1011
|
+
return UNCERTAIN;
|
|
1012
|
+
}
|
|
1013
|
+
if (closed || authorization === undefined || refusal !== null)
|
|
1014
|
+
return UNCERTAIN;
|
|
1015
|
+
journal.record(request.kind === 'path'
|
|
1016
|
+
? `transfer binary ${request.locator} ${request.path}`
|
|
1017
|
+
: `transfer binary ${request.fileRef}`);
|
|
1018
|
+
try {
|
|
1019
|
+
const result = await options.adapter.binary(authorization, request);
|
|
1020
|
+
journal.record(`outcome binary ${result.kind}`);
|
|
1021
|
+
if (result.kind === 'scoped-refusal') {
|
|
1022
|
+
const room = replicas.get(result.locator)?.confirmed.record;
|
|
1023
|
+
if (room !== undefined)
|
|
1024
|
+
await scoped(result, room, await openLocal());
|
|
1025
|
+
}
|
|
1026
|
+
if (result.kind === 'revoked-authorization')
|
|
1027
|
+
await refuse('revoked-authorization');
|
|
1028
|
+
return binaryAnswer(result);
|
|
1029
|
+
}
|
|
1030
|
+
catch {
|
|
1031
|
+
journal.record('outcome binary transport-uncertainty');
|
|
1032
|
+
return UNCERTAIN;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
async function readBinaryPath(locator, path, revision) {
|
|
1036
|
+
await ready;
|
|
1037
|
+
if (revision !== undefined)
|
|
1038
|
+
return readBinary({ kind: 'path', locator, path, revision });
|
|
1039
|
+
const visible = replicas.get(locator)?.visible;
|
|
1040
|
+
const held = visible?.binaries[path];
|
|
1041
|
+
if (visible === undefined || held === undefined)
|
|
1042
|
+
return absentBinary(path);
|
|
1043
|
+
if (held.state === 'pending') {
|
|
1044
|
+
const blob = queuedBlob(locator, path, held.localId);
|
|
1045
|
+
return blob === null ? absentBinary(path) : { kind: 'binary', blob };
|
|
1046
|
+
}
|
|
1047
|
+
const record = binaryRecord(path, held, visible.revisions[path]);
|
|
1048
|
+
if (record.state !== 'accepted')
|
|
1049
|
+
return absentBinary(path);
|
|
1050
|
+
const replica = replicas.get(locator);
|
|
1051
|
+
const queued = (replica?.queue ?? []).flatMap((batch) => batch.changes);
|
|
1052
|
+
const holds = (at) => {
|
|
1053
|
+
const kept = replica?.confirmed.record.binaries[at];
|
|
1054
|
+
return (kept?.state === 'accepted' &&
|
|
1055
|
+
kept.fileRef === record.fileRef &&
|
|
1056
|
+
replica?.confirmed.record.revisions[at] === record.revision);
|
|
1057
|
+
};
|
|
1058
|
+
let confirmed = path;
|
|
1059
|
+
for (let index = queued.length - 1; index >= 0 && !holds(confirmed); index -= 1) {
|
|
1060
|
+
const change = queued[index];
|
|
1061
|
+
if (change.kind === 'move' && change.to === confirmed)
|
|
1062
|
+
confirmed = change.path;
|
|
1063
|
+
}
|
|
1064
|
+
return readBinary({
|
|
1065
|
+
kind: 'path',
|
|
1066
|
+
locator,
|
|
1067
|
+
path: confirmed,
|
|
1068
|
+
revision: record.revision,
|
|
1069
|
+
fileRef: record.fileRef,
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
async function readBinaryReference(reference) {
|
|
1073
|
+
await ready;
|
|
1074
|
+
return readBinary({
|
|
1075
|
+
kind: 'reference',
|
|
1076
|
+
fileRef: reference.fileRef,
|
|
1077
|
+
referrer: reference.referrer,
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
918
1080
|
function declaredAgents() {
|
|
919
1081
|
for (const capability of capabilities) {
|
|
920
1082
|
if (capability.conversationAgents !== undefined)
|
|
@@ -1138,7 +1300,7 @@ export function composeRuntime(options) {
|
|
|
1138
1300
|
logAccepted(room.locator, submitted, accepted);
|
|
1139
1301
|
const applied = options.adapter.reached(room.locator, held, accepted.roomVersion)
|
|
1140
1302
|
? { kind: 'staged', confirmed: current.confirmed }
|
|
1141
|
-
: applyReturned(current.confirmed,
|
|
1303
|
+
: applyReturned(current.confirmed, submitted, accepted, options.adapter.follows(room.locator, held, accepted.roomVersion)
|
|
1142
1304
|
? accepted.roomVersion
|
|
1143
1305
|
: held, accepted.roomVersion);
|
|
1144
1306
|
if (applied.kind !== 'staged') {
|
|
@@ -1429,7 +1591,6 @@ export function composeRuntime(options) {
|
|
|
1429
1591
|
roomVersion: record.roomVersion,
|
|
1430
1592
|
documents: record.documents,
|
|
1431
1593
|
revisions: record.revisions,
|
|
1432
|
-
attachments: record.attachments,
|
|
1433
1594
|
},
|
|
1434
1595
|
];
|
|
1435
1596
|
});
|
|
@@ -2137,11 +2298,14 @@ export function composeRuntime(options) {
|
|
|
2137
2298
|
if ((current?.revision ?? null) !== revision) {
|
|
2138
2299
|
return staleWrite(current === undefined ? null : roomDraftOf(current));
|
|
2139
2300
|
}
|
|
2301
|
+
const file = parts.file === undefined
|
|
2302
|
+
? undefined
|
|
2303
|
+
: await heldFile(parts.file.blob, binaryBase(replicas.get(room)?.visible, path));
|
|
2140
2304
|
const record = {
|
|
2141
2305
|
locator: room,
|
|
2142
2306
|
path,
|
|
2143
2307
|
revision: roomDraftRevision(),
|
|
2144
|
-
parts: held(current?.parts, parts),
|
|
2308
|
+
parts: held(current?.parts, parts, file),
|
|
2145
2309
|
returned: current?.returned ?? null,
|
|
2146
2310
|
};
|
|
2147
2311
|
await local.keepRoomDraft(record);
|
|
@@ -2190,6 +2354,10 @@ export function composeRuntime(options) {
|
|
|
2190
2354
|
history(locator, path, query) {
|
|
2191
2355
|
return readHistory(locator, path, query);
|
|
2192
2356
|
},
|
|
2357
|
+
binaryFile: {
|
|
2358
|
+
read: readBinaryPath,
|
|
2359
|
+
readReference: readBinaryReference,
|
|
2360
|
+
},
|
|
2193
2361
|
call(name, input) {
|
|
2194
2362
|
return invokeAction(name, input);
|
|
2195
2363
|
},
|
|
@@ -2222,6 +2390,7 @@ export function composeRuntime(options) {
|
|
|
2222
2390
|
const reachable = {
|
|
2223
2391
|
md,
|
|
2224
2392
|
watch,
|
|
2393
|
+
referrerScope: (referrer) => options.adapter.referrerScope(referrer),
|
|
2225
2394
|
plan: planned,
|
|
2226
2395
|
query: (plan) => rowsQuery(plan),
|
|
2227
2396
|
watchPlan,
|
package/dist/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C,OAAO,EAGL,KAAK,WAAW,EAOjB,MAAM,WAAW,CAAC;AAInB,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,IAAI,IAAI,CAAC;IACf,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAC1F,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB,CAAC;AAsFF,wBAAgB,cAAc,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAkH3E;AAED,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/host.js
CHANGED
|
@@ -17,6 +17,10 @@ function answered(md, app, writtenBy, member, input) {
|
|
|
17
17
|
return md.save(input[0], input[1], writtenBy);
|
|
18
18
|
case 'history':
|
|
19
19
|
return md.history(input[0], input[1], input[2]);
|
|
20
|
+
case 'binaryFile.read':
|
|
21
|
+
return md.binaryFile.read(input[0], input[1], input[2]);
|
|
22
|
+
case 'binaryFile.readReference':
|
|
23
|
+
return md.binaryFile.readReference(input[0]);
|
|
20
24
|
case 'call':
|
|
21
25
|
return md.call(input[0], input[1]);
|
|
22
26
|
case 'reached':
|
package/dist/identity.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export declare function changeBatchIdentity(at?: number): string;
|
|
|
2
2
|
export declare function roomDraftRevision(): string;
|
|
3
3
|
export declare function chatDraftRevision(): string;
|
|
4
4
|
export declare function transferIdentity(): string;
|
|
5
|
+
export declare function binaryLocalId(): string;
|
|
5
6
|
//# sourceMappingURL=identity.d.ts.map
|
package/dist/identity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,EAAE,GAAE,MAAmB,GAAG,MAAM,CAWnE;AAQD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,aAAa,IAAI,MAAM,CAEtC"}
|
package/dist/identity.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization,
|
|
1
|
+
export type { AcceptedMessage, ActionDeclaration, ActionRequest, ActionResult, Adapter, AdapterFailure, Authorization, BinaryFile, BinaryRequest, BinaryResult, ReferrerScope, BootstrapPage, BootstrapRequest, BootstrapResult, Capability, ChangeAuthor, ContractUnavailable, ConversationAction, ConversationAgents, ConversationEvent, ConversationHistories, ConversationHistoryPage, ConversationHistoryRequest, ConversationMessage, ConversationStream, DiscoverResult, DiscoveredRoom, Discovery, HistoryAuthor, HistoryRequest, HistoryResult, HistoryRetention, HistoryRevision, HeldRoom, ListedConversation, MdModelIdentity, Member, MutationRequest, MutationResult, PageToken, ProviderLimit, ProviderRefusal, RefreshPage, RefreshRequest, RefreshResult, Retention, RetryableRefusal, RevokedAuthorization, RoomModels, RoomNotReadable, RoomStream, RoomStreamEvent, RoomVersionAt, ServiceMode, ServiceModeSignal, TransportUncertainty, TurnContext, TurnOperation, TypedSelection, } from './adapter.js';
|
|
2
2
|
export type { Change, ChangeBatch, Precondition, WrittenBy } from './change.js';
|
|
3
3
|
export type { ChatDraft, ChatDraftSurface, ConversationAgent, ConversationEntry, ConversationOptions, ConversationState, ConversationSurface, ConversationView, RunningTurn, } from './conversation.js';
|
|
4
4
|
export type { ChatDraftFile, FileDeclaration } from './file.js';
|
|
5
|
-
export type { AppRoom, AppTypedSelection, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
5
|
+
export type { AppRoom, AppTypedSelection, BinaryFileSurface, ConnectionRefusal, ConnectionRefusalCode, HistoryQuery, MdRuntime, MdRuntimeOptions, PresentationSurface, RoomDraftSurface, RoomSchemas, SavedRoomDraft, SaveResult, } from './connection.js';
|
|
6
6
|
export type { Observation } from './observation.js';
|
|
7
|
-
export type { CallResult, Failure, HistoryAnswer, QueueEntry, Submission } from './outcome.js';
|
|
7
|
+
export type { BinaryAnswer, CallResult, Failure, HistoryAnswer, QueueEntry, Submission, } from './outcome.js';
|
|
8
|
+
export type { BinaryFileRecord, BinaryReference } from './binary.js';
|
|
8
9
|
export type { RuntimeError } from './failure.js';
|
|
9
10
|
export type { ChangedPart, FieldValue, ReturnReason, RoomDraft, RoomDraftCreation, RoomDraftParts, RoomDraftWrite, } from './room-draft.js';
|
|
10
11
|
export type { SaveRefusal } from './save.js';
|
|
11
12
|
export type { DocumentHit, DocumentPart, MessageHit, SearchRequest, SearchResult, } from './search.js';
|
|
13
|
+
export { departure } from './change.js';
|
|
12
14
|
export { changeBatchIdentity } from './identity.js';
|
|
13
15
|
export { attempts, identities, intentOf, type Answered, type Attempt, type Attempts, type Identities, } from './attempt.js';
|
|
14
16
|
export { expectedList, expecting, type ExpectedOf, type Expecting } from './expectation.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,cAAc,EACd,aAAa,EACb,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,eAAe,EACf,cAAc,EACd,SAAS,EACT,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,UAAU,EACV,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAChE,YAAY,EACV,OAAO,EACP,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,YAAY,E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,UAAU,EACV,WAAW,EACX,OAAO,EACP,MAAM,EACN,KAAK,EACL,KAAK,GACN,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,aAAa,EACb,UAAU,EACV,WAAW,EACX,WAAW,EACX,iBAAiB,GAClB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/memory.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ModelResult } from './model.js';
|
|
2
|
-
import { type AcceptedMessage, type ActionResult, type Adapter, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type
|
|
2
|
+
import { type AcceptedMessage, type ActionResult, type Adapter, type BinaryFile, type Capability, type ConversationAction, type ConversationEvent, type DiscoveredRoom, type HeadChange, type ListedConversation, type Member, type ProviderLimit, type Retention, type ServiceMode } from './adapter.js';
|
|
3
3
|
export type MemoryRoom = DiscoveredRoom & {
|
|
4
4
|
model?: ModelResult;
|
|
5
5
|
selectionModel?: ModelResult;
|
|
6
6
|
documents?: Readonly<Record<string, string>>;
|
|
7
7
|
revisions?: Readonly<Record<string, string>>;
|
|
8
8
|
changes?: Readonly<Record<string, HeadChange>>;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
binaryFiles?: Readonly<Record<string, BinaryFile>>;
|
|
10
|
+
blobs?: Readonly<Record<string, Blob>>;
|
|
11
11
|
};
|
|
12
12
|
export type MemoryConversation = {
|
|
13
13
|
conversation: string;
|
package/dist/memory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,KAAK,eAAe,EAE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,EAAE,CAAC;CAC9C,CAAC;AA+CF,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,aAAa,CA0drF"}
|
package/dist/memory.js
CHANGED
|
@@ -114,24 +114,23 @@ export function createMemoryAdapter(options = {}) {
|
|
|
114
114
|
const size = pageSize ?? paths.length;
|
|
115
115
|
const taken = paths.slice(from, from + size);
|
|
116
116
|
const next = from + taken.length;
|
|
117
|
-
const targets = opening ? (room.
|
|
117
|
+
const targets = opening ? Object.keys(room.binaryFiles ?? {}) : [];
|
|
118
118
|
return {
|
|
119
119
|
kind: 'bootstrap',
|
|
120
120
|
roomVersion: room.roomVersion,
|
|
121
121
|
...(opening ? { models: modelsOf(room) } : {}),
|
|
122
122
|
documents: named(room.documents ?? {}, taken),
|
|
123
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
123
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
124
124
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
125
|
-
|
|
126
|
-
...(opening && room.attachments !== undefined ? { attachments: room.attachments } : {}),
|
|
125
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
127
126
|
...(next < paths.length ? { pageToken: taken.at(-1) } : {}),
|
|
128
127
|
};
|
|
129
128
|
}
|
|
130
129
|
function advancement(room, from, at) {
|
|
131
130
|
const current = room.documents ?? {};
|
|
132
131
|
const previous = from.documents ?? {};
|
|
133
|
-
const currentTargets = new Set(room.
|
|
134
|
-
const previousTargets = new Set(from.
|
|
132
|
+
const currentTargets = new Set(Object.keys(room.binaryFiles ?? {}));
|
|
133
|
+
const previousTargets = new Set(Object.keys(from.binaryFiles ?? {}));
|
|
135
134
|
const headMoved = (path) => room.revisions?.[path] !== from.revisions?.[path] ||
|
|
136
135
|
!sameChange(room.changes?.[path], from.changes?.[path]);
|
|
137
136
|
const changed = Object.keys(current)
|
|
@@ -147,24 +146,21 @@ export function createMemoryAdapter(options = {}) {
|
|
|
147
146
|
const targets = opening
|
|
148
147
|
? [...currentTargets].filter((target) => !previousTargets.has(target) || headMoved(target))
|
|
149
148
|
: [];
|
|
150
|
-
const attachments = room.attachments ?? [];
|
|
151
|
-
const declared = opening && JSON.stringify(attachments) !== JSON.stringify(from.attachments ?? []);
|
|
152
149
|
const models = opening ? changedModels(room, from) : undefined;
|
|
153
150
|
return {
|
|
154
151
|
kind: 'net-advancement',
|
|
155
152
|
roomVersion: room.roomVersion,
|
|
156
153
|
...(models === undefined ? {} : { models }),
|
|
157
154
|
documents: named(current, taken),
|
|
158
|
-
revisions: named(room.revisions ?? {}, taken),
|
|
155
|
+
revisions: named(room.revisions ?? {}, [...taken, ...targets]),
|
|
159
156
|
changes: named(room.changes ?? {}, [...taken, ...targets]),
|
|
160
|
-
|
|
157
|
+
binaryFiles: named(room.binaryFiles ?? {}, targets),
|
|
161
158
|
removals: opening
|
|
162
159
|
? [
|
|
163
160
|
...Object.keys(previous).filter((path) => !(path in current) && !currentTargets.has(path)),
|
|
164
161
|
...[...previousTargets].filter((target) => !currentTargets.has(target) && !(target in current)),
|
|
165
162
|
].sort()
|
|
166
163
|
: [],
|
|
167
|
-
...(declared ? { attachments } : {}),
|
|
168
164
|
...(pageToken === undefined ? {} : { pageToken }),
|
|
169
165
|
};
|
|
170
166
|
}
|
|
@@ -447,6 +443,30 @@ export function createMemoryAdapter(options = {}) {
|
|
|
447
443
|
};
|
|
448
444
|
}, request);
|
|
449
445
|
},
|
|
446
|
+
async binary(_authorization, request) {
|
|
447
|
+
return resolveScript(scripts.binary, () => {
|
|
448
|
+
if (request.kind === 'reference') {
|
|
449
|
+
return { kind: 'rejected', code: 'unscripted-binary', fields: {}, retryable: false };
|
|
450
|
+
}
|
|
451
|
+
const room = rooms.find((entry) => entry.locator === request.locator);
|
|
452
|
+
if (room === undefined)
|
|
453
|
+
return { kind: 'room-not-readable', locator: request.locator };
|
|
454
|
+
const blob = room.blobs?.[request.path];
|
|
455
|
+
return blob === undefined
|
|
456
|
+
? { kind: 'rejected', code: 'file_not_found', fields: {}, retryable: false }
|
|
457
|
+
: { kind: 'binary', blob };
|
|
458
|
+
}, request);
|
|
459
|
+
},
|
|
460
|
+
referrerScope(referrer) {
|
|
461
|
+
if (typeof referrer !== 'object' || referrer === null)
|
|
462
|
+
return null;
|
|
463
|
+
const { room, path, message } = referrer;
|
|
464
|
+
if (typeof message === 'string')
|
|
465
|
+
return { kind: 'conversations' };
|
|
466
|
+
if (typeof room !== 'string')
|
|
467
|
+
return null;
|
|
468
|
+
return { kind: 'room', locator: room, ...(typeof path === 'string' ? { path } : {}) };
|
|
469
|
+
},
|
|
450
470
|
async action(_authorization, request) {
|
|
451
471
|
return resolveScript(scripts.action, () => {
|
|
452
472
|
if (request.name.startsWith('conversation.'))
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryResult, HistoryResult, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
4
|
kind: Kind;
|
|
@@ -14,6 +14,12 @@ export type CallResult = {
|
|
|
14
14
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
15
|
kind: Failure['kind'];
|
|
16
16
|
}> | Failure;
|
|
17
|
+
export type BinaryAnswer = {
|
|
18
|
+
kind: 'binary';
|
|
19
|
+
blob: Blob;
|
|
20
|
+
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
+
export declare function absentBinary(path: string): BinaryAnswer;
|
|
22
|
+
export declare function binaryAnswer(result: BinaryResult): BinaryAnswer;
|
|
17
23
|
export declare const UNCERTAIN: Failure;
|
|
18
24
|
export declare function undeclared(name: string): CallResult;
|
|
19
25
|
export declare function failure(result: AdapterFailure): Failure;
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|
+
export function absentBinary(path) {
|
|
2
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
3
|
+
}
|
|
4
|
+
export function binaryAnswer(result) {
|
|
5
|
+
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
6
|
+
}
|
|
1
7
|
export const UNCERTAIN = {
|
|
2
8
|
kind: 'transport-uncertainty',
|
|
3
9
|
code: 'transport-uncertainty',
|
package/dist/overlay.d.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import type { HeadChange } from './adapter.js';
|
|
1
|
+
import type { BinaryFile, HeadChange } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
3
|
export type Heads = {
|
|
4
4
|
revisions: Readonly<Record<string, string>>;
|
|
5
5
|
changes: Readonly<Record<string, HeadChange>>;
|
|
6
6
|
};
|
|
7
|
+
export type HeldBinary = ({
|
|
8
|
+
readonly state: 'accepted';
|
|
9
|
+
} & BinaryFile) | {
|
|
10
|
+
readonly state: 'pending';
|
|
11
|
+
readonly localId: string;
|
|
12
|
+
readonly byteLength: number;
|
|
13
|
+
readonly mediaType: string;
|
|
14
|
+
readonly sha256: string;
|
|
15
|
+
};
|
|
7
16
|
export type Layer = Heads & {
|
|
8
17
|
documents: Readonly<Record<string, string>>;
|
|
9
|
-
|
|
18
|
+
binaries: Readonly<Record<string, HeldBinary>>;
|
|
10
19
|
};
|
|
20
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Record<string, HeldBinary>;
|
|
21
|
+
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
11
22
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
12
23
|
export declare function overlay(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Layer;
|
|
13
24
|
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
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