clef-mcp 0.1.1 → 0.1.2

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/dist/index.d.ts CHANGED
@@ -426,6 +426,6 @@ declare function clefDecideOutputSchema(): z.ZodObject<{
426
426
  /** `state` cannot be size-checked inside zod (it is `unknown`), so it is validated separately. */
427
427
  declare function validateStateSize(state: unknown, limits: Limits): void;
428
428
 
429
- declare const VERSION = "0.1.1";
429
+ declare const VERSION = "0.1.2";
430
430
 
431
431
  export { CLEF_FLASH, type ClefConfig, type ClefDecideInput, type ClefDecideOutput, type ClefDecisionAnswer, ClefError, ClefErrorCode, type ClefQuestion, type ClefRuntime, type ClefServerDeps, DEFAULT_LIMITS, type DownloadProgress, type InstallModelResult, type Limits, LlamaCppRuntime, type LlamaCppRuntimeOptions, type LogLevel, type Logger, MODELS, type ModelManifest, type ModelSpec, type PlatformInfo, type ProbeResult, type QuantSpec, type QuestionType, type ResolvedBinary, type RunningClefServer, type RuntimeHealth, SERVER_INSTRUCTIONS, StderrLogger, type SystemOneRequest, type SystemOneResponse, TOOL_NAME, VERSION, assertSupportedPlatform, clefDecideInputSchema, clefDecideOutputSchema, createClefServer, createLogger, deepVerifyChecksum, defaultClefHome, detectPlatform, downloadFile, downloadManagedLlama, ensureLlamaRuntime, errorJson, exitCodeFor, fetchFileInfo, findInstalledManifest, formatBytes, fromSystemOneResponse, getModelSpec, getQuantSpec, installModel, limitsFromEnv, loadConfig, manifestPathFor, modelQuantDir, pathsFor, pickQuant, probeInference, readModelManifest, removeManagedRuntime, resolveLlamaServerBinary, toSystemOneRequest, validateStateSize, verifyModelFiles, writeModelManifest };
package/dist/index.js CHANGED
@@ -210,7 +210,9 @@ function toSystemOneRequest(input, defaultModel) {
210
210
  const questions = {};
211
211
  for (const [qid, q] of Object.entries(input.questions)) {
212
212
  const question = { type: q.type, instructions: q.instructions };
213
- if (q.criteria !== void 0) question.criteria = q.criteria;
213
+ if (q.criteria !== void 0) {
214
+ question.criteria = q.type === "choice" && Array.isArray(q.criteria) ? Object.fromEntries(q.criteria.map((c) => [c, c])) : q.criteria;
215
+ }
214
216
  questions[qid] = question;
215
217
  }
216
218
  return {
@@ -1211,14 +1213,23 @@ import { z } from "zod";
1211
1213
  function criteriaDescription(limits) {
1212
1214
  return z.string().min(1).max(limits.maxCriteriaDescChars);
1213
1215
  }
1216
+ function countIssues(count, limits) {
1217
+ if (count === 0) return "criteria must not be empty";
1218
+ if (count > limits.maxCriteriaPerQuestion) return `too many criteria (max ${limits.maxCriteriaPerQuestion})`;
1219
+ return void 0;
1220
+ }
1214
1221
  function choiceCriteria(limits) {
1215
- return z.record(z.string().min(1).max(limits.maxCriteriaDescChars), criteriaDescription(limits)).check((ctx) => {
1216
- const count = Object.keys(ctx.value).length;
1217
- if (count === 0) ctx.issues.push({ code: "custom", message: "criteria must not be empty", input: ctx.value });
1218
- if (count > limits.maxCriteriaPerQuestion) {
1219
- ctx.issues.push({ code: "custom", message: `too many criteria (max ${limits.maxCriteriaPerQuestion})`, input: ctx.value });
1220
- }
1221
- });
1222
+ return z.union([
1223
+ // Plain list: option ids equal to the strings themselves.
1224
+ z.array(criteriaDescription(limits)).check((ctx) => {
1225
+ const problem = countIssues(ctx.value.length, limits);
1226
+ if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
1227
+ }),
1228
+ z.record(z.string().min(1).max(limits.maxCriteriaDescChars), criteriaDescription(limits)).check((ctx) => {
1229
+ const problem = countIssues(Object.keys(ctx.value).length, limits);
1230
+ if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
1231
+ })
1232
+ ]);
1222
1233
  }
1223
1234
  function scoreCriteria(limits) {
1224
1235
  return z.array(criteriaDescription(limits)).check((ctx) => {
@@ -1239,7 +1250,7 @@ function questionSchema(limits) {
1239
1250
  if (!parsed.success) {
1240
1251
  ctx.addIssue({
1241
1252
  code: "custom",
1242
- message: `"choice" questions require non-empty criteria as a map of option id -> description (${parsed.error.issues[0]?.message ?? "invalid criteria"})`
1253
+ message: `"choice" questions require non-empty criteria as a map of option id -> description, or a plain list of options (${parsed.error.issues[0]?.message ?? "invalid criteria"})`
1243
1254
  });
1244
1255
  }
1245
1256
  } else if (q.type === "score") {
@@ -1414,7 +1425,7 @@ function createClefServer(deps = {}) {
1414
1425
  }
1415
1426
 
1416
1427
  // src/version.ts
1417
- var VERSION = "0.1.1";
1428
+ var VERSION = "0.1.2";
1418
1429
  export {
1419
1430
  CLEF_FLASH,
1420
1431
  ClefError,