@agentshouse/mdruntime 0.1.0-ca4dc698bd0c4 → 0.1.0-ca6edc1abd618
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 +18 -15
- package/dist/adapter.d.ts +77 -41
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -1
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +21 -4
- package/dist/binary.d.ts +0 -5
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -1
- package/dist/bootstrap.d.ts +26 -8
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +150 -81
- 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 -88
- package/dist/change.d.ts +31 -1
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js +10 -1
- package/dist/client.d.ts +15 -6
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +47 -8
- package/dist/collection.d.ts +6 -19
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +31 -289
- package/dist/compile.d.ts +16 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +721 -0
- package/dist/connection.d.ts +25 -12
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +2664 -1031
- package/dist/conversation.d.ts +18 -3
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +346 -109
- 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 +3 -5
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -0
- package/dist/entry.d.ts +3 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +18 -23
- package/dist/file.d.ts +2 -10
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +3 -120
- package/dist/fulltext.d.ts +27 -0
- package/dist/fulltext.d.ts.map +1 -0
- package/dist/fulltext.js +368 -0
- package/dist/host.d.ts +10 -8
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +95 -18
- 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 +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- 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 +9 -4
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +45 -31
- package/dist/messages.d.ts +28 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +90 -0
- package/dist/model.d.ts +3 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +2 -2
- package/dist/name.d.ts +4 -0
- package/dist/name.d.ts.map +1 -0
- package/dist/name.js +122 -0
- package/dist/observation.d.ts +14 -0
- package/dist/observation.d.ts.map +1 -1
- package/dist/observation.js +93 -3
- package/dist/opened.d.ts +22 -0
- package/dist/opened.d.ts.map +1 -0
- package/dist/opened.js +107 -0
- package/dist/outcome.d.ts +34 -4
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +25 -0
- package/dist/overlay.d.ts +3 -5
- package/dist/overlay.d.ts.map +1 -1
- package/dist/overlay.js +95 -156
- package/dist/query.d.ts +33 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +48 -7
- package/dist/reach.d.ts +6 -5
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +170 -62
- package/dist/react.d.ts +3 -3
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -17
- package/dist/readiness.d.ts +20 -9
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +6 -6
- package/dist/reads.d.ts +11 -0
- package/dist/reads.d.ts.map +1 -0
- package/dist/reads.js +100 -0
- package/dist/recovery.d.ts +2 -2
- package/dist/recovery.d.ts.map +1 -1
- package/dist/recovery.js +8 -7
- package/dist/refresh.d.ts +16 -15
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +113 -50
- package/dist/replica.d.ts +56 -33
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +297 -179
- package/dist/room-draft.d.ts +17 -2
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +65 -25
- package/dist/rows.d.ts +29 -29
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +113 -62
- package/dist/save.d.ts +51 -14
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +518 -180
- package/dist/search.d.ts +32 -43
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +37 -168
- package/dist/seed.d.ts +16 -0
- package/dist/seed.d.ts.map +1 -0
- package/dist/seed.js +75 -0
- package/dist/shared.d.ts +8 -3
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +129 -66
- package/dist/store.d.ts +98 -89
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +337 -655
- package/dist/stored.d.ts +145 -0
- package/dist/stored.d.ts.map +1 -0
- package/dist/stored.js +567 -0
- package/dist/tables.d.ts +354 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +624 -0
- package/dist/turn.d.ts +5 -3
- package/dist/turn.d.ts.map +1 -1
- package/dist/turn.js +51 -21
- package/dist/validation.d.ts +30 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +162 -0
- package/dist/windows.d.ts +22 -0
- package/dist/windows.d.ts.map +1 -0
- package/dist/windows.js +89 -0
- package/dist/wire.d.ts +163 -33
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +54 -32
- package/dist/words.d.ts +19 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +150 -0
- package/package.json +18 -19
- package/AGENTS.md +0 -300
- package/dist/acquisition.d.ts +0 -14
- package/dist/acquisition.d.ts.map +0 -1
- package/dist/acquisition.js +0 -24
- package/dist/chat/acts.d.ts +0 -33
- package/dist/chat/acts.d.ts.map +0 -1
- package/dist/chat/acts.js +0 -36
- package/dist/chat/context.d.ts +0 -3
- package/dist/chat/context.d.ts.map +0 -1
- package/dist/chat/context.js +0 -10
- package/dist/chat/input.d.ts +0 -9
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -99
- package/dist/chat/kit.d.ts +0 -60
- package/dist/chat/kit.d.ts.map +0 -1
- package/dist/chat/kit.js +0 -123
- package/dist/chat/lasting.d.ts +0 -6
- package/dist/chat/lasting.d.ts.map +0 -1
- package/dist/chat/lasting.js +0 -19
- package/dist/chat/list.d.ts +0 -26
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -62
- package/dist/chat/markdown.d.ts +0 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -188
- package/dist/chat/message.d.ts +0 -6
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -192
- package/dist/chat/messages.d.ts +0 -21
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -151
- package/dist/chat/name.d.ts +0 -6
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -11
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -17
- package/dist/chat/overlay.d.ts +0 -31
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -97
- package/dist/chat/parts.d.ts +0 -57
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -119
- package/dist/chat/process.d.ts +0 -20
- package/dist/chat/process.d.ts.map +0 -1
- package/dist/chat/process.js +0 -32
- package/dist/chat/provider.d.ts +0 -63
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -620
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -80
- package/dist/chat/questions.d.ts +0 -31
- package/dist/chat/questions.d.ts.map +0 -1
- package/dist/chat/questions.js +0 -111
- package/dist/chat/read.d.ts +0 -5
- package/dist/chat/read.d.ts.map +0 -1
- package/dist/chat/read.js +0 -13
- package/dist/chat/ready.d.ts +0 -33
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -91
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -302
- package/dist/chat.d.ts +0 -14
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- package/dist/read-side.d.ts +0 -25
- package/dist/read-side.d.ts.map +0 -1
- package/dist/read-side.js +0 -639
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedRoomDraft, SaveResult } from './connection.js';
|
|
1
|
+
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
2
|
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
|
-
import type {
|
|
6
|
-
import type { BinaryAnswer, CallResult, HistoryAnswer, Offline, QueueEntry } from './outcome.js';
|
|
5
|
+
import type { ChosenFile } from './file.js';
|
|
6
|
+
import type { BinaryAnswer, BinaryLinkAnswer, CallResult, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
7
7
|
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
8
8
|
import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
|
|
9
9
|
import type { SearchRequest, SearchResult } from './search.js';
|
|
@@ -21,19 +21,22 @@ export type MdRuntimeClient = {
|
|
|
21
21
|
roomDraft: {
|
|
22
22
|
list(): Promise<readonly RoomDraft[]>;
|
|
23
23
|
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
24
|
-
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
24
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
|
|
25
25
|
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
26
26
|
};
|
|
27
27
|
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
28
|
+
saveParts(room: string, parts: readonly SavedParts[]): Promise<SaveResult>;
|
|
28
29
|
presentation: {
|
|
29
30
|
read(): Promise<unknown>;
|
|
30
31
|
write(value: unknown): Promise<void>;
|
|
32
|
+
edit(members: Readonly<Record<string, unknown>>): Promise<void>;
|
|
31
33
|
};
|
|
32
34
|
conversation: {
|
|
33
35
|
list(): Promise<readonly ConversationEntry[]>;
|
|
34
36
|
read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
|
|
35
37
|
create(input: unknown): Promise<CallResult>;
|
|
36
38
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
39
|
+
attach(room: string, file: ChosenFile): Promise<CallResult | Offline>;
|
|
37
40
|
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
38
41
|
interrupt(conversation: string): Promise<CallResult>;
|
|
39
42
|
kill(conversation: string): Promise<CallResult>;
|
|
@@ -42,18 +45,21 @@ export type MdRuntimeClient = {
|
|
|
42
45
|
};
|
|
43
46
|
chatDraft: {
|
|
44
47
|
write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
|
|
48
|
+
prepend(conversation: string, draft: ChatDraft): Promise<void>;
|
|
45
49
|
discard(conversation: string): Promise<void>;
|
|
46
50
|
};
|
|
47
51
|
history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryAnswer>;
|
|
52
|
+
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
48
53
|
binaryFile: {
|
|
49
54
|
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
50
|
-
|
|
55
|
+
link(room: string, path: string, revision?: string): Promise<BinaryLinkAnswer>;
|
|
51
56
|
};
|
|
52
57
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
53
58
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
54
59
|
log(): Promise<string>;
|
|
55
60
|
persistence(): Promise<boolean>;
|
|
56
61
|
retry(): Promise<void>;
|
|
62
|
+
cleanUp(): Promise<number>;
|
|
57
63
|
observe: {
|
|
58
64
|
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
59
65
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
@@ -77,6 +83,9 @@ export type MdRuntimeClient = {
|
|
|
77
83
|
};
|
|
78
84
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
79
85
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
86
|
+
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
87
|
+
export { roomDraftRevision } from './identity.js';
|
|
80
88
|
export type { Observation } from './observation.js';
|
|
81
|
-
export type {
|
|
89
|
+
export type { Open } from './open.js';
|
|
90
|
+
export { unanswered, type RuntimePort, type WireMember } from './wire.js';
|
|
82
91
|
//# sourceMappingURL=client.d.ts.map
|
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,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB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OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC1C,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAAC,CAAC;KACvE,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAMF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAsQnE;AAID,wBAAgB,MAAM,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAUxF;AAED,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { observed } from './observation.js';
|
|
2
2
|
import { runtimeError } from './failure.js';
|
|
3
3
|
import { answer, AUTHORIZATION_ENDED, PORT_CLOSED, } from './wire.js';
|
|
4
|
+
// React renders an arrived value in a later task and opens what that render observes as it commits, so this many frames opening nothing mean the page drew what it observes.
|
|
5
|
+
const SETTLED_FRAMES = 2;
|
|
4
6
|
function refused(refusal) {
|
|
5
7
|
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
6
8
|
}
|
|
@@ -131,6 +133,29 @@ export function connectMdRuntime(port) {
|
|
|
131
133
|
drawing?.();
|
|
132
134
|
});
|
|
133
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
|
+
}
|
|
134
159
|
function settled() {
|
|
135
160
|
if (settling !== null)
|
|
136
161
|
return settling;
|
|
@@ -141,14 +166,19 @@ export function connectMdRuntime(port) {
|
|
|
141
166
|
if (opening.size > 0)
|
|
142
167
|
return;
|
|
143
168
|
const at = moved;
|
|
144
|
-
|
|
169
|
+
const waited = (frames) => {
|
|
145
170
|
requestAnimationFrame(() => {
|
|
171
|
+
if (frames < SETTLED_FRAMES) {
|
|
172
|
+
waited(frames + 1);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
146
175
|
if (moved !== at || opening.size > 0)
|
|
147
176
|
return;
|
|
148
177
|
drawing = null;
|
|
149
178
|
resolve();
|
|
150
179
|
});
|
|
151
|
-
}
|
|
180
|
+
};
|
|
181
|
+
waited(1);
|
|
152
182
|
};
|
|
153
183
|
drawing = check;
|
|
154
184
|
check();
|
|
@@ -163,19 +193,22 @@ export function connectMdRuntime(port) {
|
|
|
163
193
|
roomDraft: {
|
|
164
194
|
list: () => ask('roomDraft.list', []),
|
|
165
195
|
read: (room, path) => ask('roomDraft.read', [room, path]),
|
|
166
|
-
write: (room, path, revision, parts) => ask('roomDraft.write', [room, path, revision, parts]),
|
|
196
|
+
write: (room, path, revision, parts, next) => ask('roomDraft.write', next === undefined ? [room, path, revision, parts] : [room, path, revision, parts, next]),
|
|
167
197
|
discard: (room, path, revision) => ask('roomDraft.discard', [room, path, revision]),
|
|
168
198
|
},
|
|
169
199
|
save: (room, roomDrafts) => ask('save', [room, roomDrafts]),
|
|
200
|
+
saveParts: (room, parts) => ask('saveParts', [room, parts]),
|
|
170
201
|
presentation: {
|
|
171
202
|
read: () => ask('presentation.read', []),
|
|
172
203
|
write: (value) => ask('presentation.write', [value]),
|
|
204
|
+
edit: (members) => ask('presentation.edit', [members]),
|
|
173
205
|
},
|
|
174
206
|
conversation: {
|
|
175
207
|
list: () => ask('conversation.list', []),
|
|
176
208
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
177
209
|
create: (input) => ask('conversation.create', [input]),
|
|
178
210
|
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
211
|
+
attach: (room, file) => ask('conversation.attach', [room, file]),
|
|
179
212
|
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
180
213
|
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
181
214
|
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
@@ -184,18 +217,21 @@ export function connectMdRuntime(port) {
|
|
|
184
217
|
},
|
|
185
218
|
chatDraft: {
|
|
186
219
|
write: (conversation, draft, revision) => ask('chatDraft.write', [conversation, draft, revision]),
|
|
220
|
+
prepend: (conversation, draft) => ask('chatDraft.prepend', [conversation, draft]),
|
|
187
221
|
discard: (conversation) => ask('chatDraft.discard', [conversation]),
|
|
188
222
|
},
|
|
189
223
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
224
|
+
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
190
225
|
binaryFile: {
|
|
191
|
-
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]),
|
|
192
|
-
|
|
226
|
+
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then(streamed),
|
|
227
|
+
link: (room, path, revision) => ask('binaryFile.link', [room, path, revision]),
|
|
193
228
|
},
|
|
194
229
|
call: (name, input) => ask('call', [name, input]),
|
|
195
230
|
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
196
231
|
log: () => ask('log', []),
|
|
197
232
|
persistence: () => ask('persistence', []),
|
|
198
233
|
retry: () => ask('retry', []),
|
|
234
|
+
cleanUp: () => ask('cleanUp', []),
|
|
199
235
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
200
236
|
reauthorize: () => ask('reauthorize', []),
|
|
201
237
|
settled,
|
|
@@ -203,7 +239,10 @@ export function connectMdRuntime(port) {
|
|
|
203
239
|
}
|
|
204
240
|
const turns = new WeakMap();
|
|
205
241
|
export function inTurn(client, work) {
|
|
206
|
-
const
|
|
207
|
-
turns.set(client,
|
|
208
|
-
return
|
|
242
|
+
const turn = (turns.get(client) ?? Promise.resolve()).then(work);
|
|
243
|
+
turns.set(client, turn.then(() => undefined, () => undefined));
|
|
244
|
+
return turn;
|
|
209
245
|
}
|
|
246
|
+
export { chainedWindows } from './chain.js';
|
|
247
|
+
export { roomDraftRevision } from './identity.js';
|
|
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;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAsB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAEhG,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACvC,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE;QAAE,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,UAAU,CAAA;KAAE,GAAG,IAAI,CAAC;CACnE,CAAC;AAEF,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAKxE;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAI5E;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,UAAU,CAcZ;AAED,wBAAiB,WAAW,CAC1B,UAAU,EAAE,UAAU,GACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAQhE;AAED,wBAAiB,UAAU,CACzB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,KAAK,GAAE,QAAQ,CAAC,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,CAE3D"}
|
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 { 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,307 +12,51 @@ 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];
|
|
80
|
-
}
|
|
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 };
|
|
53
|
+
yield ROW_WEIGHT + content.length;
|
|
90
54
|
}
|
|
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 referrersOf = new WeakMap();
|
|
128
|
-
function typing(left, right) {
|
|
129
|
-
return (sameTyping(left.model, right.model) &&
|
|
130
|
-
(left.selection === null || right.selection === null
|
|
131
|
-
? left.selection === right.selection
|
|
132
|
-
: sameTyping(left.selection.model, right.selection.model)) &&
|
|
133
|
-
JSON.stringify(left.selection?.roots ?? null) === JSON.stringify(right.selection?.roots ?? null));
|
|
134
|
-
}
|
|
135
|
-
function declared(content) {
|
|
136
|
-
if (content === undefined)
|
|
137
|
-
return undefined;
|
|
138
|
-
const read = parseFrontmatter(content);
|
|
139
|
-
return read.ok ? (read.frontmatter.type ?? 'any') : undefined;
|
|
140
|
-
}
|
|
141
|
-
function typedIn(content) {
|
|
142
|
-
const type = declared(content);
|
|
143
|
-
return type !== undefined && type !== 'any';
|
|
144
|
-
}
|
|
145
|
-
function modelOf(composition, path) {
|
|
146
|
-
const model = governing(composition, path);
|
|
147
|
-
return model.status === 'unavailable' ? null : { types: model.types };
|
|
148
|
-
}
|
|
149
|
-
function checked(path, content, composition) {
|
|
150
|
-
return checkDocument(path, content, modelOf(composition, path) ?? NO_TYPES);
|
|
151
|
-
}
|
|
152
|
-
function targetsOf(check) {
|
|
153
|
-
if (!check.ok)
|
|
154
|
-
return [];
|
|
155
|
-
return [...new Set(check.references.flatMap(({ target }) => (target === null ? [] : [target])))];
|
|
156
|
-
}
|
|
157
|
-
function referencedBy(path, content, composition) {
|
|
158
|
-
const model = modelOf(composition, path);
|
|
159
|
-
if (model === null)
|
|
160
|
-
return [];
|
|
161
|
-
const read = parseFrontmatter(content, path);
|
|
162
|
-
const type = read.ok ? read.frontmatter.type : undefined;
|
|
163
|
-
if (!read.ok || type === undefined || !Object.hasOwn(model.types, type))
|
|
164
|
-
return [];
|
|
165
|
-
const definition = model.types[type];
|
|
166
|
-
return [
|
|
167
|
-
...new Set([
|
|
168
|
-
...references(read.frontmatter, definition).flatMap(({ value }) => {
|
|
169
|
-
const found = target(path, value);
|
|
170
|
-
return found === null ? [] : [found];
|
|
171
|
-
}),
|
|
172
|
-
...sectionReferences(path, content, definition).flatMap(({ target }) => target === null ? [] : [target]),
|
|
173
|
-
]),
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
function reindexed(index, changed) {
|
|
177
|
-
const referrers = new Map();
|
|
178
|
-
const touch = (target) => {
|
|
179
|
-
let held = referrers.get(target);
|
|
180
|
-
if (held === undefined) {
|
|
181
|
-
held = new Set(Object.hasOwn(index.referrers, target) ? index.referrers[target] : []);
|
|
182
|
-
referrers.set(target, held);
|
|
183
|
-
}
|
|
184
|
-
return held;
|
|
185
|
-
};
|
|
186
|
-
for (const [path, found] of changed) {
|
|
187
|
-
const before = Object.hasOwn(index.targets, path) ? index.targets[path] : [];
|
|
188
|
-
for (const target of before)
|
|
189
|
-
touch(target).delete(path);
|
|
190
|
-
for (const target of found)
|
|
191
|
-
touch(target).add(path);
|
|
192
|
-
}
|
|
193
|
-
const emptied = [...referrers].filter(([, held]) => held.size === 0).map(([target]) => target);
|
|
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]
|
|
198
|
-
.filter(([, held]) => held.size > 0)
|
|
199
|
-
.map(([target, held]) => [target, [...held]]), emptied),
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function heldIndex(held, composition) {
|
|
203
|
-
const index = referrersOf.get(held.text);
|
|
204
|
-
return index !== undefined && typing(index.composition, composition) ? index : null;
|
|
205
|
-
}
|
|
206
|
-
const indexing = new WeakMap();
|
|
207
|
-
export function indexReferrers(held, composition) {
|
|
208
|
-
if (heldIndex(held, composition) !== null)
|
|
209
|
-
return;
|
|
210
|
-
const running = indexing.get(held.text);
|
|
211
|
-
if (running !== undefined)
|
|
212
|
-
return running;
|
|
213
|
-
const targets = new Map();
|
|
214
|
-
const referrers = new Map();
|
|
215
|
-
const filled = inUnits(Object.keys(held.text), (path) => {
|
|
216
|
-
const content = held.text[path];
|
|
217
|
-
const found = referencedBy(path, content, composition);
|
|
218
|
-
if (found.length > 0)
|
|
219
|
-
targets.set(path, found);
|
|
220
|
-
for (const target of found)
|
|
221
|
-
referrers.set(target, [...(referrers.get(target) ?? []), path]);
|
|
222
|
-
return ROW_WEIGHT + content.length;
|
|
223
|
-
});
|
|
224
|
-
const indexed = () => {
|
|
225
|
-
referrersOf.set(held.text, {
|
|
226
|
-
composition,
|
|
227
|
-
targets: patched(shared({}), targets),
|
|
228
|
-
referrers: patched(shared({}), referrers),
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
if (!(filled instanceof Promise))
|
|
232
|
-
return indexed();
|
|
233
|
-
const building = filled.then(indexed).finally(() => indexing.delete(held.text));
|
|
234
|
-
indexing.set(held.text, building);
|
|
235
|
-
return building;
|
|
236
|
-
}
|
|
237
|
-
export function referencesIndexed(held, composition) {
|
|
238
|
-
return heldIndex(held, composition) !== null;
|
|
239
|
-
}
|
|
240
|
-
export function referring(held, composition, targets) {
|
|
241
|
-
const index = heldIndex(held, composition);
|
|
242
|
-
if (index === null)
|
|
243
|
-
return null;
|
|
244
|
-
const found = new Set();
|
|
245
|
-
for (const target of targets) {
|
|
246
|
-
if (!Object.hasOwn(index.referrers, target))
|
|
247
|
-
continue;
|
|
248
|
-
for (const file of index.referrers[target])
|
|
249
|
-
found.add(file);
|
|
250
|
-
}
|
|
251
|
-
return found;
|
|
252
|
-
}
|
|
253
60
|
export function available(composition) {
|
|
254
|
-
return
|
|
255
|
-
(composition.selection === null || composition.selection.model.status !== 'unavailable'));
|
|
256
|
-
}
|
|
257
|
-
export function changedCleanly(next, previous, composition) {
|
|
258
|
-
if (!typing(previous.composition, composition))
|
|
259
|
-
return false;
|
|
260
|
-
const paths = new Set([
|
|
261
|
-
...differing(previous.text, next.text),
|
|
262
|
-
...differing(previous.binaries, next.binaries, () => true),
|
|
263
|
-
]);
|
|
264
|
-
const binary = (path) => Object.hasOwn(next.binaries, path);
|
|
265
|
-
const within = (file) => (path) => selected(composition, path) === selected(composition, file);
|
|
266
|
-
const reaching = (file, check) => {
|
|
267
|
-
if (!check.ok)
|
|
268
|
-
return false;
|
|
269
|
-
const part = within(file);
|
|
270
|
-
return check.references.every((reference) => resolves(reference, (path) => (part(path) ? declared(next.text[path]) : undefined), (path) => part(path) && binary(path)));
|
|
271
|
-
};
|
|
272
|
-
const changedTargets = new Map();
|
|
273
|
-
const shifted = [];
|
|
274
|
-
for (const path of paths) {
|
|
275
|
-
const now = next.text[path];
|
|
276
|
-
const was = previous.text[path];
|
|
277
|
-
const modeled = modelOf(composition, path) !== null;
|
|
278
|
-
if ((now === undefined) !== (was === undefined) ||
|
|
279
|
-
declared(now) !== declared(was) ||
|
|
280
|
-
binary(path) !== Object.hasOwn(previous.binaries, path)) {
|
|
281
|
-
shifted.push(path);
|
|
282
|
-
}
|
|
283
|
-
if (!modeled && typedIn(was) && !typedIn(now))
|
|
284
|
-
return false;
|
|
285
|
-
if (now === undefined) {
|
|
286
|
-
if (modeled)
|
|
287
|
-
changedTargets.set(path, []);
|
|
288
|
-
continue;
|
|
289
|
-
}
|
|
290
|
-
if (binary(path))
|
|
291
|
-
return false;
|
|
292
|
-
if (!modeled) {
|
|
293
|
-
if (declared(now) === undefined)
|
|
294
|
-
return false;
|
|
295
|
-
if (!typedIn(now) && !checked(path, now, composition).ok)
|
|
296
|
-
return false;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
const check = checked(path, now, composition);
|
|
300
|
-
if (!reaching(path, check))
|
|
301
|
-
return false;
|
|
302
|
-
changedTargets.set(path, targetsOf(check));
|
|
303
|
-
}
|
|
304
|
-
const index = heldIndex(previous, composition);
|
|
305
|
-
if (index === null && shifted.length > 0)
|
|
306
|
-
return false;
|
|
307
|
-
for (const target of shifted) {
|
|
308
|
-
const files = index !== null && Object.hasOwn(index.referrers, target) ? index.referrers[target] : [];
|
|
309
|
-
for (const file of files) {
|
|
310
|
-
if (paths.has(file))
|
|
311
|
-
continue;
|
|
312
|
-
if (!reaching(file, checked(file, next.text[file], composition)))
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
if (index !== null) {
|
|
317
|
-
referrersOf.set(next.text, changedTargets.size === 0 ? index : reindexed(index, changedTargets));
|
|
318
|
-
}
|
|
319
|
-
return true;
|
|
61
|
+
return composition.model.status !== 'unavailable';
|
|
320
62
|
}
|
|
@@ -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;AA+pBjF,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"}
|