@agentshouse/mdruntime 0.1.0-ca14c49c06d90 → 0.1.0-ca4dc698bd0c4
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 +260 -259
- package/dist/acquisition.d.ts +14 -0
- package/dist/acquisition.d.ts.map +1 -0
- package/dist/acquisition.js +24 -0
- package/dist/adapter.d.ts +6 -1
- package/dist/adapter.d.ts.map +1 -1
- package/dist/change-set.d.ts +2 -0
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +34 -9
- package/dist/client.d.ts +8 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1 -0
- package/dist/collection.d.ts +17 -3
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +230 -19
- package/dist/connection.d.ts +20 -7
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +926 -175
- package/dist/conversation.d.ts +8 -5
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +128 -83
- package/dist/durability.d.ts +7 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +2 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +3 -3
- package/dist/host.d.ts +11 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +33 -3
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +6 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/memory.d.ts +2 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +7 -2
- package/dist/model.d.ts +1 -0
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +9 -0
- package/dist/observation.d.ts +5 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +22 -11
- package/dist/overlay.d.ts +1 -0
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +25 -54
- package/dist/query.d.ts +28 -3
- package/dist/query.d.ts.map +1 -1
- package/dist/reach.d.ts +6 -2
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +16 -4
- package/dist/react.d.ts +5 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/read-side.d.ts +13 -6
- package/dist/read-side.d.ts.map +1 -1
- package/dist/read-side.js +282 -83
- package/dist/readiness.d.ts +53 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +33 -0
- package/dist/recovery.d.ts +25 -0
- package/dist/recovery.d.ts.map +1 -0
- package/dist/recovery.js +197 -0
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +11 -10
- package/dist/replica.d.ts +1 -1
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +47 -19
- package/dist/rows.d.ts +4 -13
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +2 -12
- package/dist/save.d.ts +5 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +36 -13
- package/dist/search.d.ts +28 -6
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +108 -45
- package/dist/shared.d.ts +11 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +368 -0
- package/dist/status.d.ts +4 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/store.d.ts +18 -3
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +147 -49
- package/dist/turn.d.ts +7 -0
- package/dist/turn.d.ts.map +1 -0
- package/dist/turn.js +45 -0
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Open } from './open.js';
|
|
2
|
+
export type CodeAvailability = Open<'stored' | 'absent'>;
|
|
3
|
+
export type RoomPreparation = Open<'complete' | 'acquiring' | 'preparing' | 'indexing' | 'refused' | 'unadmitted'>;
|
|
4
|
+
export type RoomCoverage = {
|
|
5
|
+
readonly room: string;
|
|
6
|
+
readonly state: RoomPreparation;
|
|
7
|
+
};
|
|
8
|
+
export type ConversationCoverage = Open<'complete' | 'acquiring' | 'indexing' | 'undeclared'>;
|
|
9
|
+
export type SearchObligation = Open<'required' | 'unused'>;
|
|
10
|
+
export type TargetCoverage = {
|
|
11
|
+
readonly complete: boolean;
|
|
12
|
+
readonly listed: boolean;
|
|
13
|
+
readonly rooms: readonly RoomCoverage[];
|
|
14
|
+
readonly conversations: ConversationCoverage;
|
|
15
|
+
readonly search: SearchObligation;
|
|
16
|
+
};
|
|
17
|
+
export type Persistence = Open<'granted' | 'denied' | 'unavailable'>;
|
|
18
|
+
export type Durability = Open<'persistent' | 'best-effort'>;
|
|
19
|
+
export type ConnectionAvailability = Open<'connected' | 'connecting' | 'unreachable'>;
|
|
20
|
+
export type HouseOutcome = Open<'open' | 'write-halted' | 'refused'>;
|
|
21
|
+
export type CapacityCause = {
|
|
22
|
+
readonly cause: Open<'insufficient-space' | 'quota-exceeded'>;
|
|
23
|
+
readonly needed: number | null;
|
|
24
|
+
readonly available: number | null;
|
|
25
|
+
};
|
|
26
|
+
export type RefusedRoom = {
|
|
27
|
+
readonly room: string;
|
|
28
|
+
readonly file: string;
|
|
29
|
+
readonly rule: string;
|
|
30
|
+
readonly location: string | null;
|
|
31
|
+
};
|
|
32
|
+
export type ReadinessStatus = Open<'preparing' | 'paused' | 'refused' | 'ready' | 'lost'>;
|
|
33
|
+
export type Readiness = {
|
|
34
|
+
readonly status: ReadinessStatus;
|
|
35
|
+
readonly ready: boolean;
|
|
36
|
+
readonly usable: boolean;
|
|
37
|
+
readonly code: CodeAvailability;
|
|
38
|
+
readonly coverage: TargetCoverage;
|
|
39
|
+
readonly durability: Durability;
|
|
40
|
+
readonly persistence: Persistence;
|
|
41
|
+
readonly connection: ConnectionAvailability;
|
|
42
|
+
readonly house: HouseOutcome;
|
|
43
|
+
readonly capacity: CapacityCause | null;
|
|
44
|
+
readonly refused: readonly RefusedRoom[];
|
|
45
|
+
readonly lost: boolean;
|
|
46
|
+
};
|
|
47
|
+
export type ReadinessFacts = Omit<Readiness, 'status' | 'ready' | 'usable' | 'durability' | 'coverage'> & {
|
|
48
|
+
readonly coverage: Omit<TargetCoverage, 'complete'>;
|
|
49
|
+
readonly established: boolean;
|
|
50
|
+
};
|
|
51
|
+
export declare const SETTLED_ROOMS: ReadonlySet<string>;
|
|
52
|
+
export declare function readinessOf(facts: ReadinessFacts): Readiness;
|
|
53
|
+
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../src/readiness.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzD,MAAM,MAAM,eAAe,GAAG,IAAI,CAChC,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,CAC/E,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AAE9F,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,aAAa,EAAE,oBAAoB,CAAC;IAC7C,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,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AQ,CAAC,UAAU,EAAE,sBAAsB,CAAC;IAC5C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACT,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAC1D,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B,CAAC;AAIF,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,CAA2C,CAAC;AAE1F,wBAAgB,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,CAiC5D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const COMPLETE_ROOMS = new Set(['complete', 'unadmitted']);
|
|
2
|
+
export const SETTLED_ROOMS = new Set([...COMPLETE_ROOMS, 'refused']);
|
|
3
|
+
export function readinessOf(facts) {
|
|
4
|
+
const { established, coverage: held, ...reported } = facts;
|
|
5
|
+
const settledConversations = held.conversations === 'complete' || held.conversations === 'undeclared';
|
|
6
|
+
const complete = held.listed &&
|
|
7
|
+
settledConversations &&
|
|
8
|
+
held.rooms.every((room) => COMPLETE_ROOMS.has(room.state));
|
|
9
|
+
const settled = held.listed &&
|
|
10
|
+
settledConversations &&
|
|
11
|
+
held.rooms.every((room) => SETTLED_ROOMS.has(room.state));
|
|
12
|
+
const coverage = { ...held, complete };
|
|
13
|
+
const stored = facts.code === 'stored';
|
|
14
|
+
const ready = stored && complete;
|
|
15
|
+
const usable = stored && (ready || established);
|
|
16
|
+
const status = ready
|
|
17
|
+
? 'ready'
|
|
18
|
+
: facts.capacity !== null
|
|
19
|
+
? 'paused'
|
|
20
|
+
: facts.lost && !established
|
|
21
|
+
? 'lost'
|
|
22
|
+
: settled && !complete
|
|
23
|
+
? 'refused'
|
|
24
|
+
: 'preparing';
|
|
25
|
+
return {
|
|
26
|
+
...reported,
|
|
27
|
+
coverage,
|
|
28
|
+
status,
|
|
29
|
+
ready,
|
|
30
|
+
usable,
|
|
31
|
+
durability: facts.persistence === 'granted' ? 'persistent' : 'best-effort',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type Attempted = 'done' | 'again' | {
|
|
2
|
+
readonly at: number;
|
|
3
|
+
};
|
|
4
|
+
export type Attempt = (signal: AbortSignal) => Promise<Attempted>;
|
|
5
|
+
export type AttemptOptions = {
|
|
6
|
+
readonly at?: number;
|
|
7
|
+
readonly again?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type RecoveryOptions = {
|
|
10
|
+
readonly firstMs?: number;
|
|
11
|
+
readonly ceilingMs?: number;
|
|
12
|
+
readonly attempts?: number;
|
|
13
|
+
readonly inFlight?: number;
|
|
14
|
+
};
|
|
15
|
+
export type Recovery = {
|
|
16
|
+
attempt(intent: string, run: Attempt, options?: AttemptOptions): Promise<boolean>;
|
|
17
|
+
pending(intent: string): boolean;
|
|
18
|
+
resume(): void;
|
|
19
|
+
cancel(intent: string): void;
|
|
20
|
+
scope(inFlight?: number): Recovery;
|
|
21
|
+
retire(): Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
export declare function retryDelay(tries: number, firstMs?: number, ceilingMs?: number): number;
|
|
24
|
+
export declare function createRecovery(options?: RecoveryOptions): Recovery;
|
|
25
|
+
//# sourceMappingURL=recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../src/recovery.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,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
const FIRST_MS = 1_000;
|
|
3
|
+
// Waits stop doubling at half a minute, so work resumes soon after a long failure ends.
|
|
4
|
+
const CEILING_MS = 30_000;
|
|
5
|
+
const ATTEMPTS = 8;
|
|
6
|
+
export function retryDelay(tries, firstMs = FIRST_MS, ceilingMs = CEILING_MS) {
|
|
7
|
+
const ceiling = Math.min(ceilingMs, firstMs * 2 ** tries);
|
|
8
|
+
return ceiling / 2 + (Math.random() * ceiling) / 2;
|
|
9
|
+
}
|
|
10
|
+
function owner(backoff, inFlight, release = () => { }) {
|
|
11
|
+
const intents = new Map();
|
|
12
|
+
const children = new Set();
|
|
13
|
+
const running = new Set();
|
|
14
|
+
const queued = [];
|
|
15
|
+
let free = inFlight;
|
|
16
|
+
let retired = false;
|
|
17
|
+
function finish(key, intent, done) {
|
|
18
|
+
if (intents.get(key) === intent)
|
|
19
|
+
intents.delete(key);
|
|
20
|
+
if (intent.timer !== null)
|
|
21
|
+
clearTimeout(intent.timer);
|
|
22
|
+
intent.timer = null;
|
|
23
|
+
intent.end(done);
|
|
24
|
+
}
|
|
25
|
+
function wait(key, intent, at, guided) {
|
|
26
|
+
if (intent.timer !== null)
|
|
27
|
+
clearTimeout(intent.timer);
|
|
28
|
+
intent.due = at;
|
|
29
|
+
intent.guided = guided;
|
|
30
|
+
intent.timer = setTimeout(() => {
|
|
31
|
+
intent.timer = null;
|
|
32
|
+
launch(key, intent);
|
|
33
|
+
}, Math.max(0, at - Date.now()));
|
|
34
|
+
}
|
|
35
|
+
function launch(key, intent) {
|
|
36
|
+
intent.due = null;
|
|
37
|
+
intent.guided = false;
|
|
38
|
+
const controller = new AbortController();
|
|
39
|
+
intent.controller = controller;
|
|
40
|
+
const run = start(key, intent, controller);
|
|
41
|
+
running.add(run);
|
|
42
|
+
void run.finally(() => running.delete(run));
|
|
43
|
+
}
|
|
44
|
+
async function start(key, intent, controller) {
|
|
45
|
+
while (free === 0)
|
|
46
|
+
await new Promise((admit) => queued.push(admit));
|
|
47
|
+
if (controller.signal.aborted) {
|
|
48
|
+
queued.shift()?.();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
free -= 1;
|
|
52
|
+
const abandoned = new Promise((resolve) => {
|
|
53
|
+
controller.signal.addEventListener('abort', () => resolve(null), { once: true });
|
|
54
|
+
});
|
|
55
|
+
let result;
|
|
56
|
+
try {
|
|
57
|
+
result = await Promise.race([intent.run(controller.signal), abandoned]);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
result = 'again';
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
free += 1;
|
|
64
|
+
queued.shift()?.();
|
|
65
|
+
}
|
|
66
|
+
if (result === null || controller.signal.aborted || intents.get(key) !== intent)
|
|
67
|
+
return;
|
|
68
|
+
intent.controller = null;
|
|
69
|
+
const again = intent.again;
|
|
70
|
+
intent.again = null;
|
|
71
|
+
if (result === 'done') {
|
|
72
|
+
intent.tries = 0;
|
|
73
|
+
if (again === null)
|
|
74
|
+
finish(key, intent, true);
|
|
75
|
+
else if (again === 'now')
|
|
76
|
+
launch(key, intent);
|
|
77
|
+
else
|
|
78
|
+
wait(key, intent, again, true);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
intent.tries += 1;
|
|
82
|
+
if (intent.tries >= backoff.attempts) {
|
|
83
|
+
finish(key, intent, false);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (result === 'again') {
|
|
87
|
+
const delay = retryDelay(intent.tries - 1, backoff.firstMs, backoff.ceilingMs);
|
|
88
|
+
wait(key, intent, Date.now() + delay, false);
|
|
89
|
+
}
|
|
90
|
+
else
|
|
91
|
+
wait(key, intent, result.at, true);
|
|
92
|
+
}
|
|
93
|
+
const recovery = {
|
|
94
|
+
attempt(key, run, options = {}) {
|
|
95
|
+
if (retired)
|
|
96
|
+
return Promise.resolve(false);
|
|
97
|
+
const held = intents.get(key);
|
|
98
|
+
if (held !== undefined) {
|
|
99
|
+
held.run = run;
|
|
100
|
+
if (held.controller !== null) {
|
|
101
|
+
const at = options.at;
|
|
102
|
+
held.again =
|
|
103
|
+
at === undefined || held.again === 'now'
|
|
104
|
+
? 'now'
|
|
105
|
+
: Math.min(at, held.again ?? Number.POSITIVE_INFINITY);
|
|
106
|
+
}
|
|
107
|
+
else if (held.due !== null && held.due <= Date.now()) {
|
|
108
|
+
if (held.timer !== null)
|
|
109
|
+
clearTimeout(held.timer);
|
|
110
|
+
held.timer = null;
|
|
111
|
+
launch(key, held);
|
|
112
|
+
}
|
|
113
|
+
else if (options.at !== undefined && (held.due === null || options.at < held.due)) {
|
|
114
|
+
wait(key, held, options.at, true);
|
|
115
|
+
}
|
|
116
|
+
return held.ended;
|
|
117
|
+
}
|
|
118
|
+
let end = () => { };
|
|
119
|
+
const ended = new Promise((resolve) => {
|
|
120
|
+
end = resolve;
|
|
121
|
+
});
|
|
122
|
+
const intent = {
|
|
123
|
+
run,
|
|
124
|
+
tries: 0,
|
|
125
|
+
timer: null,
|
|
126
|
+
due: null,
|
|
127
|
+
guided: false,
|
|
128
|
+
controller: null,
|
|
129
|
+
again: null,
|
|
130
|
+
ended,
|
|
131
|
+
end,
|
|
132
|
+
};
|
|
133
|
+
intents.set(key, intent);
|
|
134
|
+
if (options.at !== undefined)
|
|
135
|
+
wait(key, intent, options.at, true);
|
|
136
|
+
else if (options.again === true) {
|
|
137
|
+
intent.tries = 1;
|
|
138
|
+
wait(key, intent, Date.now() + retryDelay(0, backoff.firstMs, backoff.ceilingMs), false);
|
|
139
|
+
}
|
|
140
|
+
else
|
|
141
|
+
launch(key, intent);
|
|
142
|
+
return ended;
|
|
143
|
+
},
|
|
144
|
+
pending(key) {
|
|
145
|
+
const intent = intents.get(key);
|
|
146
|
+
return intent !== undefined && intent.controller === null;
|
|
147
|
+
},
|
|
148
|
+
resume() {
|
|
149
|
+
if (retired)
|
|
150
|
+
return;
|
|
151
|
+
for (const [key, intent] of [...intents]) {
|
|
152
|
+
if (intent.guided && intent.due !== null && intent.due > Date.now())
|
|
153
|
+
continue;
|
|
154
|
+
if (intent.timer !== null)
|
|
155
|
+
clearTimeout(intent.timer);
|
|
156
|
+
intent.timer = null;
|
|
157
|
+
intent.controller?.abort();
|
|
158
|
+
intent.again = null;
|
|
159
|
+
intent.tries = 0;
|
|
160
|
+
launch(key, intent);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
cancel(key) {
|
|
164
|
+
const intent = intents.get(key);
|
|
165
|
+
if (intent === undefined)
|
|
166
|
+
return;
|
|
167
|
+
intent.controller?.abort();
|
|
168
|
+
finish(key, intent, false);
|
|
169
|
+
},
|
|
170
|
+
scope(bound = Infinity) {
|
|
171
|
+
const child = owner(backoff, bound, () => children.delete(child));
|
|
172
|
+
if (retired)
|
|
173
|
+
void child.retire();
|
|
174
|
+
else
|
|
175
|
+
children.add(child);
|
|
176
|
+
return child;
|
|
177
|
+
},
|
|
178
|
+
async retire() {
|
|
179
|
+
retired = true;
|
|
180
|
+
release();
|
|
181
|
+
for (const [key, intent] of [...intents]) {
|
|
182
|
+
intent.controller?.abort();
|
|
183
|
+
finish(key, intent, false);
|
|
184
|
+
}
|
|
185
|
+
await Promise.all([...children].map((child) => child.retire()));
|
|
186
|
+
await Promise.all(running);
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
return recovery;
|
|
190
|
+
}
|
|
191
|
+
export function createRecovery(options = {}) {
|
|
192
|
+
return owner({
|
|
193
|
+
firstMs: options.firstMs ?? FIRST_MS,
|
|
194
|
+
ceilingMs: options.ceilingMs ?? CEILING_MS,
|
|
195
|
+
attempts: options.attempts ?? ATTEMPTS,
|
|
196
|
+
}, options.inFlight ?? Infinity);
|
|
197
|
+
}
|
package/dist/refresh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../src/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,aAAa,
|
|
1
|
+
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CAKzB"}
|
package/dist/refresh.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { acceptedBinaries } from './overlay.js';
|
|
2
2
|
import { readStaged } from './replica.js';
|
|
3
|
+
import { drafted, settled } from './shared.js';
|
|
3
4
|
import { unconfirmed } from './transfer.js';
|
|
4
5
|
export async function advancement(adapter, authorization, held, remodel, continuing) {
|
|
5
6
|
const locator = held.locator;
|
|
@@ -16,11 +17,11 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
16
17
|
collection: held.model,
|
|
17
18
|
selection: held.selectionModel,
|
|
18
19
|
});
|
|
19
|
-
const documents =
|
|
20
|
-
const revisions =
|
|
21
|
-
const changes =
|
|
22
|
-
const written =
|
|
23
|
-
const binaries =
|
|
20
|
+
const documents = drafted(held.documents);
|
|
21
|
+
const revisions = drafted(held.revisions);
|
|
22
|
+
const changes = drafted(held.changes);
|
|
23
|
+
const written = drafted(held.written);
|
|
24
|
+
const binaries = drafted(held.binaries);
|
|
24
25
|
const stage = (page) => {
|
|
25
26
|
for (const path of Object.keys(page.documents)) {
|
|
26
27
|
delete binaries[path];
|
|
@@ -71,11 +72,11 @@ export async function advancement(adapter, authorization, held, remodel, continu
|
|
|
71
72
|
model: models.collection,
|
|
72
73
|
selectionModel: models.selection,
|
|
73
74
|
roomVersion,
|
|
74
|
-
documents,
|
|
75
|
-
binaries,
|
|
76
|
-
revisions,
|
|
77
|
-
changes,
|
|
78
|
-
written,
|
|
75
|
+
documents: settled(documents),
|
|
76
|
+
binaries: settled(binaries),
|
|
77
|
+
revisions: settled(revisions),
|
|
78
|
+
changes: settled(changes),
|
|
79
|
+
written: settled(written),
|
|
79
80
|
},
|
|
80
81
|
};
|
|
81
82
|
}
|
package/dist/replica.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ type ReplayStep = {
|
|
|
31
31
|
export declare function compositionOf(record: ReplicaRecord): Composition;
|
|
32
32
|
export declare function confirmedOf(record: ReplicaRecord, previous?: ConfirmedLayer): ConfirmedLayer;
|
|
33
33
|
export declare function sameMembership(record: ReplicaRecord, other: ReplicaRecord): boolean;
|
|
34
|
-
export declare function readStaged(
|
|
34
|
+
export declare function readStaged(staged: ReplicaRecord, previous?: ConfirmedLayer): Staged;
|
|
35
35
|
export declare function readReclassified(record: ReplicaRecord, previous: ConfirmedLayer): Staged | {
|
|
36
36
|
kind: 'deferred';
|
|
37
37
|
};
|
package/dist/replica.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,
|
|
1
|
+
{"version":3,"file":"replica.d.ts","sourceRoot":"","sources":["../src/replica.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,WAAW,EAAqB,MAAM,aAAa,CAAC;AACnG,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG;IACjC,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAAG,OAAO,CAAC;AAE7E,MAAM,MAAM,OAAO,GAAG;IACpB,SAAS,EAAE,cAAc,CAAC;IAC1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,EAClB,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM,GAC7C,OAAO,CAoBT;AAED,wBAAgB,WAAW,CACzB,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,EAC7C,KAAK,EAAE,OAAO,GACb,SAAS,WAAW,EAAE,CA2BxB"}
|
package/dist/replica.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { equalValue, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { immutable, landing } from './change.js';
|
|
3
|
-
import { collectionOf, unreadable, validateCollection, } from './collection.js';
|
|
3
|
+
import { changedCleanly, collectionOf, unreadable, validateCollection, } from './collection.js';
|
|
4
4
|
import { acceptedBinaries, overlay, overlayChanged, sameLayerText, } from './overlay.js';
|
|
5
5
|
import { providerRewritten } from './save.js';
|
|
6
|
+
import { drafted, patched, settled, shared } from './shared.js';
|
|
6
7
|
export function compositionOf(record) {
|
|
7
8
|
return {
|
|
8
9
|
model: record.model,
|
|
@@ -11,23 +12,46 @@ export function compositionOf(record) {
|
|
|
11
12
|
: { roots: record.typedSelection.roots, model: record.selectionModel },
|
|
12
13
|
};
|
|
13
14
|
}
|
|
15
|
+
function held(record) {
|
|
16
|
+
const documents = shared(record.documents);
|
|
17
|
+
const binaries = shared(record.binaries);
|
|
18
|
+
const revisions = shared(record.revisions);
|
|
19
|
+
const changes = shared(record.changes);
|
|
20
|
+
const written = shared(record.written);
|
|
21
|
+
return documents === record.documents &&
|
|
22
|
+
binaries === record.binaries &&
|
|
23
|
+
revisions === record.revisions &&
|
|
24
|
+
changes === record.changes &&
|
|
25
|
+
written === record.written
|
|
26
|
+
? record
|
|
27
|
+
: { ...record, documents, binaries, revisions, changes, written };
|
|
28
|
+
}
|
|
14
29
|
export function confirmedOf(record, previous) {
|
|
30
|
+
const kept = held(record);
|
|
15
31
|
return {
|
|
16
|
-
record,
|
|
17
|
-
collection: collectionOf(
|
|
32
|
+
record: kept,
|
|
33
|
+
collection: collectionOf(kept.documents, compositionOf(kept), previous?.collection),
|
|
18
34
|
};
|
|
19
35
|
}
|
|
20
36
|
export function sameMembership(record, other) {
|
|
21
37
|
return (JSON.stringify(record.typedSelection?.roots ?? null) ===
|
|
22
38
|
JSON.stringify(other.typedSelection?.roots ?? null));
|
|
23
39
|
}
|
|
24
|
-
|
|
40
|
+
function cleanly(record, previous) {
|
|
41
|
+
if (previous === undefined)
|
|
42
|
+
return false;
|
|
43
|
+
const before = previous.record;
|
|
44
|
+
return changedCleanly({ text: record.documents, binaries: record.binaries }, { text: before.documents, binaries: before.binaries, composition: compositionOf(before) }, compositionOf(record));
|
|
45
|
+
}
|
|
46
|
+
export function readStaged(staged, previous) {
|
|
47
|
+
const record = held(staged);
|
|
25
48
|
const textChanged = previous === undefined || !sameLayerText(record, previous.record);
|
|
26
49
|
const modeled = record.model.status !== 'unavailable' || record.selectionModel.status !== 'unavailable';
|
|
27
50
|
if (modeled &&
|
|
28
51
|
(textChanged ||
|
|
29
52
|
record.model !== previous?.record.model ||
|
|
30
|
-
record.selectionModel !== previous?.record.selectionModel)
|
|
53
|
+
record.selectionModel !== previous?.record.selectionModel) &&
|
|
54
|
+
!cleanly(record, previous)) {
|
|
31
55
|
const verdict = validateCollection(record.documents, Object.keys(record.binaries), compositionOf(record));
|
|
32
56
|
if (verdict.verdict === 'refuse' && verdict.rule !== 'model-unavailable') {
|
|
33
57
|
return { kind: 'refused', refusal: verdict };
|
|
@@ -54,7 +78,7 @@ export function readReclassified(record, previous) {
|
|
|
54
78
|
: { kind: 'refused', refusal: verdict };
|
|
55
79
|
}
|
|
56
80
|
function returnedBinaries(held, submitted, accepted) {
|
|
57
|
-
const binaries =
|
|
81
|
+
const binaries = drafted(held);
|
|
58
82
|
for (const change of submitted.changes) {
|
|
59
83
|
if (change.kind !== 'move')
|
|
60
84
|
continue;
|
|
@@ -67,17 +91,18 @@ function returnedBinaries(held, submitted, accepted) {
|
|
|
67
91
|
Object.assign(binaries, acceptedBinaries(accepted.binaryFiles ?? {}));
|
|
68
92
|
for (const path of accepted.removals)
|
|
69
93
|
delete binaries[path];
|
|
70
|
-
return binaries;
|
|
94
|
+
return settled(binaries);
|
|
71
95
|
}
|
|
72
96
|
export function applyReturned(confirmed, submitted, accepted, roomVersion, writtenAt) {
|
|
73
97
|
const { documents, revisions, changes, removals } = accepted;
|
|
74
|
-
const nextDocuments =
|
|
75
|
-
const nextRevisions =
|
|
76
|
-
const nextChanges =
|
|
77
|
-
const nextWritten =
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
98
|
+
const nextDocuments = drafted(confirmed.record.documents);
|
|
99
|
+
const nextRevisions = drafted(confirmed.record.revisions);
|
|
100
|
+
const nextChanges = drafted(confirmed.record.changes);
|
|
101
|
+
const nextWritten = drafted(confirmed.record.written);
|
|
102
|
+
Object.assign(nextDocuments, documents);
|
|
103
|
+
Object.assign(nextRevisions, revisions);
|
|
104
|
+
for (const path of Object.keys(documents))
|
|
105
|
+
nextWritten[path] = writtenAt;
|
|
81
106
|
for (const [path, revision] of Object.entries(revisions)) {
|
|
82
107
|
if (confirmed.record.revisions[path] !== revision)
|
|
83
108
|
delete nextChanges[path];
|
|
@@ -92,10 +117,10 @@ export function applyReturned(confirmed, submitted, accepted, roomVersion, writt
|
|
|
92
117
|
return readStaged({
|
|
93
118
|
...confirmed.record,
|
|
94
119
|
roomVersion,
|
|
95
|
-
documents: nextDocuments,
|
|
96
|
-
revisions: nextRevisions,
|
|
97
|
-
changes: nextChanges,
|
|
98
|
-
written: nextWritten,
|
|
120
|
+
documents: settled(nextDocuments),
|
|
121
|
+
revisions: settled(nextRevisions),
|
|
122
|
+
changes: settled(nextChanges),
|
|
123
|
+
written: settled(nextWritten),
|
|
99
124
|
binaries: returnedBinaries(confirmed.record.binaries, submitted, accepted),
|
|
100
125
|
}, confirmed);
|
|
101
126
|
}
|
|
@@ -238,7 +263,10 @@ function effects(change) {
|
|
|
238
263
|
return [{ kind: 'absent', path }];
|
|
239
264
|
}
|
|
240
265
|
export function landed(batch, confirmed, current = {}) {
|
|
241
|
-
const layer = {
|
|
266
|
+
const layer = {
|
|
267
|
+
...confirmed.record,
|
|
268
|
+
documents: patched(confirmed.record.documents, Object.entries(current)),
|
|
269
|
+
};
|
|
242
270
|
return batch.changes.every((change, index) => {
|
|
243
271
|
if (change.kind === 'replace' || (change.kind === 'create' && 'content' in change)) {
|
|
244
272
|
const at = landing(batch.changes, index, change.path);
|
package/dist/rows.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Frontmatter } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { HeadChange } from './adapter.js';
|
|
3
3
|
import type { BinaryFileRecord } from './binary.js';
|
|
4
4
|
import { type Composition } from './collection.js';
|
|
@@ -13,19 +13,10 @@ export type DocumentRow = {
|
|
|
13
13
|
values: Fields;
|
|
14
14
|
reached: Readonly<Record<string, readonly unknown[]>>;
|
|
15
15
|
directories: readonly string[];
|
|
16
|
-
|
|
16
|
+
text: string | null;
|
|
17
17
|
change: HeadChange | null;
|
|
18
18
|
binary: BinaryFileRecord | null;
|
|
19
19
|
};
|
|
20
|
-
export type BodyRow = {
|
|
21
|
-
key: string;
|
|
22
|
-
kind: 'body';
|
|
23
|
-
room: string;
|
|
24
|
-
path: string;
|
|
25
|
-
preamble: string;
|
|
26
|
-
sections: Readonly<Record<string, string>>;
|
|
27
|
-
markdown: string;
|
|
28
|
-
};
|
|
29
20
|
export type ReferenceRow = {
|
|
30
21
|
key: string;
|
|
31
22
|
kind: 'reference';
|
|
@@ -37,10 +28,10 @@ export type ReferenceRow = {
|
|
|
37
28
|
path: string;
|
|
38
29
|
type: string;
|
|
39
30
|
};
|
|
40
|
-
export type Row = DocumentRow |
|
|
31
|
+
export type Row = DocumentRow | ReferenceRow;
|
|
41
32
|
export declare function documentKey(room: string, path: string): string;
|
|
42
33
|
export declare function roomOfKey(key: string): string;
|
|
43
34
|
export declare function markdownPath(path: string): boolean;
|
|
44
|
-
export declare function rowsOf(room: string, path: string, document:
|
|
35
|
+
export declare function rowsOf(room: string, path: string, document: Frontmatter | null, composition: Composition, change: HeadChange | null, binary: BinaryFileRecord | null): readonly Row[];
|
|
45
36
|
export {};
|
|
46
37
|
//# sourceMappingURL=rows.d.ts.map
|
package/dist/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,
|
|
1
|
+
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../src/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,KAAK,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,GAAG,GAAG,WAAW,GAAG,YAAY,CAAC;AAM7C,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7C;AAmFD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,WAAW,GAAG,IAAI,EAC5B,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,GAC9B,SAAS,GAAG,EAAE,CA+DhB"}
|
package/dist/rows.js
CHANGED
|
@@ -73,7 +73,6 @@ export function markdownPath(path) {
|
|
|
73
73
|
}
|
|
74
74
|
export function rowsOf(room, path, document, composition, change, binary) {
|
|
75
75
|
const key = documentKey(room, path);
|
|
76
|
-
const body = keyOf('b', room, path);
|
|
77
76
|
if (document === null || !markdownPath(path)) {
|
|
78
77
|
return [
|
|
79
78
|
{
|
|
@@ -86,7 +85,7 @@ export function rowsOf(room, path, document, composition, change, binary) {
|
|
|
86
85
|
values: {},
|
|
87
86
|
reached: {},
|
|
88
87
|
directories: directoriesOf(path),
|
|
89
|
-
|
|
88
|
+
text: null,
|
|
90
89
|
change,
|
|
91
90
|
binary,
|
|
92
91
|
},
|
|
@@ -117,19 +116,10 @@ export function rowsOf(room, path, document, composition, change, binary) {
|
|
|
117
116
|
values,
|
|
118
117
|
reached,
|
|
119
118
|
directories: directoriesOf(path),
|
|
120
|
-
|
|
119
|
+
text: document.content,
|
|
121
120
|
change,
|
|
122
121
|
binary,
|
|
123
122
|
},
|
|
124
|
-
{
|
|
125
|
-
key: body,
|
|
126
|
-
kind: 'body',
|
|
127
|
-
room,
|
|
128
|
-
path,
|
|
129
|
-
preamble: document.preamble,
|
|
130
|
-
sections: document.sections,
|
|
131
|
-
markdown: document.content,
|
|
132
|
-
},
|
|
133
123
|
...[...reading.targets.values()].map(({ field, target: found, forms }) => ({
|
|
134
124
|
key: keyOf('r', room, path, field, found),
|
|
135
125
|
kind: 'reference',
|
package/dist/save.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export type SaveInput = {
|
|
|
24
24
|
bases: readonly Precondition[];
|
|
25
25
|
queued?: ReadonlySet<string>;
|
|
26
26
|
writtenBy?: WrittenBy;
|
|
27
|
+
clean?: {
|
|
28
|
+
text: Readonly<Record<string, string>>;
|
|
29
|
+
binaries: Readonly<Record<string, unknown>>;
|
|
30
|
+
composition: Composition;
|
|
31
|
+
};
|
|
27
32
|
};
|
|
28
33
|
export type BatchResult = {
|
|
29
34
|
kind: 'batch';
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAIL,KAAK,MA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