@agentshouse/mdruntime 0.1.0-ccbe92df1c4f6 → 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 +11 -9
- package/dist/adapter.d.ts +91 -58
- package/dist/adapter.d.ts.map +1 -1
- package/dist/attached-model.d.ts +5 -11
- package/dist/attached-model.d.ts.map +1 -1
- package/dist/attached-model.js +36 -47
- package/dist/bootstrap.d.ts +11 -14
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +101 -89
- package/dist/chain.d.ts +2 -1
- package/dist/chain.d.ts.map +1 -1
- package/dist/client.d.ts +15 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +56 -7
- package/dist/collection.d.ts +7 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +24 -19
- package/dist/compile.d.ts +1 -6
- package/dist/compile.d.ts.map +1 -1
- package/dist/compile.js +108 -243
- package/dist/connection.d.ts +14 -11
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +1256 -1225
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/{chat/context.js → context.js} +1 -4
- package/dist/conversation.d.ts +16 -15
- package/dist/conversation.d.ts.map +1 -1
- package/dist/conversation.js +234 -167
- 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/file.d.ts +2 -11
- package/dist/file.d.ts.map +1 -1
- package/dist/file.js +6 -4
- package/dist/host.d.ts +3 -7
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +53 -36
- 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 +12 -9
- 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 +9 -5
- package/dist/media.d.ts +8 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +218 -0
- package/dist/memory.d.ts +12 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +210 -91
- 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 +7 -13
- 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 +13 -5
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +16 -2
- 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 +8 -207
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -505
- package/dist/reach.d.ts +14 -7
- package/dist/reach.d.ts.map +1 -1
- package/dist/reach.js +83 -53
- package/dist/react.d.ts +3 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/readiness.d.ts +3 -16
- package/dist/readiness.d.ts.map +1 -1
- package/dist/readiness.js +2 -8
- 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 +30 -10
- package/dist/replica.d.ts +10 -9
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +30 -15
- package/dist/room-draft.d.ts +22 -5
- package/dist/room-draft.d.ts.map +1 -1
- package/dist/room-draft.js +131 -51
- package/dist/rows.d.ts +18 -16
- package/dist/rows.d.ts.map +1 -1
- package/dist/rows.js +45 -153
- 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 -39
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +33 -73
- package/dist/stored.d.ts +11 -27
- package/dist/stored.d.ts.map +1 -1
- package/dist/stored.js +187 -230
- package/dist/tables.d.ts +34 -51
- package/dist/tables.d.ts.map +1 -1
- package/dist/tables.js +75 -68
- 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 +17 -8
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +5 -2
- package/package.json +10 -17
- package/AGENTS.md +0 -317
- 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/earlier.d.ts +0 -10
- package/dist/chat/earlier.d.ts.map +0 -1
- package/dist/chat/earlier.js +0 -54
- package/dist/chat/house.d.ts +0 -25
- package/dist/chat/house.d.ts.map +0 -1
- package/dist/chat/house.js +0 -38
- package/dist/chat/input.d.ts +0 -11
- package/dist/chat/input.d.ts.map +0 -1
- package/dist/chat/input.js +0 -92
- package/dist/chat/kit.d.ts +0 -61
- 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 -28
- package/dist/chat/list.d.ts.map +0 -1
- package/dist/chat/list.js +0 -103
- package/dist/chat/markdown.d.ts +0 -20
- package/dist/chat/markdown.d.ts.map +0 -1
- package/dist/chat/markdown.js +0 -229
- package/dist/chat/message.d.ts +0 -7
- package/dist/chat/message.d.ts.map +0 -1
- package/dist/chat/message.js +0 -254
- package/dist/chat/messages.d.ts +0 -35
- package/dist/chat/messages.d.ts.map +0 -1
- package/dist/chat/messages.js +0 -210
- package/dist/chat/name.d.ts +0 -7
- package/dist/chat/name.d.ts.map +0 -1
- package/dist/chat/name.js +0 -37
- package/dist/chat/opened.d.ts +0 -12
- package/dist/chat/opened.d.ts.map +0 -1
- package/dist/chat/opened.js +0 -19
- package/dist/chat/overlay.d.ts +0 -32
- package/dist/chat/overlay.d.ts.map +0 -1
- package/dist/chat/overlay.js +0 -103
- package/dist/chat/parts.d.ts +0 -58
- package/dist/chat/parts.d.ts.map +0 -1
- package/dist/chat/parts.js +0 -120
- package/dist/chat/pieces.d.ts +0 -62
- package/dist/chat/pieces.d.ts.map +0 -1
- package/dist/chat/pieces.js +0 -1110
- 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 -70
- package/dist/chat/provider.d.ts.map +0 -1
- package/dist/chat/provider.js +0 -635
- package/dist/chat/question.d.ts +0 -9
- package/dist/chat/question.d.ts.map +0 -1
- package/dist/chat/question.js +0 -69
- 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 -37
- package/dist/chat/ready.d.ts.map +0 -1
- package/dist/chat/ready.js +0 -93
- package/dist/chat/room-file.d.ts +0 -8
- package/dist/chat/room-file.d.ts.map +0 -1
- package/dist/chat/room-file.js +0 -72
- package/dist/chat/steady.d.ts +0 -3
- package/dist/chat/steady.d.ts.map +0 -1
- package/dist/chat/steady.js +0 -26
- package/dist/chat/style.d.ts +0 -4
- package/dist/chat/style.d.ts.map +0 -1
- package/dist/chat/style.js +0 -307
- package/dist/chat.d.ts +0 -15
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js +0 -8
- 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/bootstrap.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { transferIdentity } from './identity.js';
|
|
2
2
|
import { advancement, pageEntries } from './refresh.js';
|
|
3
|
+
import { entriesIn } from './shared.js';
|
|
3
4
|
import { unconfirmed } from './transfer.js';
|
|
4
|
-
const NOTHING_DONE = { parts: 0, bytes: 0 };
|
|
5
|
-
const RESUMABLE = new Set([
|
|
6
|
-
'transport-uncertainty',
|
|
7
|
-
'retryable-refusal',
|
|
8
|
-
'unconfirmed',
|
|
9
|
-
]);
|
|
10
5
|
const NOTHING_PRIOR = () => Promise.resolve(new Map());
|
|
6
|
+
function textOf(page) {
|
|
7
|
+
let text = 0;
|
|
8
|
+
for (const [, content] of entriesIn(page.documents))
|
|
9
|
+
text += content.length;
|
|
10
|
+
return text;
|
|
11
|
+
}
|
|
11
12
|
async function pageOf(page) {
|
|
12
13
|
return {
|
|
13
14
|
entries: await pageEntries(page, [], page.roomVersion, NOTHING_PRIOR),
|
|
@@ -38,17 +39,16 @@ const NO_CONTENT = {
|
|
|
38
39
|
files: () => Promise.resolve([]),
|
|
39
40
|
contents: () => Promise.resolve(new Map()),
|
|
40
41
|
};
|
|
41
|
-
export async function bootstrapRoom(adapter, authorization, room, held, remodel, continuing, staging, reuse) {
|
|
42
|
-
|
|
43
|
-
const resumed = kept !== null && kept.selection === room.replica.selection ? kept : null;
|
|
44
|
-
if (kept !== null && resumed === null)
|
|
42
|
+
export async function bootstrapRoom(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, reuse) {
|
|
43
|
+
if (staging.held(room.locator) !== null)
|
|
45
44
|
await staging.abandon(room.locator);
|
|
46
|
-
const
|
|
45
|
+
const begun = (pool) => started(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, pool);
|
|
46
|
+
const first = await begun(reuse);
|
|
47
47
|
if (first.kind !== 'expired')
|
|
48
48
|
return first;
|
|
49
49
|
await staging.setAside(room.locator);
|
|
50
50
|
try {
|
|
51
|
-
const replacement = await
|
|
51
|
+
const replacement = await begun(heldTogether(reuse, first.held));
|
|
52
52
|
if (replacement.kind !== 'expired')
|
|
53
53
|
return replacement;
|
|
54
54
|
await staging.abandon(room.locator);
|
|
@@ -59,74 +59,87 @@ export async function bootstrapRoom(adapter, authorization, room, held, remodel,
|
|
|
59
59
|
await staging.release(first.key);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
function dropped(ahead) {
|
|
63
|
+
void ahead?.fetched.then(({ next, written }) => {
|
|
64
|
+
written();
|
|
65
|
+
dropped(next);
|
|
66
|
+
}, () => { });
|
|
67
|
+
}
|
|
68
|
+
function compositionFor(room, models, builtIn, typedPaths) {
|
|
64
69
|
return {
|
|
65
70
|
model: models.collection,
|
|
66
71
|
selection: room.typedSelection === undefined
|
|
67
72
|
? null
|
|
68
|
-
: { roots: room.typedSelection.roots, model:
|
|
73
|
+
: { roots: room.typedSelection.roots, model: builtIn },
|
|
74
|
+
typedPaths,
|
|
69
75
|
};
|
|
70
76
|
}
|
|
71
|
-
async function
|
|
77
|
+
async function started(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, pool) {
|
|
78
|
+
let outcome;
|
|
79
|
+
try {
|
|
80
|
+
outcome = await bundle(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, pool);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
await staging.abandon(room.locator).catch(() => { });
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
if (outcome.kind !== 'staged' && outcome.kind !== 'expired') {
|
|
87
|
+
await staging.abandon(room.locator);
|
|
88
|
+
}
|
|
89
|
+
return outcome;
|
|
90
|
+
}
|
|
91
|
+
async function bundle(adapter, authorization, room, held, builtIn, typedPaths, remodel, continuing, staging, pool) {
|
|
72
92
|
const locator = room.locator;
|
|
73
93
|
const selection = room.replica.selection;
|
|
74
|
-
|
|
75
|
-
let lookups = kept === null ? 0 : RESUMED_LOOKUPS;
|
|
76
|
-
let ahead = null;
|
|
94
|
+
const ending = new AbortController();
|
|
77
95
|
const arriving = staging.arriving(locator);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
const downloaded = await staging.turn(locator, 'downloading');
|
|
97
|
+
const asking = (token) => adapter.bootstrap(authorization, {
|
|
98
|
+
locator,
|
|
99
|
+
selection,
|
|
100
|
+
signal: ending.signal,
|
|
101
|
+
...(token === null
|
|
102
|
+
? { arriving: (bytes) => arriving.at(bytes) }
|
|
103
|
+
: { pageToken: token }),
|
|
104
|
+
...(pool === null ? {} : { held: pool }),
|
|
105
|
+
});
|
|
106
|
+
const fetching = (token) => {
|
|
107
|
+
const fetched = (async () => {
|
|
108
|
+
await staging.unqueued();
|
|
109
|
+
const page = continuing() ? await asking(token) : unconfirmed;
|
|
110
|
+
if (page.kind !== 'bootstrap')
|
|
111
|
+
return { page, next: null, written: () => { } };
|
|
112
|
+
const written = staging.queued(textOf(page));
|
|
113
|
+
const later = page.pageToken;
|
|
114
|
+
if (later === undefined) {
|
|
115
|
+
downloaded();
|
|
116
|
+
arriving.end();
|
|
117
|
+
}
|
|
118
|
+
return { page, written, next: later === undefined || !continuing() ? null : fetching(later) };
|
|
119
|
+
})();
|
|
120
|
+
fetched.catch(() => { });
|
|
121
|
+
return { fetched };
|
|
96
122
|
};
|
|
123
|
+
let transfer = null;
|
|
124
|
+
let ahead = fetching(null);
|
|
97
125
|
try {
|
|
98
|
-
while (
|
|
126
|
+
while (ahead !== null) {
|
|
99
127
|
if (!continuing())
|
|
100
128
|
return unconfirmed;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
const fetched = ahead !== null && ahead.token === asked ? ahead : null;
|
|
104
|
-
if (ahead !== fetched)
|
|
105
|
-
ahead?.release();
|
|
106
|
-
ahead = null;
|
|
107
|
-
const turned = fetched?.release ??
|
|
108
|
-
(await staging.turn(locator, transfer === null ? 'listing' : 'downloading'));
|
|
129
|
+
const fetched = await ahead.fetched;
|
|
130
|
+
ahead = fetched.next;
|
|
109
131
|
try {
|
|
110
132
|
if (!continuing())
|
|
111
133
|
return unconfirmed;
|
|
112
|
-
const page =
|
|
134
|
+
const page = fetched.page;
|
|
113
135
|
if (page.kind === 'beyond-horizon') {
|
|
114
136
|
const key = transfer?.key ?? null;
|
|
115
137
|
return { kind: 'expired', held: key === null ? NO_CONTENT : staging.content(key), key };
|
|
116
138
|
}
|
|
117
|
-
if (page.kind !== 'bootstrap')
|
|
118
|
-
if (!RESUMABLE.has(page.kind))
|
|
119
|
-
await staging.abandon(locator);
|
|
139
|
+
if (page.kind !== 'bootstrap')
|
|
120
140
|
return page;
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
const spare = later === undefined || !continuing() ? null : staging.spare();
|
|
124
|
-
if (later !== undefined && spare !== null) {
|
|
125
|
-
const answer = asking(later);
|
|
126
|
-
answer.catch(() => { });
|
|
127
|
-
ahead = { token: later, page: answer, release: spare };
|
|
128
|
-
}
|
|
129
|
-
const next = {
|
|
141
|
+
const models = remodel(page.models, transfer?.models ?? held);
|
|
142
|
+
const staged = await staging.stage({
|
|
130
143
|
locator,
|
|
131
144
|
transfer: transfer?.transfer ?? transferIdentity(),
|
|
132
145
|
selection,
|
|
@@ -136,27 +149,31 @@ async function bundle(adapter, authorization, room, held, remodel, continuing, s
|
|
|
136
149
|
last: transfer !== null && !adapter.reached(locator, page.roomVersion, transfer.last)
|
|
137
150
|
? transfer.last
|
|
138
151
|
: page.roomVersion,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
inventory: page.inventory ?? transfer?.inventory ?? null,
|
|
142
|
-
done: transfer?.done ?? NOTHING_DONE,
|
|
143
|
-
models: remodel(page.models, transfer?.models ?? held),
|
|
152
|
+
done: { bytes: (transfer?.done.bytes ?? 0) + (page.bytes ?? 0) },
|
|
153
|
+
models,
|
|
144
154
|
key: transfer?.key ?? null,
|
|
145
|
-
};
|
|
146
|
-
const staged = await staging.stage(next, await pageOf(page), compositionFor(room, next.models), page.received ?? null);
|
|
155
|
+
}, await pageOf(page), compositionFor(room, models, builtIn, typedPaths));
|
|
147
156
|
if (staged === null)
|
|
148
157
|
return unconfirmed;
|
|
149
158
|
transfer = staged;
|
|
150
159
|
}
|
|
151
160
|
finally {
|
|
152
|
-
|
|
161
|
+
fetched.written();
|
|
153
162
|
}
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
165
|
finally {
|
|
157
|
-
|
|
166
|
+
ending.abort();
|
|
167
|
+
downloaded();
|
|
158
168
|
arriving.end();
|
|
169
|
+
dropped(ahead);
|
|
159
170
|
}
|
|
171
|
+
if (transfer === null)
|
|
172
|
+
return unconfirmed;
|
|
173
|
+
const installed = transfer;
|
|
174
|
+
const composition = compositionFor(room, installed.models, builtIn, typedPaths);
|
|
175
|
+
if (!(await staging.derive(locator, installed.key, composition)))
|
|
176
|
+
return unconfirmed;
|
|
160
177
|
await staging.turn(locator, 'replaying');
|
|
161
178
|
if (!continuing())
|
|
162
179
|
return unconfirmed;
|
|
@@ -166,34 +183,29 @@ async function bundle(adapter, authorization, room, held, remodel, continuing, s
|
|
|
166
183
|
handle: room.handle,
|
|
167
184
|
operations: room.operations,
|
|
168
185
|
replica: room.replica,
|
|
169
|
-
model:
|
|
186
|
+
model: installed.models.collection,
|
|
170
187
|
typedSelection: room.typedSelection ?? null,
|
|
171
|
-
selectionModel: transfer.models.selection,
|
|
172
188
|
providerOwnedPaths: room.providerOwnedPaths,
|
|
173
|
-
roomVersion:
|
|
174
|
-
transfer:
|
|
175
|
-
inventory:
|
|
176
|
-
key:
|
|
189
|
+
roomVersion: installed.from,
|
|
190
|
+
transfer: installed.transfer,
|
|
191
|
+
inventory: installed.done,
|
|
192
|
+
key: installed.key,
|
|
177
193
|
};
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const reconciled = last ===
|
|
194
|
+
const last = installed.last;
|
|
195
|
+
const refresh = adapter.refresh;
|
|
196
|
+
const reconciled = last === installed.from &&
|
|
197
|
+
(staging.streamed || adapter.reached(locator, last, room.roomVersion))
|
|
181
198
|
? { kind: 'still-current' }
|
|
182
|
-
:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (refused !== null) {
|
|
188
|
-
await staging.abandon(locator);
|
|
189
|
-
return refused;
|
|
190
|
-
}
|
|
191
|
-
return { kind: 'staged', record: result, refreshed };
|
|
199
|
+
: refresh === undefined
|
|
200
|
+
? unconfirmed
|
|
201
|
+
: await advancement(refresh, authorization, record, remodel, continuing, await staging.refreshing(locator, record.key, composition));
|
|
202
|
+
if (reconciled.kind === 'advanced') {
|
|
203
|
+
return { kind: 'staged', record: reconciled.record, refreshed: true };
|
|
192
204
|
}
|
|
205
|
+
if (reconciled.kind === 'still-current')
|
|
206
|
+
return { kind: 'staged', record, refreshed: false };
|
|
193
207
|
if (reconciled.kind === 'beyond-horizon') {
|
|
194
208
|
return { kind: 'expired', held: staging.content(record.key), key: record.key };
|
|
195
209
|
}
|
|
196
|
-
if (!RESUMABLE.has(reconciled.kind))
|
|
197
|
-
await staging.abandon(locator);
|
|
198
210
|
return reconciled;
|
|
199
211
|
}
|
package/dist/chain.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { MdRuntimeClient } from './client.js';
|
|
2
|
-
import type {
|
|
3
|
+
import type { DocumentResult, GroupResult, PendingResult } from './query.js';
|
|
3
4
|
type Rows = DocumentResult | GroupResult;
|
|
4
5
|
export type WindowAnswer = Rows | PendingResult;
|
|
5
6
|
export type WindowChain = {
|
package/dist/chain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,IAAI,GAAG,cAAc,GAAG,WAAW,CAAC;AAEzC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAaF,wBAAgB,cAAc,CAC5B,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE,aAAa,GAAG,UAAU,EACjC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAC7E,WAAW,CAkEb"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { DocumentQuery, GroupQuery } from '@agentshouse/mdmodel';
|
|
1
2
|
import type { AppRoom, ConnectionRefusal, HistoryQuery, RoomSchemas, SavedParts, SavedRoomDraft, SaveResult } from './connection.js';
|
|
2
3
|
import type { Member, ServiceMode } from './adapter.js';
|
|
3
|
-
import type {
|
|
4
|
+
import type { UnsentWork } from './durability.js';
|
|
5
|
+
import type { ChatDraft, ConversationAgent, ConversationAnswer, ConversationEntry, ConversationOptions, ConversationRead, ConversationView } from './conversation.js';
|
|
4
6
|
import { type Observation } from './observation.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult, PendingResult } from './query.js';
|
|
7
|
+
import type { AttachAnswer, BinaryAnswer, CallResult, DownloadAnswer, HistoryAnswer, Offline, QueueEntry, Resolution } from './outcome.js';
|
|
8
|
+
import type { DocumentResult, 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';
|
|
10
11
|
import type { Readiness } from './readiness.js';
|
|
@@ -21,7 +22,7 @@ export type MdRuntimeClient = {
|
|
|
21
22
|
roomDraft: {
|
|
22
23
|
list(): Promise<readonly RoomDraft[]>;
|
|
23
24
|
read(room: string, path: string): Promise<RoomDraft | null>;
|
|
24
|
-
write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
|
|
25
|
+
write(room: string, path: string, revision: string | null, parts: RoomDraftParts, next?: string): Promise<RoomDraftWrite>;
|
|
25
26
|
discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
|
|
26
27
|
};
|
|
27
28
|
save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
|
|
@@ -33,14 +34,12 @@ export type MdRuntimeClient = {
|
|
|
33
34
|
};
|
|
34
35
|
conversation: {
|
|
35
36
|
list(): Promise<readonly ConversationEntry[]>;
|
|
36
|
-
read(conversation: string, options?:
|
|
37
|
+
read(conversation: string, options?: ConversationRead): Promise<ConversationView>;
|
|
37
38
|
create(input: unknown): Promise<CallResult>;
|
|
38
39
|
send(conversation: string, operation?: string, draft?: ChatDraft): Promise<CallResult | Offline>;
|
|
39
|
-
|
|
40
|
-
answer(conversation: string, answer: unknown): Promise<CallResult>;
|
|
40
|
+
answer(conversation: string, answer: ConversationAnswer): Promise<CallResult>;
|
|
41
41
|
interrupt(conversation: string): Promise<CallResult>;
|
|
42
42
|
kill(conversation: string): Promise<CallResult>;
|
|
43
|
-
cancel(conversation: string, turn: string): Promise<CallResult>;
|
|
44
43
|
delete(conversation: string): Promise<CallResult>;
|
|
45
44
|
};
|
|
46
45
|
chatDraft: {
|
|
@@ -52,7 +51,8 @@ export type MdRuntimeClient = {
|
|
|
52
51
|
resolve(room: string, path: string, destination: string): Promise<Resolution>;
|
|
53
52
|
binaryFile: {
|
|
54
53
|
read(room: string, path: string, revision?: string): Promise<BinaryAnswer>;
|
|
55
|
-
|
|
54
|
+
attach(room: string, file: File): Promise<AttachAnswer>;
|
|
55
|
+
download(room: string, path: string, revision?: string): Promise<DownloadAnswer>;
|
|
56
56
|
};
|
|
57
57
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
58
58
|
reached(locator: string, roomVersion: string, path?: string): Promise<boolean>;
|
|
@@ -60,6 +60,8 @@ export type MdRuntimeClient = {
|
|
|
60
60
|
persistence(): Promise<boolean>;
|
|
61
61
|
retry(): Promise<void>;
|
|
62
62
|
cleanUp(): Promise<number>;
|
|
63
|
+
unsent(): Promise<readonly UnsentWork[]>;
|
|
64
|
+
reset(): Promise<void>;
|
|
63
65
|
observe: {
|
|
64
66
|
(topic: 'deployment-facts'): Promise<Observation<unknown>>;
|
|
65
67
|
(topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
|
|
@@ -69,6 +71,7 @@ export type MdRuntimeClient = {
|
|
|
69
71
|
(topic: 'sync-status'): Promise<Observation<SyncStatus>>;
|
|
70
72
|
(topic: 'service-mode'): Promise<Observation<ServiceMode>>;
|
|
71
73
|
(topic: 'member'): Promise<Observation<Member | null>>;
|
|
74
|
+
(topic: 'authority-changes'): Promise<Observation<number>>;
|
|
72
75
|
(topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult | PendingResult>>;
|
|
73
76
|
(topic: 'query', query: GroupQuery): Promise<Observation<GroupResult | PendingResult>>;
|
|
74
77
|
(topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
|
|
@@ -84,6 +87,8 @@ export type MdRuntimeClient = {
|
|
|
84
87
|
export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
|
|
85
88
|
export declare function inTurn(client: MdRuntimeClient, work: () => Promise<void>): Promise<void>;
|
|
86
89
|
export { chainedWindows, type WindowAnswer, type WindowChain } from './chain.js';
|
|
90
|
+
export { roomDraftRevision } from './identity.js';
|
|
91
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
87
92
|
export type { Observation } from './observation.js';
|
|
88
93
|
export type { Open } from './open.js';
|
|
89
94
|
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,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,mBAAmB,CA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AE,cAAc,EACrB,YAAY,EAAE,MAAM,EACpB,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,CAuSnE;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,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACzD,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,8 +1,25 @@
|
|
|
1
|
+
import { shownBy } from './media.js';
|
|
1
2
|
import { observed } from './observation.js';
|
|
2
3
|
import { runtimeError } from './failure.js';
|
|
3
4
|
import { answer, AUTHORIZATION_ENDED, PORT_CLOSED, } from './wire.js';
|
|
4
5
|
// 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
6
|
const SETTLED_FRAMES = 2;
|
|
7
|
+
// A browser reads a download's address only after the click that hands it returns, so a copy's address is released a minute later.
|
|
8
|
+
const HANDED_COPY_MS = 60_000;
|
|
9
|
+
const PAGE = /\.html?$/iu;
|
|
10
|
+
const STARTED = { kind: 'started' };
|
|
11
|
+
const BLOCKED = {
|
|
12
|
+
kind: 'blocked',
|
|
13
|
+
code: 'popup-blocked',
|
|
14
|
+
fields: {},
|
|
15
|
+
retryable: true,
|
|
16
|
+
};
|
|
17
|
+
function handed(url, name) {
|
|
18
|
+
const anchor = document.createElement('a');
|
|
19
|
+
anchor.href = url;
|
|
20
|
+
anchor.download = name;
|
|
21
|
+
anchor.click();
|
|
22
|
+
}
|
|
6
23
|
function refused(refusal) {
|
|
7
24
|
return runtimeError(refusal.code, refusal.code, refusal.retryable);
|
|
8
25
|
}
|
|
@@ -156,6 +173,34 @@ export function connectMdRuntime(port) {
|
|
|
156
173
|
}, { highWaterMark: 0 });
|
|
157
174
|
return { kind: 'binary', stream, byteLength, mediaType };
|
|
158
175
|
}
|
|
176
|
+
async function download(room, path, revision) {
|
|
177
|
+
const tab = PAGE.test(path) ? globalThis.open('', '_blank') : null;
|
|
178
|
+
const linked = await ask('binaryFile.link', [room, path, revision]);
|
|
179
|
+
if (linked.kind === 'link' && PAGE.test(linked.name)) {
|
|
180
|
+
const away = tab ?? globalThis.open('', '_blank');
|
|
181
|
+
if (away === null)
|
|
182
|
+
return BLOCKED;
|
|
183
|
+
away.location.replace(linked.url);
|
|
184
|
+
return STARTED;
|
|
185
|
+
}
|
|
186
|
+
tab?.close();
|
|
187
|
+
if (linked.kind === 'link') {
|
|
188
|
+
handed(linked.url, linked.name);
|
|
189
|
+
return STARTED;
|
|
190
|
+
}
|
|
191
|
+
if (linked.kind !== 'absent')
|
|
192
|
+
return linked;
|
|
193
|
+
const read = streamed(await ask('binaryFile.read', [room, path, revision]));
|
|
194
|
+
if (read.kind !== 'binary')
|
|
195
|
+
return read;
|
|
196
|
+
const copy = await new Response(read.stream, {
|
|
197
|
+
headers: { 'content-type': read.mediaType },
|
|
198
|
+
}).blob();
|
|
199
|
+
const url = URL.createObjectURL(copy);
|
|
200
|
+
handed(url, path.slice(path.lastIndexOf('/') + 1));
|
|
201
|
+
setTimeout(() => URL.revokeObjectURL(url), HANDED_COPY_MS);
|
|
202
|
+
return STARTED;
|
|
203
|
+
}
|
|
159
204
|
function settled() {
|
|
160
205
|
if (settling !== null)
|
|
161
206
|
return settling;
|
|
@@ -185,7 +230,8 @@ export function connectMdRuntime(port) {
|
|
|
185
230
|
});
|
|
186
231
|
return settling;
|
|
187
232
|
}
|
|
188
|
-
|
|
233
|
+
const show = (room, path, revision) => ask('binaryFile.show', [room, path, revision]).then((shown) => streamed(shown));
|
|
234
|
+
return shownBy(show, {
|
|
189
235
|
rooms: () => ask('rooms', []),
|
|
190
236
|
query: ((query) => ask('query', [query])),
|
|
191
237
|
search: (request) => ask('search', [request]),
|
|
@@ -193,7 +239,7 @@ export function connectMdRuntime(port) {
|
|
|
193
239
|
roomDraft: {
|
|
194
240
|
list: () => ask('roomDraft.list', []),
|
|
195
241
|
read: (room, path) => ask('roomDraft.read', [room, path]),
|
|
196
|
-
write: (room, path, revision, parts) => ask('roomDraft.write', [room, path, revision, parts]),
|
|
242
|
+
write: (room, path, revision, parts, next) => ask('roomDraft.write', next === undefined ? [room, path, revision, parts] : [room, path, revision, parts, next]),
|
|
197
243
|
discard: (room, path, revision) => ask('roomDraft.discard', [room, path, revision]),
|
|
198
244
|
},
|
|
199
245
|
save: (room, roomDrafts) => ask('save', [room, roomDrafts]),
|
|
@@ -208,11 +254,9 @@ export function connectMdRuntime(port) {
|
|
|
208
254
|
read: (conversation, options) => ask('conversation.read', [conversation, options]),
|
|
209
255
|
create: (input) => ask('conversation.create', [input]),
|
|
210
256
|
send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
|
|
211
|
-
attach: (room, file) => ask('conversation.attach', [room, file]),
|
|
212
257
|
answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
|
|
213
258
|
interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
|
|
214
259
|
kill: (conversation) => ask('conversation.kill', [conversation]),
|
|
215
|
-
cancel: (conversation, turn) => ask('conversation.cancel', [conversation, turn]),
|
|
216
260
|
delete: (conversation) => ask('conversation.delete', [conversation]),
|
|
217
261
|
},
|
|
218
262
|
chatDraft: {
|
|
@@ -223,8 +267,9 @@ export function connectMdRuntime(port) {
|
|
|
223
267
|
history: (locator, path, query) => ask('history', [locator, path, query]),
|
|
224
268
|
resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
|
|
225
269
|
binaryFile: {
|
|
226
|
-
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then(streamed),
|
|
227
|
-
|
|
270
|
+
read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then((read) => streamed(read)),
|
|
271
|
+
attach: (room, file) => ask('binaryFile.attach', [room, file]),
|
|
272
|
+
download,
|
|
228
273
|
},
|
|
229
274
|
call: (name, input) => ask('call', [name, input]),
|
|
230
275
|
reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
|
|
@@ -232,10 +277,12 @@ export function connectMdRuntime(port) {
|
|
|
232
277
|
persistence: () => ask('persistence', []),
|
|
233
278
|
retry: () => ask('retry', []),
|
|
234
279
|
cleanUp: () => ask('cleanUp', []),
|
|
280
|
+
unsent: () => ask('unsent', []),
|
|
281
|
+
reset: () => ask('reset', []),
|
|
235
282
|
observe: ((topic, ...input) => watch(topic, input)),
|
|
236
283
|
reauthorize: () => ask('reauthorize', []),
|
|
237
284
|
settled,
|
|
238
|
-
};
|
|
285
|
+
});
|
|
239
286
|
}
|
|
240
287
|
const turns = new WeakMap();
|
|
241
288
|
export function inTurn(client, work) {
|
|
@@ -244,4 +291,6 @@ export function inTurn(client, work) {
|
|
|
244
291
|
return turn;
|
|
245
292
|
}
|
|
246
293
|
export { chainedWindows } from './chain.js';
|
|
294
|
+
export { roomDraftRevision } from './identity.js';
|
|
295
|
+
export { defineRoomMedia, ROOM_MEDIA } from './media.js';
|
|
247
296
|
export { unanswered } from './wire.js';
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { type Document } from '@agentshouse/mdmodel';
|
|
1
|
+
import { type Document, type TypedPath } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { ModelState } from './model.js';
|
|
3
3
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
|
-
import { type Paths } from './shared.js';
|
|
5
|
-
import type { Refused } from './transfer.js';
|
|
6
4
|
export declare const MD_MODEL: MdModelIdentity;
|
|
7
5
|
export type Collection = {
|
|
8
6
|
text: Readonly<Record<string, string>>;
|
|
@@ -15,12 +13,17 @@ export type Composition = {
|
|
|
15
13
|
roots: readonly string[];
|
|
16
14
|
model: ModelState;
|
|
17
15
|
} | null;
|
|
16
|
+
typedPaths: readonly TypedPath[];
|
|
18
17
|
};
|
|
18
|
+
export type Composed = {
|
|
19
|
+
readonly composition: Composition;
|
|
20
|
+
readonly fingerprint: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function composedOf(composition: Composition): Composed;
|
|
19
23
|
export declare function selected(composition: Composition, path: string): boolean;
|
|
20
24
|
export declare function governing(composition: Composition, path: string): ModelState;
|
|
21
25
|
export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
22
26
|
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>;
|
|
24
27
|
export declare function validRoot(root: unknown): root is string;
|
|
25
28
|
export declare function available(composition: Composition): boolean;
|
|
26
29
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.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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,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,8 +1,29 @@
|
|
|
1
1
|
import { parse, VERSION } from '@agentshouse/mdmodel';
|
|
2
2
|
import { beneath, normalize } from './paths.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { hashed } from './observation.js';
|
|
4
|
+
import { sortedKeys } from './shared.js';
|
|
5
5
|
export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
|
|
6
|
+
const typesPrinted = new WeakMap();
|
|
7
|
+
function typesPrint(model) {
|
|
8
|
+
if (model.status === 'unavailable')
|
|
9
|
+
return '';
|
|
10
|
+
let print = typesPrinted.get(model.types);
|
|
11
|
+
if (print === undefined) {
|
|
12
|
+
print = hashed(JSON.stringify(model.types)).toString(36);
|
|
13
|
+
typesPrinted.set(model.types, print);
|
|
14
|
+
}
|
|
15
|
+
return print;
|
|
16
|
+
}
|
|
17
|
+
export function composedOf(composition) {
|
|
18
|
+
const { model, selection } = composition;
|
|
19
|
+
return {
|
|
20
|
+
composition,
|
|
21
|
+
fingerprint: JSON.stringify([
|
|
22
|
+
typesPrint(model),
|
|
23
|
+
selection === null ? null : [selection.roots, typesPrint(selection.model)],
|
|
24
|
+
]),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
6
27
|
export function selected(composition, path) {
|
|
7
28
|
return (composition.selection !== null &&
|
|
8
29
|
composition.selection.roots.some((root) => beneath(root, path)));
|
|
@@ -39,25 +60,9 @@ export function* documentsOf(collection) {
|
|
|
39
60
|
}
|
|
40
61
|
})();
|
|
41
62
|
}
|
|
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)
|
|
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 } };
|
|
52
|
-
}
|
|
53
|
-
yield ROW_WEIGHT + content.length;
|
|
54
|
-
}
|
|
55
|
-
return least?.refused ?? null;
|
|
56
|
-
}
|
|
57
63
|
export function validRoot(root) {
|
|
58
64
|
return typeof root === 'string' && normalize(root) === root;
|
|
59
65
|
}
|
|
60
66
|
export function available(composition) {
|
|
61
|
-
return
|
|
62
|
-
(composition.selection === null || composition.selection.model.status !== 'unavailable'));
|
|
67
|
+
return composition.model.status !== 'unavailable';
|
|
63
68
|
}
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { Plan, QueryRows } from './query.js';
|
|
2
|
-
import type { Connection
|
|
2
|
+
import type { Connection } from './tables.js';
|
|
3
3
|
export type QueryRoom = {
|
|
4
4
|
readonly locator: string;
|
|
5
5
|
readonly key: number;
|
|
6
6
|
};
|
|
7
|
-
export type Fragment = {
|
|
8
|
-
readonly sql: string;
|
|
9
|
-
readonly bind: readonly Value[];
|
|
10
|
-
};
|
|
11
7
|
export type QueryAnswer = QueryRows & {
|
|
12
8
|
readonly more?: string;
|
|
13
9
|
};
|
|
14
|
-
export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
|
|
15
10
|
export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
|
|
16
11
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,IAAI,EAAuC,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvF,OAAO,KAAK,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AA+a3E,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAkUjE,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"}
|