@tobi-or-not/quorum 0.1.0 → 0.2.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.
Files changed (40) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +4 -0
  3. package/dist/cli/bin.js +9 -1
  4. package/dist/cli/main.js +49 -12
  5. package/dist/cli/print-config.js +38 -9
  6. package/dist/cli/render.js +18 -6
  7. package/dist/config/claude-code.js +42 -11
  8. package/dist/config/env.js +135 -32
  9. package/dist/config/from-config.js +43 -9
  10. package/dist/config/load.js +163 -37
  11. package/dist/config/profiles.js +87 -20
  12. package/dist/config/resolve.js +194 -47
  13. package/dist/config/schema.js +98 -23
  14. package/dist/core/diff.js +65 -17
  15. package/dist/core/errors.js +14 -5
  16. package/dist/core/flags.js +30 -6
  17. package/dist/core/output.js +49 -13
  18. package/dist/core/policy.js +6 -2
  19. package/dist/core/profile.js +42 -15
  20. package/dist/core/prompts.js +20 -5
  21. package/dist/core/quorum.js +128 -33
  22. package/dist/core/sanitize.js +3 -1
  23. package/dist/core/stages/context.js +30 -5
  24. package/dist/core/stages/panel.js +55 -9
  25. package/dist/core/stages/research.js +13 -3
  26. package/dist/core/verify.js +6 -2
  27. package/dist/index.js +5 -1
  28. package/dist/providers/anthropic.js +28 -5
  29. package/dist/providers/build.js +57 -16
  30. package/dist/providers/claude-code.js +206 -51
  31. package/dist/providers/gemini.js +61 -14
  32. package/dist/providers/http.js +32 -9
  33. package/dist/providers/messages.js +14 -2
  34. package/dist/providers/ollama.js +31 -8
  35. package/dist/providers/openai-compatible.js +51 -15
  36. package/dist/providers/options.js +120 -40
  37. package/dist/providers/presets.js +143 -16
  38. package/dist/providers/reply.js +15 -5
  39. package/dist/providers/size.js +11 -3
  40. package/package.json +5 -4
@@ -31,8 +31,11 @@ function isHttpUrlWithHost(baseUrl) {
31
31
  * fragment is refused, since the endpoint's path is appended to the base URL.
32
32
  */
33
33
  export function baseUrlIssues(path, baseUrl) {
34
- if (!isHttpUrlWithHost(baseUrl))
35
- return [{ path, message: 'must be an http:// or https:// URL with a host' }];
34
+ if (!isHttpUrlWithHost(baseUrl)) {
35
+ return [
36
+ { path, message: 'must be an http:// or https:// URL with a host' },
37
+ ];
38
+ }
36
39
  const url = new URL(baseUrl);
37
40
  const issues = [];
38
41
  if (url.username !== '' || url.password !== '')
@@ -64,10 +67,17 @@ function isJsonValue(value) {
64
67
  function authIssues(id, auth, apiKey, fixedHeaders) {
65
68
  if (auth === 'bearer' || auth === 'x-api-key')
66
69
  return [];
67
- if (auth === 'none')
68
- return apiKey ? [{ path: `${id}.apiKey`, message: 'is set, but auth is none, so it would never be sent' }] : [];
70
+ if (auth === 'none') {
71
+ return apiKey
72
+ ? [
73
+ { path: `${id}.apiKey`, message: 'is set, but auth is none, so it would never be sent' },
74
+ ]
75
+ : [];
76
+ }
69
77
  if (!isRecord(auth) || typeof auth.header !== 'string' || (auth.prefix !== undefined && typeof auth.prefix !== 'string')) {
70
- return [{ path: `${id}.auth`, message: 'must be bearer, x-api-key, none or { header, prefix }' }];
78
+ return [
79
+ { path: `${id}.auth`, message: 'must be bearer, x-api-key, none or { header, prefix }' },
80
+ ];
71
81
  }
72
82
  const issues = [];
73
83
  if (!HEADER_NAME.test(auth.header))
@@ -85,19 +95,38 @@ function headerIssues(id, headers, keyHeader, fixedHeaders) {
85
95
  const seen = new Set();
86
96
  return Object.entries(headers).flatMap(([name, value]) => {
87
97
  const path = `${id}.${issuePath(['headers', name])}`;
88
- if (!HEADER_NAME.test(name))
89
- return [{ path, message: 'must be an HTTP header name' }];
98
+ if (!HEADER_NAME.test(name)) {
99
+ return [
100
+ { path, message: 'must be an HTTP header name' },
101
+ ];
102
+ }
90
103
  const lower = name.toLowerCase();
91
- if (RESERVED_HEADERS.has(lower))
92
- return [{ path, message: 'must not be content-type, content-length or host' }];
93
- if (lower === keyHeader)
94
- return [{ path, message: 'is the header that carries the key: set apiKey instead' }];
95
- if (fixedHeaders.includes(lower))
96
- return [{ path, message: FIXED_HEADER }];
97
- if (seen.has(lower))
98
- return [{ path, message: 'repeats a header name in another letter case' }];
104
+ if (RESERVED_HEADERS.has(lower)) {
105
+ return [
106
+ { path, message: 'must not be content-type, content-length or host' },
107
+ ];
108
+ }
109
+ if (lower === keyHeader) {
110
+ return [
111
+ { path, message: 'is the header that carries the key: set apiKey instead' },
112
+ ];
113
+ }
114
+ if (fixedHeaders.includes(lower)) {
115
+ return [
116
+ { path, message: FIXED_HEADER },
117
+ ];
118
+ }
119
+ if (seen.has(lower)) {
120
+ return [
121
+ { path, message: 'repeats a header name in another letter case' },
122
+ ];
123
+ }
99
124
  seen.add(lower);
100
- return typeof value === 'string' && !NOT_PRINTABLE_ASCII.test(value) ? [] : [{ path, message: 'must be a string of printable ASCII characters' }];
125
+ return typeof value === 'string' && !NOT_PRINTABLE_ASCII.test(value)
126
+ ? []
127
+ : [
128
+ { path, message: 'must be a string of printable ASCII characters' },
129
+ ];
101
130
  });
102
131
  }
103
132
  /**
@@ -115,7 +144,11 @@ export function bodyKeyForm(key) {
115
144
  * the adapter's. The message writes the canonical spelling, a constant of the adapter, never the key it was given.
116
145
  */
117
146
  export function spellingIssues(id, key, canonical) {
118
- return key === canonical ? [] : [{ path: `${id}.${issuePath(['extraBody', key])}`, message: `must be written ${canonical}` }];
147
+ return key === canonical
148
+ ? []
149
+ : [
150
+ { path: `${id}.${issuePath(['extraBody', key])}`, message: `must be written ${canonical}` },
151
+ ];
119
152
  }
120
153
  /**
121
154
  * The problems of the `extraBody` fields at `limits`, the paths below `trail` that set the reply limit, one per
@@ -124,9 +157,14 @@ export function spellingIssues(id, key, canonical) {
124
157
  function replyLimitIssues(id, body, limits, trail = []) {
125
158
  return Object.entries(body).flatMap(([key, value]) => {
126
159
  const below = limits.filter(([head]) => bodyKeyForm(head) === bodyKeyForm(key)).map(path => path.slice(1));
127
- if (below.some(path => path.length === 0))
128
- return [{ path: `${id}.${issuePath(['extraBody', ...trail, key])}`, message: 'sets the reply limit: use maxTokens' }];
129
- return isRecord(value) && below.length > 0 ? replyLimitIssues(id, value, below, [...trail, key]) : [];
160
+ if (below.some(path => path.length === 0)) {
161
+ return [
162
+ { path: `${id}.${issuePath(['extraBody', ...trail, key])}`, message: 'sets the reply limit: use maxTokens' },
163
+ ];
164
+ }
165
+ return isRecord(value) && below.length > 0
166
+ ? replyLimitIssues(id, value, below, [...trail, key])
167
+ : [];
130
168
  });
131
169
  }
132
170
  /**
@@ -139,11 +177,21 @@ function extraBodyIssues(id, extraBody, rules) {
139
177
  const keyIssues = Object.keys(extraBody).flatMap((key) => {
140
178
  const path = `${id}.${issuePath(['extraBody', key])}`;
141
179
  const form = bodyKeyForm(key);
142
- if (reserved.has(form))
143
- return [{ path, message: 'is written by the adapter and cannot be replaced' }];
144
- return tools.has(form) ? [{ path, message: 'offers the model a tool, which quorum never does' }] : [];
180
+ if (reserved.has(form)) {
181
+ return [
182
+ { path, message: 'is written by the adapter and cannot be replaced' },
183
+ ];
184
+ }
185
+ return tools.has(form)
186
+ ? [
187
+ { path, message: 'offers the model a tool, which quorum never does' },
188
+ ]
189
+ : [];
145
190
  });
146
- return [...keyIssues, ...replyLimitIssues(id, extraBody, rules.replyLimitPaths)];
191
+ return [
192
+ ...keyIssues,
193
+ ...replyLimitIssues(id, extraBody, rules.replyLimitPaths),
194
+ ];
147
195
  }
148
196
  /** The query entries whose value is the key, which travels only in the header `auth` names. No message repeats the value. */
149
197
  function queryKeyIssues(id, query, apiKey) {
@@ -153,7 +201,9 @@ function queryKeyIssues(id, query, apiKey) {
153
201
  }
154
202
  /** The words of a list as a message names them: commas between them, and the conjunction before the last. */
155
203
  export function wordList(words, conjunction = 'or') {
156
- return words.length < 2 ? words.join('') : `${words.slice(0, -1).join(', ')} ${conjunction} ${words.at(-1)}`;
204
+ return words.length < 2
205
+ ? words.join('')
206
+ : `${words.slice(0, -1).join(', ')} ${conjunction} ${words.at(-1)}`;
157
207
  }
158
208
  /** Whether `value` is a whole number of tokens, at least 1 and safe to count with. */
159
209
  function isTokenCount(value) {
@@ -167,16 +217,24 @@ function isTokenCount(value) {
167
217
  */
168
218
  export function contextTokensIssues(id, contextTokens, maxTokens, templateTokens = TEMPLATE_TOKENS) {
169
219
  const path = `${id}.contextTokens`;
170
- if (contextTokens === undefined)
171
- return [{ path, message: CONTEXT_REQUIRED }];
172
- if (!isTokenCount(contextTokens))
173
- return [{ path, message: 'must be a whole number of at least 1' }];
220
+ if (contextTokens === undefined) {
221
+ return [
222
+ { path, message: CONTEXT_REQUIRED },
223
+ ];
224
+ }
225
+ if (!isTokenCount(contextTokens)) {
226
+ return [
227
+ { path, message: 'must be a whole number of at least 1' },
228
+ ];
229
+ }
174
230
  if (maxTokens !== undefined && !isTokenCount(maxTokens))
175
231
  return [];
176
232
  const reply = maxTokens ?? DEFAULT_REPLY_TOKENS;
177
233
  if (contextTokens > reply + templateTokens)
178
234
  return [];
179
- return [{ path, message: `must be more than ${reply + templateTokens}, the ${reply} tokens of the reply budget and ${templateTokens} for the chat template` }];
235
+ return [
236
+ { path, message: `must be more than ${reply + templateTokens}, the ${reply} tokens of the reply budget and ${templateTokens} for the chat template` },
237
+ ];
180
238
  }
181
239
  /**
182
240
  * The problems of the options every HTTP adapter shares, under the rules the adapter declares. No
@@ -186,16 +244,22 @@ export function httpOptionIssues(options, rules) {
186
244
  const { id, baseUrl, apiKey, headers, query, extraBody, temperature, maxTokens, contextTokens, systemPrompt, structuredOutput } = options;
187
245
  const { auth, structuredOutputs } = rules;
188
246
  const fixedHeaders = rules.fixedHeaders.map(name => name.toLowerCase());
189
- const issues = [...baseUrlIssues(`${id}.baseUrl`, baseUrl)];
247
+ const issues = [
248
+ ...baseUrlIssues(`${id}.baseUrl`, baseUrl),
249
+ ];
190
250
  if (apiKey !== undefined && NOT_VISIBLE_ASCII.test(apiKey)) {
191
251
  issues.push({ path: `${id}.apiKey`, message: 'must only contain visible ASCII characters, which an HTTP header can carry' });
192
252
  }
193
253
  const authProblems = authIssues(id, auth, apiKey, fixedHeaders);
194
254
  issues.push(...authProblems);
195
- if (headers !== undefined && !isPlainRecord(headers))
255
+ if (headers !== undefined && !isPlainRecord(headers)) {
196
256
  issues.push({ path: `${id}.headers`, message: 'must map names to strings' });
197
- else if (headers !== undefined)
198
- issues.push(...headerIssues(id, headers, authProblems.length === 0 ? keyHeaderName(auth) : undefined, fixedHeaders));
257
+ }
258
+ else if (headers !== undefined) {
259
+ issues.push(...headerIssues(id, headers, authProblems.length === 0
260
+ ? keyHeaderName(auth)
261
+ : undefined, fixedHeaders));
262
+ }
199
263
  if (query !== undefined && (!isPlainRecord(query) || !Object.values(query).every(value => typeof value === 'string'))) {
200
264
  issues.push({ path: `${id}.query`, message: 'must map names to strings' });
201
265
  }
@@ -230,7 +294,10 @@ export function httpOptionIssues(options, rules) {
230
294
  * @throws ConfigError with the problems of `httpOptionIssues`, then `adapterIssues`, before any request
231
295
  */
232
296
  export function prepareHttp(options, rules, path, adapterIssues = []) {
233
- const issues = [...httpOptionIssues(options, rules), ...adapterIssues];
297
+ const issues = [
298
+ ...httpOptionIssues(options, rules),
299
+ ...adapterIssues,
300
+ ];
234
301
  if (issues.length > 0)
235
302
  throw new ConfigError(issues);
236
303
  const { baseUrl, apiKey, headers, query, extraBody } = options;
@@ -238,15 +305,24 @@ export function prepareHttp(options, rules, path, adapterIssues = []) {
238
305
  url: endpointUrl(baseUrl, path, query),
239
306
  headers: requestHeaders(rules.auth, apiKey, headers),
240
307
  redact: redactionsOf(baseUrl, apiKey, headers),
241
- extraBody: extraBody === undefined ? undefined : structuredClone(extraBody),
308
+ extraBody: extraBody === undefined
309
+ ? undefined
310
+ : structuredClone(extraBody),
242
311
  };
243
312
  }
244
313
  /** The headers a provider sends besides the content type: its own, then its key as `auth` says. Names are lower-cased. */
245
314
  export function requestHeaders(auth, apiKey, headers = {}) {
246
- const result = Object.fromEntries(Object.entries(headers).map(([name, value]) => [name.toLowerCase(), value]));
315
+ const result = Object.fromEntries(Object.entries(headers).map(([name, value]) => [
316
+ name.toLowerCase(),
317
+ value,
318
+ ]));
247
319
  const name = keyHeaderName(auth);
248
320
  if (name !== undefined && apiKey) {
249
- result[name] = auth === 'bearer' ? `Bearer ${apiKey}` : typeof auth === 'object' ? `${auth.prefix ?? ''}${apiKey}` : apiKey;
321
+ result[name] = auth === 'bearer'
322
+ ? `Bearer ${apiKey}`
323
+ : typeof auth === 'object'
324
+ ? `${auth.prefix ?? ''}${apiKey}`
325
+ : apiKey;
250
326
  }
251
327
  return result;
252
328
  }
@@ -257,13 +333,17 @@ export function mergeBody(body, extra) {
257
333
  const merged = { ...body };
258
334
  for (const [key, value] of Object.entries(extra)) {
259
335
  const current = merged[key];
260
- merged[key] = isRecord(current) && isRecord(value) ? mergeBody(current, value) : value;
336
+ merged[key] = isRecord(current) && isRecord(value)
337
+ ? mergeBody(current, value)
338
+ : value;
261
339
  }
262
340
  return merged;
263
341
  }
264
342
  /** `fields`, or undefined when every one of them is undefined, so the body leaves out an object that would be empty. */
265
343
  export function unlessEmpty(fields) {
266
- return Object.values(fields).every(value => value === undefined) ? undefined : fields;
344
+ return Object.values(fields).every(value => value === undefined)
345
+ ? undefined
346
+ : fields;
267
347
  }
268
348
  /** Whether `value` is a non-null object that is not an array. */
269
349
  export function isRecord(value) {
@@ -16,15 +16,71 @@ function deepFreeze(value) {
16
16
  * vendor documents: OpenAI, Azure, Groq and xAI deprecate `max_tokens`.
17
17
  */
18
18
  export const presets = deepFreeze({
19
- ollama: { protocol: 'ollama', baseUrl: 'http://localhost:11434', auth: 'bearer', structuredOutput: 'json', temperature: 0, toolModels: [] },
20
- 'ollama-cloud': { protocol: 'ollama', baseUrl: 'https://ollama.com', auth: 'bearer', apiKeyEnv: 'OLLAMA_API_KEY', structuredOutput: 'json', temperature: 0, toolModels: [] },
21
- lmstudio: { protocol: 'openai-compatible', baseUrl: 'http://localhost:1234/v1', auth: 'bearer', structuredOutput: 'schema', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
22
- llamacpp: { protocol: 'openai-compatible', baseUrl: 'http://127.0.0.1:9931/v1', auth: 'bearer', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
23
- vllm: { protocol: 'openai-compatible', baseUrl: 'http://localhost:8000/v1', auth: 'bearer', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
19
+ ollama: {
20
+ protocol: 'ollama',
21
+ baseUrl: 'http://localhost:11434',
22
+ auth: 'bearer',
23
+ structuredOutput: 'json',
24
+ temperature: 0,
25
+ toolModels: [],
26
+ },
27
+ 'ollama-cloud': {
28
+ protocol: 'ollama',
29
+ baseUrl: 'https://ollama.com',
30
+ auth: 'bearer',
31
+ apiKeyEnv: 'OLLAMA_API_KEY',
32
+ structuredOutput: 'json',
33
+ temperature: 0,
34
+ toolModels: [],
35
+ },
36
+ lmstudio: {
37
+ protocol: 'openai-compatible',
38
+ baseUrl: 'http://localhost:1234/v1',
39
+ auth: 'bearer',
40
+ structuredOutput: 'schema',
41
+ temperature: 0,
42
+ maxTokensField: 'max_tokens',
43
+ toolModels: [],
44
+ },
45
+ llamacpp: {
46
+ protocol: 'openai-compatible',
47
+ baseUrl: 'http://127.0.0.1:9931/v1',
48
+ auth: 'bearer',
49
+ structuredOutput: 'json',
50
+ temperature: 0,
51
+ maxTokensField: 'max_tokens',
52
+ toolModels: [],
53
+ },
54
+ vllm: {
55
+ protocol: 'openai-compatible',
56
+ baseUrl: 'http://localhost:8000/v1',
57
+ auth: 'bearer',
58
+ structuredOutput: 'json',
59
+ temperature: 0,
60
+ maxTokensField: 'max_tokens',
61
+ toolModels: [],
62
+ },
24
63
  // The search models search the web before every answer; the computer-use models drive a browser.
25
- openai: { protocol: 'openai-compatible', baseUrl: 'https://api.openai.com/v1', auth: 'bearer', apiKeyEnv: 'OPENAI_API_KEY', structuredOutput: 'json', temperature: null, maxTokensField: 'max_completion_tokens', toolModels: ['*search*', '*computer-use*'] },
64
+ openai: {
65
+ protocol: 'openai-compatible',
66
+ baseUrl: 'https://api.openai.com/v1',
67
+ auth: 'bearer',
68
+ apiKeyEnv: 'OPENAI_API_KEY',
69
+ structuredOutput: 'json',
70
+ temperature: null,
71
+ maxTokensField: 'max_completion_tokens',
72
+ toolModels: ['*search*', '*computer-use*'],
73
+ },
26
74
  // The base URL names the user's own resource, and the model ids are the user's own deployment names.
27
- 'azure-openai': { protocol: 'openai-compatible', auth: { header: 'api-key' }, apiKeyEnv: 'AZURE_OPENAI_API_KEY', structuredOutput: 'json', temperature: null, maxTokensField: 'max_completion_tokens', toolModels: [] },
75
+ 'azure-openai': {
76
+ protocol: 'openai-compatible',
77
+ auth: { header: 'api-key' },
78
+ apiKeyEnv: 'AZURE_OPENAI_API_KEY',
79
+ structuredOutput: 'json',
80
+ temperature: null,
81
+ maxTokensField: 'max_completion_tokens',
82
+ toolModels: [],
83
+ },
28
84
  // `:online` searches the web, a `@preset/` slug can hold tools, fusion searches and fetches, auto routes
29
85
  // to a pool that may hold search models, and Perplexity's models and any search model search by themselves.
30
86
  openrouter: {
@@ -35,18 +91,87 @@ export const presets = deepFreeze({
35
91
  structuredOutput: 'prompt',
36
92
  temperature: 0,
37
93
  maxTokensField: 'max_tokens',
38
- toolModels: ['*:online*', '*@preset/*', 'openrouter/fusion*', 'openrouter/auto*', 'perplexity/*', '*search*'],
94
+ toolModels: [
95
+ '*:online*',
96
+ '*@preset/*',
97
+ 'openrouter/fusion*',
98
+ 'openrouter/auto*',
99
+ 'perplexity/*',
100
+ '*search*',
101
+ ],
39
102
  },
40
103
  // gpt-oss runs its built-in web search and code execution by itself, which no parameter turns off, and
41
104
  // the compound models run tools by themselves.
42
- groq: { protocol: 'openai-compatible', baseUrl: 'https://api.groq.com/openai/v1', auth: 'bearer', apiKeyEnv: 'GROQ_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_completion_tokens', toolModels: ['openai/gpt-oss-*', 'groq/compound*', 'compound-beta*'] },
43
- mistral: { protocol: 'openai-compatible', baseUrl: 'https://api.mistral.ai/v1', auth: 'bearer', apiKeyEnv: 'MISTRAL_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
44
- deepseek: { protocol: 'openai-compatible', baseUrl: 'https://api.deepseek.com', auth: 'bearer', apiKeyEnv: 'DEEPSEEK_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
45
- together: { protocol: 'openai-compatible', baseUrl: 'https://api.together.ai/v1', auth: 'bearer', apiKeyEnv: 'TOGETHER_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
46
- fireworks: { protocol: 'openai-compatible', baseUrl: 'https://api.fireworks.ai/inference/v1', auth: 'bearer', apiKeyEnv: 'FIREWORKS_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_tokens', toolModels: [] },
105
+ groq: {
106
+ protocol: 'openai-compatible',
107
+ baseUrl: 'https://api.groq.com/openai/v1',
108
+ auth: 'bearer',
109
+ apiKeyEnv: 'GROQ_API_KEY',
110
+ structuredOutput: 'json',
111
+ temperature: 0,
112
+ maxTokensField: 'max_completion_tokens',
113
+ toolModels: ['openai/gpt-oss-*', 'groq/compound*', 'compound-beta*'],
114
+ },
115
+ mistral: {
116
+ protocol: 'openai-compatible',
117
+ baseUrl: 'https://api.mistral.ai/v1',
118
+ auth: 'bearer',
119
+ apiKeyEnv: 'MISTRAL_API_KEY',
120
+ structuredOutput: 'json',
121
+ temperature: 0,
122
+ maxTokensField: 'max_tokens',
123
+ toolModels: [],
124
+ },
125
+ deepseek: {
126
+ protocol: 'openai-compatible',
127
+ baseUrl: 'https://api.deepseek.com',
128
+ auth: 'bearer',
129
+ apiKeyEnv: 'DEEPSEEK_API_KEY',
130
+ structuredOutput: 'json',
131
+ temperature: 0,
132
+ maxTokensField: 'max_tokens',
133
+ toolModels: [],
134
+ },
135
+ together: {
136
+ protocol: 'openai-compatible',
137
+ baseUrl: 'https://api.together.ai/v1',
138
+ auth: 'bearer',
139
+ apiKeyEnv: 'TOGETHER_API_KEY',
140
+ structuredOutput: 'json',
141
+ temperature: 0,
142
+ maxTokensField: 'max_tokens',
143
+ toolModels: [],
144
+ },
145
+ fireworks: {
146
+ protocol: 'openai-compatible',
147
+ baseUrl: 'https://api.fireworks.ai/inference/v1',
148
+ auth: 'bearer',
149
+ apiKeyEnv: 'FIREWORKS_API_KEY',
150
+ structuredOutput: 'json',
151
+ temperature: 0,
152
+ maxTokensField: 'max_tokens',
153
+ toolModels: [],
154
+ },
47
155
  // The multi-agent model works only on the Responses API, where xAI runs its server-side tools.
48
- xai: { protocol: 'openai-compatible', baseUrl: 'https://api.x.ai/v1', auth: 'bearer', apiKeyEnv: 'XAI_API_KEY', structuredOutput: 'json', temperature: 0, maxTokensField: 'max_completion_tokens', toolModels: ['*multi-agent*'] },
49
- anthropic: { protocol: 'anthropic', baseUrl: 'https://api.anthropic.com', auth: 'bearer', apiKeyEnv: 'ANTHROPIC_API_KEY', structuredOutput: 'schema', temperature: null, toolModels: [] },
156
+ xai: {
157
+ protocol: 'openai-compatible',
158
+ baseUrl: 'https://api.x.ai/v1',
159
+ auth: 'bearer',
160
+ apiKeyEnv: 'XAI_API_KEY',
161
+ structuredOutput: 'json',
162
+ temperature: 0,
163
+ maxTokensField: 'max_completion_tokens',
164
+ toolModels: ['*multi-agent*'],
165
+ },
166
+ anthropic: {
167
+ protocol: 'anthropic',
168
+ baseUrl: 'https://api.anthropic.com',
169
+ auth: 'bearer',
170
+ apiKeyEnv: 'ANTHROPIC_API_KEY',
171
+ structuredOutput: 'schema',
172
+ temperature: null,
173
+ toolModels: [],
174
+ },
50
175
  // Deep Research and Antigravity are agents that search, fetch URLs and run code; the computer-use models drive a browser.
51
176
  gemini: {
52
177
  protocol: 'gemini',
@@ -64,5 +189,7 @@ export function withoutPrototype(entries) {
64
189
  }
65
190
  /** The preset a name names, or undefined: a name is looked up among the table's own keys only, never its prototype's, and the row is a copy that has no prototype either. */
66
191
  export function presetOf(name) {
67
- return typeof name === 'string' && Object.hasOwn(presets, name) ? withoutPrototype(Object.entries(presets[name])) : undefined;
192
+ return typeof name === 'string' && Object.hasOwn(presets, name)
193
+ ? withoutPrototype(Object.entries(presets[name]))
194
+ : undefined;
68
195
  }
@@ -16,7 +16,9 @@ function countOf(source, [first = '', ...others]) {
16
16
  return undefined;
17
17
  return others.reduce((sum, key) => {
18
18
  const count = source[key];
19
- return typeof count === 'number' ? sum + count : sum;
19
+ return typeof count === 'number'
20
+ ? sum + count
21
+ : sum;
20
22
  }, base);
21
23
  }
22
24
  /**
@@ -30,16 +32,24 @@ export function tokenUsage(source, inputKeys, outputKeys) {
30
32
  return undefined;
31
33
  const inputTokens = countOf(source, inputKeys);
32
34
  const outputTokens = countOf(source, outputKeys);
33
- return inputTokens === undefined || outputTokens === undefined ? undefined : { inputTokens, outputTokens };
35
+ return inputTokens === undefined || outputTokens === undefined
36
+ ? undefined
37
+ : { inputTokens, outputTokens };
34
38
  }
35
39
  /** The message of a reply that stopped for a reason the adapter does not accept, quoting the reason when it is a string. */
36
40
  export function endedEarly(reason, redact) {
37
- return typeof reason === 'string' ? `reply ended early: ${snippet(reason, MAX_REASON, redact)}` : 'reply ended early';
41
+ return typeof reason === 'string'
42
+ ? `reply ended early: ${snippet(reason, MAX_REASON, redact)}`
43
+ : 'reply ended early';
38
44
  }
39
45
  /** The string `text` of the parts `keep` accepts, joined, or undefined when `parts` is not an array or holds no such part. */
40
46
  export function joinedText(parts, keep) {
41
47
  if (!Array.isArray(parts))
42
48
  return undefined;
43
- const texts = parts.flatMap(part => isRecord(part) && typeof part.text === 'string' && keep(part) ? [part.text] : []);
44
- return texts.length === 0 ? undefined : texts.join('');
49
+ const texts = parts.flatMap(part => isRecord(part) && typeof part.text === 'string' && keep(part)
50
+ ? [part.text]
51
+ : []);
52
+ return texts.length === 0
53
+ ? undefined
54
+ : texts.join('');
45
55
  }
@@ -62,9 +62,13 @@ function normalizedLength(text) {
62
62
  bytes += 1;
63
63
  continue;
64
64
  }
65
- const low = index + 1 < text.length ? text.charCodeAt(index + 1) : 0;
65
+ const low = index + 1 < text.length
66
+ ? text.charCodeAt(index + 1)
67
+ : 0;
66
68
  const pair = unit >= 0xD800 && unit <= 0xDBFF && low >= 0xDC00 && low <= 0xDFFF;
67
- bytes += longestFormLength(pair ? 0x10000 + ((unit - 0xD800) << 10) + (low - 0xDC00) : unit);
69
+ bytes += longestFormLength(pair
70
+ ? 0x10000 + ((unit - 0xD800) << 10) + (low - 0xDC00)
71
+ : unit);
68
72
  if (pair)
69
73
  index++;
70
74
  }
@@ -82,7 +86,11 @@ function normalizedLength(text) {
82
86
  * prompt.
83
87
  */
84
88
  export function textTokens(shaped, output) {
85
- const texts = [shaped.system ?? '', ...shaped.messages.map(message => message.content), JSON.stringify(output.schema)];
89
+ const texts = [
90
+ shaped.system ?? '',
91
+ ...shaped.messages.map(message => message.content),
92
+ JSON.stringify(output.schema),
93
+ ];
86
94
  return texts.reduce((sum, text) => sum + normalizedLength(text), 0);
87
95
  }
88
96
  /**
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@tobi-or-not/quorum",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.2.0",
5
5
  "packageManager": "bun@1.4.4",
6
6
  "description": "Multi-agent code review for diffs: a model proposes candidate findings, then a panel of blind voters judges each before it's reported.",
7
+ "license": "Apache-2.0",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "https://github.com/this-is-tobi/quorum.git"
@@ -47,15 +48,15 @@
47
48
  "zod": "4.6.7"
48
49
  },
49
50
  "devDependencies": {
50
- "@antfu/eslint-config": "^9.2.0",
51
+ "@antfu/eslint-config": "^10.0.0",
51
52
  "@commitlint/cli": "^21.2.1",
52
53
  "@commitlint/config-conventional": "^21.2.0",
53
54
  "@types/node": "^26.0.0",
54
- "@vitest/coverage-istanbul": "^4.1.11",
55
+ "@vitest/coverage-istanbul": "^5.0.0",
55
56
  "eslint": "^10.8.0",
56
57
  "husky": "^9.1.7",
57
58
  "lint-staged": "^17.2.0",
58
59
  "typescript": "^5.9.0",
59
- "vitest": "^4.1.11"
60
+ "vitest": "^5.0.0"
60
61
  }
61
62
  }