@tobi-or-not/quorum 0.3.0 → 0.5.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/README.md +2 -1
- package/dist/bench/attacks.d.ts +103 -0
- package/dist/bench/attacks.js +272 -0
- package/dist/bench/fingerprint.d.ts +7 -4
- package/dist/bench/fingerprint.js +22 -8
- package/dist/bench/independence.d.ts +28 -0
- package/dist/bench/independence.js +67 -0
- package/dist/bench/records.d.ts +241 -13
- package/dist/bench/records.js +64 -11
- package/dist/bench/report.d.ts +44 -11
- package/dist/bench/report.js +238 -32
- package/dist/bench/run-dir.d.ts +52 -26
- package/dist/bench/run-dir.js +124 -45
- package/dist/bench/runner.d.ts +47 -17
- package/dist/bench/runner.js +82 -21
- package/dist/bench/score.d.ts +38 -7
- package/dist/bench/score.js +64 -17
- package/dist/bench/stats.d.ts +61 -7
- package/dist/bench/stats.js +82 -7
- package/dist/bench/suite.d.ts +54 -9
- package/dist/bench/suite.js +264 -96
- package/dist/cli/bench.d.ts +27 -9
- package/dist/cli/bench.js +174 -83
- package/dist/cli/bin.js +2 -2
- package/dist/cli/io.d.ts +9 -2
- package/dist/cli/io.js +20 -2
- package/dist/cli/main.d.ts +34 -14
- package/dist/cli/main.js +100 -38
- package/dist/cli/print-config.d.ts +8 -6
- package/dist/cli/print-config.js +21 -8
- package/dist/cli/render.d.ts +2 -2
- package/dist/cli/render.js +21 -2
- package/dist/config/env.d.ts +32 -19
- package/dist/config/env.js +95 -32
- package/dist/config/from-config.js +15 -3
- package/dist/config/load.d.ts +3 -0
- package/dist/config/load.js +17 -8
- package/dist/config/resolve.d.ts +9 -1
- package/dist/config/resolve.js +17 -1
- package/dist/config/schema.d.ts +141 -5
- package/dist/config/schema.js +125 -12
- package/dist/core/clock.d.ts +17 -0
- package/dist/core/clock.js +14 -0
- package/dist/core/coverage.d.ts +49 -0
- package/dist/core/coverage.js +144 -0
- package/dist/core/diff.d.ts +34 -0
- package/dist/core/diff.js +140 -18
- package/dist/core/errors.d.ts +18 -3
- package/dist/core/errors.js +26 -2
- package/dist/core/exclude.d.ts +42 -0
- package/dist/core/exclude.js +189 -0
- package/dist/core/limits.d.ts +82 -0
- package/dist/core/limits.js +163 -0
- package/dist/core/output.d.ts +3 -2
- package/dist/core/output.js +3 -2
- package/dist/core/ports.d.ts +57 -2
- package/dist/core/ports.js +36 -1
- package/dist/core/quorum.d.ts +24 -8
- package/dist/core/quorum.js +187 -56
- package/dist/core/retry.d.ts +36 -0
- package/dist/core/retry.js +46 -0
- package/dist/core/stages/context.d.ts +126 -22
- package/dist/core/stages/context.js +319 -41
- package/dist/core/stages/panel.d.ts +5 -4
- package/dist/core/stages/panel.js +30 -11
- package/dist/core/stages/research.d.ts +15 -6
- package/dist/core/stages/research.js +75 -18
- package/dist/core/tokens.d.ts +31 -0
- package/dist/core/tokens.js +81 -0
- package/dist/core/types.d.ts +77 -10
- package/dist/index.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +2 -1
- package/dist/providers/anthropic.js +14 -6
- package/dist/providers/claude-code.d.ts +51 -11
- package/dist/providers/claude-code.js +69 -33
- package/dist/providers/gemini.d.ts +4 -1
- package/dist/providers/gemini.js +72 -15
- package/dist/providers/http.d.ts +49 -4
- package/dist/providers/http.js +155 -14
- package/dist/providers/ollama.d.ts +3 -1
- package/dist/providers/ollama.js +17 -9
- package/dist/providers/openai-compatible.d.ts +3 -1
- package/dist/providers/openai-compatible.js +17 -9
- package/dist/providers/options.d.ts +12 -3
- package/dist/providers/options.js +30 -10
- package/dist/providers/reply.d.ts +6 -2
- package/dist/providers/reply.js +13 -3
- package/dist/providers/size.d.ts +10 -14
- package/dist/providers/size.js +15 -69
- package/package.json +1 -1
- package/schema/quorum.schema.json +34 -1
package/dist/config/env.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MAX_RETRIES, MAX_TIMEOUT_MS, MIN_TIMEOUT_MS } from "../core/ports.js";
|
|
1
2
|
import { commandProblem } from "../providers/claude-code.js";
|
|
2
3
|
import { httpOrigin } from "../providers/http.js";
|
|
3
4
|
import { wordList } from "../providers/options.js";
|
|
@@ -20,6 +21,8 @@ const VARIABLES = [
|
|
|
20
21
|
{ field: 'baseUrl', suffix: 'BASE_URL', aliased: true },
|
|
21
22
|
{ field: 'model', suffix: 'MODEL', aliased: true },
|
|
22
23
|
{ field: 'contextTokens', suffix: 'CONTEXT_TOKENS', aliased: false },
|
|
24
|
+
{ field: 'timeoutMs', suffix: 'TIMEOUT_MS', aliased: false },
|
|
25
|
+
{ field: 'retries', suffix: 'RETRIES', aliased: false },
|
|
23
26
|
{ field: 'apiKey', suffix: 'API_KEY', aliased: true },
|
|
24
27
|
];
|
|
25
28
|
const ROLES = ['RESEARCH', 'VOTER'];
|
|
@@ -37,24 +40,60 @@ export const VARIABLE_NAME = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
|
37
40
|
const canonicalName = (role, suffix) => `QUORUM_${role}_${suffix}`;
|
|
38
41
|
/** The variable that names the executable of every `claude-code` provider. */
|
|
39
42
|
export const CLAUDE_CODE_COMMAND = 'QUORUM_CLAUDE_CODE_COMMAND';
|
|
43
|
+
/** The deadline variables' rule, a role's `_TIMEOUT_MS` and the review's alike: milliseconds in the range a provider's deadline may take. */
|
|
44
|
+
const TIMEOUT_RULE = {
|
|
45
|
+
form: /^[1-9]\d{3,7}$/,
|
|
46
|
+
max: MAX_TIMEOUT_MS,
|
|
47
|
+
message: `must be a whole number of milliseconds, from ${MIN_TIMEOUT_MS} to ${MAX_TIMEOUT_MS}`,
|
|
48
|
+
};
|
|
49
|
+
/** The variables of the review itself, which belong to no role: each by the field it sets and the rule it is read by. */
|
|
50
|
+
const LIMIT_VARIABLES = [
|
|
51
|
+
{
|
|
52
|
+
field: 'maxReviewTokens',
|
|
53
|
+
name: 'QUORUM_MAX_REVIEW_TOKENS',
|
|
54
|
+
rule: { form: /^[1-9]\d{0,15}$/, max: Number.MAX_SAFE_INTEGER, message: `must be a whole number of tokens, from 1 to ${Number.MAX_SAFE_INTEGER}` },
|
|
55
|
+
},
|
|
56
|
+
{ field: 'reviewTimeoutMs', name: 'QUORUM_REVIEW_TIMEOUT_MS', rule: TIMEOUT_RULE },
|
|
57
|
+
];
|
|
40
58
|
/**
|
|
41
59
|
* Every variable the environment layer reads: `QUORUM_CONFIG`, `QUORUM_PROFILES`, `QUORUM_CLAUDE_CODE_COMMAND`, the
|
|
42
|
-
* `QUORUM_` form of each role's variables and the deprecated aliases of those that have one.
|
|
43
|
-
* variable added to `VARIABLES` joins it.
|
|
60
|
+
* review's two limits, the `QUORUM_` form of each role's variables and the deprecated aliases of those that have one.
|
|
61
|
+
* The one list: a variable added to `VARIABLES` or `LIMIT_VARIABLES` joins it.
|
|
44
62
|
*/
|
|
45
63
|
export const READ_VARIABLES = new Set([
|
|
46
64
|
'QUORUM_CONFIG',
|
|
47
65
|
'QUORUM_PROFILES',
|
|
48
66
|
CLAUDE_CODE_COMMAND,
|
|
67
|
+
...LIMIT_VARIABLES.map(({ name }) => name),
|
|
49
68
|
...ROLES.flatMap(role => VARIABLES.map(({ suffix }) => canonicalName(role, suffix))),
|
|
50
69
|
...ROLES.flatMap(role => VARIABLES.filter(({ aliased }) => aliased).map(({ suffix }) => `${role}_${suffix}`)),
|
|
51
70
|
]);
|
|
52
|
-
/**
|
|
53
|
-
const
|
|
54
|
-
|
|
71
|
+
/** The variables of a role that hold a whole number, each by the field it sets: decimal digits, no sign, no leading zero. A `Map`, so a field is never found on a prototype. */
|
|
72
|
+
const NUMBERS = new Map([
|
|
73
|
+
[
|
|
74
|
+
'contextTokens',
|
|
75
|
+
{ form: /^[1-9]\d{0,8}$/, max: 999_999_999, message: 'must be a whole number of tokens, from 1 to 999999999' },
|
|
76
|
+
],
|
|
77
|
+
['timeoutMs', TIMEOUT_RULE],
|
|
78
|
+
[
|
|
79
|
+
'retries',
|
|
80
|
+
{ form: /^[0-5]$/, max: MAX_RETRIES, message: `must be a whole number, from 0 to ${MAX_RETRIES}` },
|
|
81
|
+
],
|
|
82
|
+
]);
|
|
83
|
+
/** The number a variable holds, or the issue at the variable when it is not a whole number in the rule's range, which never repeats it. */
|
|
84
|
+
function readNumber(name, value, rule) {
|
|
85
|
+
return rule.form.test(value) && Number(value) <= rule.max
|
|
86
|
+
? {
|
|
87
|
+
number: Number(value),
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
issue: { path: name, message: rule.message },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
55
93
|
/**
|
|
56
94
|
* The variables of one role that are set, each as its field and value: the `QUORUM_` form, else its alias. A
|
|
57
|
-
* context size that is not a whole number in range sets nothing and is
|
|
95
|
+
* number (the context size, the deadline, the retries) that is not a whole number in range sets nothing and is
|
|
96
|
+
* an issue at its variable, which never repeats it.
|
|
58
97
|
*/
|
|
59
98
|
function readRole(env, role) {
|
|
60
99
|
const entries = [];
|
|
@@ -66,18 +105,16 @@ function readRole(env, role) {
|
|
|
66
105
|
: undefined);
|
|
67
106
|
if (value === undefined)
|
|
68
107
|
continue;
|
|
69
|
-
|
|
108
|
+
const rule = NUMBERS.get(field);
|
|
109
|
+
if (rule === undefined) {
|
|
70
110
|
entries.push([field, value]);
|
|
111
|
+
continue;
|
|
71
112
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
issues.push({ path: name, message: CONTEXT_TOKENS_FORM });
|
|
80
|
-
}
|
|
113
|
+
const read = readNumber(name, value, rule);
|
|
114
|
+
if ('issue' in read)
|
|
115
|
+
issues.push(read.issue);
|
|
116
|
+
else
|
|
117
|
+
entries.push([field, read.number]);
|
|
81
118
|
}
|
|
82
119
|
return {
|
|
83
120
|
overrides: Object.fromEntries(entries),
|
|
@@ -114,6 +151,25 @@ function unreadWarnings(env) {
|
|
|
114
151
|
: `${wordList(printed, 'and')} are not variables quorum reads`,
|
|
115
152
|
];
|
|
116
153
|
}
|
|
154
|
+
/** The review's limits the variables set, each as its field and value, and an issue at each variable that is not a whole number in range, which never repeats it. */
|
|
155
|
+
function readLimits(env) {
|
|
156
|
+
const entries = [];
|
|
157
|
+
const issues = [];
|
|
158
|
+
for (const { field, name, rule } of LIMIT_VARIABLES) {
|
|
159
|
+
const value = envValue(env, name);
|
|
160
|
+
if (value === undefined)
|
|
161
|
+
continue;
|
|
162
|
+
const read = readNumber(name, value, rule);
|
|
163
|
+
if ('issue' in read)
|
|
164
|
+
issues.push(read.issue);
|
|
165
|
+
else
|
|
166
|
+
entries.push([field, read.number]);
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
...Object.fromEntries(entries),
|
|
170
|
+
issues,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
117
173
|
/** The profile ids of `QUORUM_PROFILES`, or the one issue that refuses it. Neither repeats the value. */
|
|
118
174
|
function readProfiles(env) {
|
|
119
175
|
const value = envValue(env, 'QUORUM_PROFILES');
|
|
@@ -151,21 +207,26 @@ function readClaudeCodeCommand(env) {
|
|
|
151
207
|
};
|
|
152
208
|
}
|
|
153
209
|
/**
|
|
154
|
-
* Read the `QUORUM_*` variables: the preset, protocol, base URL, model, context size and key
|
|
155
|
-
* which are `QUORUM_RESEARCH_*` and `QUORUM_VOTER_*`, `QUORUM_PROFILES`, and
|
|
156
|
-
* executable of the `claude-code` protocol: an absolute path, or a name to
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
210
|
+
* Read the `QUORUM_*` variables: the preset, protocol, base URL, model, context size, deadline, retries and key
|
|
211
|
+
* of each role, which are `QUORUM_RESEARCH_*` and `QUORUM_VOTER_*`, `QUORUM_PROFILES`, and
|
|
212
|
+
* `QUORUM_CLAUDE_CODE_COMMAND`, the executable of the `claude-code` protocol: an absolute path, or a name to
|
|
213
|
+
* find on `PATH`; and the review's two limits, the run-level `QUORUM_MAX_REVIEW_TOKENS` and
|
|
214
|
+
* `QUORUM_REVIEW_TIMEOUT_MS`, which belong to no role and are read as strictly as a role's numbers.
|
|
215
|
+
* `RESEARCH_*` and `VOTER_*` are read as deprecated aliases of the base URL, model and key, and
|
|
216
|
+
* the `QUORUM_` form wins; the context size (`QUORUM_RESEARCH_CONTEXT_TOKENS`, `QUORUM_VOTER_CONTEXT_TOKENS`),
|
|
217
|
+
* the deadline (`_TIMEOUT_MS`) and the retries (`_RETRIES`) have no alias. Any other variable set under a
|
|
218
|
+
* `QUORUM_` name is named in one warning. No message repeats a value.
|
|
160
219
|
*/
|
|
161
220
|
export function readEnv(env) {
|
|
162
221
|
const { issues: profileIssues, ...profiles } = readProfiles(env);
|
|
163
222
|
const { issues: commandIssues, ...command } = readClaudeCodeCommand(env);
|
|
223
|
+
const { issues: limitIssues, ...limits } = readLimits(env);
|
|
164
224
|
const research = readRole(env, 'RESEARCH');
|
|
165
225
|
const voter = readRole(env, 'VOTER');
|
|
166
226
|
return {
|
|
167
227
|
...profiles,
|
|
168
228
|
...command,
|
|
229
|
+
...limits,
|
|
169
230
|
research: research.overrides,
|
|
170
231
|
voter: voter.overrides,
|
|
171
232
|
warnings: [
|
|
@@ -175,6 +236,7 @@ export function readEnv(env) {
|
|
|
175
236
|
issues: [
|
|
176
237
|
...profileIssues,
|
|
177
238
|
...commandIssues,
|
|
239
|
+
...limitIssues,
|
|
178
240
|
...research.issues,
|
|
179
241
|
...voter.issues,
|
|
180
242
|
],
|
|
@@ -290,16 +352,17 @@ function unboundRoles(providers, roles) {
|
|
|
290
352
|
* Set the variables of each role on its provider. The research variables go on the provider research is
|
|
291
353
|
* bound to. The voter variables go on the voter's own provider, or, when the voter shares the research
|
|
292
354
|
* provider, derive a provider named `voter` from it: a copy on the same endpoint, and on another one a copy
|
|
293
|
-
* with no key, header, query, body field, model or context size (ADR-0013)
|
|
294
|
-
* builds the role's provider from its variables alone.
|
|
295
|
-
* so it crosses to neither: a role's variables that name a
|
|
296
|
-
* context size of the provider they are set on, the
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
* is
|
|
301
|
-
*
|
|
302
|
-
*
|
|
355
|
+
* with no key, header, query, body field, model or context size (ADR-0013); its deadline and retries stay, as
|
|
356
|
+
* its `maxTokens` does. A preset or a protocol variable builds the role's provider from its variables alone.
|
|
357
|
+
* A context size describes one model on one endpoint, so it crosses to neither: a role's variables that name a
|
|
358
|
+
* preset, a protocol, a base URL or a model drop the context size of the provider they are set on, the
|
|
359
|
+
* derived voter's included, unless they set one; a variable that sets only a key, a deadline or a retry
|
|
360
|
+
* count leaves it. A provider object cannot be changed: each variable aimed at one is an issue. Nothing it
|
|
361
|
+
* is given changes; nested objects are shared. A role bound to a name that is not an own key of `providers`
|
|
362
|
+
* is an issue at that role, and nothing is applied. `builtIn` is true when `providers` is the built-in
|
|
363
|
+
* default alone: while the research variables name no preset or protocol, a voter derived from it whose
|
|
364
|
+
* variables set a base URL alone speaks OpenAI-compatible to it, as that variable always meant, and does not
|
|
365
|
+
* inherit the default's own protocol. A provider of a config keeps what it names.
|
|
303
366
|
*/
|
|
304
367
|
export function applyRoleOverrides(providers, roles, layer, builtIn = false) {
|
|
305
368
|
const unbound = unboundRoles(providers, roles);
|
|
@@ -3,7 +3,7 @@ import { createQuorum } from "../core/quorum.js";
|
|
|
3
3
|
import { buildProvider } from "../providers/build.js";
|
|
4
4
|
import { checkCodeValue } from "./load.js";
|
|
5
5
|
import { isResolvedConfig, resolveConfig } from "./resolve.js";
|
|
6
|
-
import { configInputSchema, configPath, isProvider } from "./schema.js";
|
|
6
|
+
import { configInputSchema, configPath, isProvider, statedFacts, statedWorstCase } 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 {
|
|
@@ -20,7 +20,7 @@ function fromSpec(name, spec, env) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
/** A provider object of the config, which the check read once into a snapshot, under the name the config gives it. */
|
|
23
|
+
/** A provider object of the config, which the check read once into a snapshot, under the name the config gives it, with the `timeoutMs`, `retries` and `worstCase` the snapshot holds. */
|
|
24
24
|
function fromObject(name, snapshot) {
|
|
25
25
|
const { model, complete } = snapshot;
|
|
26
26
|
if (typeof model !== 'string') {
|
|
@@ -33,8 +33,17 @@ function fromObject(name, snapshot) {
|
|
|
33
33
|
],
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
const worstCase = statedWorstCase(snapshot);
|
|
36
37
|
return {
|
|
37
|
-
provider: {
|
|
38
|
+
provider: {
|
|
39
|
+
id: name,
|
|
40
|
+
model,
|
|
41
|
+
complete,
|
|
42
|
+
...statedFacts(snapshot).stated,
|
|
43
|
+
...worstCase === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { worstCase },
|
|
46
|
+
},
|
|
38
47
|
issues: [],
|
|
39
48
|
};
|
|
40
49
|
}
|
|
@@ -91,6 +100,9 @@ export async function fromConfig(config, options = {}) {
|
|
|
91
100
|
profiles: resolved.profiles.map(({ profile }) => profile),
|
|
92
101
|
concurrency: resolved.concurrency,
|
|
93
102
|
maxFindings: resolved.maxFindings,
|
|
103
|
+
maxReviewTokens: resolved.maxReviewTokens,
|
|
104
|
+
reviewTimeoutMs: resolved.reviewTimeoutMs,
|
|
105
|
+
exclude: resolved.exclude,
|
|
94
106
|
}, { profiles: ports, events: options.events });
|
|
95
107
|
return Object.freeze({
|
|
96
108
|
review: quorum.review,
|
package/dist/config/load.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs';
|
|
1
2
|
import type { z } from 'zod';
|
|
2
3
|
import type { ConfigIssue } from '../core/errors.ts';
|
|
3
4
|
import type { Env } from './env.ts';
|
|
@@ -18,6 +19,8 @@ export type Read<T> = {
|
|
|
18
19
|
readonly problem: string;
|
|
19
20
|
readonly counted?: number;
|
|
20
21
|
};
|
|
22
|
+
/** The `lstat` of a path, or the problem a failed one means by its code: the path is missing, or it cannot be read. */
|
|
23
|
+
export declare function lstatOf(absolute: string): Promise<Read<Stats>>;
|
|
21
24
|
/**
|
|
22
25
|
* The bytes of a regular file of at most `limit` bytes. The file is opened without blocking, so a FIFO
|
|
23
26
|
* is refused instead of waiting for a writer, and at most one byte past the limit is read, however large
|
package/dist/config/load.js
CHANGED
|
@@ -54,20 +54,29 @@ function openProblem(error, noFollow) {
|
|
|
54
54
|
? 'is a symbolic link'
|
|
55
55
|
: 'cannot be read';
|
|
56
56
|
}
|
|
57
|
-
/** The
|
|
58
|
-
async function
|
|
57
|
+
/** The `lstat` of a path, or the problem a failed one means by its code: the path is missing, or it cannot be read. */
|
|
58
|
+
export async function lstatOf(absolute) {
|
|
59
59
|
try {
|
|
60
|
-
return
|
|
61
|
-
? 'is a symbolic link'
|
|
62
|
-
: undefined;
|
|
60
|
+
return { value: await lstat(absolute) };
|
|
63
61
|
}
|
|
64
62
|
catch (error) {
|
|
65
63
|
const code = error.code;
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
return {
|
|
65
|
+
problem: code === 'ENOENT' || code === 'ENOTDIR'
|
|
66
|
+
? 'does not exist'
|
|
67
|
+
: 'cannot be read',
|
|
68
|
+
};
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
+
/** The problem a path has before an open that must not follow a link: it is one, or it is missing or unreadable; undefined when it is not a link. */
|
|
72
|
+
async function linkProblem(absolute) {
|
|
73
|
+
const stats = await lstatOf(absolute);
|
|
74
|
+
if ('problem' in stats)
|
|
75
|
+
return stats.problem;
|
|
76
|
+
return stats.value.isSymbolicLink()
|
|
77
|
+
? 'is a symbolic link'
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
71
80
|
/**
|
|
72
81
|
* The bytes of a regular file of at most `limit` bytes. The file is opened without blocking, so a FIFO
|
|
73
82
|
* is refused instead of waiting for a writer, and at most one byte past the limit is read, however large
|
package/dist/config/resolve.d.ts
CHANGED
|
@@ -15,6 +15,12 @@ export interface ResolvedConfig {
|
|
|
15
15
|
readonly profiles: readonly ResolvedProfile[];
|
|
16
16
|
readonly concurrency?: number;
|
|
17
17
|
readonly maxFindings?: number;
|
|
18
|
+
/** The most tokens one review spends: `QUORUM_MAX_REVIEW_TOKENS`, else the config's; absent when neither sets it. */
|
|
19
|
+
readonly maxReviewTokens?: number;
|
|
20
|
+
/** The deadline of one review, in milliseconds: `QUORUM_REVIEW_TIMEOUT_MS`, else the config's; absent when neither sets it. */
|
|
21
|
+
readonly reviewTimeoutMs?: number;
|
|
22
|
+
/** The path patterns of the files every review leaves out; absent when the config lists none. */
|
|
23
|
+
readonly exclude?: readonly string[];
|
|
18
24
|
readonly warnings: readonly string[];
|
|
19
25
|
}
|
|
20
26
|
/** Whether `value` is a config `resolveConfig` returned. */
|
|
@@ -27,7 +33,9 @@ export declare function isResolvedConfig(value: unknown): value is ResolvedConfi
|
|
|
27
33
|
* preset's own variable is read only at the preset's origin. Every provider needs a context size, and the issue
|
|
28
34
|
* of a missing one names what to set (`reportMissingContext`). A `claude-code` provider in use gets its
|
|
29
35
|
* command as it gets its key: `QUORUM_CLAUDE_CODE_COMMAND`, else the config's, else `claude` in an absolute
|
|
30
|
-
* entry of `PATH`, found or refused here, and its billing warning.
|
|
36
|
+
* entry of `PATH`, found or refused here, and its billing warning. The review's limits, `maxReviewTokens` and
|
|
37
|
+
* `reviewTimeoutMs`, come from `QUORUM_MAX_REVIEW_TOKENS` and `QUORUM_REVIEW_TIMEOUT_MS`, else from the config,
|
|
38
|
+
* and are kept only when one of them sets them. A resolved config is returned as it is. The
|
|
31
39
|
* input must already have passed a config schema. `options.selection`, when given, names the profiles that
|
|
32
40
|
* run, over `QUORUM_PROFILES`, which is still checked; its ids are checked before anything is resolved.
|
|
33
41
|
*
|
package/dist/config/resolve.js
CHANGED
|
@@ -370,7 +370,9 @@ function bindRoles(roles, names) {
|
|
|
370
370
|
* preset's own variable is read only at the preset's origin. Every provider needs a context size, and the issue
|
|
371
371
|
* of a missing one names what to set (`reportMissingContext`). A `claude-code` provider in use gets its
|
|
372
372
|
* command as it gets its key: `QUORUM_CLAUDE_CODE_COMMAND`, else the config's, else `claude` in an absolute
|
|
373
|
-
* entry of `PATH`, found or refused here, and its billing warning.
|
|
373
|
+
* entry of `PATH`, found or refused here, and its billing warning. The review's limits, `maxReviewTokens` and
|
|
374
|
+
* `reviewTimeoutMs`, come from `QUORUM_MAX_REVIEW_TOKENS` and `QUORUM_REVIEW_TIMEOUT_MS`, else from the config,
|
|
375
|
+
* and are kept only when one of them sets them. A resolved config is returned as it is. The
|
|
374
376
|
* input must already have passed a config schema. `options.selection`, when given, names the profiles that
|
|
375
377
|
* run, over `QUORUM_PROFILES`, which is still checked; its ids are checked before anything is resolved.
|
|
376
378
|
*
|
|
@@ -443,6 +445,9 @@ export function resolveConfig(input, options) {
|
|
|
443
445
|
throw new ConfigError(issues);
|
|
444
446
|
const concurrency = own(input, 'concurrency');
|
|
445
447
|
const maxFindings = own(input, 'maxFindings');
|
|
448
|
+
const maxReviewTokens = own(layer, 'maxReviewTokens') ?? own(input, 'maxReviewTokens');
|
|
449
|
+
const reviewTimeoutMs = own(layer, 'reviewTimeoutMs') ?? own(input, 'reviewTimeoutMs');
|
|
450
|
+
const exclude = own(input, 'exclude');
|
|
446
451
|
const resolved = Object.freeze({
|
|
447
452
|
providers: deepFreeze(Object.fromEntries(checked.providers)),
|
|
448
453
|
profiles: Object.freeze([...profiles.profiles]),
|
|
@@ -452,6 +457,17 @@ export function resolveConfig(input, options) {
|
|
|
452
457
|
...maxFindings === undefined
|
|
453
458
|
? {}
|
|
454
459
|
: { maxFindings },
|
|
460
|
+
...maxReviewTokens === undefined
|
|
461
|
+
? {}
|
|
462
|
+
: { maxReviewTokens },
|
|
463
|
+
...reviewTimeoutMs === undefined
|
|
464
|
+
? {}
|
|
465
|
+
: { reviewTimeoutMs },
|
|
466
|
+
...exclude === undefined || exclude.length === 0
|
|
467
|
+
? {}
|
|
468
|
+
: {
|
|
469
|
+
exclude: Object.freeze([...exclude]),
|
|
470
|
+
},
|
|
455
471
|
warnings: Object.freeze([
|
|
456
472
|
...layer.warnings,
|
|
457
473
|
...checked.warnings,
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -3,9 +3,33 @@ import type { ConfigIssue } from '../core/errors.ts';
|
|
|
3
3
|
import type { JsonSchema, Provider } from '../core/ports.ts';
|
|
4
4
|
/** Whether `value` implements `Provider` as a code config can hand one over: an object whose `complete` is a function. */
|
|
5
5
|
export declare function isProvider(value: unknown): value is Provider;
|
|
6
|
+
/** The facts a provider object states of its calls, as the port names them. */
|
|
7
|
+
interface StatedFacts {
|
|
8
|
+
readonly timeoutMs?: number;
|
|
9
|
+
readonly retries?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The facts `provider` states, each read as own data, so a getter never runs and an inherited property
|
|
13
|
+
* or a proxy that throws states nothing: `stated` holds those that pass their check, and `problems` the
|
|
14
|
+
* field and wording of each that does not. A value is never quoted.
|
|
15
|
+
*/
|
|
16
|
+
export declare function statedFacts(provider: unknown): {
|
|
17
|
+
readonly stated: StatedFacts;
|
|
18
|
+
readonly problems: ReadonlyArray<{
|
|
19
|
+
readonly field: keyof StatedFacts;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
}>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The `worstCase` a provider states, as own data: a function, else undefined. It is no fact of `FACTS`: a
|
|
25
|
+
* function is no number to check or to hash, so the fingerprint and the printed config never see it, and a
|
|
26
|
+
* value that is no function is an issue of `providerObject` and is never read here.
|
|
27
|
+
*/
|
|
28
|
+
export declare function statedWorstCase(provider: unknown): Provider['worstCase'];
|
|
6
29
|
/**
|
|
7
30
|
* `entry` named `id`, the config's key for it, when it is a snapshot the schema made of a provider object: a
|
|
8
|
-
* copy that holds `id` as well, built from the snapshot's own data
|
|
31
|
+
* copy that holds `id` as well, built from the snapshot's own data, the facts and the `worstCase` it states
|
|
32
|
+
* included. Anything else is returned as it is.
|
|
9
33
|
*/
|
|
10
34
|
export declare function nameSnapshot(id: string, entry: unknown): unknown;
|
|
11
35
|
/**
|
|
@@ -75,6 +99,8 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
75
99
|
native: "native";
|
|
76
100
|
inline: "inline";
|
|
77
101
|
}>>;
|
|
102
|
+
timeoutMs: z.ZodOptional<z.ZodInt>;
|
|
103
|
+
retries: z.ZodOptional<z.ZodInt>;
|
|
78
104
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
79
105
|
}, z.core.$strict>>>;
|
|
80
106
|
roles: z.ZodOptional<z.ZodObject<{
|
|
@@ -83,6 +109,9 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
83
109
|
}, z.core.$strict>>;
|
|
84
110
|
concurrency: z.ZodOptional<z.ZodInt>;
|
|
85
111
|
maxFindings: z.ZodOptional<z.ZodInt>;
|
|
112
|
+
maxReviewTokens: z.ZodOptional<z.ZodInt>;
|
|
113
|
+
reviewTimeoutMs: z.ZodOptional<z.ZodInt>;
|
|
114
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
86
115
|
profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
87
116
|
extends: z.ZodOptional<z.ZodEnum<{
|
|
88
117
|
[x: string]: string;
|
|
@@ -143,7 +172,55 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
143
172
|
export declare const configCodeSchema: z.ZodObject<{
|
|
144
173
|
$schema: z.ZodOptional<z.ZodString>;
|
|
145
174
|
version: z.ZodOptional<z.ZodLiteral<1>>;
|
|
146
|
-
providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<Provider, Provider>, z.ZodTransform<Provider, Provider>>, z.
|
|
175
|
+
providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<Provider, Provider>, z.ZodTransform<Provider, Provider>>, z.ZodPipe<z.ZodCustom<{
|
|
176
|
+
apiKey?: string | undefined;
|
|
177
|
+
command?: string | undefined;
|
|
178
|
+
preset?: "anthropic" | "gemini" | "ollama" | "ollama-cloud" | "lmstudio" | "llamacpp" | "vllm" | "openai" | "azure-openai" | "openrouter" | "groq" | "mistral" | "deepseek" | "together" | "fireworks" | "xai" | undefined;
|
|
179
|
+
protocol?: "openai-compatible" | "anthropic" | "gemini" | "ollama" | "claude-code" | undefined;
|
|
180
|
+
baseUrl?: string | undefined;
|
|
181
|
+
model?: string | undefined;
|
|
182
|
+
contextTokens?: number | undefined;
|
|
183
|
+
apiKeyEnv?: string | undefined;
|
|
184
|
+
auth?: "bearer" | "x-api-key" | "none" | "inherit" | "login" | "api-key" | {
|
|
185
|
+
header: string;
|
|
186
|
+
prefix?: string | undefined;
|
|
187
|
+
} | undefined;
|
|
188
|
+
headers?: Record<string, string> | undefined;
|
|
189
|
+
query?: Record<string, string> | undefined;
|
|
190
|
+
extraBody?: Record<string, z.core.util.JSONType> | undefined;
|
|
191
|
+
structuredOutput?: "prompt" | "json" | "schema" | undefined;
|
|
192
|
+
temperature?: number | null | undefined;
|
|
193
|
+
maxTokens?: number | undefined;
|
|
194
|
+
maxTokensField?: "max_tokens" | "max_completion_tokens" | undefined;
|
|
195
|
+
systemPrompt?: "native" | "inline" | undefined;
|
|
196
|
+
timeoutMs?: number | undefined;
|
|
197
|
+
retries?: number | undefined;
|
|
198
|
+
args?: string[] | undefined;
|
|
199
|
+
}, {
|
|
200
|
+
apiKey?: string | undefined;
|
|
201
|
+
command?: string | undefined;
|
|
202
|
+
preset?: "anthropic" | "gemini" | "ollama" | "ollama-cloud" | "lmstudio" | "llamacpp" | "vllm" | "openai" | "azure-openai" | "openrouter" | "groq" | "mistral" | "deepseek" | "together" | "fireworks" | "xai" | undefined;
|
|
203
|
+
protocol?: "openai-compatible" | "anthropic" | "gemini" | "ollama" | "claude-code" | undefined;
|
|
204
|
+
baseUrl?: string | undefined;
|
|
205
|
+
model?: string | undefined;
|
|
206
|
+
contextTokens?: number | undefined;
|
|
207
|
+
apiKeyEnv?: string | undefined;
|
|
208
|
+
auth?: "bearer" | "x-api-key" | "none" | "inherit" | "login" | "api-key" | {
|
|
209
|
+
header: string;
|
|
210
|
+
prefix?: string | undefined;
|
|
211
|
+
} | undefined;
|
|
212
|
+
headers?: Record<string, string> | undefined;
|
|
213
|
+
query?: Record<string, string> | undefined;
|
|
214
|
+
extraBody?: Record<string, z.core.util.JSONType> | undefined;
|
|
215
|
+
structuredOutput?: "prompt" | "json" | "schema" | undefined;
|
|
216
|
+
temperature?: number | null | undefined;
|
|
217
|
+
maxTokens?: number | undefined;
|
|
218
|
+
maxTokensField?: "max_tokens" | "max_completion_tokens" | undefined;
|
|
219
|
+
systemPrompt?: "native" | "inline" | undefined;
|
|
220
|
+
timeoutMs?: number | undefined;
|
|
221
|
+
retries?: number | undefined;
|
|
222
|
+
args?: string[] | undefined;
|
|
223
|
+
}>, z.ZodObject<{
|
|
147
224
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
148
225
|
command: z.ZodOptional<z.ZodString>;
|
|
149
226
|
preset: z.ZodOptional<z.ZodEnum<{
|
|
@@ -204,14 +281,19 @@ export declare const configCodeSchema: z.ZodObject<{
|
|
|
204
281
|
native: "native";
|
|
205
282
|
inline: "inline";
|
|
206
283
|
}>>;
|
|
284
|
+
timeoutMs: z.ZodOptional<z.ZodInt>;
|
|
285
|
+
retries: z.ZodOptional<z.ZodInt>;
|
|
207
286
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
208
|
-
}, z.core.$strict
|
|
287
|
+
}, z.core.$strict>>]>>>;
|
|
209
288
|
roles: z.ZodOptional<z.ZodObject<{
|
|
210
289
|
research: z.ZodOptional<z.ZodString>;
|
|
211
290
|
voter: z.ZodOptional<z.ZodString>;
|
|
212
291
|
}, z.core.$strict>>;
|
|
213
292
|
concurrency: z.ZodOptional<z.ZodInt>;
|
|
214
293
|
maxFindings: z.ZodOptional<z.ZodInt>;
|
|
294
|
+
maxReviewTokens: z.ZodOptional<z.ZodInt>;
|
|
295
|
+
reviewTimeoutMs: z.ZodOptional<z.ZodInt>;
|
|
296
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
215
297
|
profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
216
298
|
extends: z.ZodOptional<z.ZodEnum<{
|
|
217
299
|
[x: string]: string;
|
|
@@ -272,7 +354,55 @@ export declare const configCodeSchema: z.ZodObject<{
|
|
|
272
354
|
export declare const configInputSchema: z.ZodObject<{
|
|
273
355
|
$schema: z.ZodOptional<z.ZodString>;
|
|
274
356
|
version: z.ZodOptional<z.ZodLiteral<1>>;
|
|
275
|
-
providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<Provider, Provider>, z.ZodTransform<Provider, Provider>>, z.
|
|
357
|
+
providers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodPipe<z.ZodCustom<Provider, Provider>, z.ZodTransform<Provider, Provider>>, z.ZodPipe<z.ZodCustom<{
|
|
358
|
+
apiKey?: string | undefined;
|
|
359
|
+
command?: string | undefined;
|
|
360
|
+
preset?: "anthropic" | "gemini" | "ollama" | "ollama-cloud" | "lmstudio" | "llamacpp" | "vllm" | "openai" | "azure-openai" | "openrouter" | "groq" | "mistral" | "deepseek" | "together" | "fireworks" | "xai" | undefined;
|
|
361
|
+
protocol?: "openai-compatible" | "anthropic" | "gemini" | "ollama" | "claude-code" | undefined;
|
|
362
|
+
baseUrl?: string | undefined;
|
|
363
|
+
model?: string | undefined;
|
|
364
|
+
contextTokens?: number | undefined;
|
|
365
|
+
apiKeyEnv?: string | undefined;
|
|
366
|
+
auth?: "bearer" | "x-api-key" | "none" | "inherit" | "login" | "api-key" | {
|
|
367
|
+
header: string;
|
|
368
|
+
prefix?: string | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
headers?: Record<string, string> | undefined;
|
|
371
|
+
query?: Record<string, string> | undefined;
|
|
372
|
+
extraBody?: Record<string, z.core.util.JSONType> | undefined;
|
|
373
|
+
structuredOutput?: "prompt" | "json" | "schema" | undefined;
|
|
374
|
+
temperature?: number | null | undefined;
|
|
375
|
+
maxTokens?: number | undefined;
|
|
376
|
+
maxTokensField?: "max_tokens" | "max_completion_tokens" | undefined;
|
|
377
|
+
systemPrompt?: "native" | "inline" | undefined;
|
|
378
|
+
timeoutMs?: number | undefined;
|
|
379
|
+
retries?: number | undefined;
|
|
380
|
+
args?: string[] | undefined;
|
|
381
|
+
}, {
|
|
382
|
+
apiKey?: string | undefined;
|
|
383
|
+
command?: string | undefined;
|
|
384
|
+
preset?: "anthropic" | "gemini" | "ollama" | "ollama-cloud" | "lmstudio" | "llamacpp" | "vllm" | "openai" | "azure-openai" | "openrouter" | "groq" | "mistral" | "deepseek" | "together" | "fireworks" | "xai" | undefined;
|
|
385
|
+
protocol?: "openai-compatible" | "anthropic" | "gemini" | "ollama" | "claude-code" | undefined;
|
|
386
|
+
baseUrl?: string | undefined;
|
|
387
|
+
model?: string | undefined;
|
|
388
|
+
contextTokens?: number | undefined;
|
|
389
|
+
apiKeyEnv?: string | undefined;
|
|
390
|
+
auth?: "bearer" | "x-api-key" | "none" | "inherit" | "login" | "api-key" | {
|
|
391
|
+
header: string;
|
|
392
|
+
prefix?: string | undefined;
|
|
393
|
+
} | undefined;
|
|
394
|
+
headers?: Record<string, string> | undefined;
|
|
395
|
+
query?: Record<string, string> | undefined;
|
|
396
|
+
extraBody?: Record<string, z.core.util.JSONType> | undefined;
|
|
397
|
+
structuredOutput?: "prompt" | "json" | "schema" | undefined;
|
|
398
|
+
temperature?: number | null | undefined;
|
|
399
|
+
maxTokens?: number | undefined;
|
|
400
|
+
maxTokensField?: "max_tokens" | "max_completion_tokens" | undefined;
|
|
401
|
+
systemPrompt?: "native" | "inline" | undefined;
|
|
402
|
+
timeoutMs?: number | undefined;
|
|
403
|
+
retries?: number | undefined;
|
|
404
|
+
args?: string[] | undefined;
|
|
405
|
+
}>, z.ZodObject<{
|
|
276
406
|
apiKey: z.ZodOptional<z.ZodString>;
|
|
277
407
|
command: z.ZodOptional<z.ZodString>;
|
|
278
408
|
preset: z.ZodOptional<z.ZodEnum<{
|
|
@@ -333,14 +463,19 @@ export declare const configInputSchema: z.ZodObject<{
|
|
|
333
463
|
native: "native";
|
|
334
464
|
inline: "inline";
|
|
335
465
|
}>>;
|
|
466
|
+
timeoutMs: z.ZodOptional<z.ZodInt>;
|
|
467
|
+
retries: z.ZodOptional<z.ZodInt>;
|
|
336
468
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
337
|
-
}, z.core.$strict
|
|
469
|
+
}, z.core.$strict>>]>>>;
|
|
338
470
|
roles: z.ZodOptional<z.ZodObject<{
|
|
339
471
|
research: z.ZodOptional<z.ZodString>;
|
|
340
472
|
voter: z.ZodOptional<z.ZodString>;
|
|
341
473
|
}, z.core.$strict>>;
|
|
342
474
|
concurrency: z.ZodOptional<z.ZodInt>;
|
|
343
475
|
maxFindings: z.ZodOptional<z.ZodInt>;
|
|
476
|
+
maxReviewTokens: z.ZodOptional<z.ZodInt>;
|
|
477
|
+
reviewTimeoutMs: z.ZodOptional<z.ZodInt>;
|
|
478
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
344
479
|
profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
345
480
|
extends: z.ZodOptional<z.ZodEnum<{
|
|
346
481
|
[x: string]: string;
|
|
@@ -439,3 +574,4 @@ export declare function parseConfig<T>(schema: z.ZodType<T>, value: unknown, pre
|
|
|
439
574
|
* secret pasted in the wrong place.
|
|
440
575
|
*/
|
|
441
576
|
export declare function unknownName(path: string, kind: 'provider' | 'profile', name: string, defined: readonly string[]): ConfigIssue;
|
|
577
|
+
export {};
|