@agentshouse/mdruntime 0.1.0-c01d4615bfe46 → 0.1.0-c024a9c474f5e
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/README.md +14 -13
- package/dist/acceptance.d.ts.map +1 -1
- package/dist/acceptance.js +32 -3
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +58 -19
- package/dist/adapter.d.ts +183 -21
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +2 -2
- package/dist/{binary.d.ts → attachment.d.ts} +8 -4
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +15 -0
- package/dist/authored.d.ts +88 -0
- package/dist/authored.d.ts.map +1 -0
- package/dist/authored.js +345 -0
- package/dist/chain.d.ts +1 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +5 -2
- package/dist/change.d.ts +6 -2
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +3 -0
- package/dist/chat-types.js +2 -2
- package/dist/client.d.ts +23 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +25 -54
- package/dist/collection.d.ts +6 -1
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -9
- package/dist/column.d.ts +5 -0
- package/dist/column.d.ts.map +1 -0
- package/dist/column.js +9 -0
- package/dist/compile.d.ts +2 -1
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +73 -42
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +16 -6
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -1
- package/dist/conversation-live.d.ts +8 -5
- package/dist/conversation-live.d.ts.map +1 -1
- package/dist/conversation-live.js +5 -3
- package/dist/conversation-row.d.ts +23 -1
- package/dist/conversation-row.d.ts.map +1 -1
- package/dist/conversation-row.js +37 -8
- package/dist/conversation.d.ts +20 -9
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +102 -68
- package/dist/declaration.js +3 -3
- package/dist/discovery.d.ts +3 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +30 -5
- package/dist/download.d.ts +6 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +42 -0
- package/dist/durability.d.ts +2 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +3 -0
- package/dist/entry.d.ts +26 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +126 -36
- package/dist/failure.d.ts.map +1 -1
- package/dist/failure.js +3 -1
- package/dist/figures.d.ts +1 -1
- package/dist/figures.d.ts.map +1 -1
- package/dist/figures.js +6 -4
- package/dist/file.d.ts +1 -1
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +1 -1
- package/dist/holdings.d.ts.map +1 -1
- package/dist/holdings.js +5 -3
- package/dist/host.d.ts +6 -2
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +70 -29
- package/dist/house-query.d.ts +24 -0
- package/dist/house-query.d.ts.map +1 -0
- package/dist/house-query.js +102 -0
- package/dist/identity.d.ts +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/index.d.ts +20 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -5
- package/dist/install.d.ts +8 -2
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +40 -33
- package/dist/lifecycle.d.ts +1 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +42 -25
- package/dist/linked-file.d.ts +7 -0
- package/dist/linked-file.d.ts.map +1 -0
- package/dist/linked-file.js +13 -0
- package/dist/listing.d.ts +24 -12
- package/dist/listing.d.ts.map +1 -1
- package/dist/listing.js +50 -21
- package/dist/live.d.ts +19 -3
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +94 -36
- package/dist/loaded.d.ts +7 -0
- package/dist/loaded.d.ts.map +1 -0
- package/dist/loaded.js +46 -0
- package/dist/locks.d.ts.map +1 -1
- package/dist/locks.js +4 -2
- package/dist/lost.js +1 -1
- package/dist/media.d.ts +19 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +177 -27
- package/dist/memory.d.ts +4 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +50 -16
- package/dist/messages.d.ts +12 -1
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +28 -6
- package/dist/modal.d.ts +2 -0
- package/dist/modal.d.ts.map +1 -0
- package/dist/modal.js +11 -0
- package/dist/model.d.ts +10 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +7 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js +3 -3
- package/dist/name.d.ts +0 -1
- package/dist/name.d.ts.map +1 -1
- package/dist/name.js +3 -7
- package/dist/observation.d.ts +26 -10
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +200 -69
- package/dist/online.d.ts +7 -0
- package/dist/online.d.ts.map +1 -0
- package/dist/online.js +29 -0
- package/dist/opened.d.ts +5 -5
- package/dist/opened.d.ts.map +1 -1
- package/dist/opened.js +2 -2
- package/dist/opening.d.ts.map +1 -1
- package/dist/opening.js +20 -2
- package/dist/outcome.d.ts +27 -14
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +14 -5
- package/dist/overlay.d.ts +20 -9
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +110 -41
- package/dist/parts.d.ts +4 -1
- package/dist/parts.d.ts.map +1 -1
- package/dist/parts.js +30 -7
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/preparation.d.ts +33 -7
- package/dist/preparation.d.ts.map +1 -1
- package/dist/preparation.js +195 -78
- package/dist/presence.d.ts +8 -2
- package/dist/presence.d.ts.map +1 -1
- package/dist/presence.js +24 -13
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +115 -67
- package/dist/query.d.ts +2 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/questions.d.ts +1 -0
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +3 -1
- package/dist/queue.d.ts +1 -1
- package/dist/queue.d.ts.map +1 -1
- package/dist/queue.js +55 -23
- package/dist/reach.d.ts +15 -6
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +140 -25
- package/dist/react.d.ts +11 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +22 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +18 -10
- package/dist/reads.d.ts +2 -2
- package/dist/reads.d.ts.map +1 -1
- package/dist/reads.js +21 -13
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +2 -1
- package/dist/refresh.d.ts +1 -1
- package/dist/refresh.js +4 -4
- package/dist/replica.d.ts +3 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +5 -5
- package/dist/room-draft.d.ts +29 -4
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +237 -16
- package/dist/room-drafts.d.ts.map +1 -1
- package/dist/room-drafts.js +12 -7
- package/dist/room-list.d.ts +10 -0
- package/dist/room-list.d.ts.map +1 -0
- package/dist/room-list.js +47 -0
- package/dist/rows.d.ts +11 -3
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +25 -11
- package/dist/run-tables.d.ts +25 -0
- package/dist/run-tables.d.ts.map +1 -0
- package/dist/run-tables.js +98 -0
- package/dist/running.d.ts +5 -0
- package/dist/running.d.ts.map +1 -0
- package/dist/running.js +10 -0
- package/dist/runs.d.ts +27 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +92 -0
- package/dist/runtime.d.ts +7 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/save.d.ts +1 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +31 -96
- package/dist/saves.d.ts +7 -5
- package/dist/saves.d.ts.map +1 -1
- package/dist/saves.js +108 -54
- package/dist/seed.d.ts.map +1 -1
- package/dist/seed.js +2 -2
- package/dist/selector.d.ts +3 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/selector.js +22 -0
- package/dist/shown.d.ts +4 -2
- package/dist/shown.d.ts.map +1 -1
- package/dist/shown.js +73 -48
- package/dist/socket/session.d.ts +4 -1
- package/dist/socket/session.d.ts.map +1 -1
- package/dist/socket/session.js +3 -0
- package/dist/socket.d.ts +6 -1
- package/dist/socket.d.ts.map +1 -1
- package/dist/socket.js +14 -2
- package/dist/source.d.ts +42 -0
- package/dist/source.d.ts.map +1 -1
- package/dist/source.js +76 -9
- package/dist/store/installs.d.ts +2 -2
- package/dist/store/installs.d.ts.map +1 -1
- package/dist/store/installs.js +10 -4
- package/dist/store/readiness.d.ts +5 -4
- package/dist/store/readiness.d.ts.map +1 -1
- package/dist/store/readiness.js +28 -12
- package/dist/store/records.d.ts +24 -5
- package/dist/store/records.d.ts.map +1 -1
- package/dist/store/records.js +59 -24
- package/dist/store/rooms-shown.d.ts +8 -0
- package/dist/store/rooms-shown.d.ts.map +1 -0
- package/dist/store/rooms-shown.js +13 -0
- package/dist/store.d.ts +15 -10
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +12 -5
- package/dist/stored.d.ts +40 -16
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +210 -52
- package/dist/surface.d.ts +18 -7
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +52 -16
- package/dist/sync.d.ts +4 -2
- package/dist/sync.d.ts.map +1 -1
- package/dist/sync.js +47 -25
- package/dist/tables.d.ts +34 -49
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +84 -325
- package/dist/tallies.js +2 -2
- package/dist/validation.d.ts +2 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +50 -10
- package/dist/wire.d.ts +29 -14
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +18 -13
- package/package.json +4 -4
- package/dist/binary.d.ts.map +0 -1
- package/dist/binary.js +0 -8
package/dist/overlay.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { type ApplyResult } from '@agentshouse/mdmodel';
|
|
2
|
-
import type {
|
|
1
|
+
import { type ApplyResult, type Refusal as ModelRefusal } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { Attachment, HeadChange } from './adapter.js';
|
|
3
3
|
import { type Composition } from './collection.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type ChangeBatch } from './change.js';
|
|
5
5
|
export type Heads = {
|
|
6
6
|
revisions: Readonly<Record<string, string>>;
|
|
7
7
|
fileIds: Readonly<Record<string, string>>;
|
|
8
8
|
created: Readonly<Record<string, string>>;
|
|
9
9
|
changes: Readonly<Record<string, HeadChange>>;
|
|
10
10
|
};
|
|
11
|
-
export type
|
|
11
|
+
export type HeldAttachment = ({
|
|
12
12
|
readonly state: 'accepted';
|
|
13
|
-
} &
|
|
13
|
+
} & Attachment) | {
|
|
14
14
|
readonly state: 'pending';
|
|
15
15
|
readonly localId: string;
|
|
16
16
|
readonly byteLength: number;
|
|
@@ -19,12 +19,23 @@ export type HeldBinary = ({
|
|
|
19
19
|
};
|
|
20
20
|
export type Layer = Heads & {
|
|
21
21
|
documents: Readonly<Record<string, string>>;
|
|
22
|
-
binaries: Readonly<Record<string,
|
|
22
|
+
binaries: Readonly<Record<string, HeldAttachment>>;
|
|
23
23
|
};
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
24
|
+
export declare function acceptedAttachments(files: Readonly<Record<string, Attachment>>): Generator<readonly [string, HeldAttachment]>;
|
|
25
|
+
export declare function sameAttachment(left: HeldAttachment | undefined, right: HeldAttachment | undefined): boolean;
|
|
26
26
|
export declare function sameChange(left: HeadChange | undefined, right: HeadChange | undefined): boolean;
|
|
27
27
|
export declare function composed(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): ApplyResult;
|
|
28
|
-
export declare function compose(path: string, fields: Readonly<Record<string, unknown>>, sections: Readonly<Record<string, string>>, composition: Composition): string;
|
|
29
28
|
export declare function overlaying(base: Layer, queue: readonly ChangeBatch[], composition: Composition, unapplied?: () => void): Generator<number, Layer, void>;
|
|
29
|
+
export type WrittenDocument = {
|
|
30
|
+
readonly stale: true;
|
|
31
|
+
readonly refusal?: ModelRefusal;
|
|
32
|
+
} | {
|
|
33
|
+
readonly stale: false;
|
|
34
|
+
readonly content: string;
|
|
35
|
+
readonly base: string | null;
|
|
36
|
+
readonly created: boolean;
|
|
37
|
+
};
|
|
38
|
+
export type Written = readonly (WrittenDocument | null)[];
|
|
39
|
+
export declare function unreadDocuments(batch: ChangeBatch, base: string): Written;
|
|
40
|
+
export declare function writtenDocuments(base: Layer, batch: ChangeBatch, composition: Composition): Generator<number, Written, void>;
|
|
30
41
|
//# 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":"AAAA,OAAO,EAOL,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../src/overlay.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,WAAW,EAEhB,KAAK,OAAO,IAAI,YAAY,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAIL,KAAK,WAAW,EAGjB,MAAM,aAAa,CAAC;AAIrB,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,CA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AAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC1C,WAAW,EAAE,WAAW,GACvB,WAAW,CAqBb;AAgMD,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,WAAW,EAAE,WAAW,EACxB,SAAS,CAAC,EAAE,MAAM,IAAI,GACrB,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAehC;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,YAAY,CAAA;CAAE,GACzD;IACE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEN,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,eAAe,GAAG,IAAI,CAAC,EAAE,CAAC;AAmB1D,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAQzE;AAED,wBAAiB,gBAAgB,CAC/B,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,WAAW,EAClB,WAAW,EAAE,WAAW,GACvB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAoClC"}
|
package/dist/overlay.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { apply, create,
|
|
1
|
+
import { apply, create, documentValue, parse, serialize, TYPE_FIELD, } from '@agentshouse/mdmodel';
|
|
2
2
|
import { definitionsAt } from './collection.js';
|
|
3
|
+
import { departure, isPart, } from './change.js';
|
|
3
4
|
import { drafted, entriesIn, settling } from './shared.js';
|
|
4
5
|
import { ROW_WEIGHT } from './turn.js';
|
|
5
|
-
export function*
|
|
6
|
+
export function* acceptedAttachments(files) {
|
|
6
7
|
for (const [path, file] of entriesIn(files))
|
|
7
8
|
yield [path, { state: 'accepted', ...file }];
|
|
8
9
|
}
|
|
9
|
-
export function
|
|
10
|
+
export function sameAttachment(left, right) {
|
|
10
11
|
if (left === undefined || right === undefined)
|
|
11
12
|
return left === right;
|
|
12
13
|
return (left.state === right.state &&
|
|
@@ -25,9 +26,6 @@ export function sameChange(left, right) {
|
|
|
25
26
|
left.author?.id === right.author?.id &&
|
|
26
27
|
left.author?.name === right.author?.name);
|
|
27
28
|
}
|
|
28
|
-
function isPart(change) {
|
|
29
|
-
return change.kind === 'field' || change.kind === 'section' || change.kind === 'preamble';
|
|
30
|
-
}
|
|
31
29
|
function at(path, name) {
|
|
32
30
|
return `${path} ${name}`;
|
|
33
31
|
}
|
|
@@ -58,7 +56,7 @@ export function composed(path, fields, sections, composition) {
|
|
|
58
56
|
const type = typeof declared === 'string' && declared !== '' ? declared : undefined;
|
|
59
57
|
const definition = definitionsAt(composition, path)(type);
|
|
60
58
|
return apply(create(type, definition), [
|
|
61
|
-
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) &&
|
|
59
|
+
...Object.entries(fields).flatMap(([name, value]) => (name !== TYPE_FIELD || type === undefined) && documentValue(value)
|
|
62
60
|
? [{ kind: 'field', name, value, prior: undefined }]
|
|
63
61
|
: []),
|
|
64
62
|
...Object.entries(sections).map(([name, value]) => ({
|
|
@@ -69,12 +67,6 @@ export function composed(path, fields, sections, composition) {
|
|
|
69
67
|
})),
|
|
70
68
|
], definition);
|
|
71
69
|
}
|
|
72
|
-
export function compose(path, fields, sections, composition) {
|
|
73
|
-
const next = composed(path, fields, sections, composition);
|
|
74
|
-
if (next.outcome !== 'applied')
|
|
75
|
-
throw new Error(`the creation of ${path} writes no document`);
|
|
76
|
-
return serialize(next.document);
|
|
77
|
-
}
|
|
78
70
|
function edited(change, priors) {
|
|
79
71
|
if (change.kind === 'field')
|
|
80
72
|
return {
|
|
@@ -106,7 +98,7 @@ function edit(staged, changes, priors, composition) {
|
|
|
106
98
|
const wanted = changes.map((change) => edited(change, priors));
|
|
107
99
|
const first = apply(parsed.document, wanted, definition);
|
|
108
100
|
if (first.outcome === 'refuse')
|
|
109
|
-
return
|
|
101
|
+
return { refusal: first.refusal };
|
|
110
102
|
if (first.outcome === 'applied') {
|
|
111
103
|
staged.documents[path] = serialize(first.document);
|
|
112
104
|
return 0;
|
|
@@ -166,10 +158,16 @@ function erase(staged, path) {
|
|
|
166
158
|
}
|
|
167
159
|
function stage(staged, change, composition) {
|
|
168
160
|
if (change.kind === 'create') {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
161
|
+
if ('content' in change)
|
|
162
|
+
staged.documents[change.path] = change.content;
|
|
163
|
+
else {
|
|
164
|
+
const next = composed(change.path, change.fields, change.sections, composition);
|
|
165
|
+
if (next.outcome === 'refuse')
|
|
166
|
+
return { refusal: next.refusal };
|
|
167
|
+
if (next.outcome === 'stale')
|
|
168
|
+
throw new Error(`the creation of ${change.path} writes no document`);
|
|
169
|
+
staged.documents[change.path] = serialize(next.document);
|
|
170
|
+
}
|
|
173
171
|
delete staged.fileIds[change.path];
|
|
174
172
|
delete staged.created[change.path];
|
|
175
173
|
delete staged.changes[change.path];
|
|
@@ -221,8 +219,38 @@ function arrive(heads, change) {
|
|
|
221
219
|
if (change.change !== undefined)
|
|
222
220
|
heads.changes[change.path] = change.change;
|
|
223
221
|
}
|
|
224
|
-
|
|
225
|
-
const
|
|
222
|
+
function* stagedBatch(staged, batch, composition, settled) {
|
|
223
|
+
const priors = yield* priorsOf(batch.preconditions);
|
|
224
|
+
for (let index = 0; index < batch.changes.length; index += 1) {
|
|
225
|
+
const change = batch.changes[index];
|
|
226
|
+
if (!isPart(change)) {
|
|
227
|
+
const staging = stage(staged, change, composition);
|
|
228
|
+
if (typeof staging === 'boolean')
|
|
229
|
+
settled(index, change.path, staging ? 0 : 1);
|
|
230
|
+
else
|
|
231
|
+
settled(index, change.path, 1, staging.refusal);
|
|
232
|
+
yield ROW_WEIGHT;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
const run = [change];
|
|
236
|
+
while (index + 1 < batch.changes.length) {
|
|
237
|
+
const next = batch.changes[index + 1];
|
|
238
|
+
if (!isPart(next) || next.path !== change.path)
|
|
239
|
+
break;
|
|
240
|
+
run.push(next);
|
|
241
|
+
index += 1;
|
|
242
|
+
}
|
|
243
|
+
const text = staged.documents[change.path] ?? '';
|
|
244
|
+
const edited = edit(staged, run, priors, composition);
|
|
245
|
+
if (typeof edited === 'number')
|
|
246
|
+
settled(index, change.path, edited);
|
|
247
|
+
else
|
|
248
|
+
settled(index, change.path, run.length, edited.refusal);
|
|
249
|
+
yield ROW_WEIGHT + text.length;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function stagedOf(base) {
|
|
253
|
+
return {
|
|
226
254
|
documents: drafted(base.documents),
|
|
227
255
|
binaries: drafted(base.binaries),
|
|
228
256
|
revisions: drafted(base.revisions),
|
|
@@ -230,29 +258,14 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
230
258
|
created: drafted(base.created),
|
|
231
259
|
changes: drafted(base.changes),
|
|
232
260
|
};
|
|
261
|
+
}
|
|
262
|
+
export function* overlaying(base, queue, composition, unapplied) {
|
|
263
|
+
const staged = stagedOf(base);
|
|
233
264
|
for (const batch of queue) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const change = batch.changes[index];
|
|
237
|
-
if (!isPart(change)) {
|
|
238
|
-
if (!stage(staged, change, composition))
|
|
239
|
-
unapplied?.();
|
|
240
|
-
yield ROW_WEIGHT;
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
const run = [change];
|
|
244
|
-
while (index + 1 < batch.changes.length) {
|
|
245
|
-
const next = batch.changes[index + 1];
|
|
246
|
-
if (!isPart(next) || next.path !== change.path)
|
|
247
|
-
break;
|
|
248
|
-
run.push(next);
|
|
249
|
-
index += 1;
|
|
250
|
-
}
|
|
251
|
-
const text = staged.documents[change.path] ?? '';
|
|
252
|
-
for (let left = edit(staged, run, priors, composition); left > 0; left -= 1)
|
|
265
|
+
yield* stagedBatch(staged, batch, composition, (_index, _path, left) => {
|
|
266
|
+
for (let count = left; count > 0; count -= 1)
|
|
253
267
|
unapplied?.();
|
|
254
|
-
|
|
255
|
-
}
|
|
268
|
+
});
|
|
256
269
|
}
|
|
257
270
|
return {
|
|
258
271
|
documents: yield* settling(staged.documents),
|
|
@@ -263,3 +276,59 @@ export function* overlaying(base, queue, composition, unapplied) {
|
|
|
263
276
|
changes: yield* settling(staged.changes),
|
|
264
277
|
};
|
|
265
278
|
}
|
|
279
|
+
function writesText(change) {
|
|
280
|
+
return isPart(change) || change.kind === 'create' || change.kind === 'replace';
|
|
281
|
+
}
|
|
282
|
+
function textWrites(changes) {
|
|
283
|
+
const identities = changes.map((_, index) => departure(changes, index));
|
|
284
|
+
const created = new Set(changes.flatMap((change, index) => (change.kind === 'create' ? [identities[index]] : [])));
|
|
285
|
+
const last = new Map(changes.flatMap((change, index) => writesText(change) ? [[identities[index], index]] : []));
|
|
286
|
+
return { identities, created, last };
|
|
287
|
+
}
|
|
288
|
+
export function unreadDocuments(batch, base) {
|
|
289
|
+
const { identities, created, last } = textWrites(batch.changes);
|
|
290
|
+
return batch.changes.map((_, index) => {
|
|
291
|
+
const identity = identities[index];
|
|
292
|
+
if (last.get(identity) !== index)
|
|
293
|
+
return null;
|
|
294
|
+
const made = created.has(identity);
|
|
295
|
+
return { stale: false, content: '', base: made ? null : base, created: made };
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
export function* writtenDocuments(base, batch, composition) {
|
|
299
|
+
const { changes } = batch;
|
|
300
|
+
const { identities, created, last } = textWrites(changes);
|
|
301
|
+
const read = new Map(batch.preconditions.flatMap((precondition) => precondition.kind === 'revision' ? [[precondition.path, precondition.revision]] : []));
|
|
302
|
+
const stale = new Set();
|
|
303
|
+
const refused = new Map();
|
|
304
|
+
const texts = new Map();
|
|
305
|
+
const staged = stagedOf(base);
|
|
306
|
+
yield* stagedBatch(staged, batch, composition, (index, path, unapplied, refusal) => {
|
|
307
|
+
if (!writesText(changes[index]))
|
|
308
|
+
return;
|
|
309
|
+
const identity = identities[index];
|
|
310
|
+
if (unapplied > 0)
|
|
311
|
+
stale.add(identity);
|
|
312
|
+
if (refusal !== undefined && !refused.has(identity))
|
|
313
|
+
refused.set(identity, refusal);
|
|
314
|
+
const text = staged.documents[path];
|
|
315
|
+
if (text !== undefined)
|
|
316
|
+
texts.set(index, text);
|
|
317
|
+
});
|
|
318
|
+
return changes.map((_, index) => {
|
|
319
|
+
const identity = identities[index];
|
|
320
|
+
if (last.get(identity) !== index)
|
|
321
|
+
return null;
|
|
322
|
+
const content = texts.get(index);
|
|
323
|
+
if (content === undefined || stale.has(identity)) {
|
|
324
|
+
const refusal = refused.get(identity);
|
|
325
|
+
return refusal === undefined ? { stale: true } : { stale: true, refusal };
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
stale: false,
|
|
329
|
+
content,
|
|
330
|
+
base: read.get(changes[index].path) ?? read.get(identity) ?? base.revisions[identity] ?? null,
|
|
331
|
+
created: created.has(identity),
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
}
|
package/dist/parts.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { type Part } from '@agentshouse/session-content';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const WORKING = "Working";
|
|
3
|
+
export declare function linesWords(added: number, removed: number): string;
|
|
4
|
+
export declare function capitalized(words: string): string;
|
|
5
|
+
export declare function turnLine(parts: readonly Part[], lead: string | null): string | null;
|
|
3
6
|
export declare function runningLine(parts: readonly Part[]): string | null;
|
|
4
7
|
//# sourceMappingURL=parts.d.ts.map
|
package/dist/parts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"parts.d.ts","sourceRoot":"","sources":["../src/parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAGrE,eAAO,MAAM,OAAO,YAAY,CAAC;AAOjC,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAenF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAIjE"}
|
package/dist/parts.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { turnCounts } from '@agentshouse/session-content';
|
|
2
2
|
import { excerpt } from './read.js';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export const WORKING = 'Working';
|
|
4
|
+
function said(count, one, many) {
|
|
5
|
+
if (count === 0)
|
|
6
|
+
return null;
|
|
7
|
+
return count === 1 ? one : many(count);
|
|
8
|
+
}
|
|
9
|
+
export function linesWords(added, removed) {
|
|
10
|
+
return `+${added} −${removed}`;
|
|
11
|
+
}
|
|
12
|
+
export function capitalized(words) {
|
|
13
|
+
return words.charAt(0).toUpperCase() + words.slice(1);
|
|
14
|
+
}
|
|
15
|
+
export function turnLine(parts, lead) {
|
|
16
|
+
const counts = turnCounts(parts);
|
|
17
|
+
const kinds = [
|
|
18
|
+
said(counts.commands, 'ran 1 command', (count) => `ran ${count} commands`),
|
|
19
|
+
said(counts.edited, 'edited 1 file', (count) => `edited ${count} files`),
|
|
20
|
+
said(counts.other, 'made 1 other call', (count) => `made ${count} other calls`),
|
|
21
|
+
].filter((one) => one !== null);
|
|
22
|
+
if (kinds.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
const changed = counts.added === 0 && counts.removed === 0 ? null : linesWords(counts.added, counts.removed);
|
|
25
|
+
const failed = counts.failed === 0 ? null : `${counts.failed} failed`;
|
|
26
|
+
const words = kinds.join(' · ');
|
|
27
|
+
return [lead === null ? capitalized(words) : `${lead} · ${words}`, changed, failed]
|
|
28
|
+
.filter((one) => one !== null)
|
|
29
|
+
.join(' · ');
|
|
6
30
|
}
|
|
7
31
|
export function runningLine(parts) {
|
|
8
|
-
const
|
|
9
|
-
const note = [...own].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
32
|
+
const note = [...parts].reverse().find((part) => part.type === 'text' && part.text.trim() !== '');
|
|
10
33
|
if (note?.type === 'text')
|
|
11
34
|
return excerpt(note.text);
|
|
12
|
-
return
|
|
35
|
+
return turnLine(parts, null);
|
|
13
36
|
}
|
package/dist/paths.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare function normalize(path: string): string | null;
|
|
2
2
|
export declare function beneath(prefix: string, path: string): boolean;
|
|
3
3
|
export declare function covered(prefixes: readonly string[], path: string): boolean;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function documentAt(patterns: readonly string[], path: string): boolean;
|
|
5
5
|
export declare function ancestors(path: string): readonly string[];
|
|
6
6
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.js
CHANGED
|
@@ -41,7 +41,7 @@ function matched(pattern, path) {
|
|
|
41
41
|
return ((open ? names.length > fixed.length : names.length === fixed.length) &&
|
|
42
42
|
fixed.every((one, at) => named(one, names[at])));
|
|
43
43
|
}
|
|
44
|
-
export function
|
|
44
|
+
export function documentAt(patterns, path) {
|
|
45
45
|
return patterns.some((pattern) => matched(pattern, path));
|
|
46
46
|
}
|
|
47
47
|
export function ancestors(path) {
|
package/dist/preparation.d.ts
CHANGED
|
@@ -1,20 +1,46 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type InstallShare } from './install.js';
|
|
2
|
+
import { type ReadinessChange } from './observation.js';
|
|
2
3
|
import { type PortReach } from './reach.js';
|
|
3
|
-
import { type CodeAvailability, type ConnectionAvailability, type Readiness } from './readiness.js';
|
|
4
|
+
import { type CodeAvailability, type ConnectionAvailability, type FirstTier, type Readiness, type RoomCoverage } from './readiness.js';
|
|
4
5
|
import type { Runtime } from './runtime.js';
|
|
5
6
|
export type ReadinessPort = {
|
|
6
7
|
readonly target: string;
|
|
7
8
|
readonly code: CodeAvailability;
|
|
9
|
+
readonly first: FirstTier | null;
|
|
10
|
+
readonly inboxed: readonly string[] | null;
|
|
8
11
|
};
|
|
12
|
+
export type ReadinessMessage = Readiness | ReadinessChange;
|
|
9
13
|
export type ReadinessWatch = {
|
|
10
14
|
readonly port: ReadinessPort;
|
|
11
15
|
readonly reach: PortReach | null;
|
|
12
|
-
readonly deliver: (readiness:
|
|
16
|
+
readonly deliver: (readiness: ReadinessMessage) => void;
|
|
17
|
+
};
|
|
18
|
+
type Share = InstallShare & {
|
|
19
|
+
readonly coverage: RoomCoverage;
|
|
20
|
+
};
|
|
21
|
+
type Settled = {
|
|
22
|
+
acquiring: number;
|
|
23
|
+
unsettled: number;
|
|
24
|
+
};
|
|
25
|
+
type Totals = Settled & {
|
|
26
|
+
installing: number;
|
|
27
|
+
downloading: number;
|
|
28
|
+
done: number;
|
|
29
|
+
total: number;
|
|
30
|
+
};
|
|
31
|
+
export type ReadinessShowing = {
|
|
32
|
+
readonly listing: number;
|
|
33
|
+
readonly roomsListed: boolean;
|
|
34
|
+
readonly named: ReadonlySet<string> | null;
|
|
35
|
+
readonly rooms: Map<string, Share>;
|
|
36
|
+
readonly first: Map<string, string>;
|
|
37
|
+
readonly totals: Totals;
|
|
38
|
+
shown: string;
|
|
13
39
|
};
|
|
14
40
|
export declare function prepare(runtime: Runtime, locators?: readonly string[]): void;
|
|
15
|
-
export declare function roomsOfReach(reach: PlanReach): ReadonlySet<string>;
|
|
16
41
|
export declare function connectionNow(runtime: Runtime): Promise<ConnectionAvailability>;
|
|
17
|
-
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[]): Promise<void>;
|
|
18
|
-
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness:
|
|
19
|
-
export declare function filled(
|
|
42
|
+
export declare function deliverOwedReadiness(runtime: Runtime, owed: readonly ReadinessWatch[], touched: ReadonlySet<string> | null): Promise<void>;
|
|
43
|
+
export declare function watchReadiness({ store }: Runtime, port: ReadinessPort, reach: PortReach | null, deliver: (readiness: ReadinessMessage) => void): () => void;
|
|
44
|
+
export declare function filled({ store, socket }: Runtime): void;
|
|
45
|
+
export {};
|
|
20
46
|
//# sourceMappingURL=preparation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preparation.d.ts","sourceRoot":"","sources":["../src/preparation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgC,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE3B,KAAK,SAAS,EACd,KAAK,SAAS,EAEd,KAAK,YAAY,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IACh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