@agentshouse/mdruntime 0.1.0-ccbb89b0ca151 → 0.1.0-ccc0e3407f107
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 +1 -1
- package/dist/adapter.d.ts +74 -57
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +3 -10
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +29 -47
- package/dist/bootstrap.d.ts +11 -18
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +85 -108
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/client.d.ts +9 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +23 -17
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +91 -270
- package/dist/connection.d.ts +10 -9
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1009 -1063
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +7 -0
- package/dist/conversation.d.ts +16 -13
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +229 -155
- package/dist/durability.d.ts +6 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -2
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +17 -8
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +22 -27
- package/dist/identity.d.ts +0 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +0 -3
- package/dist/index.d.ts +11 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/job.d.ts +14 -0
- package/dist/job.d.ts.map +1 -0
- package/dist/job.js +28 -0
- package/dist/live.d.ts +2 -1
- package/dist/live.d.ts.map +1 -1
- package/dist/live.js +10 -7
- package/dist/media.d.ts +1 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +27 -4
- package/dist/memory.d.ts +11 -5
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +167 -84
- package/dist/messages.d.ts +2 -2
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js +15 -16
- package/dist/model.d.ts +8 -8
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +6 -12
- package/dist/observation.d.ts +3 -2
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +8 -3
- package/dist/outcome.d.ts +0 -3
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +3 -1
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +4 -0
- package/dist/query.d.ts +4 -209
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/reach.d.ts +9 -8
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +37 -48
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +3 -17
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +4 -10
- package/dist/recovery.d.ts +1 -0
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +26 -0
- package/dist/refresh.d.ts +7 -5
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +29 -5
- package/dist/replica.d.ts +10 -8
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +29 -14
- package/dist/room-draft.d.ts +21 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +98 -51
- package/dist/rows.d.ts +14 -21
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +48 -184
- package/dist/save.d.ts +2 -0
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +20 -12
- package/dist/search.d.ts +12 -63
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +9 -52
- package/dist/shared.d.ts +0 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +0 -10
- package/dist/status.d.ts +4 -3
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +3 -1
- package/dist/store.d.ts +21 -34
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +34 -77
- package/dist/stored.d.ts +11 -34
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +158 -241
- package/dist/tables.d.ts +23 -48
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +29 -66
- package/dist/transfer.d.ts +0 -5
- package/dist/transfer.d.ts.map +1 -1
- package/dist/validation.d.ts +3 -4
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +42 -100
- package/dist/windows.d.ts +1 -12
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +2 -75
- package/dist/wire.d.ts +9 -4
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +3 -1
- package/package.json +2 -2
- package/dist/fulltext.d.ts +0 -27
- package/dist/fulltext.d.ts.map +0 -1
- package/dist/fulltext.js +0 -368
- package/dist/reads.d.ts +0 -11
- package/dist/reads.d.ts.map +0 -1
- package/dist/reads.js +0 -100
- package/dist/words.d.ts +0 -19
- package/dist/words.d.ts.map +0 -1
- package/dist/words.js +0 -150
package/dist/rows.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { byCodePoint, documentFacts, indexed, parse } from '@agentshouse/mdmodel';
|
|
2
2
|
import { governing } from './collection.js';
|
|
3
3
|
import { definitionOf } from './model.js';
|
|
4
4
|
function keyOf(...parts) {
|
|
@@ -19,196 +19,60 @@ export function markdownPath(path) {
|
|
|
19
19
|
export function folderOf(path) {
|
|
20
20
|
return path.slice(0, Math.max(path.lastIndexOf('/'), 0));
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const keys = [first];
|
|
25
|
-
const gaps = [[]];
|
|
26
|
-
for (const segment of rest) {
|
|
27
|
-
if (ARRAY_INDEX.test(segment)) {
|
|
28
|
-
gaps.at(-1).push(segment);
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
keys.push(segment);
|
|
32
|
-
gaps.push([]);
|
|
33
|
-
}
|
|
34
|
-
const places = gaps
|
|
35
|
-
.map((gap, at) => {
|
|
36
|
-
const open = at < gaps.length - 1 ? reach !== 'exact' : reach === 'link';
|
|
37
|
-
return `/${gap.map((number) => `[.:]${number}`).join('')}.${open ? '*' : ''}`;
|
|
38
|
-
})
|
|
39
|
-
.join('');
|
|
40
|
-
return {
|
|
41
|
-
keys: keys.map((key) => `/${key}`).join(''),
|
|
42
|
-
places,
|
|
43
|
-
glob: /[[*]/u.test(places),
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function placesOf({ done, head, tail }) {
|
|
47
|
-
return `${done}/${head}${tail}.`;
|
|
48
|
-
}
|
|
49
|
-
function throughOf(keys, places) {
|
|
50
|
-
const gaps = places.split('/').slice(1);
|
|
51
|
-
return keys
|
|
52
|
-
.split('/')
|
|
53
|
-
.slice(1)
|
|
54
|
-
.map((key, at) => `/${key}${gaps[at].replace(/\.\d*/gu, '').replaceAll(':', '/')}`)
|
|
55
|
-
.join('');
|
|
56
|
-
}
|
|
57
|
-
function plainObject(value) {
|
|
58
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
59
|
-
}
|
|
60
|
-
function compared(reading, exact, value) {
|
|
61
|
-
if (!reading.references.has(exact))
|
|
62
|
-
return value;
|
|
63
|
-
return (typeof value === 'string' ? target(reading.path, value) : null) ?? undefined;
|
|
64
|
-
}
|
|
65
|
-
export function kindOf(value) {
|
|
66
|
-
if (value === undefined)
|
|
67
|
-
return 'undefined';
|
|
68
|
-
if (value === null)
|
|
69
|
-
return 'null';
|
|
70
|
-
if (Array.isArray(value))
|
|
71
|
-
return 'array';
|
|
72
|
-
if (typeof value === 'object')
|
|
73
|
-
return 'object';
|
|
74
|
-
return typeof value;
|
|
75
|
-
}
|
|
76
|
-
function scalarOf(value) {
|
|
77
|
-
if (typeof value === 'string' || typeof value === 'number')
|
|
22
|
+
function byKey(_key, value) {
|
|
23
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
78
24
|
return value;
|
|
79
|
-
|
|
80
|
-
return value ? 1 : 0;
|
|
81
|
-
if (Array.isArray(value))
|
|
82
|
-
return JSON.stringify(value);
|
|
83
|
-
return null;
|
|
25
|
+
return Object.fromEntries(Object.entries(value).sort(([one], [other]) => byCodePoint(one, other)));
|
|
84
26
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
87
|
-
keys,
|
|
88
|
-
places,
|
|
89
|
-
item: -1,
|
|
90
|
-
kind: kindOf(value),
|
|
91
|
-
value: scalarOf(value),
|
|
92
|
-
size: Array.isArray(value) ? value.length : null,
|
|
93
|
-
});
|
|
94
|
-
if (!Array.isArray(value))
|
|
95
|
-
return;
|
|
96
|
-
value.forEach((item, index) => {
|
|
97
|
-
const itemKind = kindOf(item);
|
|
98
|
-
reading.values.push({
|
|
99
|
-
keys,
|
|
100
|
-
places,
|
|
101
|
-
item: index,
|
|
102
|
-
kind: itemKind,
|
|
103
|
-
value: itemKind === 'array' ? null : scalarOf(item),
|
|
104
|
-
size: null,
|
|
105
|
-
});
|
|
106
|
-
});
|
|
27
|
+
function fieldsText(fields) {
|
|
28
|
+
return JSON.stringify(fields, byKey);
|
|
107
29
|
}
|
|
108
|
-
function
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
:
|
|
112
|
-
const places = placesOf(at);
|
|
113
|
-
held(reading, at.keys, places, value);
|
|
114
|
-
if (typeof value !== 'string' || !reading.references.has(at.exact))
|
|
115
|
-
return;
|
|
116
|
-
reading.links.push({
|
|
117
|
-
kind: 'field',
|
|
118
|
-
keys: at.keys,
|
|
119
|
-
places,
|
|
120
|
-
target: value,
|
|
121
|
-
field: throughOf(at.keys, places),
|
|
30
|
+
export function writtenFacts(path, content, composition) {
|
|
31
|
+
const model = governing(composition, path);
|
|
32
|
+
const facts = documentFacts(path, parse(content, path), {
|
|
33
|
+
types: model.status === 'unavailable' ? {} : model.types,
|
|
122
34
|
});
|
|
35
|
+
return facts === null
|
|
36
|
+
? null
|
|
37
|
+
: { ...facts, fields: JSON.parse(fieldsText(facts.fields)) };
|
|
123
38
|
}
|
|
124
|
-
function
|
|
125
|
-
record(reading, node, at);
|
|
126
|
-
if (Array.isArray(node)) {
|
|
127
|
-
node.forEach((item, index) => walk(reading, item, { ...at, tail: `${at.tail}.${index}`, exact: `${at.exact}/${index}` }));
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (!plainObject(node))
|
|
131
|
-
return;
|
|
132
|
-
for (const [key, value] of Object.entries(node)) {
|
|
133
|
-
const segment = escapePointer(key);
|
|
134
|
-
const exact = `${at.exact}/${segment}`;
|
|
135
|
-
walk(reading, value, ARRAY_INDEX.test(segment)
|
|
136
|
-
? { ...at, head: `${at.head}${at.tail.replaceAll('.', ':')}:${segment}`, tail: '', exact }
|
|
137
|
-
: { keys: `${at.keys}/${segment}`, done: placesOf(at), head: '', tail: '', exact });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function bodyTargets(path, content) {
|
|
141
|
-
const seen = new Set();
|
|
142
|
-
const found = [];
|
|
143
|
-
for (const { target: reached } of bodyLinks(bodyAfterFrontmatter(content), path)) {
|
|
144
|
-
if (seen.has(reached))
|
|
145
|
-
continue;
|
|
146
|
-
seen.add(reached);
|
|
147
|
-
found.push({ kind: 'body', keys: '', places: '', target: reached, field: '' });
|
|
148
|
-
}
|
|
149
|
-
return found;
|
|
150
|
-
}
|
|
151
|
-
function typedRows(path, content, document, composition) {
|
|
152
|
-
const definition = definitionOf(governing(composition, path), document.type);
|
|
153
|
-
const reading = {
|
|
154
|
-
path,
|
|
155
|
-
references: new Set(definition === undefined ? [] : references(document, definition).map((one) => one.pointer)),
|
|
156
|
-
values: [],
|
|
157
|
-
links: [],
|
|
158
|
-
};
|
|
159
|
-
for (const [name, value] of Object.entries(document.fields)) {
|
|
160
|
-
const segment = escapePointer(name);
|
|
161
|
-
walk(reading, value, {
|
|
162
|
-
keys: `/${segment}`,
|
|
163
|
-
done: '',
|
|
164
|
-
head: '',
|
|
165
|
-
tail: '',
|
|
166
|
-
exact: `/${segment}`,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
const links = reading.links;
|
|
170
|
-
if (definition !== undefined) {
|
|
171
|
-
const sectioned = new Set();
|
|
172
|
-
for (const { target: reached } of sectionReferences(path, content, definition)) {
|
|
173
|
-
if (reached === null || sectioned.has(reached))
|
|
174
|
-
continue;
|
|
175
|
-
sectioned.add(reached);
|
|
176
|
-
links.push({ kind: 'section', keys: '', places: '', target: reached, field: '' });
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
return { values: reading.values, links: [...links, ...bodyTargets(path, content)] };
|
|
180
|
-
}
|
|
181
|
-
function read(path, content) {
|
|
39
|
+
export function described(path, content, facts) {
|
|
182
40
|
const folder = folderOf(path);
|
|
183
|
-
const unread = {
|
|
184
|
-
if (content === null)
|
|
185
|
-
return {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
if (!markdownPath(path)
|
|
190
|
-
return {
|
|
191
|
-
}
|
|
192
|
-
const document = parsed.frontmatter;
|
|
41
|
+
const unread = { type: null, fields: null, links: null, folder };
|
|
42
|
+
if (content === null)
|
|
43
|
+
return { ...unread, declared: null, queried: true };
|
|
44
|
+
if (facts === null)
|
|
45
|
+
return { ...unread, declared: null, queried: !markdownPath(path) };
|
|
46
|
+
const links = JSON.stringify(facts.links);
|
|
47
|
+
if (!markdownPath(path))
|
|
48
|
+
return { ...unread, declared: facts.type, queried: true, links };
|
|
193
49
|
return {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
},
|
|
201
|
-
document,
|
|
50
|
+
type: facts.type,
|
|
51
|
+
declared: facts.type,
|
|
52
|
+
queried: true,
|
|
53
|
+
folder,
|
|
54
|
+
fields: fieldsText(facts.fields),
|
|
55
|
+
links,
|
|
202
56
|
};
|
|
203
57
|
}
|
|
204
|
-
export function
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
|
|
58
|
+
export function heldOf(path, content, facts) {
|
|
59
|
+
if (content === null || facts === null)
|
|
60
|
+
return { type: null, fields: null, links: [] };
|
|
61
|
+
return markdownPath(path)
|
|
62
|
+
? { type: facts.type, fields: facts.fields, links: facts.links }
|
|
63
|
+
: { type: null, fields: null, links: facts.links };
|
|
64
|
+
}
|
|
65
|
+
export function derived(path, held, composition) {
|
|
66
|
+
const stored = held.links.map((target) => ({
|
|
67
|
+
kind: 'link',
|
|
68
|
+
keys: '',
|
|
69
|
+
places: '',
|
|
70
|
+
target,
|
|
71
|
+
field: '',
|
|
72
|
+
}));
|
|
73
|
+
if (held.type === null || held.fields === null)
|
|
74
|
+
return { values: [], links: stored };
|
|
75
|
+
const definition = definitionOf(governing(composition, path), held.type);
|
|
76
|
+
const { values, links: fields } = indexed(path, held.fields, definition);
|
|
77
|
+
return { values, links: [...fields, ...stored] };
|
|
214
78
|
}
|
package/dist/save.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export type SaveInput = {
|
|
|
21
21
|
providerOwnedPaths: readonly string[];
|
|
22
22
|
providerLimits: readonly ProviderLimit[];
|
|
23
23
|
visible: VisibleLayer;
|
|
24
|
+
folders: ReadonlySet<string>;
|
|
24
25
|
handle: string;
|
|
25
26
|
changes: readonly Change[];
|
|
26
27
|
bases: readonly Precondition[];
|
|
@@ -75,6 +76,7 @@ export type MoveSide = {
|
|
|
75
76
|
operations: OperationScopes;
|
|
76
77
|
providerOwnedPaths: readonly string[];
|
|
77
78
|
visible: VisibleLayer;
|
|
79
|
+
folders: ReadonlySet<string>;
|
|
78
80
|
queued: ReadonlySet<string>;
|
|
79
81
|
unmodeled: boolean;
|
|
80
82
|
validate: Validator;
|
package/dist/save.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../src/save.ts"],"names":[],"mappings":"AACA,OAAO,EAkBL,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAKL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,WAAW,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,cAAc,EAAE,eAAe,CAAC;IACnD,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,MAAM,EAAE,CA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ACxB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,eAAe,CAAC;IAC5B,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,QAAQ,CAAC;IACjB,WAAW,EAAE,QAAQ,CAAC;IACtB,KAAK,EAAE,SAAS;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,WAAW,CAAA;CAAE,GAAG,QAAQ,CAAC;AAmInG,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAE/D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAEjE"}
|
package/dist/save.js
CHANGED
|
@@ -4,7 +4,7 @@ import { immutable, leaving, queuedFile, departure, } from './change.js';
|
|
|
4
4
|
import { collectionOf, documentsOf, governing, } from './collection.js';
|
|
5
5
|
import { changeBatchIdentity } from './identity.js';
|
|
6
6
|
import { overlaying } from './overlay.js';
|
|
7
|
-
import { covered, normalize } from './paths.js';
|
|
7
|
+
import { ancestors, covered, normalize } from './paths.js';
|
|
8
8
|
import { sorting } from './shared.js';
|
|
9
9
|
import { paced, ROW_WEIGHT, stepped } from './turn.js';
|
|
10
10
|
import { validatedCollection } from './validation.js';
|
|
@@ -321,6 +321,8 @@ function* incoming(collection, removed, candidates) {
|
|
|
321
321
|
function affected(change) {
|
|
322
322
|
return change.kind === 'move' ? [change.path, change.to] : [change.path];
|
|
323
323
|
}
|
|
324
|
+
const WRITE = ['write'];
|
|
325
|
+
const MOVE_OUT = ['write', 'erase'];
|
|
324
326
|
function guard(changes, input, removing) {
|
|
325
327
|
const overridden = new Map();
|
|
326
328
|
const existing = {
|
|
@@ -329,6 +331,7 @@ function guard(changes, input, removing) {
|
|
|
329
331
|
add: (path) => void overridden.set(path, true),
|
|
330
332
|
delete: (path) => void overridden.set(path, false),
|
|
331
333
|
};
|
|
334
|
+
const occupied = (path) => input.folders.has(path) ? path : (ancestors(path).find((one) => existing.has(one)) ?? null);
|
|
332
335
|
for (const [index, change] of changes.entries()) {
|
|
333
336
|
for (const path of affected(change)) {
|
|
334
337
|
const normalized = normalize(path);
|
|
@@ -337,13 +340,14 @@ function guard(changes, input, removing) {
|
|
|
337
340
|
if (covered(input.providerOwnedPaths, normalized)) {
|
|
338
341
|
return refuse('provider-owned-path', normalized);
|
|
339
342
|
}
|
|
340
|
-
const operation
|
|
341
|
-
|
|
342
|
-
|
|
343
|
+
for (const operation of change.kind === 'remove' ? removing : WRITE)
|
|
344
|
+
if (!input.local && !covered(input.operations[operation], normalized))
|
|
345
|
+
return refuse(`${operation}-grant`, normalized);
|
|
343
346
|
}
|
|
344
347
|
if (change.kind === 'create' || change.kind === 'arrival') {
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
const taken = existing.has(change.path) ? change.path : occupied(change.path);
|
|
349
|
+
if (taken !== null)
|
|
350
|
+
return refuse('path-collision', taken);
|
|
347
351
|
existing.add(change.path);
|
|
348
352
|
continue;
|
|
349
353
|
}
|
|
@@ -353,6 +357,9 @@ function guard(changes, input, removing) {
|
|
|
353
357
|
input.bases.some((base) => base.kind === 'absent' && base.path === change.path))) {
|
|
354
358
|
return refuse('path-collision', change.path);
|
|
355
359
|
}
|
|
360
|
+
const taken = occupied(change.path);
|
|
361
|
+
if (taken !== null)
|
|
362
|
+
return refuse('path-collision', taken);
|
|
356
363
|
if (!input.local &&
|
|
357
364
|
existing.has(change.path) &&
|
|
358
365
|
input.visible.revisions[departure(changes, index)] === undefined) {
|
|
@@ -364,8 +371,9 @@ function guard(changes, input, removing) {
|
|
|
364
371
|
if (change.kind === 'move') {
|
|
365
372
|
if (!existing.has(change.path))
|
|
366
373
|
return refuse('path-absent', change.path);
|
|
367
|
-
|
|
368
|
-
|
|
374
|
+
const taken = existing.has(change.to) ? change.to : occupied(change.to);
|
|
375
|
+
if (taken !== null)
|
|
376
|
+
return refuse('path-collision', taken);
|
|
369
377
|
if (unrevised(input, change.path)) {
|
|
370
378
|
return refuse('unknown-revision', change.path);
|
|
371
379
|
}
|
|
@@ -968,7 +976,7 @@ function roomReferencesIn(path, content, composition) {
|
|
|
968
976
|
const parsed = parse(content, path);
|
|
969
977
|
if (!parsed.ok)
|
|
970
978
|
return [];
|
|
971
|
-
return roomReferences(
|
|
979
|
+
return roomReferences(parsed.document, definitionOf(governing(composition, path), parsed.document.type));
|
|
972
980
|
}
|
|
973
981
|
function* admittedRooms(changes, visible, resulting, composition) {
|
|
974
982
|
const from = new Map();
|
|
@@ -1014,7 +1022,7 @@ async function batching(input) {
|
|
|
1014
1022
|
const rewritten = await stepped(rewrites(changes, input.visible));
|
|
1015
1023
|
if (rewritten.kind === 'refused')
|
|
1016
1024
|
return rewritten;
|
|
1017
|
-
const refusal = guard(changes, input,
|
|
1025
|
+
const refusal = guard(changes, input, WRITE);
|
|
1018
1026
|
if (refusal !== null)
|
|
1019
1027
|
return refusal;
|
|
1020
1028
|
const preconditions = await stepped(preconditionsOf(changes, input.visible, input.bases));
|
|
@@ -1095,7 +1103,7 @@ async function moving(input) {
|
|
|
1095
1103
|
if (moves.length === 0)
|
|
1096
1104
|
return refuse('no-change');
|
|
1097
1105
|
const removals = moves.map(({ path }) => ({ kind: 'remove', path }));
|
|
1098
|
-
const leaves = guard(removals, { ...source, local: input.local, bases: [] },
|
|
1106
|
+
const leaves = guard(removals, { ...source, local: input.local, bases: [] }, MOVE_OUT);
|
|
1099
1107
|
if (leaves !== null)
|
|
1100
1108
|
return leaves;
|
|
1101
1109
|
const uploading = moves.find(({ path }) => source.visible.binaries[path]?.state === 'pending');
|
|
@@ -1103,7 +1111,7 @@ async function moving(input) {
|
|
|
1103
1111
|
return refuse('unknown-revision', uploading.path);
|
|
1104
1112
|
const moved = new Map(moves.map(({ path, to }) => [path, to]));
|
|
1105
1113
|
const arrivals = moves.map((move) => arrivalOf(move, source, moved));
|
|
1106
|
-
const arrives = guard(arrivals, { ...destination, local: input.local, bases: [] },
|
|
1114
|
+
const arrives = guard(arrivals, { ...destination, local: input.local, bases: [] }, WRITE);
|
|
1107
1115
|
if (arrives !== null)
|
|
1108
1116
|
return arrives;
|
|
1109
1117
|
const bound = input.providerLimits.find((limit) => limit.name === MOVE_DOCUMENTS)?.value;
|
package/dist/search.d.ts
CHANGED
|
@@ -1,73 +1,22 @@
|
|
|
1
|
-
import type { ProviderRefusal } from './adapter.js';
|
|
2
|
-
import
|
|
3
|
-
import type { Open } from './open.js';
|
|
4
|
-
export type DocumentPart = Open<'fields' | 'sections' | 'preamble' | 'path'>;
|
|
1
|
+
import type { ProviderRefusal, SearchHit } from './adapter.js';
|
|
2
|
+
import type { Failure, Offline } from './outcome.js';
|
|
5
3
|
export type SearchRequest = {
|
|
6
4
|
text: string;
|
|
7
|
-
|
|
8
|
-
collection?: true;
|
|
9
|
-
conversations?: readonly string[];
|
|
10
|
-
limit?: number;
|
|
11
|
-
after?: string;
|
|
12
|
-
total?: true;
|
|
5
|
+
rooms?: readonly string[];
|
|
13
6
|
};
|
|
14
|
-
export type
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
at: readonly [number, number];
|
|
19
|
-
};
|
|
20
|
-
export type DocumentHit = {
|
|
21
|
-
room: string;
|
|
22
|
-
path: string;
|
|
23
|
-
type: string;
|
|
24
|
-
score: number;
|
|
25
|
-
matches: Readonly<Record<string, readonly DocumentPart[]>>;
|
|
26
|
-
snippet?: Snippet<DocumentPart>;
|
|
27
|
-
};
|
|
28
|
-
export type MessageHit = {
|
|
29
|
-
conversation: string;
|
|
30
|
-
identity: string;
|
|
31
|
-
score: number;
|
|
32
|
-
matches: Readonly<Record<string, readonly MessagePart[]>>;
|
|
33
|
-
snippet?: Snippet<MessagePart>;
|
|
34
|
-
};
|
|
35
|
-
export type SearchCoverage = {
|
|
36
|
-
rooms: readonly CoveredRoom[];
|
|
37
|
-
conversations: readonly string[];
|
|
38
|
-
overlay: readonly string[];
|
|
7
|
+
export type { SearchHit } from './adapter.js';
|
|
8
|
+
export type SearchFound = {
|
|
9
|
+
kind: 'found';
|
|
10
|
+
documents: readonly SearchHit[];
|
|
39
11
|
};
|
|
40
|
-
export type
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
export type SearchWindow = SearchHits & {
|
|
45
|
-
next?: string;
|
|
46
|
-
total?: {
|
|
47
|
-
documents: number;
|
|
48
|
-
messages: number;
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
export type SearchPending = SearchHits & {
|
|
52
|
-
pending: readonly PendingRoom[];
|
|
53
|
-
coverage: SearchCoverage;
|
|
54
|
-
};
|
|
55
|
-
export type SearchUndeclared = ProviderRefusal & {
|
|
12
|
+
export type SearchResult = SearchFound | Offline | (ProviderRefusal & {
|
|
13
|
+
kind: 'rejected';
|
|
14
|
+
}) | (ProviderRefusal & {
|
|
56
15
|
kind: 'undeclared';
|
|
57
|
-
};
|
|
58
|
-
export type SearchResult = (SearchWindow & {
|
|
59
|
-
coverage: SearchCoverage;
|
|
60
|
-
}) | SearchPending | SearchUndeclared;
|
|
61
|
-
export declare function undeclaredSearch(): SearchUndeclared;
|
|
62
|
-
export type HitCursor = readonly [number, string, string] | readonly [] | null;
|
|
16
|
+
}) | Failure;
|
|
63
17
|
export type SearchPlan = {
|
|
64
18
|
text: string;
|
|
65
|
-
|
|
66
|
-
collection: boolean;
|
|
67
|
-
conversations: readonly string[] | null;
|
|
68
|
-
limit: number | null;
|
|
69
|
-
after: readonly [HitCursor, HitCursor] | null;
|
|
70
|
-
total: boolean;
|
|
19
|
+
rooms: readonly string[] | null;
|
|
71
20
|
};
|
|
72
21
|
export declare function searchPlanOf(input: unknown): SearchPlan;
|
|
73
22
|
//# sourceMappingURL=search.d.ts.map
|
package/dist/search.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC;AAExE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,SAAS,SAAS,EAAE,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,OAAO,GACP,CAAC,eAAe,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,GACxC,CAAC,eAAe,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,GAC1C,OAAO,CAAC;AAEZ,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAYvD"}
|
package/dist/search.js
CHANGED
|
@@ -1,57 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { decodedCursor } from './windows.js';
|
|
3
|
-
export function undeclaredSearch() {
|
|
4
|
-
return {
|
|
5
|
-
kind: 'undeclared',
|
|
6
|
-
code: 'search-undeclared',
|
|
7
|
-
fields: { name: 'local_search' },
|
|
8
|
-
retryable: false,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
function hitCursor(input) {
|
|
12
|
-
if (input === null)
|
|
13
|
-
return null;
|
|
14
|
-
if (!Array.isArray(input))
|
|
15
|
-
return undefined;
|
|
16
|
-
if (input.length === 0)
|
|
17
|
-
return [];
|
|
18
|
-
const [score, first, second] = input;
|
|
19
|
-
return input.length === 3 &&
|
|
20
|
-
typeof score === 'number' &&
|
|
21
|
-
typeof first === 'string' &&
|
|
22
|
-
typeof second === 'string'
|
|
23
|
-
? [score, first, second]
|
|
24
|
-
: undefined;
|
|
25
|
-
}
|
|
26
|
-
function searchAfter(input) {
|
|
27
|
-
if (input === undefined)
|
|
28
|
-
return null;
|
|
29
|
-
const decoded = typeof input === 'string' ? decodedCursor(input) : null;
|
|
30
|
-
const documents = decoded?.length === 2 ? hitCursor(decoded[0]) : undefined;
|
|
31
|
-
const messages = decoded?.length === 2 ? hitCursor(decoded[1]) : undefined;
|
|
32
|
-
if (documents === undefined || messages === undefined) {
|
|
33
|
-
invalid('after', 'expects the next an earlier search returned');
|
|
34
|
-
}
|
|
35
|
-
return [documents, messages];
|
|
36
|
-
}
|
|
1
|
+
import { invalid, known, plain } from '@agentshouse/mdmodel';
|
|
37
2
|
export function searchPlanOf(input) {
|
|
38
3
|
if (!plain(input))
|
|
39
4
|
invalid('search', 'expects a search object');
|
|
40
|
-
known(input, ['text', '
|
|
41
|
-
if (typeof input.text !== 'string')
|
|
42
|
-
invalid('text', 'expects
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
(!Array.isArray(
|
|
46
|
-
invalid('
|
|
5
|
+
known(input, ['text', 'rooms'], '');
|
|
6
|
+
if (typeof input.text !== 'string' || input.text.trim() === '')
|
|
7
|
+
invalid('text', 'expects words');
|
|
8
|
+
const rooms = input.rooms;
|
|
9
|
+
if (rooms !== undefined &&
|
|
10
|
+
(!Array.isArray(rooms) || rooms.some((named) => typeof named !== 'string'))) {
|
|
11
|
+
invalid('rooms', 'expects a list of Rooms');
|
|
47
12
|
}
|
|
48
|
-
return {
|
|
49
|
-
text: input.text,
|
|
50
|
-
documents: input.documents,
|
|
51
|
-
collection: flag(input.collection, 'collection'),
|
|
52
|
-
conversations: conversations ?? null,
|
|
53
|
-
limit: limitOf(input.limit),
|
|
54
|
-
after: searchAfter(input.after),
|
|
55
|
-
total: flag(input.total, 'total'),
|
|
56
|
-
};
|
|
13
|
+
return { text: input.text, rooms: rooms ?? null };
|
|
57
14
|
}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export type Paths<V> = Readonly<Record<string, V>>;
|
|
2
2
|
export declare function entriesIn<V>(map: Paths<V>): Generator<readonly [string, V]>;
|
|
3
|
-
export declare function keysIn(...maps: readonly Paths<unknown>[]): Generator<number, Set<string>, void>;
|
|
4
3
|
export declare function sortedKeys(map: Paths<unknown>): Generator<number, readonly string[], void>;
|
|
5
4
|
export declare function sorting(keys: Iterable<string>): Generator<number, readonly string[], void>;
|
|
6
5
|
export declare function sharing<V>(map: Paths<V>): Generator<number, Paths<V>, void>;
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,MAA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,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAUxF"}
|
package/dist/shared.js
CHANGED
|
@@ -202,16 +202,6 @@ function* rooted(map) {
|
|
|
202
202
|
}
|
|
203
203
|
return { node, size };
|
|
204
204
|
}
|
|
205
|
-
export function* keysIn(...maps) {
|
|
206
|
-
const keys = new Set();
|
|
207
|
-
for (const map of maps) {
|
|
208
|
-
for (const [key] of entriesIn(map)) {
|
|
209
|
-
keys.add(key);
|
|
210
|
-
yield ROW_WEIGHT;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return keys;
|
|
214
|
-
}
|
|
215
205
|
const RUN = 1 << 10;
|
|
216
206
|
function* merged(left, right) {
|
|
217
207
|
const into = [];
|
package/dist/status.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { Open } from './open.js';
|
|
2
|
-
import type { ProviderRefusal } from './adapter.js';
|
|
3
2
|
import type { ReturnReason } from './room-draft.js';
|
|
4
3
|
export type AttentionEntry = {
|
|
5
4
|
room: string;
|
|
6
5
|
path: string;
|
|
7
6
|
returned: ReturnReason;
|
|
8
|
-
}
|
|
7
|
+
};
|
|
8
|
+
export type UnsentChange = {
|
|
9
9
|
room: string;
|
|
10
|
-
|
|
10
|
+
path: string;
|
|
11
11
|
};
|
|
12
12
|
export type SyncStatus = {
|
|
13
13
|
state: Open<'pending' | 'syncing' | 'synced'>;
|
|
14
14
|
lastCompleted: string | null;
|
|
15
15
|
providerUnreachable: boolean;
|
|
16
16
|
attentionRequired: readonly AttentionEntry[];
|
|
17
|
+
unsent: readonly UnsentChange[];
|
|
17
18
|
reset: string | null;
|
|
18
19
|
};
|
|
19
20
|
export type CycleProgress = {
|
package/dist/status.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OA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|
|
|
3
3
|
lastCompleted: null,
|
|
4
4
|
providerUnreachable: false,
|
|
5
5
|
attentionRequired: [],
|
|
6
|
+
unsent: [],
|
|
6
7
|
reset: null,
|
|
7
8
|
};
|
|
8
9
|
export function transferring(status) {
|
|
@@ -16,5 +17,6 @@ export function same(one, other) {
|
|
|
16
17
|
one.lastCompleted === other.lastCompleted &&
|
|
17
18
|
one.providerUnreachable === other.providerUnreachable &&
|
|
18
19
|
one.reset === other.reset &&
|
|
19
|
-
JSON.stringify(one.attentionRequired) === JSON.stringify(other.attentionRequired)
|
|
20
|
+
JSON.stringify(one.attentionRequired) === JSON.stringify(other.attentionRequired) &&
|
|
21
|
+
JSON.stringify(one.unsent) === JSON.stringify(other.unsent));
|
|
20
22
|
}
|