@tobi-or-not/quorum 0.1.0 → 0.3.0
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/LICENSE +202 -0
- package/README.md +5 -0
- package/dist/bench/fingerprint.d.ts +36 -0
- package/dist/bench/fingerprint.js +79 -0
- package/dist/bench/records.d.ts +62 -0
- package/dist/bench/records.js +161 -0
- package/dist/bench/report.d.ts +110 -0
- package/dist/bench/report.js +332 -0
- package/dist/bench/run-dir.d.ts +101 -0
- package/dist/bench/run-dir.js +379 -0
- package/dist/bench/runner.d.ts +80 -0
- package/dist/bench/runner.js +160 -0
- package/dist/bench/score.d.ts +30 -0
- package/dist/bench/score.js +38 -0
- package/dist/bench/stats.d.ts +51 -0
- package/dist/bench/stats.js +83 -0
- package/dist/bench/suite.d.ts +87 -0
- package/dist/bench/suite.js +286 -0
- package/dist/cli/bench.d.ts +32 -0
- package/dist/cli/bench.js +463 -0
- package/dist/cli/bin.js +9 -1
- package/dist/cli/io.d.ts +45 -0
- package/dist/cli/io.js +45 -0
- package/dist/cli/main.d.ts +7 -37
- package/dist/cli/main.js +47 -60
- package/dist/cli/print-config.js +38 -9
- package/dist/cli/render.d.ts +10 -0
- package/dist/cli/render.js +37 -16
- package/dist/config/claude-code.js +42 -11
- package/dist/config/env.js +135 -32
- package/dist/config/from-config.js +43 -9
- package/dist/config/load.d.ts +43 -0
- package/dist/config/load.js +205 -46
- package/dist/config/profiles.js +87 -20
- package/dist/config/resolve.js +194 -47
- package/dist/config/schema.js +98 -23
- package/dist/core/diff.d.ts +10 -0
- package/dist/core/diff.js +90 -17
- package/dist/core/errors.js +14 -5
- package/dist/core/flags.js +30 -6
- package/dist/core/output.js +49 -13
- package/dist/core/policy.js +6 -2
- package/dist/core/profile.js +42 -15
- package/dist/core/prompts.d.ts +3 -1
- package/dist/core/prompts.js +28 -8
- package/dist/core/quorum.js +128 -33
- package/dist/core/sanitize.d.ts +16 -1
- package/dist/core/sanitize.js +31 -5
- package/dist/core/stages/context.js +30 -5
- package/dist/core/stages/panel.js +55 -9
- package/dist/core/stages/research.js +13 -3
- package/dist/core/verify.js +6 -2
- package/dist/index.js +5 -1
- package/dist/providers/anthropic.js +28 -5
- package/dist/providers/build.js +57 -16
- package/dist/providers/claude-code.js +206 -51
- package/dist/providers/gemini.js +61 -14
- package/dist/providers/http.js +32 -9
- package/dist/providers/messages.js +14 -2
- package/dist/providers/ollama.js +31 -8
- package/dist/providers/openai-compatible.js +51 -15
- package/dist/providers/options.js +120 -40
- package/dist/providers/presets.js +143 -16
- package/dist/providers/reply.js +15 -5
- package/dist/providers/size.js +11 -3
- package/package.json +6 -5
package/dist/config/env.js
CHANGED
|
@@ -9,7 +9,9 @@ import { configPath, isProvider, unknownName } from "./schema.js";
|
|
|
9
9
|
* not break a key. A blank variable is unset, and so is one the environment only inherits from its prototype.
|
|
10
10
|
*/
|
|
11
11
|
export function envValue(env, name) {
|
|
12
|
-
return Object.hasOwn(env, name)
|
|
12
|
+
return Object.hasOwn(env, name)
|
|
13
|
+
? env[name]?.trim() || undefined
|
|
14
|
+
: undefined;
|
|
13
15
|
}
|
|
14
16
|
/** The variables of a role, in the order issues name them; those with an alias are read as `<ROLE>_<suffix>` too. */
|
|
15
17
|
const VARIABLES = [
|
|
@@ -22,7 +24,10 @@ const VARIABLES = [
|
|
|
22
24
|
];
|
|
23
25
|
const ROLES = ['RESEARCH', 'VOTER'];
|
|
24
26
|
/** Each role as `RoleBinding` names it, with its variables' prefix. */
|
|
25
|
-
const BINDINGS = [
|
|
27
|
+
const BINDINGS = [
|
|
28
|
+
['research', 'RESEARCH'],
|
|
29
|
+
['voter', 'VOTER'],
|
|
30
|
+
];
|
|
26
31
|
/** The aliases in the order the deprecation line lists them, role by role. */
|
|
27
32
|
const ALIAS_SUFFIXES = ['BASE_URL', 'API_KEY', 'MODEL'];
|
|
28
33
|
/** The form of a profile id: what `QUORUM_PROFILES` and a selection of profiles may name. */
|
|
@@ -56,24 +61,40 @@ function readRole(env, role) {
|
|
|
56
61
|
const issues = [];
|
|
57
62
|
for (const { field, suffix, aliased } of VARIABLES) {
|
|
58
63
|
const name = canonicalName(role, suffix);
|
|
59
|
-
const value = envValue(env, name) ?? (aliased
|
|
64
|
+
const value = envValue(env, name) ?? (aliased
|
|
65
|
+
? envValue(env, `${role}_${suffix}`)
|
|
66
|
+
: undefined);
|
|
60
67
|
if (value === undefined)
|
|
61
68
|
continue;
|
|
62
|
-
if (field !== 'contextTokens')
|
|
69
|
+
if (field !== 'contextTokens') {
|
|
63
70
|
entries.push([field, value]);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
}
|
|
72
|
+
else if (CONTEXT_TOKENS.test(value)) {
|
|
73
|
+
entries.push([
|
|
74
|
+
field,
|
|
75
|
+
Number(value),
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
67
79
|
issues.push({ path: name, message: CONTEXT_TOKENS_FORM });
|
|
80
|
+
}
|
|
68
81
|
}
|
|
69
|
-
return {
|
|
82
|
+
return {
|
|
83
|
+
overrides: Object.fromEntries(entries),
|
|
84
|
+
issues,
|
|
85
|
+
};
|
|
70
86
|
}
|
|
71
87
|
/** The one deprecation line: every alias that is set, whether or not its `QUORUM_` form won, and what to set instead. */
|
|
72
88
|
function deprecationWarnings(env) {
|
|
73
|
-
const aliases = ROLES.flatMap(role => ALIAS_SUFFIXES.filter(suffix => envValue(env, `${role}_${suffix}`) !== undefined).map(suffix => [
|
|
89
|
+
const aliases = ROLES.flatMap(role => ALIAS_SUFFIXES.filter(suffix => envValue(env, `${role}_${suffix}`) !== undefined).map(suffix => [
|
|
90
|
+
`${role}_${suffix}`,
|
|
91
|
+
canonicalName(role, suffix),
|
|
92
|
+
]));
|
|
74
93
|
if (aliases.length === 0)
|
|
75
94
|
return [];
|
|
76
|
-
const verb = aliases.length === 1
|
|
95
|
+
const verb = aliases.length === 1
|
|
96
|
+
? 'is'
|
|
97
|
+
: 'are';
|
|
77
98
|
return [`${wordList(aliases.map(([alias]) => alias), 'and')} ${verb} deprecated: set ${wordList(aliases.map(([, canonical]) => canonical), 'and')} instead`];
|
|
78
99
|
}
|
|
79
100
|
/**
|
|
@@ -84,8 +105,14 @@ function unreadWarnings(env) {
|
|
|
84
105
|
const names = Object.keys(env).filter(name => name.startsWith('QUORUM_') && !READ_VARIABLES.has(name) && envValue(env, name) !== undefined).sort();
|
|
85
106
|
if (names.length === 0)
|
|
86
107
|
return [];
|
|
87
|
-
const printed = names.map(name => VARIABLE_NAME.test(name)
|
|
88
|
-
|
|
108
|
+
const printed = names.map(name => VARIABLE_NAME.test(name)
|
|
109
|
+
? name
|
|
110
|
+
: '*');
|
|
111
|
+
return [
|
|
112
|
+
names.length === 1
|
|
113
|
+
? `${printed[0]} is not a variable quorum reads`
|
|
114
|
+
: `${wordList(printed, 'and')} are not variables quorum reads`,
|
|
115
|
+
];
|
|
89
116
|
}
|
|
90
117
|
/** The profile ids of `QUORUM_PROFILES`, or the one issue that refuses it. Neither repeats the value. */
|
|
91
118
|
function readProfiles(env) {
|
|
@@ -93,10 +120,20 @@ function readProfiles(env) {
|
|
|
93
120
|
if (value === undefined)
|
|
94
121
|
return { issues: [] };
|
|
95
122
|
const ids = value.split(',').map(id => id.trim());
|
|
96
|
-
if (!ids.every(id => PROFILE_ID.test(id)))
|
|
97
|
-
return {
|
|
98
|
-
|
|
99
|
-
|
|
123
|
+
if (!ids.every(id => PROFILE_ID.test(id))) {
|
|
124
|
+
return {
|
|
125
|
+
issues: [
|
|
126
|
+
{ path: 'QUORUM_PROFILES', message: `must list profile ids separated by commas, each matching ${PROFILE_ID.source}` },
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (new Set(ids).size < ids.length) {
|
|
131
|
+
return {
|
|
132
|
+
issues: [
|
|
133
|
+
{ path: 'QUORUM_PROFILES', message: 'names a profile more than once' },
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
100
137
|
return { profiles: ids, issues: [] };
|
|
101
138
|
}
|
|
102
139
|
/** `QUORUM_CLAUDE_CODE_COMMAND`, or the one issue that refuses it: the adapter's own problem with a command, at the variable, never repeating its value. */
|
|
@@ -105,7 +142,13 @@ function readClaudeCodeCommand(env) {
|
|
|
105
142
|
if (command === undefined)
|
|
106
143
|
return { issues: [] };
|
|
107
144
|
const problem = commandProblem(command);
|
|
108
|
-
return problem === undefined
|
|
145
|
+
return problem === undefined
|
|
146
|
+
? { claudeCodeCommand: command, issues: [] }
|
|
147
|
+
: {
|
|
148
|
+
issues: [
|
|
149
|
+
{ path: CLAUDE_CODE_COMMAND, message: problem },
|
|
150
|
+
],
|
|
151
|
+
};
|
|
109
152
|
}
|
|
110
153
|
/**
|
|
111
154
|
* Read the `QUORUM_*` variables: the preset, protocol, base URL, model, context size and key of each role,
|
|
@@ -125,8 +168,16 @@ export function readEnv(env) {
|
|
|
125
168
|
...command,
|
|
126
169
|
research: research.overrides,
|
|
127
170
|
voter: voter.overrides,
|
|
128
|
-
warnings: [
|
|
129
|
-
|
|
171
|
+
warnings: [
|
|
172
|
+
...deprecationWarnings(env),
|
|
173
|
+
...unreadWarnings(env),
|
|
174
|
+
],
|
|
175
|
+
issues: [
|
|
176
|
+
...profileIssues,
|
|
177
|
+
...commandIssues,
|
|
178
|
+
...research.issues,
|
|
179
|
+
...voter.issues,
|
|
180
|
+
],
|
|
130
181
|
};
|
|
131
182
|
}
|
|
132
183
|
/** The base URL of a provider's settings: their own, else their preset's. Both are read as own fields, so a polluted `Object.prototype` sets neither. */
|
|
@@ -142,7 +193,12 @@ function setVariables(overrides) {
|
|
|
142
193
|
return VARIABLES.filter(({ field }) => isSet(overrides, field));
|
|
143
194
|
}
|
|
144
195
|
/** The fields that name a model on an endpoint: a context size describes what they name. */
|
|
145
|
-
const MODEL_OR_ENDPOINT = [
|
|
196
|
+
const MODEL_OR_ENDPOINT = [
|
|
197
|
+
'preset',
|
|
198
|
+
'protocol',
|
|
199
|
+
'baseUrl',
|
|
200
|
+
'model',
|
|
201
|
+
];
|
|
146
202
|
/** Whether the variables of a role name a preset, a protocol, a base URL or a model: another model, or another endpoint, than the provider they are set on. */
|
|
147
203
|
export function namesModelOrEndpoint(overrides) {
|
|
148
204
|
return MODEL_OR_ENDPOINT.some(field => isSet(overrides, field));
|
|
@@ -176,24 +232,54 @@ function startsAfresh(variables) {
|
|
|
176
232
|
}
|
|
177
233
|
/** The settings with the fields the variables set, or those fields alone when the variables name a preset or a protocol; the context size stays only while the variables name no model or endpoint, unless they set one. */
|
|
178
234
|
function withVariables(settings, overrides, variables) {
|
|
179
|
-
return {
|
|
235
|
+
return {
|
|
236
|
+
...startsAfresh(variables)
|
|
237
|
+
? {}
|
|
238
|
+
: inheritedBy(overrides, settings),
|
|
239
|
+
...fieldsOf(overrides, variables),
|
|
240
|
+
};
|
|
180
241
|
}
|
|
181
242
|
/** One issue per variable set, at that variable: none of them can change a provider object. */
|
|
182
243
|
function objectIssues(role, variables, providerName) {
|
|
183
|
-
return variables.map(({ suffix }) => ({
|
|
244
|
+
return variables.map(({ suffix }) => ({
|
|
245
|
+
path: canonicalName(role, suffix),
|
|
246
|
+
message: `cannot change ${configPath(['providers', providerName])}, an object implementing Provider`,
|
|
247
|
+
}));
|
|
184
248
|
}
|
|
185
249
|
/**
|
|
186
250
|
* The provider the voter variables derive from the research provider `base`: all of it on the same endpoint, and nothing that is a secret, a model or the context size of that model elsewhere (ADR-0013). Its context size crosses only while the variables name no model or endpoint.
|
|
187
251
|
* `unnamedProtocol` is true when nobody named `base`'s protocol, the built-in default's: a base URL alone then names a server of no kind, which speaks OpenAI-compatible, never the default's own protocol.
|
|
188
252
|
*/
|
|
189
253
|
function derivedVoter(base, overrides, variables, unnamedProtocol) {
|
|
190
|
-
const fields = {
|
|
254
|
+
const fields = {
|
|
255
|
+
...fieldsOf(overrides, variables),
|
|
256
|
+
...unnamedProtocol && setsOnlyBaseUrl(overrides)
|
|
257
|
+
? { protocol: 'openai-compatible' }
|
|
258
|
+
: {},
|
|
259
|
+
};
|
|
191
260
|
const origin = httpOrigin(baseUrlOf(base));
|
|
192
261
|
const sameEndpoint = origin !== undefined && origin === httpOrigin(own(fields, 'baseUrl') ?? baseUrlOf(base));
|
|
193
262
|
const { apiKeyEnv: _apiKeyEnv, apiKey: _apiKey, headers: _headers, query: _query, extraBody: _extraBody, model: _model, contextTokens: _contextTokens, ...endpoint } = base;
|
|
194
|
-
const provider = startsAfresh(variables)
|
|
263
|
+
const provider = startsAfresh(variables)
|
|
264
|
+
? fields
|
|
265
|
+
: {
|
|
266
|
+
...(sameEndpoint
|
|
267
|
+
? inheritedBy(overrides, base)
|
|
268
|
+
: endpoint),
|
|
269
|
+
...fields,
|
|
270
|
+
};
|
|
195
271
|
const needsModel = (startsAfresh(variables) || !sameEndpoint) && provider.model === undefined;
|
|
196
|
-
return {
|
|
272
|
+
return {
|
|
273
|
+
provider,
|
|
274
|
+
issues: needsModel
|
|
275
|
+
? [
|
|
276
|
+
{
|
|
277
|
+
path: canonicalName('VOTER', 'MODEL'),
|
|
278
|
+
message: 'must be set when the voter variables name another endpoint than the research provider\'s',
|
|
279
|
+
},
|
|
280
|
+
]
|
|
281
|
+
: [],
|
|
282
|
+
};
|
|
197
283
|
}
|
|
198
284
|
/** One issue per role bound to a name that is not an own key of `providers`: a role is never assumed to be bound. */
|
|
199
285
|
function unboundRoles(providers, roles) {
|
|
@@ -217,16 +303,26 @@ function unboundRoles(providers, roles) {
|
|
|
217
303
|
*/
|
|
218
304
|
export function applyRoleOverrides(providers, roles, layer, builtIn = false) {
|
|
219
305
|
const unbound = unboundRoles(providers, roles);
|
|
220
|
-
if (unbound.length > 0)
|
|
221
|
-
return {
|
|
306
|
+
if (unbound.length > 0) {
|
|
307
|
+
return {
|
|
308
|
+
providers: { ...providers },
|
|
309
|
+
roles,
|
|
310
|
+
issues: unbound,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
222
313
|
const issues = [];
|
|
223
314
|
let result = { ...providers };
|
|
224
315
|
const setOn = (role, name, overrides, variables) => {
|
|
225
316
|
const entry = result[name];
|
|
226
|
-
if (isProvider(entry))
|
|
317
|
+
if (isProvider(entry)) {
|
|
227
318
|
issues.push(...objectIssues(role, variables, name));
|
|
228
|
-
|
|
229
|
-
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
result = {
|
|
322
|
+
...result,
|
|
323
|
+
[name]: withVariables(entry, overrides, variables),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
230
326
|
};
|
|
231
327
|
const researchVariables = setVariables(layer.research);
|
|
232
328
|
if (researchVariables.length > 0)
|
|
@@ -239,7 +335,10 @@ export function applyRoleOverrides(providers, roles, layer, builtIn = false) {
|
|
|
239
335
|
else if (voterVariables.length > 0) {
|
|
240
336
|
const base = result[roles.research];
|
|
241
337
|
if (Object.hasOwn(result, 'voter')) {
|
|
242
|
-
issues.push({
|
|
338
|
+
issues.push({
|
|
339
|
+
path: configPath(['providers', 'voter']),
|
|
340
|
+
message: 'is the name the voter variables give the provider they derive: rename this provider',
|
|
341
|
+
});
|
|
243
342
|
}
|
|
244
343
|
else if (isProvider(base)) {
|
|
245
344
|
issues.push(...objectIssues('VOTER', voterVariables, roles.research));
|
|
@@ -251,7 +350,11 @@ export function applyRoleOverrides(providers, roles, layer, builtIn = false) {
|
|
|
251
350
|
voterRole = 'voter';
|
|
252
351
|
}
|
|
253
352
|
}
|
|
254
|
-
return {
|
|
353
|
+
return {
|
|
354
|
+
providers: result,
|
|
355
|
+
roles: { research: roles.research, voter: voterRole },
|
|
356
|
+
issues,
|
|
357
|
+
};
|
|
255
358
|
}
|
|
256
359
|
/**
|
|
257
360
|
* `issues` of the builder, each one on a field a variable set moved to that variable, as its `QUORUM_` name
|
|
@@ -7,27 +7,45 @@ import { configInputSchema, configPath, isProvider } from "./schema.js";
|
|
|
7
7
|
/** A provider the config defines as data, built by the builder: its issues name the provider where the config defines it. */
|
|
8
8
|
function fromSpec(name, spec, env) {
|
|
9
9
|
try {
|
|
10
|
-
return {
|
|
10
|
+
return {
|
|
11
|
+
provider: buildProvider({ ...spec, id: name }, { env }),
|
|
12
|
+
issues: [],
|
|
13
|
+
};
|
|
11
14
|
}
|
|
12
15
|
catch (error) {
|
|
13
16
|
if (!(error instanceof ConfigError))
|
|
14
17
|
throw error;
|
|
15
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
issues: error.issues.map(({ path, message }) => ({ path: `providers.${path}`, message })),
|
|
20
|
+
};
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
/** A provider object of the config, which the check read once into a snapshot, under the name the config gives it. */
|
|
19
24
|
function fromObject(name, snapshot) {
|
|
20
25
|
const { model, complete } = snapshot;
|
|
21
|
-
if (typeof model !== 'string')
|
|
22
|
-
return {
|
|
23
|
-
|
|
26
|
+
if (typeof model !== 'string') {
|
|
27
|
+
return {
|
|
28
|
+
issues: [
|
|
29
|
+
{
|
|
30
|
+
path: configPath(['providers', name, 'model']),
|
|
31
|
+
message: 'must be a string',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
provider: { id: name, model, complete },
|
|
38
|
+
issues: [],
|
|
39
|
+
};
|
|
24
40
|
}
|
|
25
41
|
/** Each provider of a resolved config as a `Provider`, by name, or every issue of the providers that cannot be built. `env` is what a `claude-code` provider's CLI inherits. */
|
|
26
42
|
function buildProviders(providers, env) {
|
|
27
43
|
const built = new Map();
|
|
28
44
|
const issues = [];
|
|
29
45
|
for (const [name, entry] of Object.entries(providers)) {
|
|
30
|
-
const result = isProvider(entry)
|
|
46
|
+
const result = isProvider(entry)
|
|
47
|
+
? fromObject(name, entry)
|
|
48
|
+
: fromSpec(name, entry, env);
|
|
31
49
|
issues.push(...result.issues);
|
|
32
50
|
if (result.provider !== undefined)
|
|
33
51
|
built.set(name, result.provider);
|
|
@@ -61,8 +79,24 @@ export async function fromConfig(config, options = {}) {
|
|
|
61
79
|
const provider = (name) => providers.get(name);
|
|
62
80
|
const ports = Object.fromEntries(resolved.profiles.map(({ profile, research, voters }) => [
|
|
63
81
|
profile.id,
|
|
64
|
-
{
|
|
82
|
+
{
|
|
83
|
+
research: provider(research),
|
|
84
|
+
voters: Object.fromEntries(Object.entries(voters).map(([lens, name]) => [
|
|
85
|
+
lens,
|
|
86
|
+
provider(name),
|
|
87
|
+
])),
|
|
88
|
+
},
|
|
65
89
|
]));
|
|
66
|
-
const quorum = createQuorum({
|
|
67
|
-
|
|
90
|
+
const quorum = createQuorum({
|
|
91
|
+
profiles: resolved.profiles.map(({ profile }) => profile),
|
|
92
|
+
concurrency: resolved.concurrency,
|
|
93
|
+
maxFindings: resolved.maxFindings,
|
|
94
|
+
}, { profiles: ports, events: options.events });
|
|
95
|
+
return Object.freeze({
|
|
96
|
+
review: quorum.review,
|
|
97
|
+
warnings: Object.freeze([
|
|
98
|
+
...resolved.warnings,
|
|
99
|
+
...quorum.warnings,
|
|
100
|
+
]),
|
|
101
|
+
});
|
|
68
102
|
}
|
package/dist/config/load.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
+
import type { ConfigIssue } from '../core/errors.ts';
|
|
2
3
|
import type { Env } from './env.ts';
|
|
3
4
|
import type { ProfileSelection } from './profiles.ts';
|
|
4
5
|
import type { ResolvedConfig } from './resolve.ts';
|
|
@@ -10,6 +11,48 @@ export interface LoadedConfig {
|
|
|
10
11
|
/** The absolute path of the file. */
|
|
11
12
|
readonly source: string;
|
|
12
13
|
}
|
|
14
|
+
/** What a read found, or the problem with the file, as an issue words it, and how many bytes the problem counts toward a total. */
|
|
15
|
+
export type Read<T> = {
|
|
16
|
+
readonly value: T;
|
|
17
|
+
} | {
|
|
18
|
+
readonly problem: string;
|
|
19
|
+
readonly counted?: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The bytes of a regular file of at most `limit` bytes. The file is opened without blocking, so a FIFO
|
|
23
|
+
* is refused instead of waiting for a writer, and at most one byte past the limit is read, however large
|
|
24
|
+
* the file is or grows. The runtime's own message is never kept. A symbolic link is followed, unless
|
|
25
|
+
* `options.noFollow` is set: then a link is `is a symbolic link`, refused by an `lstat` before the open,
|
|
26
|
+
* and the open itself refuses one with `O_NOFOLLOW` where the platform has it, which closes the race
|
|
27
|
+
* between the two on Linux and macOS (without it, on Windows, a link swapped in after the `lstat` is
|
|
28
|
+
* followed).
|
|
29
|
+
*/
|
|
30
|
+
export declare function readBounded(absolute: string, limit: number, size: string, options?: {
|
|
31
|
+
readonly noFollow?: boolean;
|
|
32
|
+
}): Promise<Read<Uint8Array>>;
|
|
33
|
+
/** The UTF-8 text of `bytes`, a leading byte-order mark dropped (the decoder's default). */
|
|
34
|
+
export declare function decode(bytes: Uint8Array): Read<string>;
|
|
35
|
+
/**
|
|
36
|
+
* One YAML 1.2 document of the core schema, as plain data. The schema is given explicitly, since a
|
|
37
|
+
* `%YAML 1.1` directive overrides the version alone (and 1.1 reads `off` as false); the YAML 1.1 tags
|
|
38
|
+
* are not resolved; any error, any warning (an unknown tag is only a warning to the parser), a key that
|
|
39
|
+
* repeats one of its mapping and any alias refuse the file; no problem carries source text.
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseYaml(text: string): Read<unknown>;
|
|
42
|
+
/** Whether `value` is an object of data: an object whose prototype is `Object.prototype` or none, never a class instance. */
|
|
43
|
+
export declare function isPlainObject(value: unknown): value is Record<string, unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Every value of a config that is not plain data (an object of data, an array, a string, a finite
|
|
46
|
+
* number, a boolean or null), every own `__proto__` key, and every value more than `MAX_DEPTH` keys
|
|
47
|
+
* deep, each at its path after the file's. A record drops a `__proto__` key silently, and a later merge
|
|
48
|
+
* could turn one into a prototype change: it is refused here, before any schema reads the data.
|
|
49
|
+
* `constructor` and `prototype` stay allowed: they are valid names, and only `__proto__` runs a setter.
|
|
50
|
+
* Only a code config can hand over the rest: a provider object, which is not entered, and `undefined`,
|
|
51
|
+
* which leaves a field unset. Every value the walk visits counts, a provider object too, and past
|
|
52
|
+
* `MAX_VALUES` it stops and the config has that one issue, at the file: the schema never sees more data
|
|
53
|
+
* than that, and an object that refers to itself ends the walk instead of repeating it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function dataIssues(value: unknown, file: string | undefined): ConfigIssue[];
|
|
13
56
|
/**
|
|
14
57
|
* The plain object a config's code hands over, checked by `schema`: `read` returns it, then it must be a
|
|
15
58
|
* plain object, hold plain data, and pass the schema, which reads each provider object it holds once into
|