@chosengeneration/light-code 0.56.1 → 0.59.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/dist/cli.js CHANGED
@@ -39675,6 +39675,33 @@ var providerProfileSchema = external_exports.object({
39675
39675
  * a working fallback in the adapter rather than being mandatory here.
39676
39676
  */
39677
39677
  maxTokens: external_exports.number().int().positive().optional(),
39678
+ /**
39679
+ * Sampling, sent only when set.
39680
+ *
39681
+ * Absent means the server's default, which is what every request used before this existed. That
39682
+ * default is frequently 1.0, and on a mid-size model a high temperature is felt most sharply in
39683
+ * the one place it is least wanted: tool calls. A model that has to emit exactly
39684
+ * `{"path":"src/a.ts"}` and is sampling freely produces a plausible-looking argument that is
39685
+ * subtly wrong, and the failure surfaces as a tool error rather than as anything pointing at
39686
+ * sampling. Large models absorb this; smaller ones do not.
39687
+ *
39688
+ * Not given a default here, because a default would apply to every profile including the ones
39689
+ * that are fine, and silently changing how somebody's working model behaves is worse than
39690
+ * leaving a setting unset.
39691
+ */
39692
+ temperature: external_exports.number().min(0).max(2).optional(),
39693
+ topP: external_exports.number().min(0).max(1).optional(),
39694
+ /**
39695
+ * How hard this model should think, translated per wire format by `providers/thinking.ts`.
39696
+ *
39697
+ * Absent sends nothing, which is what every request did before this existed and the only
39698
+ * setting that cannot break a gateway nobody has tested against.
39699
+ */
39700
+ thinking: external_exports.object({
39701
+ level: external_exports.enum(["off", "low", "medium", "high"]),
39702
+ /** Only consulted for the OpenAI wire format, where the parameter is genuinely ambiguous. */
39703
+ style: external_exports.enum(["effort", "qwen"]).optional()
39704
+ }).optional(),
39678
39705
  /**
39679
39706
  * Per-profile corrections to the local capability table (§9). Needed because gateway
39680
39707
  * aliases hide the underlying model, so the table cannot recognise them.
@@ -39794,7 +39821,16 @@ var agentAssignmentSchema = external_exports.object({
39794
39821
  * prompt and the flags they set up. Absent means on, so nothing changes for a config written
39795
39822
  * before this.
39796
39823
  */
39797
- enabled: external_exports.boolean().optional()
39824
+ enabled: external_exports.boolean().optional(),
39825
+ /**
39826
+ * How hard this seat should think, overriding whatever its profile says.
39827
+ *
39828
+ * On the assignment because it belongs to the *job*, not to the model: the same Qwen is worth
39829
+ * thinking hard as the expert, where it is planning a change across files, and worth answering
39830
+ * quickly as the librarian, where it is reading back what is written down. One profile, two
39831
+ * seats, two settings.
39832
+ */
39833
+ thinking: external_exports.enum(["off", "low", "medium", "high"]).optional()
39798
39834
  }).strict();
39799
39835
  var customRoleSchema = external_exports.object({
39800
39836
  id: external_exports.string().min(1),
@@ -39842,6 +39878,20 @@ var workspaceApprovalsSchema = external_exports.object({
39842
39878
  /** Exact command strings — never patterns. See approval/commands.ts and §8. */
39843
39879
  allowedCommands: external_exports.array(external_exports.string())
39844
39880
  }).partial();
39881
+ var juniorAssessmentSchema = external_exports.object({
39882
+ model: external_exports.string(),
39883
+ profileLabel: external_exports.string(),
39884
+ assessedAt: external_exports.number(),
39885
+ verdict: external_exports.string(),
39886
+ costUsd: external_exports.number().optional(),
39887
+ probes: external_exports.array(external_exports.object({
39888
+ id: external_exports.string(),
39889
+ measures: external_exports.string(),
39890
+ prompt: external_exports.string(),
39891
+ answer: external_exports.string(),
39892
+ error: external_exports.string().optional()
39893
+ }))
39894
+ });
39845
39895
  var expertConfigSchema = external_exports.object({
39846
39896
  /** Off unless explicitly enabled. Nothing is spawned or spent without this. */
39847
39897
  enabled: external_exports.boolean(),
@@ -39874,20 +39924,16 @@ var expertConfigSchema = external_exports.object({
39874
39924
  * there is one, for the model that was assessed, and it records which that was so a stale
39875
39925
  * one is recognisable rather than silently applied to a different model.
39876
39926
  */
39877
- assessment: external_exports.object({
39878
- model: external_exports.string(),
39879
- profileLabel: external_exports.string(),
39880
- assessedAt: external_exports.number(),
39881
- verdict: external_exports.string(),
39882
- costUsd: external_exports.number().optional(),
39883
- probes: external_exports.array(external_exports.object({
39884
- id: external_exports.string(),
39885
- measures: external_exports.string(),
39886
- prompt: external_exports.string(),
39887
- answer: external_exports.string(),
39888
- error: external_exports.string().optional()
39889
- }))
39890
- }).optional(),
39927
+ assessment: juniorAssessmentSchema.optional(),
39928
+ /**
39929
+ * Every model assessed, so several can be compared.
39930
+ *
39931
+ * One slot answers "is this model any good"; deciding which of four models reviews and which
39932
+ * writes needs them side by side, and assessing the second used to destroy the evidence about
39933
+ * the first. Read through `expert/assessments.ts`, never directly, so this and the single
39934
+ * `assessment` above cannot come apart.
39935
+ */
39936
+ assessments: external_exports.array(juniorAssessmentSchema).optional(),
39891
39937
  /**
39892
39938
  * Consultations allowed within one task. 0 means no limit.
39893
39939
  *
@@ -42304,6 +42350,98 @@ function normalizeObjectSchema(parameters) {
42304
42350
  return normalized;
42305
42351
  }
42306
42352
 
42353
+ // ../../packages/core/dist/providers/thinking.js
42354
+ var BUDGETS = {
42355
+ low: 2048,
42356
+ medium: 8192,
42357
+ high: 24576
42358
+ };
42359
+ function applyThinking(body, wireFormat, settings, maxTokens) {
42360
+ if (settings === void 0)
42361
+ return;
42362
+ if (wireFormat === "anthropic") {
42363
+ if (settings.level === "off")
42364
+ return;
42365
+ const ceiling = maxTokens !== void 0 ? Math.max(1024, maxTokens - 1024) : Infinity;
42366
+ body.thinking = {
42367
+ type: "enabled",
42368
+ budget_tokens: Math.min(BUDGETS[settings.level], ceiling)
42369
+ };
42370
+ return;
42371
+ }
42372
+ if (wireFormat === "gemini") {
42373
+ body.thinkingConfig = {
42374
+ thinkingBudget: settings.level === "off" ? 0 : BUDGETS[settings.level]
42375
+ };
42376
+ return;
42377
+ }
42378
+ if (settings.style === "qwen") {
42379
+ body.chat_template_kwargs = { enable_thinking: settings.level !== "off" };
42380
+ return;
42381
+ }
42382
+ if (settings.level === "off")
42383
+ return;
42384
+ body.reasoning_effort = settings.level;
42385
+ }
42386
+
42387
+ // ../../packages/core/dist/providers/thinkTags.js
42388
+ var OPEN = "<think>";
42389
+ var CLOSE = "</think>";
42390
+ var ThinkTagSplitter = class {
42391
+ inside = false;
42392
+ /** A partial tag held back until the next chunk says what it is. */
42393
+ pending = "";
42394
+ push(chunk) {
42395
+ let text = "";
42396
+ let reasoning = "";
42397
+ let buffer = this.pending + chunk;
42398
+ this.pending = "";
42399
+ for (; ; ) {
42400
+ const marker = this.inside ? CLOSE : OPEN;
42401
+ const at = buffer.indexOf(marker);
42402
+ if (at !== -1) {
42403
+ const before = buffer.slice(0, at);
42404
+ if (this.inside)
42405
+ reasoning += before;
42406
+ else
42407
+ text += before;
42408
+ this.inside = !this.inside;
42409
+ buffer = buffer.slice(at + marker.length);
42410
+ continue;
42411
+ }
42412
+ const keep = partialMarkerLength(buffer, marker);
42413
+ const usable = buffer.slice(0, buffer.length - keep);
42414
+ this.pending = buffer.slice(buffer.length - keep);
42415
+ if (this.inside)
42416
+ reasoning += usable;
42417
+ else
42418
+ text += usable;
42419
+ break;
42420
+ }
42421
+ return { text, reasoning };
42422
+ }
42423
+ /**
42424
+ * Whatever is still held back when the stream ends.
42425
+ *
42426
+ * A truncated stream can leave a partial tag, or an unclosed `<think>`. Emitting the remainder
42427
+ * rather than dropping it means a cut-off reply still shows what there was — losing the end of
42428
+ * an answer to a tag that never closed would be a worse failure than showing a stray `<`.
42429
+ */
42430
+ flush() {
42431
+ const rest = this.pending;
42432
+ this.pending = "";
42433
+ return this.inside ? { text: "", reasoning: rest } : { text: rest, reasoning: "" };
42434
+ }
42435
+ };
42436
+ function partialMarkerLength(buffer, marker) {
42437
+ const most = Math.min(marker.length - 1, buffer.length);
42438
+ for (let length = most; length > 0; length -= 1) {
42439
+ if (marker.startsWith(buffer.slice(buffer.length - length)))
42440
+ return length;
42441
+ }
42442
+ return 0;
42443
+ }
42444
+
42307
42445
  // ../../packages/core/dist/providers/openai.js
42308
42446
  function describeRequestError(error51, url2) {
42309
42447
  return `Could not reach ${url2}: ${describeTlsError(error51)}`;
@@ -42358,6 +42496,11 @@ var OpenAIProvider = class {
42358
42496
  body.tools = toOpenAITools(options.tools);
42359
42497
  body.tool_choice = "auto";
42360
42498
  }
42499
+ if (this.profile.temperature !== void 0)
42500
+ body.temperature = this.profile.temperature;
42501
+ if (this.profile.topP !== void 0)
42502
+ body.top_p = this.profile.topP;
42503
+ applyThinking(body, "openai", this.profile.thinking, this.profile.maxTokens);
42361
42504
  let response;
42362
42505
  try {
42363
42506
  await this.auth.ensureTokenForStream?.();
@@ -42442,6 +42585,7 @@ async function* parseSseStream(body, url2, signal, logger) {
42442
42585
  const reader = body.getReader();
42443
42586
  const decoder = new TextDecoder();
42444
42587
  let buffer = "";
42588
+ const thinking = new ThinkTagSplitter();
42445
42589
  const toolCallAccumulators = /* @__PURE__ */ new Map();
42446
42590
  try {
42447
42591
  while (true) {
@@ -42472,7 +42616,11 @@ async function* parseSseStream(body, url2, signal, logger) {
42472
42616
  yield { type: "reasoning", text: reasoning };
42473
42617
  }
42474
42618
  if (typeof choice.delta.content === "string" && choice.delta.content.length > 0) {
42475
- yield { type: "text", text: choice.delta.content };
42619
+ const split = thinking.push(choice.delta.content);
42620
+ if (split.reasoning.length > 0)
42621
+ yield { type: "reasoning", text: split.reasoning };
42622
+ if (split.text.length > 0)
42623
+ yield { type: "text", text: split.text };
42476
42624
  }
42477
42625
  accumulateToolCallDeltas(toolCallAccumulators, choice.delta.tool_calls);
42478
42626
  if (choice.finishReason === "tool_calls") {
@@ -42524,6 +42672,11 @@ var AnthropicProvider = class {
42524
42672
  };
42525
42673
  if (system !== void 0)
42526
42674
  body.system = system;
42675
+ if (this.profile.temperature !== void 0)
42676
+ body.temperature = this.profile.temperature;
42677
+ if (this.profile.topP !== void 0)
42678
+ body.top_p = this.profile.topP;
42679
+ applyThinking(body, "anthropic", this.profile.thinking, this.profile.maxTokens ?? DEFAULT_MAX_TOKENS);
42527
42680
  if (options.tools !== void 0 && options.tools.length > 0) {
42528
42681
  body.tools = toAnthropicTools(options.tools);
42529
42682
  }
@@ -42749,6 +42902,21 @@ var GeminiProvider = class {
42749
42902
  if (this.profile.maxTokens !== void 0) {
42750
42903
  body.generationConfig = { maxOutputTokens: this.profile.maxTokens };
42751
42904
  }
42905
+ if (this.profile.temperature !== void 0 || this.profile.topP !== void 0) {
42906
+ body.generationConfig = {
42907
+ ...body.generationConfig ?? {},
42908
+ ...this.profile.temperature !== void 0 ? { temperature: this.profile.temperature } : {},
42909
+ ...this.profile.topP !== void 0 ? { topP: this.profile.topP } : {}
42910
+ };
42911
+ }
42912
+ applyThinking(body, "gemini", this.profile.thinking, this.profile.maxTokens);
42913
+ if (body.thinkingConfig !== void 0) {
42914
+ body.generationConfig = {
42915
+ ...body.generationConfig ?? {},
42916
+ thinkingConfig: body.thinkingConfig
42917
+ };
42918
+ delete body.thinkingConfig;
42919
+ }
42752
42920
  let response;
42753
42921
  try {
42754
42922
  await this.auth.ensureTokenForStream?.();
@@ -44345,6 +44513,7 @@ function resolveTeam(context) {
44345
44513
  const prompt = assignment.prompt ?? defaultPromptFor(role, custom2);
44346
44514
  const usesTools = assignment.tools ?? info.usesTools;
44347
44515
  const canWrite = assignment.write ?? info.canWrite;
44516
+ const thinking = assignment.thinking;
44348
44517
  if (assignment.kind === "cli") {
44349
44518
  resolved.push({
44350
44519
  role,
@@ -44355,6 +44524,7 @@ function resolveTeam(context) {
44355
44524
  prompt,
44356
44525
  usesTools,
44357
44526
  canWrite,
44527
+ ...thinking !== void 0 ? { thinking } : {},
44358
44528
  available: context.cliAvailable,
44359
44529
  ...context.cliAvailable ? {} : { reason: "The Claude CLI is not available on this machine." }
44360
44530
  });
@@ -44373,6 +44543,7 @@ function resolveTeam(context) {
44373
44543
  prompt,
44374
44544
  usesTools,
44375
44545
  canWrite,
44546
+ ...thinking !== void 0 ? { thinking } : {},
44376
44547
  available: profile !== void 0,
44377
44548
  /*
44378
44549
  * A profile that has been deleted leaves the role unavailable and says so, rather than
@@ -45100,6 +45271,58 @@ function buildExpertBriefing(input) {
45100
45271
  return sections.join("\n");
45101
45272
  }
45102
45273
 
45274
+ // ../../packages/core/dist/expert/assessments.js
45275
+ function allAssessments(expert) {
45276
+ const list = [...expert.assessments ?? []];
45277
+ const legacy = expert.assessment;
45278
+ if (legacy !== void 0 && !list.some((entry) => sameSubject(entry, legacy))) {
45279
+ list.push(legacy);
45280
+ }
45281
+ return list.sort((a, b) => b.assessedAt - a.assessedAt);
45282
+ }
45283
+ function assessmentFor(all, model, profileLabel) {
45284
+ if (model.length === 0)
45285
+ return void 0;
45286
+ const exact = profileLabel === void 0 ? void 0 : all.find((entry) => entry.model === model && entry.profileLabel === profileLabel);
45287
+ return exact ?? all.find((entry) => entry.model === model);
45288
+ }
45289
+ function recordAssessment(all, entry, limit = MAX_ASSESSMENTS) {
45290
+ const kept = all.filter((existing) => !sameSubject(existing, entry));
45291
+ return [entry, ...kept].sort((a, b) => b.assessedAt - a.assessedAt).slice(0, limit);
45292
+ }
45293
+ function forgetAssessment(all, model, profileLabel) {
45294
+ return all.filter((entry) => !(entry.model === model && entry.profileLabel === profileLabel));
45295
+ }
45296
+ var MAX_ASSESSMENTS = 12;
45297
+ function sameSubject(a, b) {
45298
+ return a.model === b.model && a.profileLabel === b.profileLabel;
45299
+ }
45300
+
45301
+ // ../../packages/core/dist/agents/seats.js
45302
+ var SEAT_FITS = [
45303
+ {
45304
+ role: "programmer",
45305
+ probes: ["code", "instruction-following"],
45306
+ lookFor: "Code that is correct and *only* code \u2014 no preamble, no explanation you did not ask for, no rewriting of things it was not asked to change. A model that cannot hold an output format will produce diffs you have to unpick before you can apply them."
45307
+ },
45308
+ {
45309
+ role: "reviewer",
45310
+ probes: ["debugging", "instruction-conflict"],
45311
+ lookFor: "Finding the actual fault rather than the first plausible one, and saying when two instructions contradict instead of quietly obeying one. A model that agrees easily makes an approving reviewer, which is worse than none because it gets believed."
45312
+ },
45313
+ {
45314
+ role: "tester",
45315
+ probes: ["instruction-conflict", "debugging"],
45316
+ lookFor: "Noticing what does not add up. The tester earns its place by thinking of the case you did not, which is the same instinct as spotting a contradiction."
45317
+ },
45318
+ {
45319
+ role: "librarian",
45320
+ probes: ["honesty"],
45321
+ lookFor: "Admitting it does not know. This is the one seat where inventing is worse than silence \u2014 a convention guessed at and stated confidently becomes the convention."
45322
+ }
45323
+ ];
45324
+ var EXPERT_GUIDANCE = "Planning across files is the whole of what the expert does, and no short probe stands in for it. Give the seat the model you would trust with an unfamiliar codebase, turn its thinking up, and judge it on whether its first plan survives contact with the work.";
45325
+
45103
45326
  // ../../packages/core/dist/expert/budget.js
45104
45327
  function money2(value) {
45105
45328
  return `$${value.toFixed(value < 1 ? 4 : 2)}`;
@@ -59795,6 +60018,39 @@ var OfficeBridge = class {
59795
60018
  }
59796
60019
  };
59797
60020
 
60021
+ // ../../packages/core/dist/agents/direct.js
60022
+ var DIRECTED = /(?:^|\s)#([a-z][a-z0-9-]{1,23})\b/g;
60023
+ function findDirectedRoles(text, team) {
60024
+ const usable = new Set(team.filter((agent) => agent.available).map((agent) => agent.role));
60025
+ const addressed = [];
60026
+ const unknown2 = [];
60027
+ for (const match of text.matchAll(DIRECTED)) {
60028
+ const name = match[1];
60029
+ if (name === void 0)
60030
+ continue;
60031
+ if (usable.has(name)) {
60032
+ if (!addressed.includes(name))
60033
+ addressed.push(name);
60034
+ continue;
60035
+ }
60036
+ if (team.some((agent) => agent.role === name) && !unknown2.includes(name))
60037
+ unknown2.push(name);
60038
+ }
60039
+ return { addressed, unknown: unknown2 };
60040
+ }
60041
+ function describeDirectedRoles(directed, team) {
60042
+ const lines = [];
60043
+ if (directed.addressed.length > 0) {
60044
+ const names = directed.addressed.map((role) => `\`${role}\``).join(", ");
60045
+ lines.push(`The user addressed ${names} directly with #. Consult ${directed.addressed.length > 1 ? "each of them" : "it"} with \`ask_agent\` before you answer \u2014 this is not a judgement call about whether a consultation is worth it, they asked. Put the code, error or output they are referring to in the question, and say plainly in your reply what came back and whether you agree.`);
60046
+ }
60047
+ if (directed.unknown.length > 0) {
60048
+ const usable = team.filter((agent) => agent.available).map((agent) => agent.role);
60049
+ lines.push(`The user wrote ${directed.unknown.map((role) => `#${role}`).join(", ")}, which ${directed.unknown.length > 1 ? "are not roles" : "is not a role"} that can answer here. ${usable.length > 0 ? `Available: ${usable.join(", ")}. Say so and carry on with the request.` : "No specialists are assigned. Say so, mention Settings \u2192 Agents, and carry on."}`);
60050
+ }
60051
+ return lines.join("\n\n");
60052
+ }
60053
+
59798
60054
  // ../../packages/core/dist/tools/roleTools.js
59799
60055
  var readParams = external_exports.object({
59800
60056
  role: external_exports.string().describe("Which role to read \u2014 one of the roles configured here. Omit to list them all.").optional()
@@ -59900,9 +60156,19 @@ function createUpdateRolePromptTool(access) {
59900
60156
  id: details.id,
59901
60157
  name: params.name?.trim() ?? details.name,
59902
60158
  summary: params.summary?.trim() ?? details.summary,
59903
- // Carried over rather than re-sent: this path is about identity, and the prompt has its
59904
- // own store. Passing the old one back keeps the two from disagreeing.
59905
- prompt: details.prompt,
60159
+ /*
60160
+ * The **original**, not the one in force.
60161
+ *
60162
+ * This path rewrites the role's definition, and for a custom role the definition's
60163
+ * prompt is what "reset to default" restores. Passing the effective prompt here would
60164
+ * quietly bake an edit into the definition: rename a role whose prompt had been changed,
60165
+ * and resetting it afterwards would hand back the edit, with the text it was created
60166
+ * with gone for good and nothing having reported a loss.
60167
+ *
60168
+ * An edit lives in its own store and is untouched by this, which is the point — the two
60169
+ * are separate so that one can be undone.
60170
+ */
60171
+ prompt: details.originalPrompt,
59906
60172
  usesTools: params.usesTools ?? details.usesTools
59907
60173
  });
59908
60174
  }
@@ -61239,6 +61505,9 @@ ${preview.text}` } : {}
61239
61505
  name: info.name,
61240
61506
  summary: info.summary,
61241
61507
  prompt: cachedAgentRoles?.[role]?.prompt ?? info.prompt,
61508
+ // What a reset restores. `info.prompt` is the definition's for a custom role and the
61509
+ // shipped text for a built-in one, in both cases ignoring any edit on top.
61510
+ originalPrompt: info.prompt,
61242
61511
  usesTools: cachedAgentRoles?.[role]?.tools ?? info.usesTools,
61243
61512
  custom: cachedAgentDefinitions.some((definition) => definition.id === role)
61244
61513
  };
@@ -61604,7 +61873,14 @@ ${preview.text}` } : {}
61604
61873
  cachedToolTimeoutSeconds = config2.tools?.timeoutSeconds;
61605
61874
  cachedToolTimeouts = config2.tools?.timeouts;
61606
61875
  cachedExpertColor = config2.ui?.expertColor ?? "#D97757";
61607
- cachedAssessment = config2.expert?.assessment;
61876
+ const junior = (() => {
61877
+ try {
61878
+ return resolveActiveProfile(config2);
61879
+ } catch {
61880
+ return void 0;
61881
+ }
61882
+ })();
61883
+ cachedAssessment = junior === void 0 ? void 0 : assessmentFor(allAssessments(config2.expert ?? {}), junior.model, junior.label ?? junior.model);
61608
61884
  cachedReportsCost = config2.expert?.reportsCost;
61609
61885
  cachedPricing = config2.expert?.pricing;
61610
61886
  cachedKeepAlive = config2.expert?.keepAlive === true;
@@ -62225,7 +62501,11 @@ ${preview.text}` } : {}
62225
62501
  pythonNestedContext = toolContext;
62226
62502
  pythonNestedCallsAllowed = schedule === void 0;
62227
62503
  const mentions = await resolveMentions(text, { fs: toolContext.fs, workspaceRoot, denylist });
62228
- const messageText = attachMentions(text, mentions);
62504
+ const directed = findDirectedRoles(text, cachedTeam);
62505
+ const direction = describeDirectedRoles(directed, cachedTeam);
62506
+ const messageText = direction.length > 0 ? `${attachMentions(text, mentions)}
62507
+
62508
+ ${direction}` : attachMentions(text, mentions);
62229
62509
  const turnOptions = {
62230
62510
  signal: activeAbortController.signal,
62231
62511
  truncationStore,
@@ -62717,7 +62997,25 @@ ${preview.text}` } : {}
62717
62997
  maxConsultations: settings?.maxConsultations ?? 0,
62718
62998
  keepAlive: settings?.keepAlive === true,
62719
62999
  ...settings?.model !== void 0 ? { model: settings.model } : {},
62720
- ...settings?.assessment !== void 0 ? { assessment: settings.assessment } : {},
63000
+ // The one that applies to the active junior, chosen through the module that owns both
63001
+ // config shapes - not `settings.assessment`, which is only the legacy slot.
63002
+ ...cachedAssessment !== void 0 ? { assessment: cachedAssessment } : {},
63003
+ assessments: allAssessments(settings ?? {}),
63004
+ /*
63005
+ * What the probes predict about each seat, and who grades them.
63006
+ *
63007
+ * Sent rather than duplicated in the UI: the mapping is reasoned about beside the probes,
63008
+ * in `agents/seats.ts`, and a copy in a React component is the second declaration of one
63009
+ * fact that this repository keeps paying for.
63010
+ */
63011
+ seatFits: SEAT_FITS.map((fit) => ({
63012
+ role: fit.role,
63013
+ name: roleInfo(fit.role, cachedAgentDefinitions).name,
63014
+ probes: [...fit.probes],
63015
+ lookFor: fit.lookFor
63016
+ })),
63017
+ expertGuidance: EXPERT_GUIDANCE,
63018
+ assessor: describeAssessor(),
62721
63019
  ...settings?.reportsCost !== void 0 ? { reportsCost: settings.reportsCost } : {},
62722
63020
  ...settings?.pricing !== void 0 ? { pricing: settings.pricing } : {},
62723
63021
  ...measuringStep !== void 0 ? { measuringStep } : {},
@@ -62759,7 +63057,11 @@ ${preview.text}` } : {}
62759
63057
  // resolution `resolveTeam` does, so the switch in the tab shows what will actually happen.
62760
63058
  usesTools: config2.agents?.roles?.[info.role]?.tools ?? info.usesTools,
62761
63059
  canWrite: config2.agents?.roles?.[info.role]?.write ?? info.canWrite,
62762
- enabled: config2.agents?.roles?.[info.role]?.enabled !== false
63060
+ enabled: config2.agents?.roles?.[info.role]?.enabled !== false,
63061
+ ...(() => {
63062
+ const level = config2.agents?.roles?.[info.role]?.thinking;
63063
+ return level !== void 0 ? { thinking: level } : {};
63064
+ })()
62763
63065
  };
62764
63066
  });
62765
63067
  const guidance = config2.agents?.teamGuidance;
@@ -62770,6 +63072,14 @@ ${preview.text}` } : {}
62770
63072
  cliAvailable: teamContext.cliAvailable,
62771
63073
  ...cli?.available === false && cli.reason !== void 0 ? { cliReason: cli.reason } : {},
62772
63074
  budgetMatters: budgetMatters(teamContext),
63075
+ /*
63076
+ * Assigned, rather than assigned *and* detected.
63077
+ *
63078
+ * Somebody who put Claude in a seat on a machine where it is momentarily missing has still
63079
+ * said they intend to spend money there, and taking the budget controls away from them
63080
+ * because a probe failed would be the panel arguing with the user.
63081
+ */
63082
+ claudeSeated: [...assigned.values()].some((agent) => agent.kind === "cli"),
62773
63083
  teamGuidance: guidance ?? DEFAULT_TEAM_GUIDANCE,
62774
63084
  defaultTeamGuidance: DEFAULT_TEAM_GUIDANCE,
62775
63085
  teamGuidanceIsDefault: guidance === void 0,
@@ -62995,24 +63305,89 @@ ${preview.text}` } : {}
62995
63305
  await postExpert({ redetect: false });
62996
63306
  }
62997
63307
  }
62998
- async function handleAssessJunior() {
63308
+ function describeAssessor() {
63309
+ const expert = cachedTeam.find((agent) => agent.role === "expert");
63310
+ if (expert === void 0) {
63311
+ return { label: "Nobody is in the expert seat", available: false };
63312
+ }
63313
+ return { label: expert.label, available: expert.available };
63314
+ }
63315
+ async function askExpertSeat(question, config2, expert) {
63316
+ if (expert.kind === "cli") {
63317
+ const cli = await detectCli(config2.expert?.path ?? "claude");
63318
+ if (!cli.available)
63319
+ throw new Error("The Claude CLI is not available.");
63320
+ const graded = await consultExpert(cli, {
63321
+ question,
63322
+ cwd: workspaceRoot ?? process.cwd(),
63323
+ ...config2.expert?.model !== void 0 ? { model: config2.expert.model } : {}
63324
+ });
63325
+ recordConsultation({
63326
+ isError: graded.isError,
63327
+ ...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
63328
+ });
63329
+ if (graded.isError)
63330
+ throw new Error(graded.text);
63331
+ return {
63332
+ text: graded.text,
63333
+ ...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
63334
+ };
63335
+ }
63336
+ const profile = config2.profiles?.find((candidate) => candidate.id === expert.profileId);
63337
+ if (profile === void 0) {
63338
+ throw new Error(`No profile "${expert.profileId ?? ""}" exists any more.`);
63339
+ }
63340
+ const seatProfile = expert.thinking === void 0 ? profile : {
63341
+ ...profile,
63342
+ thinking: {
63343
+ ...profile.thinking ?? { level: expert.thinking },
63344
+ level: expert.thinking
63345
+ }
63346
+ };
63347
+ const provider = createChatProvider(seatProfile, httpClient, authStrategyFor(config2, profile), logger);
63348
+ let text = "";
63349
+ for await (const chunk of provider.streamChat([
63350
+ { role: "system", content: expert.prompt },
63351
+ { role: "user", content: question }
63352
+ ])) {
63353
+ if (chunk.type === "text")
63354
+ text += chunk.text;
63355
+ if (chunk.type === "error")
63356
+ throw new Error(chunk.error);
63357
+ }
63358
+ if (text.trim().length === 0)
63359
+ throw new Error("The expert replied with nothing.");
63360
+ return { text };
63361
+ }
63362
+ async function handleAssessJunior(profileId) {
62999
63363
  if (assessmentStep !== void 0)
63000
63364
  return;
63001
63365
  try {
63002
63366
  const { config: config2 } = await configManager.load();
63003
- const cli = await resolveExpert(config2);
63004
- if (cli === void 0) {
63367
+ const cli = await detectCli(config2.expert?.path ?? "claude").catch(() => void 0);
63368
+ const team = resolveTeam({
63369
+ config: config2.agents,
63370
+ profiles: (config2.profiles ?? []).map((entry) => ({ id: entry.id, label: entry.label })),
63371
+ cliAvailable: cli?.available === true
63372
+ });
63373
+ const expert = team.find((agent) => agent.role === "expert" && agent.available);
63374
+ if (expert === void 0) {
63005
63375
  post({
63006
63376
  type: "error",
63007
- message: "Enable the expert first \u2014 the assessment is its judgement, not ours."
63377
+ message: "Nothing is in the expert seat. Assign one in the Agents tab - the assessment is its judgement, not ours."
63008
63378
  });
63009
63379
  return;
63010
63380
  }
63011
- const profile = resolveActiveProfile(config2);
63381
+ const chosen = profileId === void 0 ? void 0 : config2.profiles?.find((candidate) => candidate.id === profileId);
63382
+ if (profileId !== void 0 && chosen === void 0) {
63383
+ post({ type: "error", message: "That profile no longer exists." });
63384
+ return;
63385
+ }
63386
+ const profile = chosen ?? resolveActiveProfile(config2);
63012
63387
  const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
63013
63388
  const results = [];
63014
63389
  for (const [index, probe2] of ASSESSMENT_PROBES.entries()) {
63015
- assessmentStep = `Asking the junior: ${probe2.measures} (${String(index + 1)}/${String(ASSESSMENT_PROBES.length)})`;
63390
+ assessmentStep = `Asking ${profile.label ?? profile.model}: ${probe2.measures} (${String(index + 1)}/${String(ASSESSMENT_PROBES.length)})`;
63016
63391
  await postExpert({ redetect: false });
63017
63392
  let answer = "";
63018
63393
  try {
@@ -63035,21 +63410,9 @@ ${preview.text}` } : {}
63035
63410
  });
63036
63411
  }
63037
63412
  }
63038
- assessmentStep = "Asking the expert to grade the answers";
63413
+ assessmentStep = `Asking ${expert.label} to grade the answers`;
63039
63414
  await postExpert({ redetect: false });
63040
- const graded = await consultExpert(cli, {
63041
- question: buildAssessmentQuestion(profile.model, results),
63042
- cwd: workspaceRoot ?? process.cwd(),
63043
- ...config2.expert?.model !== void 0 ? { model: config2.expert.model } : {}
63044
- });
63045
- recordConsultation({
63046
- isError: graded.isError,
63047
- ...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
63048
- });
63049
- if (graded.isError) {
63050
- post({ type: "error", message: `The expert could not assess the junior: ${graded.text}` });
63051
- return;
63052
- }
63415
+ const graded = await askExpertSeat(buildAssessmentQuestion(profile.model, results), config2, expert);
63053
63416
  const assessment = {
63054
63417
  model: profile.model,
63055
63418
  profileLabel: profile.label ?? profile.model,
@@ -63059,7 +63422,12 @@ ${preview.text}` } : {}
63059
63422
  ...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
63060
63423
  };
63061
63424
  const latest = (await configManager.load()).config;
63062
- await configManager.save("user", { expert: { ...latest.expert, assessment } });
63425
+ await configManager.save("user", {
63426
+ expert: {
63427
+ ...latest.expert,
63428
+ assessments: recordAssessment(allAssessments(latest.expert ?? {}), assessment)
63429
+ }
63430
+ });
63063
63431
  } catch (error51) {
63064
63432
  post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
63065
63433
  } finally {
@@ -63067,10 +63435,16 @@ ${preview.text}` } : {}
63067
63435
  await postExpert({ redetect: false });
63068
63436
  }
63069
63437
  }
63070
- async function handleClearAssessment() {
63438
+ async function handleClearAssessment(model, profileLabel) {
63071
63439
  const { config: config2 } = await configManager.load();
63072
63440
  const expert = { ...config2.expert };
63073
- delete expert.assessment;
63441
+ if (model === void 0 || profileLabel === void 0) {
63442
+ delete expert.assessment;
63443
+ delete expert.assessments;
63444
+ } else {
63445
+ expert.assessments = forgetAssessment(allAssessments(expert), model, profileLabel);
63446
+ delete expert.assessment;
63447
+ }
63074
63448
  await configManager.save("user", { expert });
63075
63449
  await postExpert();
63076
63450
  }
@@ -64921,7 +65295,11 @@ ${preview.text}` } : {}
64921
65295
  if (profile === void 0) {
64922
65296
  throw new Error(`No profile "${agent.profileId ?? ""}" exists any more.`);
64923
65297
  }
64924
- const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
65298
+ const seatProfile = agent.thinking === void 0 ? profile : {
65299
+ ...profile,
65300
+ thinking: { ...profile.thinking ?? { level: agent.thinking }, level: agent.thinking }
65301
+ };
65302
+ const provider = createChatProvider(seatProfile, httpClient, authStrategyFor(config2, profile), logger);
64925
65303
  const extraTools = new Set(agent.role === "librarian" ? ["write_skill"] : []);
64926
65304
  if (agent.canWrite) {
64927
65305
  extraTools.add("write_to_file");
@@ -65665,9 +66043,9 @@ ${preview.text}` } : {}
65665
66043
  await postExpert({ redetect: false });
65666
66044
  }).catch((error51) => post({ type: "error", message: String(error51) }));
65667
66045
  } else if (message3.type === "assessJunior") {
65668
- void handleAssessJunior();
66046
+ void handleAssessJunior(message3.profileId);
65669
66047
  } else if (message3.type === "clearAssessment") {
65670
- void handleClearAssessment();
66048
+ void handleClearAssessment(message3.model, message3.profileLabel);
65671
66049
  } else if (message3.type === "restartScheduler") {
65672
66050
  restartScheduleTimer();
65673
66051
  logger.info("schedule timer restarted by the user");
@@ -65774,6 +66152,24 @@ ${preview.text}` } : {}
65774
66152
  void handleSaveCustomRole(message3);
65775
66153
  } else if (message3.type === "deleteCustomRole") {
65776
66154
  void handleDeleteCustomRole(message3.id);
66155
+ } else if (message3.type === "setRoleThinking") {
66156
+ const role = message3.role;
66157
+ if (!isAgentRole(role, cachedAgentDefinitions)) {
66158
+ post({ type: "error", message: `There is no "${role}" role.` });
66159
+ return;
66160
+ }
66161
+ void saveAgents((current) => {
66162
+ const roles = { ...current.roles ?? {} };
66163
+ const existing = roles[role] ?? { kind: "profile" };
66164
+ if (message3.level === void 0) {
66165
+ const rest = { ...existing };
66166
+ delete rest.thinking;
66167
+ roles[role] = rest;
66168
+ } else {
66169
+ roles[role] = { ...existing, thinking: message3.level };
66170
+ }
66171
+ return { ...current, roles };
66172
+ });
65777
66173
  } else if (message3.type === "setRoleEnabled") {
65778
66174
  const role = message3.role;
65779
66175
  if (!isAgentRole(role, cachedAgentDefinitions)) {
@@ -69912,7 +70308,7 @@ function respondJson(response, status, body) {
69912
70308
  }
69913
70309
 
69914
70310
  // src/cli.ts
69915
- var VERSION = true ? "0.56.1" : "unknown (not a packaged build)";
70311
+ var VERSION = true ? "0.59.0" : "unknown (not a packaged build)";
69916
70312
  var compat = installNodeCompat();
69917
70313
  function lastMeaningfulLine(problem) {
69918
70314
  const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));