@agentshouse/mdruntime 0.1.0-cedb03eaa48b6 → 0.1.0-cee9c8aa4cd86
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 +86 -71
- package/README.md +9 -8
- package/dist/adapter.d.ts +44 -18
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +4 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +13 -3
- package/dist/bootstrap.d.ts +13 -6
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +90 -61
- package/dist/chain.d.ts +11 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/chain.js +64 -0
- package/dist/change-set.d.ts +9 -16
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +11 -89
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/chat/house.d.ts +25 -0
- package/dist/chat/house.d.ts.map +1 -0
- package/dist/chat/house.js +38 -0
- package/dist/chat/input.d.ts +3 -1
- package/dist/chat/input.d.ts.map +1 -1
- package/dist/chat/input.js +11 -18
- package/dist/chat/list.d.ts +2 -1
- package/dist/chat/list.d.ts.map +1 -1
- package/dist/chat/list.js +7 -3
- package/dist/chat/markdown.d.ts +1 -0
- package/dist/chat/markdown.d.ts.map +1 -1
- package/dist/chat/markdown.js +78 -20
- package/dist/chat/message.d.ts +1 -0
- package/dist/chat/message.d.ts.map +1 -1
- package/dist/chat/message.js +73 -11
- package/dist/chat/messages.d.ts +14 -1
- package/dist/chat/messages.d.ts.map +1 -1
- package/dist/chat/messages.js +79 -24
- package/dist/chat/name.d.ts +1 -0
- package/dist/chat/name.d.ts.map +1 -1
- package/dist/chat/name.js +1 -1
- package/dist/chat/opened.d.ts +1 -0
- package/dist/chat/opened.d.ts.map +1 -1
- package/dist/chat/opened.js +2 -0
- package/dist/chat/overlay.d.ts +1 -0
- package/dist/chat/overlay.d.ts.map +1 -1
- package/dist/chat/overlay.js +11 -5
- package/dist/chat/parts.d.ts +1 -0
- package/dist/chat/parts.d.ts.map +1 -1
- package/dist/chat/parts.js +3 -2
- package/dist/chat/pieces.d.ts +62 -0
- package/dist/chat/pieces.d.ts.map +1 -0
- package/dist/chat/pieces.js +1110 -0
- package/dist/chat/provider.d.ts +8 -1
- package/dist/chat/provider.d.ts.map +1 -1
- package/dist/chat/provider.js +88 -81
- package/dist/chat/ready.d.ts +5 -2
- package/dist/chat/ready.d.ts.map +1 -1
- package/dist/chat/ready.js +7 -5
- package/dist/chat/room-file.d.ts +8 -0
- package/dist/chat/room-file.d.ts.map +1 -0
- package/dist/chat/room-file.js +72 -0
- package/dist/chat/steady.d.ts +3 -0
- package/dist/chat/steady.d.ts.map +1 -0
- package/dist/chat/steady.js +26 -0
- package/dist/chat/style.d.ts.map +1 -1
- package/dist/chat/style.js +5 -0
- package/dist/chat.d.ts +3 -2
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +2 -2
- package/dist/client.d.ts +6 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +29 -2
- package/dist/collection.d.ts +6 -19
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +30 -317
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +718 -0
- package/dist/connection.d.ts +11 -5
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1931 -706
- package/dist/conversation.d.ts +9 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +85 -61
- package/dist/digest.d.ts +7 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +113 -0
- package/dist/durability.d.ts +2 -1
- package/dist/durability.d.ts.map +1 -1
- package/dist/entry.d.ts +3 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -24
- package/dist/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +0 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +10 -3
- 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 +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/live.d.ts +22 -0
- package/dist/live.d.ts.map +1 -0
- package/dist/live.js +123 -0
- package/dist/memory.d.ts +1 -0
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +22 -6
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +12 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +84 -0
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +29 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +25 -0
- package/dist/overlay.d.ts +2 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +86 -171
- package/dist/query.d.ts +2 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +1 -0
- package/dist/reach.d.ts +5 -1
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +158 -52
- package/dist/readiness.d.ts +3 -3
- package/dist/readiness.d.ts.map +1 -1
- package/dist/reads.js +1 -1
- package/dist/recovery.d.ts +2 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +8 -7
- package/dist/refresh.d.ts +10 -13
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +74 -51
- package/dist/replica.d.ts +54 -36
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +277 -184
- package/dist/room-draft.d.ts +3 -1
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +29 -22
- package/dist/rows.d.ts +29 -31
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -69
- package/dist/save.d.ts +50 -14
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +502 -178
- package/dist/search.d.ts +11 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +0 -213
- package/dist/shared.d.ts +8 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +129 -66
- package/dist/store.d.ts +79 -93
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +318 -687
- package/dist/stored.d.ts +138 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +544 -0
- package/dist/tables.d.ts +332 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +570 -0
- package/dist/turn.d.ts +4 -2
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +46 -22
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +2 -6
- package/dist/windows.d.ts.map +1 -1
- package/dist/windows.js +30 -34
- package/dist/wire.d.ts +16 -0
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +4 -0
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +10 -4
- package/dist/read-side.d.ts +0 -27
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -824
package/dist/chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.d.ts","sourceRoot":"","sources":["../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,OAAO,EACP,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MA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 @@
|
|
|
1
1
|
export { ChatProvider, useChat, } from './chat/provider.js';
|
|
2
|
-
export { chatMessages } from './chat/messages.js';
|
|
2
|
+
export { awaitsTurn, chatMessages } from './chat/messages.js';
|
|
3
3
|
export { Chat, mountChat } from './chat/ready.js';
|
|
4
4
|
export { ChatMessageList } from './chat/list.js';
|
|
5
5
|
export { ChatInput } from './chat/input.js';
|
|
6
6
|
export { ChatQuestionCard } from './chat/question.js';
|
|
7
7
|
export { ChatName } from './chat/name.js';
|
|
8
|
-
export { Markdown, anchorOf, plainText, slugOf, } from './chat/markdown.js';
|
|
8
|
+
export { Markdown, anchorOf, plainText, revealed, slugOf, } from './chat/markdown.js';
|
package/dist/client.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { Member, ServiceMode } from './adapter.js';
|
|
|
3
3
|
import type { ChatDraft, ConversationAgent, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
|
|
4
4
|
import { type Observation } from './observation.js';
|
|
5
5
|
import type { BinaryReference } from './binary.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { ChosenFile } from './file.js';
|
|
7
|
+
import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
7
8
|
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
9
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
9
10
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
@@ -36,6 +37,7 @@ export type MdRuntimeClient = {
|
|
|
36
37
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
37
38
|
create(input: unknown): Promise<CallResult>;
|
|
38
39
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
40
|
+
attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
|
|
39
41
|
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
40
42
|
interrupt(conversation: string): Promise<CallResult>;
|
|
41
43
|
kill(conversation: string): Promise<CallResult>;
|
|
@@ -48,6 +50,7 @@ export type MdRuntimeClient = {
|
|
|
48
50
|
discard(conversation: string): Promise<void>;
|
|
49
51
|
};
|
|
50
52
|
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
53
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
51
54
|
binaryFile: {
|
|
52
55
|
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
53
56
|
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
@@ -58,6 +61,7 @@ export type MdRuntimeClient = {
|
|
|
58
61
|
log(): Promise<string>;
|
|
59
62
|
persistence(): Promise<boolean>;
|
|
60
63
|
retry(): Promise<void>;
|
|
64
|
+
cleanUp(): Promise<number>;
|
|
61
65
|
observe: {
|
|
62
66
|
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
63
67
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
@@ -81,6 +85,7 @@ export type MdRuntimeClient = {
|
|
|
81
85
|
};
|
|
82
86
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
83
87
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
88
|
+
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
84
89
|
export type { Observation } from './observation.js';
|
|
85
90
|
export type { Open } from './open.js';
|
|
86
91
|
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EA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
|
});
|
|
135
135
|
}
|
|
136
|
+
function streamed(answer) {
|
|
137
|
+
if (answer.kind !== 'binary')
|
|
138
|
+
return answer;
|
|
139
|
+
const { file, byteLength, mediaType } = answer;
|
|
140
|
+
let part = 0;
|
|
141
|
+
let received = 0;
|
|
142
|
+
const stream = new ReadableStream({
|
|
143
|
+
async pull(controller) {
|
|
144
|
+
const bytes = await ask('binaryFile.part', [file, part]);
|
|
145
|
+
if (bytes === null) {
|
|
146
|
+
if (received === byteLength)
|
|
147
|
+
controller.close();
|
|
148
|
+
else
|
|
149
|
+
controller.error(runtimeError('binary-file-absent', 'The file ended early'));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
part += 1;
|
|
153
|
+
received += bytes.byteLength;
|
|
154
|
+
controller.enqueue(bytes);
|
|
155
|
+
},
|
|
156
|
+
}, { highWaterMark: 0 });
|
|
157
|
+
return { kind: 'binary', stream, byteLength, mediaType };
|
|
158
|
+
}
|
|
136
159
|
function settled() {
|
|
137
160
|
if (settling !== null)
|
|
138
161
|
return settling;
|
|
@@ -185,6 +208,7 @@ export function connectMdRuntime(port) {
|
|
|
185
208
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
186
209
|
create: (input) => ask('conversation.create', [input]),
|
|
187
210
|
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
211
|
+
attach: (room, file) => ask('conversation.attach', [room, file]),
|
|
188
212
|
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
189
213
|
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
190
214
|
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
@@ -197,16 +221,18 @@ export function connectMdRuntime(port) {
|
|
|
197
221
|
discard: (conversation) => ask('chatDraft.discard', [conversation]),
|
|
198
222
|
},
|
|
199
223
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
224
|
+
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
200
225
|
binaryFile: {
|
|
201
|
-
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]),
|
|
226
|
+
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then(streamed),
|
|
202
227
|
link: (room, path, revision) => ask('binaryFile.link', [room, path, revision]),
|
|
203
|
-
readReference: (reference) => ask('binaryFile.readReference', [reference]),
|
|
228
|
+
readReference: (reference) => ask('binaryFile.readReference', [reference]).then(streamed),
|
|
204
229
|
},
|
|
205
230
|
call: (name, input) => ask('call', [name, input]),
|
|
206
231
|
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
207
232
|
log: () => ask('log', []),
|
|
208
233
|
persistence: () => ask('persistence', []),
|
|
209
234
|
retry: () => ask('retry', []),
|
|
235
|
+
cleanUp: () => ask('cleanUp', []),
|
|
210
236
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
211
237
|
reauthorize: () => ask('reauthorize', []),
|
|
212
238
|
settled,
|
|
@@ -218,4 +244,5 @@ export function inTurn(client, work) {
|
|
|
218
244
|
turns.set(client, turn.then(() => undefined, () => undefined));
|
|
219
245
|
return turn;
|
|
220
246
|
}
|
|
247
|
+
export { chainedWindows } from './chain.js';
|
|
221
248
|
export { unanswered } from './wire.js';
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type Document
|
|
2
|
-
import {
|
|
1
|
+
import { type Document } from '@agentshouse/mdmodel';
|
|
2
|
+
import type { ModelState } from './model.js';
|
|
3
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
4
|
import { type Paths } from './shared.js';
|
|
5
5
|
import type { Refused } from './transfer.js';
|
|
6
|
-
import { type Later } from './turn.js';
|
|
7
6
|
export declare const MD_MODEL: MdModelIdentity;
|
|
8
7
|
export type Collection = {
|
|
9
8
|
text: Readonly<Record<string, string>>;
|
|
@@ -17,23 +16,11 @@ export type Composition = {
|
|
|
17
16
|
model: ModelState;
|
|
18
17
|
} | null;
|
|
19
18
|
};
|
|
19
|
+
export declare function selected(composition: Composition, path: string): boolean;
|
|
20
20
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
21
|
-
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function unreadable(text: Readonly<Record<string, string>>, previous?: Readonly<Record<string, string>>): Refused | null;
|
|
21
|
+
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
22
|
+
export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
|
|
23
|
+
export declare function unreadable(text: Paths<string>, paths?: Iterable<string> | null): Generator<number, Refused | null, void>;
|
|
25
24
|
export declare function validRoot(root: unknown): root is string;
|
|
26
|
-
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
|
|
27
|
-
type Held = {
|
|
28
|
-
text: Paths<string>;
|
|
29
|
-
binaries: Paths<unknown>;
|
|
30
|
-
};
|
|
31
|
-
export declare function indexReferrers(held: Held, composition: Composition): Later<void>;
|
|
32
|
-
export declare function referencesIndexed(held: Held, composition: Composition): boolean;
|
|
33
|
-
export declare function referring(held: Held, composition: Composition, targets: Iterable<string>): ReadonlySet<string> | null;
|
|
34
25
|
export declare function available(composition: Composition): boolean;
|
|
35
|
-
export declare function changedCleanly(next: Held, previous: Held & {
|
|
36
|
-
composition: Composition;
|
|
37
|
-
}, composition: Composition): boolean;
|
|
38
|
-
export {};
|
|
39
26
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AA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C,MAAM,CAAC,GAAG,IAAW,GACpC,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC,CAazC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEvD;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAK3D"}
|
package/dist/collection.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { after, inUnits, ROW_WEIGHT } from './turn.js';
|
|
3
|
+
import { keysIn, sortedKeys } from './shared.js';
|
|
4
|
+
import { ROW_WEIGHT } from './turn.js';
|
|
6
5
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
7
|
-
|
|
8
|
-
function selected(composition, path) {
|
|
6
|
+
export function selected(composition, path) {
|
|
9
7
|
return (composition.selection !== null &&
|
|
10
8
|
composition.selection.roots.some((root) => beneath(root, path)));
|
|
11
9
|
}
|
|
@@ -14,337 +12,52 @@ export function governing(composition, path) {
|
|
|
14
12
|
? composition.selection.model
|
|
15
13
|
: composition.model;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (held === undefined)
|
|
21
|
-
return shared({});
|
|
22
|
-
const kept = patched(held.base, held.added);
|
|
23
|
-
held.base = kept;
|
|
24
|
-
held.added = new Map();
|
|
25
|
-
return patched(kept, [], differing(previous.text, text));
|
|
26
|
-
}
|
|
27
|
-
function cachedIn(collection, path) {
|
|
28
|
-
const held = parsedIn.get(collection);
|
|
29
|
-
if (held === undefined)
|
|
30
|
-
return undefined;
|
|
31
|
-
if (held.added.has(path))
|
|
32
|
-
return held.added.get(path);
|
|
33
|
-
return Object.hasOwn(held.base, path) ? held.base[path] : undefined;
|
|
34
|
-
}
|
|
35
|
-
export function collectionOf(text, composition, previous) {
|
|
36
|
-
const parsed = {
|
|
37
|
-
base: previous === undefined ? shared({}) : carried(previous, text),
|
|
38
|
-
added: new Map(),
|
|
39
|
-
};
|
|
40
|
-
const collection = {
|
|
15
|
+
export function collectionOf(text, composition) {
|
|
16
|
+
const parsed = new Map();
|
|
17
|
+
return {
|
|
41
18
|
text,
|
|
42
19
|
composition,
|
|
43
20
|
document(path) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return held ?? undefined;
|
|
21
|
+
if (parsed.has(path))
|
|
22
|
+
return parsed.get(path) ?? undefined;
|
|
47
23
|
const content = text[path];
|
|
48
24
|
if (content === undefined)
|
|
49
25
|
return undefined;
|
|
50
26
|
const read = parse(content, path);
|
|
51
|
-
parsed.
|
|
27
|
+
parsed.set(path, read.ok ? read.document : null);
|
|
52
28
|
return read.ok ? read.document : undefined;
|
|
53
29
|
},
|
|
54
30
|
};
|
|
55
|
-
parsedIn.set(collection, parsed);
|
|
56
|
-
return collection;
|
|
57
|
-
}
|
|
58
|
-
export function passingFrontmatter(collection, path) {
|
|
59
|
-
const held = cachedIn(collection, path);
|
|
60
|
-
if (held !== undefined)
|
|
61
|
-
return held ?? undefined;
|
|
62
|
-
const content = collection.text[path];
|
|
63
|
-
if (content === undefined)
|
|
64
|
-
return undefined;
|
|
65
|
-
const read = parseFrontmatter(content, path);
|
|
66
|
-
return read.ok ? read.frontmatter : undefined;
|
|
67
31
|
}
|
|
68
32
|
export function* documentsOf(collection) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
33
|
+
const paths = yield* sortedKeys(collection.text);
|
|
34
|
+
return (function* () {
|
|
35
|
+
for (const path of paths) {
|
|
36
|
+
const document = collection.document(path);
|
|
37
|
+
if (document !== undefined)
|
|
38
|
+
yield [path, document];
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
}
|
|
42
|
+
export function* unreadable(text, paths = null) {
|
|
43
|
+
const named = paths ?? (yield* keysIn(text));
|
|
44
|
+
let least = null;
|
|
45
|
+
for (const path of named) {
|
|
46
|
+
const content = Object.hasOwn(text, path) ? text[path] : undefined;
|
|
47
|
+
if (content === undefined)
|
|
75
48
|
continue;
|
|
49
|
+
const read = parse(content, path);
|
|
50
|
+
if (!read.ok && (least === null || path < least.path)) {
|
|
51
|
+
least = { path, refused: { kind: 'refused', refusal: read.refusal } };
|
|
76
52
|
}
|
|
77
|
-
|
|
78
|
-
if (read.ok)
|
|
79
|
-
yield [path, read.document];
|
|
53
|
+
yield ROW_WEIGHT + content.length;
|
|
80
54
|
}
|
|
81
|
-
|
|
82
|
-
export function unreadable(text, previous) {
|
|
83
|
-
const paths = previous === undefined
|
|
84
|
-
? Object.keys(text)
|
|
85
|
-
: [...differing(previous, text)].filter((path) => text[path] !== undefined);
|
|
86
|
-
for (const path of paths.sort()) {
|
|
87
|
-
const read = parse(text[path], path);
|
|
88
|
-
if (!read.ok)
|
|
89
|
-
return { kind: 'refused', refusal: read.refusal };
|
|
90
|
-
}
|
|
91
|
-
return null;
|
|
55
|
+
return least?.refused ?? null;
|
|
92
56
|
}
|
|
93
57
|
export function validRoot(root) {
|
|
94
58
|
return typeof root === 'string' && normalize(root) === root;
|
|
95
59
|
}
|
|
96
|
-
function validateAgainst(documents, binaryTargets, model) {
|
|
97
|
-
if (model.status === 'unavailable') {
|
|
98
|
-
const typed = Object.entries(documents).find(([, content]) => {
|
|
99
|
-
const parsed = parse(content);
|
|
100
|
-
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
101
|
-
});
|
|
102
|
-
if (typed !== undefined)
|
|
103
|
-
return { verdict: 'refuse', rule: 'model-unavailable', file: typed[0] };
|
|
104
|
-
}
|
|
105
|
-
return validate(documents, { binaryTargets }, model.status === 'unavailable' ? NO_TYPES : { types: model.types });
|
|
106
|
-
}
|
|
107
|
-
export function validateCollection(text, binaryTargets, composition) {
|
|
108
|
-
const collection = {};
|
|
109
|
-
const selection = {};
|
|
110
|
-
for (const [path, content] of Object.entries(text)) {
|
|
111
|
-
if (selected(composition, path))
|
|
112
|
-
selection[path] = content;
|
|
113
|
-
else
|
|
114
|
-
collection[path] = content;
|
|
115
|
-
}
|
|
116
|
-
const verdicts = [
|
|
117
|
-
validateAgainst(collection, binaryTargets.filter((path) => !selected(composition, path)), composition.model),
|
|
118
|
-
];
|
|
119
|
-
if (composition.selection !== null) {
|
|
120
|
-
verdicts.push(validateAgainst(selection, binaryTargets.filter((path) => selected(composition, path)), composition.selection.model));
|
|
121
|
-
}
|
|
122
|
-
const refusals = verdicts.filter((verdict) => verdict.verdict === 'refuse');
|
|
123
|
-
if (refusals.length === 0)
|
|
124
|
-
return verdicts[0];
|
|
125
|
-
return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
|
|
126
|
-
}
|
|
127
|
-
const NO_REFERRERS = shared({});
|
|
128
|
-
const referrersOf = new WeakMap();
|
|
129
|
-
function typing(left, right) {
|
|
130
|
-
return (sameTyping(left.model, right.model) &&
|
|
131
|
-
(left.selection === null || right.selection === null
|
|
132
|
-
? left.selection === right.selection
|
|
133
|
-
: sameTyping(left.selection.model, right.selection.model)) &&
|
|
134
|
-
JSON.stringify(left.selection?.roots ?? null) === JSON.stringify(right.selection?.roots ?? null));
|
|
135
|
-
}
|
|
136
|
-
function declared(content) {
|
|
137
|
-
if (content === undefined)
|
|
138
|
-
return undefined;
|
|
139
|
-
const read = parseFrontmatter(content);
|
|
140
|
-
return read.ok ? (read.frontmatter.type ?? 'any') : undefined;
|
|
141
|
-
}
|
|
142
|
-
function typedIn(content) {
|
|
143
|
-
const type = declared(content);
|
|
144
|
-
return type !== undefined && type !== 'any';
|
|
145
|
-
}
|
|
146
|
-
function modelOf(composition, path) {
|
|
147
|
-
const model = governing(composition, path);
|
|
148
|
-
return model.status === 'unavailable' ? null : { types: model.types };
|
|
149
|
-
}
|
|
150
|
-
function checked(path, content, composition) {
|
|
151
|
-
return checkDocument(path, content, modelOf(composition, path) ?? NO_TYPES);
|
|
152
|
-
}
|
|
153
|
-
function targetsOf(check) {
|
|
154
|
-
if (!check.ok)
|
|
155
|
-
return [];
|
|
156
|
-
return [...new Set(check.references.flatMap(({ target }) => (target === null ? [] : [target])))];
|
|
157
|
-
}
|
|
158
|
-
function referencedBy(path, content, composition) {
|
|
159
|
-
const model = modelOf(composition, path);
|
|
160
|
-
if (model === null)
|
|
161
|
-
return [];
|
|
162
|
-
const read = parseFrontmatter(content, path);
|
|
163
|
-
const type = read.ok ? read.frontmatter.type : undefined;
|
|
164
|
-
if (!read.ok || type === undefined || !Object.hasOwn(model.types, type))
|
|
165
|
-
return [];
|
|
166
|
-
const definition = model.types[type];
|
|
167
|
-
return [
|
|
168
|
-
...new Set([
|
|
169
|
-
...references(read.frontmatter, definition).flatMap(({ value }) => {
|
|
170
|
-
const found = target(path, value);
|
|
171
|
-
return found === null ? [] : [found];
|
|
172
|
-
}),
|
|
173
|
-
...sectionReferences(path, content, definition).flatMap(({ target }) => target === null ? [] : [target]),
|
|
174
|
-
]),
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
function referrersOfTarget(index, target) {
|
|
178
|
-
return Object.hasOwn(index.referrers, target) ? index.referrers[target] : NO_REFERRERS;
|
|
179
|
-
}
|
|
180
|
-
function reindexed(index, changed) {
|
|
181
|
-
const referrers = new Map();
|
|
182
|
-
const held = (target) => referrers.get(target) ?? referrersOfTarget(index, target);
|
|
183
|
-
for (const [path, found] of changed) {
|
|
184
|
-
const before = Object.hasOwn(index.targets, path) ? index.targets[path] : [];
|
|
185
|
-
for (const target of before) {
|
|
186
|
-
if (!found.includes(target))
|
|
187
|
-
referrers.set(target, patched(held(target), [], [path]));
|
|
188
|
-
}
|
|
189
|
-
for (const target of found) {
|
|
190
|
-
if (!before.includes(target))
|
|
191
|
-
referrers.set(target, patched(held(target), [[path, true]]));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return {
|
|
195
|
-
composition: index.composition,
|
|
196
|
-
targets: patched(index.targets, [...changed].filter(([, found]) => found.length > 0), [...changed].filter(([, found]) => found.length === 0).map(([path]) => path)),
|
|
197
|
-
referrers: patched(index.referrers, [...referrers].filter(([, files]) => sizeOf(files) > 0), [...referrers].filter(([, files]) => sizeOf(files) === 0).map(([target]) => target)),
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function storedIn(entries) {
|
|
201
|
-
let stored = shared({});
|
|
202
|
-
let unit = [];
|
|
203
|
-
return after(inUnits(entries, (entry) => {
|
|
204
|
-
unit.push(entry);
|
|
205
|
-
return ROW_WEIGHT;
|
|
206
|
-
}, () => {
|
|
207
|
-
stored = patched(stored, unit);
|
|
208
|
-
unit = [];
|
|
209
|
-
}), () => stored);
|
|
210
|
-
}
|
|
211
|
-
function storedReferrers(referrers) {
|
|
212
|
-
const sets = new Map();
|
|
213
|
-
let unit = new Map();
|
|
214
|
-
const pairs = function* () {
|
|
215
|
-
for (const [target, files] of referrers)
|
|
216
|
-
for (const file of files)
|
|
217
|
-
yield [target, file];
|
|
218
|
-
};
|
|
219
|
-
return after(inUnits(pairs(), ([target, file]) => {
|
|
220
|
-
const files = unit.get(target);
|
|
221
|
-
if (files === undefined)
|
|
222
|
-
unit.set(target, [file]);
|
|
223
|
-
else
|
|
224
|
-
files.push(file);
|
|
225
|
-
return ROW_WEIGHT;
|
|
226
|
-
}, () => {
|
|
227
|
-
for (const [target, files] of unit) {
|
|
228
|
-
sets.set(target, patched(sets.get(target) ?? NO_REFERRERS, files.map((file) => [file, true])));
|
|
229
|
-
}
|
|
230
|
-
unit = new Map();
|
|
231
|
-
}), () => storedIn(sets));
|
|
232
|
-
}
|
|
233
|
-
function heldIndex(held, composition) {
|
|
234
|
-
const index = referrersOf.get(held.text);
|
|
235
|
-
return index !== undefined && typing(index.composition, composition) ? index : null;
|
|
236
|
-
}
|
|
237
|
-
const indexing = new WeakMap();
|
|
238
|
-
export function indexReferrers(held, composition) {
|
|
239
|
-
if (heldIndex(held, composition) !== null)
|
|
240
|
-
return;
|
|
241
|
-
const running = indexing.get(held.text);
|
|
242
|
-
if (running !== undefined)
|
|
243
|
-
return running;
|
|
244
|
-
const targets = new Map();
|
|
245
|
-
const referrers = new Map();
|
|
246
|
-
const filled = inUnits(Object.keys(held.text), (path) => {
|
|
247
|
-
const content = held.text[path];
|
|
248
|
-
const found = referencedBy(path, content, composition);
|
|
249
|
-
if (found.length > 0)
|
|
250
|
-
targets.set(path, found);
|
|
251
|
-
for (const target of found) {
|
|
252
|
-
const files = referrers.get(target);
|
|
253
|
-
if (files === undefined)
|
|
254
|
-
referrers.set(target, [path]);
|
|
255
|
-
else
|
|
256
|
-
files.push(path);
|
|
257
|
-
}
|
|
258
|
-
return ROW_WEIGHT + content.length;
|
|
259
|
-
});
|
|
260
|
-
const indexed = after(filled, () => after(storedIn(targets), (storedTargets) => after(storedReferrers(referrers), (stored) => {
|
|
261
|
-
referrersOf.set(held.text, { composition, targets: storedTargets, referrers: stored });
|
|
262
|
-
})));
|
|
263
|
-
if (!(indexed instanceof Promise))
|
|
264
|
-
return;
|
|
265
|
-
const building = indexed.finally(() => indexing.delete(held.text));
|
|
266
|
-
indexing.set(held.text, building);
|
|
267
|
-
return building;
|
|
268
|
-
}
|
|
269
|
-
export function referencesIndexed(held, composition) {
|
|
270
|
-
return heldIndex(held, composition) !== null;
|
|
271
|
-
}
|
|
272
|
-
export function referring(held, composition, targets) {
|
|
273
|
-
const index = heldIndex(held, composition);
|
|
274
|
-
if (index === null)
|
|
275
|
-
return null;
|
|
276
|
-
const found = new Set();
|
|
277
|
-
for (const target of targets) {
|
|
278
|
-
for (const file of Object.keys(referrersOfTarget(index, target)))
|
|
279
|
-
found.add(file);
|
|
280
|
-
}
|
|
281
|
-
return found;
|
|
282
|
-
}
|
|
283
60
|
export function available(composition) {
|
|
284
61
|
return (composition.model.status !== 'unavailable' &&
|
|
285
62
|
(composition.selection === null || composition.selection.model.status !== 'unavailable'));
|
|
286
63
|
}
|
|
287
|
-
export function changedCleanly(next, previous, composition) {
|
|
288
|
-
if (!typing(previous.composition, composition))
|
|
289
|
-
return false;
|
|
290
|
-
const paths = new Set([
|
|
291
|
-
...differing(previous.text, next.text),
|
|
292
|
-
...differing(previous.binaries, next.binaries, () => true),
|
|
293
|
-
]);
|
|
294
|
-
const binary = (path) => Object.hasOwn(next.binaries, path);
|
|
295
|
-
const within = (file) => (path) => selected(composition, path) === selected(composition, file);
|
|
296
|
-
const reaching = (file, check) => {
|
|
297
|
-
if (!check.ok)
|
|
298
|
-
return false;
|
|
299
|
-
const part = within(file);
|
|
300
|
-
return check.references.every((reference) => resolves(reference, (path) => (part(path) ? declared(next.text[path]) : undefined), (path) => part(path) && binary(path)));
|
|
301
|
-
};
|
|
302
|
-
const changedTargets = new Map();
|
|
303
|
-
const shifted = [];
|
|
304
|
-
for (const path of paths) {
|
|
305
|
-
const now = next.text[path];
|
|
306
|
-
const was = previous.text[path];
|
|
307
|
-
const modeled = modelOf(composition, path) !== null;
|
|
308
|
-
if ((now === undefined) !== (was === undefined) ||
|
|
309
|
-
declared(now) !== declared(was) ||
|
|
310
|
-
binary(path) !== Object.hasOwn(previous.binaries, path)) {
|
|
311
|
-
shifted.push(path);
|
|
312
|
-
}
|
|
313
|
-
if (!modeled && typedIn(was) && !typedIn(now))
|
|
314
|
-
return false;
|
|
315
|
-
if (now === undefined) {
|
|
316
|
-
if (modeled)
|
|
317
|
-
changedTargets.set(path, []);
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
if (binary(path))
|
|
321
|
-
return false;
|
|
322
|
-
if (!modeled) {
|
|
323
|
-
if (declared(now) === undefined)
|
|
324
|
-
return false;
|
|
325
|
-
if (!typedIn(now) && !checked(path, now, composition).ok)
|
|
326
|
-
return false;
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
-
const check = checked(path, now, composition);
|
|
330
|
-
if (!reaching(path, check))
|
|
331
|
-
return false;
|
|
332
|
-
changedTargets.set(path, targetsOf(check));
|
|
333
|
-
}
|
|
334
|
-
const index = heldIndex(previous, composition);
|
|
335
|
-
if (index === null && shifted.length > 0)
|
|
336
|
-
return false;
|
|
337
|
-
for (const target of shifted) {
|
|
338
|
-
const files = index === null ? [] : Object.keys(referrersOfTarget(index, target));
|
|
339
|
-
for (const file of files) {
|
|
340
|
-
if (paths.has(file))
|
|
341
|
-
continue;
|
|
342
|
-
if (!reaching(file, checked(file, next.text[file], composition)))
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
if (index !== null) {
|
|
347
|
-
referrersOf.set(next.text, changedTargets.size === 0 ? index : reindexed(index, changedTargets));
|
|
348
|
-
}
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Plan, QueryRows } from './query.js';
|
|
2
|
+
import type { Connection, Value } from './tables.js';
|
|
3
|
+
export type QueryRoom = {
|
|
4
|
+
readonly locator: string;
|
|
5
|
+
readonly key: number;
|
|
6
|
+
};
|
|
7
|
+
export type Fragment = {
|
|
8
|
+
readonly sql: string;
|
|
9
|
+
readonly bind: readonly Value[];
|
|
10
|
+
};
|
|
11
|
+
export type QueryAnswer = QueryRows & {
|
|
12
|
+
readonly more?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
|
|
15
|
+
export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
|
|
16
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,EAGJ,SAAS,EAIV,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,CAAC;AA4pBjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AA8SjE,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,QAAQ,CAEV;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}
|