@agentshouse/mdruntime 0.1.0-c5d3fa6fb67bc → 0.1.0-c5f333dfa0583
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 +225 -212
- package/README.md +9 -8
- package/dist/adapter.d.ts +64 -24
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +13 -3
- package/dist/bootstrap.d.ts +15 -7
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +90 -61
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +8 -9
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +10 -85
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/chat/earlier.d.ts +10 -0
- package/dist/chat/earlier.d.ts.map +1 -0
- package/dist/chat/earlier.js +54 -0
- package/dist/chat/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +3 -1
- package/dist/chat/input.d.ts.map +1 -1
- package/dist/chat/input.js +11 -18
- package/dist/chat/kit.js +1 -1
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +45 -5
- package/dist/chat/markdown.d.ts +1 -0
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +78 -20
- package/dist/chat/message.d.ts +1 -0
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +73 -11
- package/dist/chat/messages.d.ts +14 -1
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +79 -24
- package/dist/chat/name.d.ts +1 -0
- package/dist/chat/name.d.ts.map +1 -1
- package/dist/chat/name.js +1 -1
- package/dist/chat/opened.d.ts +1 -0
- package/dist/chat/opened.d.ts.map +1 -1
- package/dist/chat/opened.js +2 -0
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +11 -5
- package/dist/chat/parts.d.ts +1 -0
- package/dist/chat/parts.d.ts.map +1 -1
- package/dist/chat/parts.js +3 -2
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +8 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +98 -92
- package/dist/chat/question.d.ts +1 -1
- package/dist/chat/question.d.ts.map +1 -1
- package/dist/chat/question.js +7 -18
- package/dist/chat/ready.d.ts +5 -2
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +7 -5
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +72 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts.map +1 -1
- package/dist/chat/style.js +6 -1
- package/dist/chat.d.ts +3 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +11 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +45 -7
- package/dist/collection.d.ts +6 -19
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +30 -287
- package/dist/compile.d.ts +11 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +712 -0
- package/dist/connection.d.ts +21 -8
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2319 -688
- package/dist/conversation.d.ts +15 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +233 -80
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +2 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -23
- package/dist/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/host.d.ts +5 -4
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +55 -7
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +7 -3
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +39 -17
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +14 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +93 -3
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +35 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +28 -0
- package/dist/overlay.d.ts +2 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +86 -171
- package/dist/query.d.ts +26 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +34 -6
- package/dist/reach.d.ts +5 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +167 -48
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +1 -1
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +98 -0
- package/dist/recovery.d.ts +2 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +8 -7
- package/dist/refresh.d.ts +12 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +74 -51
- package/dist/replica.d.ts +55 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +295 -186
- package/dist/room-draft.d.ts +15 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +32 -25
- package/dist/rows.d.ts +29 -30
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -64
- package/dist/save.d.ts +51 -14
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +518 -180
- package/dist/search.d.ts +19 -4
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +192 -35
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +8 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +129 -66
- package/dist/store.d.ts +99 -71
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +461 -586
- package/dist/stored.d.ts +143 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +561 -0
- package/dist/tables.d.ts +320 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +537 -0
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +51 -21
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +32 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +8 -0
- package/package.json +10 -3
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
- package/dist/read-side.d.ts +0 -25
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -642
package/dist/opened.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { digest } from './digest.js';
|
|
2
|
+
import { binaryLocalId } from './identity.js';
|
|
3
|
+
import { FILE_PART_BYTES } from './tables.js';
|
|
4
|
+
const UNCERTAIN = { kind: 'transport-uncertainty' };
|
|
5
|
+
function kept({ key, byteLength, mediaType }) {
|
|
6
|
+
return { kind: 'binary', file: key, byteLength, mediaType };
|
|
7
|
+
}
|
|
8
|
+
function taken(chunks, size) {
|
|
9
|
+
const part = new Uint8Array(size);
|
|
10
|
+
let at = 0;
|
|
11
|
+
while (at < size) {
|
|
12
|
+
const chunk = chunks[0];
|
|
13
|
+
const wanted = Math.min(chunk.length, size - at);
|
|
14
|
+
part.set(chunk.subarray(0, wanted), at);
|
|
15
|
+
at += wanted;
|
|
16
|
+
if (wanted === chunk.length)
|
|
17
|
+
chunks.shift();
|
|
18
|
+
else
|
|
19
|
+
chunks[0] = chunk.subarray(wanted);
|
|
20
|
+
}
|
|
21
|
+
return part;
|
|
22
|
+
}
|
|
23
|
+
export function openedFiles(database, fenced) {
|
|
24
|
+
const fetching = new Map();
|
|
25
|
+
async function find(name) {
|
|
26
|
+
const held = await database.ask({ kind: 'opened.find', ...name });
|
|
27
|
+
return held === null ? null : kept(held);
|
|
28
|
+
}
|
|
29
|
+
async function written(name, { body, mediaType, sha256 }) {
|
|
30
|
+
const key = binaryLocalId();
|
|
31
|
+
const reader = body.getReader();
|
|
32
|
+
const hashed = digest();
|
|
33
|
+
const chunks = [];
|
|
34
|
+
let held = 0;
|
|
35
|
+
let size = 0;
|
|
36
|
+
let part = 0;
|
|
37
|
+
const write = async (bytes) => {
|
|
38
|
+
if (!(await database.ask({ kind: 'opened.part', key, part, bytes }))) {
|
|
39
|
+
throw new Error('the device no longer keeps this download');
|
|
40
|
+
}
|
|
41
|
+
part += 1;
|
|
42
|
+
};
|
|
43
|
+
try {
|
|
44
|
+
if (fenced(name.locator) ||
|
|
45
|
+
!(await database.ask({ kind: 'opened.begin', key, ...name, mediaType }))) {
|
|
46
|
+
throw new Error('the device no longer reads this Room');
|
|
47
|
+
}
|
|
48
|
+
for (;;) {
|
|
49
|
+
const read = await reader.read();
|
|
50
|
+
if (read.done)
|
|
51
|
+
break;
|
|
52
|
+
hashed.update(read.value);
|
|
53
|
+
size += read.value.length;
|
|
54
|
+
chunks.push(read.value);
|
|
55
|
+
held += read.value.length;
|
|
56
|
+
for (; held >= FILE_PART_BYTES; held -= FILE_PART_BYTES) {
|
|
57
|
+
await write(taken(chunks, FILE_PART_BYTES));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (held > 0)
|
|
61
|
+
await write(taken(chunks, held));
|
|
62
|
+
const received = hashed.hex();
|
|
63
|
+
if (sha256 !== undefined && sha256 !== received) {
|
|
64
|
+
throw new Error('the bytes are not the file the device asked for');
|
|
65
|
+
}
|
|
66
|
+
const whole = await database.ask({
|
|
67
|
+
kind: 'opened.keep',
|
|
68
|
+
key,
|
|
69
|
+
sha256: received,
|
|
70
|
+
byteLength: size,
|
|
71
|
+
parts: part,
|
|
72
|
+
});
|
|
73
|
+
return whole ? { kind: 'binary', file: key, byteLength: size, mediaType } : null;
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
await reader.cancel().catch(() => { });
|
|
77
|
+
await database.ask({ kind: 'opened.drop', key }).catch(() => null);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async function fetched(name, read) {
|
|
82
|
+
const held = await find(name);
|
|
83
|
+
if (held !== null)
|
|
84
|
+
return held;
|
|
85
|
+
const result = await read();
|
|
86
|
+
if (result.kind !== 'binary')
|
|
87
|
+
return result;
|
|
88
|
+
return (await written(name, result)) ?? UNCERTAIN;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
find,
|
|
92
|
+
fetch(name, read) {
|
|
93
|
+
const identity = `${name.locator}\u0000${name.path}\u0000${name.revision}`;
|
|
94
|
+
const held = fetching.get(identity);
|
|
95
|
+
if (held !== undefined)
|
|
96
|
+
return held;
|
|
97
|
+
const work = fetched(name, read);
|
|
98
|
+
fetching.set(identity, work);
|
|
99
|
+
const done = () => {
|
|
100
|
+
if (fetching.get(identity) === work)
|
|
101
|
+
fetching.delete(identity);
|
|
102
|
+
};
|
|
103
|
+
work.then(done, done);
|
|
104
|
+
return work;
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
package/dist/outcome.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { ActionResult, AdapterFailure,
|
|
1
|
+
import type { ActionResult, AdapterFailure, BinaryLinkResult, HistoryResult, HistoryRevision, ProviderRefusal, RoomVersionAt, ScopedRefusal } from './adapter.js';
|
|
2
2
|
import type { ChangeBatch } from './change.js';
|
|
3
|
+
import type { KeptBinary, KeptResult } from './opened.js';
|
|
3
4
|
type Refused<Kind extends string> = ProviderRefusal & {
|
|
4
5
|
kind: Kind;
|
|
5
6
|
};
|
|
6
7
|
export type Failure = Refused<'transport-uncertainty'> | Refused<'revoked-authorization'> | (Refused<'room-not-readable'> & {
|
|
7
8
|
locator: string;
|
|
9
|
+
}) | (Refused<'room-locked'> & {
|
|
10
|
+
locator: string;
|
|
8
11
|
}) | ScopedRefusal;
|
|
9
12
|
export type CallResult = {
|
|
10
13
|
kind: 'action';
|
|
@@ -14,12 +17,40 @@ export type CallResult = {
|
|
|
14
17
|
export type HistoryAnswer = Exclude<HistoryResult, {
|
|
15
18
|
kind: Failure['kind'];
|
|
16
19
|
}> | Failure;
|
|
20
|
+
type BinaryRefusal = Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
17
21
|
export type BinaryAnswer = {
|
|
18
22
|
kind: 'binary';
|
|
19
|
-
|
|
23
|
+
stream: ReadableStream<Uint8Array>;
|
|
24
|
+
byteLength: number;
|
|
25
|
+
mediaType: string;
|
|
26
|
+
} | BinaryRefusal;
|
|
27
|
+
export type HeldBinaryAnswer = KeptBinary | BinaryRefusal;
|
|
28
|
+
export type BinaryLinkAnswer = {
|
|
29
|
+
kind: 'link';
|
|
30
|
+
url: string;
|
|
31
|
+
name: string;
|
|
20
32
|
} | Refused<'rejected'> | Refused<'absent'> | Failure;
|
|
21
|
-
export
|
|
22
|
-
|
|
33
|
+
export type Resolution = {
|
|
34
|
+
readonly kind: 'document';
|
|
35
|
+
readonly room: string;
|
|
36
|
+
readonly path: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'deleted';
|
|
39
|
+
readonly room: string;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly revision: HistoryRevision;
|
|
42
|
+
} | Refused<'unreadable'> | Refused<'absent'> | Failure;
|
|
43
|
+
export declare const UNREADABLE: Refused<'unreadable'>;
|
|
44
|
+
export declare const LOCKED_UNREADABLE: Refused<'unreadable'>;
|
|
45
|
+
export declare const ABSENT_TARGET: Refused<'absent'>;
|
|
46
|
+
export declare function absentBinary(path: string): Refused<'absent'>;
|
|
47
|
+
export declare function absentReference(fileRef: string): Refused<'absent'>;
|
|
48
|
+
export declare function binaryAnswer(result: KeptResult): HeldBinaryAnswer;
|
|
49
|
+
export declare function binaryLinkAnswer(result: BinaryLinkResult): BinaryLinkAnswer;
|
|
50
|
+
export declare const ROOM_LOCKED = "room-locked";
|
|
51
|
+
export declare function lockedRoom(locator: string): Refused<'room-locked'> & {
|
|
52
|
+
locator: string;
|
|
53
|
+
};
|
|
23
54
|
export type Offline = {
|
|
24
55
|
readonly kind: 'offline';
|
|
25
56
|
};
|
package/dist/outcome.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/outcome.ts"],"names":[],"mappings":"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"}
|
package/dist/outcome.js
CHANGED
|
@@ -1,9 +1,37 @@
|
|
|
1
|
+
export const UNREADABLE = {
|
|
2
|
+
kind: 'unreadable',
|
|
3
|
+
code: 'room-not-readable',
|
|
4
|
+
fields: {},
|
|
5
|
+
retryable: false,
|
|
6
|
+
};
|
|
7
|
+
export const LOCKED_UNREADABLE = {
|
|
8
|
+
kind: 'unreadable',
|
|
9
|
+
code: 'room-locked',
|
|
10
|
+
fields: {},
|
|
11
|
+
retryable: true,
|
|
12
|
+
};
|
|
13
|
+
export const ABSENT_TARGET = {
|
|
14
|
+
kind: 'absent',
|
|
15
|
+
code: 'reference-absent',
|
|
16
|
+
fields: {},
|
|
17
|
+
retryable: false,
|
|
18
|
+
};
|
|
1
19
|
export function absentBinary(path) {
|
|
2
20
|
return { kind: 'absent', code: 'binary-file-absent', fields: { path }, retryable: false };
|
|
3
21
|
}
|
|
22
|
+
export function absentReference(fileRef) {
|
|
23
|
+
return { kind: 'absent', code: 'binary-file-absent', fields: { fileRef }, retryable: false };
|
|
24
|
+
}
|
|
4
25
|
export function binaryAnswer(result) {
|
|
5
26
|
return result.kind === 'binary' || result.kind === 'rejected' ? result : failure(result);
|
|
6
27
|
}
|
|
28
|
+
export function binaryLinkAnswer(result) {
|
|
29
|
+
return result.kind === 'link' || result.kind === 'rejected' ? result : failure(result);
|
|
30
|
+
}
|
|
31
|
+
export const ROOM_LOCKED = 'room-locked';
|
|
32
|
+
export function lockedRoom(locator) {
|
|
33
|
+
return { kind: ROOM_LOCKED, locator, code: ROOM_LOCKED, fields: {}, retryable: true };
|
|
34
|
+
}
|
|
7
35
|
export const OFFLINE = { kind: 'offline' };
|
|
8
36
|
export const UNCERTAIN = {
|
|
9
37
|
kind: 'transport-uncertainty',
|
package/dist/overlay.d.ts
CHANGED
|
@@ -18,11 +18,8 @@ export type Layer = Heads & {
|
|
|
18
18
|
documents: Readonly<Record<string, string>>;
|
|
19
19
|
binaries: Readonly<Record<string, HeldBinary>>;
|
|
20
20
|
};
|
|
21
|
-
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>):
|
|
21
|
+
export declare function acceptedBinaries(files: Readonly<Record<string, BinaryFile>>): Generator<readonly [string, HeldBinary]>;
|
|
22
22
|
export declare function sameBinary(left: HeldBinary | undefined, right: HeldBinary | undefined): boolean;
|
|
23
23
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function sameLayerText(left: Layer, right: Layer): boolean;
|
|
26
|
-
export declare function changedPaths(left: Layer, right: Layer): ReadonlySet<string>;
|
|
27
|
-
export declare function overlayChanged(base: Layer, queue: readonly ChangeBatch[], previousBase: Layer, previousQueue: readonly ChangeBatch[], previousVisible: Layer): Layer;
|
|
24
|
+
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], unapplied?: () => void): Generator<number, Layer, void>;
|
|
28
25
|
//# sourceMappingURL=overlay.d.ts.map
|
package/dist/overlay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAU,WAAW,EAAgB,MAAM,aAAa,CAAC;AAIrE,MAAM,MAAM,KAAK,GAAG;IAClB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAAC,GAC7C;IACE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAEN,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG;IAC1B,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,wBAAiB,gBAAgB,CAC/B,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAC1C,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAE1C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAW/F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAQ/F;AAqMD,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAoChC"}
|
package/dist/overlay.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { apply, parse, serialize } from '@agentshouse/mdmodel';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { apply, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
|
|
2
|
+
import { drafted, entriesIn, settling } from './shared.js';
|
|
3
|
+
import { ROW_WEIGHT } from './turn.js';
|
|
4
|
+
export function* acceptedBinaries(files) {
|
|
5
|
+
for (const [path, file] of entriesIn(files))
|
|
6
|
+
yield [path, { state: 'accepted', ...file }];
|
|
5
7
|
}
|
|
6
8
|
export function sameBinary(left, right) {
|
|
7
9
|
if (left === undefined || right === undefined)
|
|
@@ -23,10 +25,13 @@ export function sameChange(left, right) {
|
|
|
23
25
|
left.author?.name === right.author?.name);
|
|
24
26
|
}
|
|
25
27
|
const EMPTY_FRONTMATTER = '---\n---\n';
|
|
28
|
+
function isPart(change) {
|
|
29
|
+
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
30
|
+
}
|
|
26
31
|
function at(path, name) {
|
|
27
32
|
return `${path} ${name}`;
|
|
28
33
|
}
|
|
29
|
-
function priorsOf(preconditions) {
|
|
34
|
+
function* priorsOf(preconditions) {
|
|
30
35
|
const fields = new Map();
|
|
31
36
|
const sections = new Map();
|
|
32
37
|
const preambles = new Map();
|
|
@@ -40,6 +45,7 @@ function priorsOf(preconditions) {
|
|
|
40
45
|
if (precondition.kind === 'preamble') {
|
|
41
46
|
preambles.set(precondition.path, precondition.value);
|
|
42
47
|
}
|
|
48
|
+
yield ROW_WEIGHT;
|
|
43
49
|
}
|
|
44
50
|
return {
|
|
45
51
|
field: (path, name) => fields.get(at(path, name)),
|
|
@@ -55,51 +61,50 @@ function compose(fields, sections) {
|
|
|
55
61
|
const opened = parse(skeleton);
|
|
56
62
|
if (!opened.ok)
|
|
57
63
|
return skeleton;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const next = apply(document, { kind: 'field', name, value, prior: undefined });
|
|
61
|
-
if (next.outcome === 'applied')
|
|
62
|
-
document = next.document;
|
|
63
|
-
}
|
|
64
|
-
return serialize(document);
|
|
64
|
+
const next = apply(opened.document, Object.entries(fields).flatMap(([name, value]) => frontmatterValue(value) ? [{ kind: 'field', name, value, prior: undefined }] : []));
|
|
65
|
+
return serialize(next.outcome === 'applied' ? next.document : opened.document);
|
|
65
66
|
}
|
|
66
|
-
function edited(
|
|
67
|
-
if (change.kind === 'field')
|
|
68
|
-
return
|
|
67
|
+
function edited(change, priors) {
|
|
68
|
+
if (change.kind === 'field')
|
|
69
|
+
return {
|
|
69
70
|
kind: 'field',
|
|
70
71
|
name: change.name,
|
|
71
72
|
value: change.value,
|
|
72
73
|
prior: priors.field(change.path, change.name),
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
kind: 'preamble',
|
|
78
|
-
value: change.value,
|
|
79
|
-
prior: priors.preamble(change.path),
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (change.kind !== 'section')
|
|
83
|
-
return null;
|
|
84
|
-
return apply(document, {
|
|
74
|
+
};
|
|
75
|
+
if (change.kind === 'preamble')
|
|
76
|
+
return { kind: 'preamble', value: change.value, prior: priors.preamble(change.path) };
|
|
77
|
+
return {
|
|
85
78
|
kind: 'section',
|
|
86
79
|
name: change.name,
|
|
87
80
|
value: change.value,
|
|
88
81
|
prior: priors.section(change.path, change.name),
|
|
89
|
-
}
|
|
82
|
+
};
|
|
90
83
|
}
|
|
91
|
-
function edit(staged,
|
|
92
|
-
const
|
|
84
|
+
function edit(staged, changes, priors) {
|
|
85
|
+
const path = changes[0].path;
|
|
86
|
+
delete staged.revisions[path];
|
|
87
|
+
const text = staged.documents[path];
|
|
93
88
|
if (text === undefined)
|
|
94
|
-
return
|
|
95
|
-
const parsed = parse(text,
|
|
89
|
+
return changes.length;
|
|
90
|
+
const parsed = parse(text, path);
|
|
96
91
|
if (!parsed.ok)
|
|
97
|
-
return
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
return changes.length;
|
|
93
|
+
const wanted = changes.map((change) => edited(change, priors));
|
|
94
|
+
const first = apply(parsed.document, wanted);
|
|
95
|
+
if (first.outcome === 'refuse')
|
|
96
|
+
return changes.length;
|
|
97
|
+
if (first.outcome === 'applied') {
|
|
98
|
+
staged.documents[path] = serialize(first.document);
|
|
99
|
+
return 0;
|
|
100
|
+
}
|
|
101
|
+
const stale = new Set(first.stale);
|
|
102
|
+
const kept = wanted.filter((_, at) => !stale.has(at));
|
|
103
|
+
const rest = apply(parsed.document, kept);
|
|
104
|
+
if (rest.outcome !== 'applied')
|
|
105
|
+
return changes.length;
|
|
106
|
+
staged.documents[path] = serialize(rest.document);
|
|
107
|
+
return first.stale.length;
|
|
103
108
|
}
|
|
104
109
|
function relocate(staged, from, to) {
|
|
105
110
|
const text = staged.documents[from];
|
|
@@ -140,11 +145,7 @@ function erase(staged, path) {
|
|
|
140
145
|
delete staged.changes[path];
|
|
141
146
|
delete staged.binaries[path];
|
|
142
147
|
}
|
|
143
|
-
function stage(staged, change
|
|
144
|
-
if (change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble') {
|
|
145
|
-
delete staged.revisions[change.path];
|
|
146
|
-
return edit(staged, change, priors);
|
|
147
|
-
}
|
|
148
|
+
function stage(staged, change) {
|
|
148
149
|
if (change.kind === 'create') {
|
|
149
150
|
staged.documents[change.path] =
|
|
150
151
|
'content' in change ? change.content : compose(change.fields, change.sections);
|
|
@@ -176,10 +177,27 @@ function stage(staged, change, priors) {
|
|
|
176
177
|
if (change.kind === 'move') {
|
|
177
178
|
return relocate(staged, change.path, change.to);
|
|
178
179
|
}
|
|
180
|
+
if (change.kind === 'arrival') {
|
|
181
|
+
erase(staged, change.path);
|
|
182
|
+
if ('content' in change)
|
|
183
|
+
staged.documents[change.path] = change.content;
|
|
184
|
+
else
|
|
185
|
+
staged.binaries[change.path] = { state: 'accepted', ...change.binary };
|
|
186
|
+
arrive(staged, change);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
179
189
|
erase(staged, change.path);
|
|
180
190
|
return true;
|
|
181
191
|
}
|
|
182
|
-
|
|
192
|
+
function arrive(heads, change) {
|
|
193
|
+
if (change.revision !== undefined)
|
|
194
|
+
heads.revisions[change.path] = change.revision;
|
|
195
|
+
if (change.fileId !== undefined)
|
|
196
|
+
heads.fileIds[change.path] = change.fileId;
|
|
197
|
+
if (change.change !== undefined)
|
|
198
|
+
heads.changes[change.path] = change.change;
|
|
199
|
+
}
|
|
200
|
+
export function* overlaying(base, queue, unapplied) {
|
|
183
201
|
const staged = {
|
|
184
202
|
documents: drafted(base.documents),
|
|
185
203
|
binaries: drafted(base.binaries),
|
|
@@ -188,137 +206,34 @@ export function overlay(base, queue, unapplied) {
|
|
|
188
206
|
changes: drafted(base.changes),
|
|
189
207
|
};
|
|
190
208
|
for (const batch of queue) {
|
|
191
|
-
const priors = priorsOf(batch.preconditions);
|
|
192
|
-
for (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
documents: settled(staged.documents),
|
|
199
|
-
binaries: settled(staged.binaries),
|
|
200
|
-
revisions: settled(staged.revisions),
|
|
201
|
-
fileIds: settled(staged.fileIds),
|
|
202
|
-
changes: settled(staged.changes),
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function pathsOf(batch) {
|
|
206
|
-
return batch.changes.flatMap((change) => change.kind === 'move' ? [change.path, change.to] : [change.path]);
|
|
207
|
-
}
|
|
208
|
-
export function sameLayerText(left, right) {
|
|
209
|
-
return (differing(left.documents, right.documents).size === 0 &&
|
|
210
|
-
differing(left.binaries, right.binaries, sameBinary).size === 0);
|
|
211
|
-
}
|
|
212
|
-
export function changedPaths(left, right) {
|
|
213
|
-
return new Set([
|
|
214
|
-
...differing(left.documents, right.documents),
|
|
215
|
-
...differing(left.revisions, right.revisions),
|
|
216
|
-
...differing(left.fileIds, right.fileIds),
|
|
217
|
-
...differing(left.changes, right.changes, sameChange),
|
|
218
|
-
...differing(left.binaries, right.binaries, sameBinary),
|
|
219
|
-
]);
|
|
220
|
-
}
|
|
221
|
-
function replayHeads(base, queue) {
|
|
222
|
-
const heads = {
|
|
223
|
-
revisions: drafted(base.revisions),
|
|
224
|
-
fileIds: drafted(base.fileIds),
|
|
225
|
-
changes: drafted(base.changes),
|
|
226
|
-
};
|
|
227
|
-
for (const batch of queue) {
|
|
228
|
-
for (const change of batch.changes) {
|
|
229
|
-
if (change.kind === 'remove') {
|
|
230
|
-
delete heads.revisions[change.path];
|
|
231
|
-
delete heads.fileIds[change.path];
|
|
232
|
-
delete heads.changes[change.path];
|
|
233
|
-
}
|
|
234
|
-
else if (change.kind === 'create') {
|
|
235
|
-
delete heads.fileIds[change.path];
|
|
236
|
-
delete heads.changes[change.path];
|
|
237
|
-
}
|
|
238
|
-
else if (change.kind === 'replace' ||
|
|
239
|
-
change.kind === 'field' ||
|
|
240
|
-
change.kind === 'section' ||
|
|
241
|
-
change.kind === 'preamble') {
|
|
242
|
-
delete heads.revisions[change.path];
|
|
243
|
-
}
|
|
244
|
-
else if (change.kind === 'binary') {
|
|
245
|
-
delete heads.revisions[change.path];
|
|
246
|
-
delete heads.changes[change.path];
|
|
247
|
-
}
|
|
248
|
-
else if (change.kind === 'move') {
|
|
249
|
-
moveHead(heads, change.path, change.to);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return {
|
|
254
|
-
revisions: settled(heads.revisions),
|
|
255
|
-
fileIds: settled(heads.fileIds),
|
|
256
|
-
changes: settled(heads.changes),
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
export function overlayChanged(base, queue, previousBase, previousQueue, previousVisible) {
|
|
260
|
-
const before = previousQueue.map((batch) => JSON.stringify(batch));
|
|
261
|
-
const after = queue.map((batch) => JSON.stringify(batch));
|
|
262
|
-
if (before.length === after.length &&
|
|
263
|
-
before.every((id, index) => id === after[index]) &&
|
|
264
|
-
sameLayerText(base, previousBase)) {
|
|
265
|
-
return {
|
|
266
|
-
documents: previousVisible.documents,
|
|
267
|
-
binaries: previousVisible.binaries,
|
|
268
|
-
...replayHeads(base, queue),
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
const affected = new Set(changedPaths(base, previousBase));
|
|
272
|
-
const oldIds = new Set(before);
|
|
273
|
-
const newIds = new Set(after);
|
|
274
|
-
for (const batch of previousQueue) {
|
|
275
|
-
if (!newIds.has(JSON.stringify(batch)))
|
|
276
|
-
for (const path of pathsOf(batch))
|
|
277
|
-
affected.add(path);
|
|
278
|
-
}
|
|
279
|
-
for (const batch of queue) {
|
|
280
|
-
if (!oldIds.has(JSON.stringify(batch)))
|
|
281
|
-
for (const path of pathsOf(batch))
|
|
282
|
-
affected.add(path);
|
|
283
|
-
}
|
|
284
|
-
let expanded = true;
|
|
285
|
-
while (expanded) {
|
|
286
|
-
expanded = false;
|
|
287
|
-
for (const batch of queue) {
|
|
288
|
-
const touched = pathsOf(batch);
|
|
289
|
-
if (!touched.some((path) => affected.has(path)))
|
|
209
|
+
const priors = yield* priorsOf(batch.preconditions);
|
|
210
|
+
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
211
|
+
const change = batch.changes[index];
|
|
212
|
+
if (!isPart(change)) {
|
|
213
|
+
if (!stage(staged, change))
|
|
214
|
+
unapplied?.();
|
|
215
|
+
yield ROW_WEIGHT;
|
|
290
216
|
continue;
|
|
291
|
-
for (const path of touched) {
|
|
292
|
-
if (affected.has(path))
|
|
293
|
-
continue;
|
|
294
|
-
affected.add(path);
|
|
295
|
-
expanded = true;
|
|
296
217
|
}
|
|
218
|
+
const run = [change];
|
|
219
|
+
while (index + 1 < batch.changes.length) {
|
|
220
|
+
const next = batch.changes[index + 1];
|
|
221
|
+
if (!isPart(next) || next.path !== change.path)
|
|
222
|
+
break;
|
|
223
|
+
run.push(next);
|
|
224
|
+
index += 1;
|
|
225
|
+
}
|
|
226
|
+
const text = staged.documents[change.path] ?? '';
|
|
227
|
+
for (let left = edit(staged, run, priors); left > 0; left -= 1)
|
|
228
|
+
unapplied?.();
|
|
229
|
+
yield ROW_WEIGHT + text.length;
|
|
297
230
|
}
|
|
298
231
|
}
|
|
299
|
-
const documents = {};
|
|
300
|
-
const revisions = {};
|
|
301
|
-
const fileIds = {};
|
|
302
|
-
const changes = {};
|
|
303
|
-
const binaries = {};
|
|
304
|
-
for (const path of affected) {
|
|
305
|
-
if (base.documents[path] !== undefined)
|
|
306
|
-
documents[path] = base.documents[path];
|
|
307
|
-
if (base.revisions[path] !== undefined)
|
|
308
|
-
revisions[path] = base.revisions[path];
|
|
309
|
-
if (base.fileIds[path] !== undefined)
|
|
310
|
-
fileIds[path] = base.fileIds[path];
|
|
311
|
-
if (base.changes[path] !== undefined)
|
|
312
|
-
changes[path] = base.changes[path];
|
|
313
|
-
if (base.binaries[path] !== undefined)
|
|
314
|
-
binaries[path] = base.binaries[path];
|
|
315
|
-
}
|
|
316
|
-
const staged = overlay({ documents, revisions, fileIds, changes, binaries }, queue.filter((batch) => pathsOf(batch).some((path) => affected.has(path))));
|
|
317
232
|
return {
|
|
318
|
-
documents:
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
233
|
+
documents: yield* settling(staged.documents),
|
|
234
|
+
binaries: yield* settling(staged.binaries),
|
|
235
|
+
revisions: yield* settling(staged.revisions),
|
|
236
|
+
fileIds: yield* settling(staged.fileIds),
|
|
237
|
+
changes: yield* settling(staged.changes),
|
|
323
238
|
};
|
|
324
239
|
}
|
package/dist/query.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export type Filter = {
|
|
|
38
38
|
types?: readonly string[];
|
|
39
39
|
where?: Where;
|
|
40
40
|
pathPrefix?: string;
|
|
41
|
+
folder?: string;
|
|
42
|
+
paths?: readonly string[];
|
|
41
43
|
hop?: Related & {
|
|
42
44
|
field: string;
|
|
43
45
|
};
|
|
@@ -45,7 +47,7 @@ export type Filter = {
|
|
|
45
47
|
field?: string;
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
|
-
export type Key = 'room' | 'path' | 'type' | {
|
|
50
|
+
export type Key = 'room' | 'path' | 'type' | 'folder' | {
|
|
49
51
|
field: string;
|
|
50
52
|
};
|
|
51
53
|
export type Select = 'all' | {
|
|
@@ -71,6 +73,8 @@ export type DocumentQuery = Filter & {
|
|
|
71
73
|
direction?: Direction;
|
|
72
74
|
} & OrderOptions)[];
|
|
73
75
|
limit?: number;
|
|
76
|
+
after?: string;
|
|
77
|
+
total?: true;
|
|
74
78
|
};
|
|
75
79
|
export type GroupQuery = Filter & {
|
|
76
80
|
groupBy: readonly Exclude<Key, 'path'>[];
|
|
@@ -79,6 +83,8 @@ export type GroupQuery = Filter & {
|
|
|
79
83
|
direction?: Direction;
|
|
80
84
|
}[];
|
|
81
85
|
limit?: number;
|
|
86
|
+
after?: string;
|
|
87
|
+
total?: true;
|
|
82
88
|
};
|
|
83
89
|
export type LocalQuery = DocumentQuery | GroupQuery;
|
|
84
90
|
export type Backlink = {
|
|
@@ -113,7 +119,7 @@ export type QueryCoverage = {
|
|
|
113
119
|
indexes: readonly string[];
|
|
114
120
|
overlay: readonly string[];
|
|
115
121
|
};
|
|
116
|
-
export type Awaits = Open<'acquisition' | 'preparation' | 'index'>;
|
|
122
|
+
export type Awaits = Open<'acquisition' | 'preparation' | 'index' | 'unlock'>;
|
|
117
123
|
export type PendingRoom = {
|
|
118
124
|
room: string;
|
|
119
125
|
awaits: Awaits;
|
|
@@ -123,9 +129,13 @@ export type PendingResult = {
|
|
|
123
129
|
};
|
|
124
130
|
export type DocumentRows = {
|
|
125
131
|
documents: readonly QueryDocument[];
|
|
132
|
+
next?: string;
|
|
133
|
+
total?: number;
|
|
126
134
|
};
|
|
127
135
|
export type GroupRows = {
|
|
128
136
|
groups: readonly QueryGroup[];
|
|
137
|
+
next?: string;
|
|
138
|
+
total?: number;
|
|
129
139
|
};
|
|
130
140
|
export type QueryRows = DocumentRows | GroupRows;
|
|
131
141
|
export type DocumentResult = DocumentRows & {
|
|
@@ -189,6 +199,8 @@ export type KeyPlan = {
|
|
|
189
199
|
of: 'path';
|
|
190
200
|
} | {
|
|
191
201
|
of: 'type';
|
|
202
|
+
} | {
|
|
203
|
+
of: 'folder';
|
|
192
204
|
} | {
|
|
193
205
|
of: 'field';
|
|
194
206
|
field: string;
|
|
@@ -221,10 +233,18 @@ export type PlanReach = {
|
|
|
221
233
|
rooms: readonly string[];
|
|
222
234
|
documents: readonly string[];
|
|
223
235
|
};
|
|
236
|
+
export type Continuation = {
|
|
237
|
+
text: string;
|
|
238
|
+
values: readonly unknown[] | null;
|
|
239
|
+
};
|
|
224
240
|
export type Plan = {
|
|
241
|
+
key: string;
|
|
225
242
|
rooms: readonly string[] | null;
|
|
226
243
|
reach: PlanReach | null;
|
|
244
|
+
locked: readonly string[];
|
|
227
245
|
root: Scope;
|
|
246
|
+
folder: string | null;
|
|
247
|
+
paths: readonly string[] | null;
|
|
228
248
|
hop: (Scope & {
|
|
229
249
|
field: string;
|
|
230
250
|
}) | null;
|
|
@@ -233,6 +253,8 @@ export type Plan = {
|
|
|
233
253
|
}) | null;
|
|
234
254
|
shape: DocumentShape | GroupShape;
|
|
235
255
|
limit: number | null;
|
|
256
|
+
after: Continuation | null;
|
|
257
|
+
total: boolean;
|
|
236
258
|
};
|
|
237
259
|
export declare class QueryError extends Error {
|
|
238
260
|
readonly code: QueryErrorCode;
|
|
@@ -243,9 +265,11 @@ type Entries = Readonly<Record<string, unknown>>;
|
|
|
243
265
|
export declare function invalid(at: string, problem: string): never;
|
|
244
266
|
export declare function plain(value: unknown): value is Entries;
|
|
245
267
|
export declare function known(value: Entries, allowed: readonly string[], at: string): void;
|
|
268
|
+
export declare function flag(input: unknown, at: string): boolean;
|
|
246
269
|
export declare function planOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
247
270
|
export declare function limitOf(input: unknown): number | null;
|
|
248
271
|
export declare function filterOf(input: unknown, facts: HeldRooms, reach?: PlanReach | null): Plan;
|
|
272
|
+
export declare function queryKey(query: unknown): string;
|
|
249
273
|
export declare function identityOf(plan: Plan): string;
|
|
250
274
|
export {};
|
|
251
275
|
//# sourceMappingURL=query.d.ts.map
|