@chosengeneration/light-code 0.56.1 → 0.59.1
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 +450 -50
- package/dist/client/client.js +63 -63
- package/dist/server.js +449 -49
- package/package.json +1 -1
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:
|
|
39878
|
-
|
|
39879
|
-
|
|
39880
|
-
|
|
39881
|
-
|
|
39882
|
-
|
|
39883
|
-
|
|
39884
|
-
|
|
39885
|
-
|
|
39886
|
-
|
|
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
|
-
|
|
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
|
-
|
|
59904
|
-
|
|
59905
|
-
|
|
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
|
}
|
|
@@ -60871,6 +61137,8 @@ async function toSummary(profile, secrets) {
|
|
|
60871
61137
|
};
|
|
60872
61138
|
if (profile.modelCapabilities !== void 0)
|
|
60873
61139
|
summary.modelCapabilities = profile.modelCapabilities;
|
|
61140
|
+
if (profile.thinking !== void 0)
|
|
61141
|
+
summary.thinking = profile.thinking;
|
|
60874
61142
|
if (profile.tls !== void 0)
|
|
60875
61143
|
summary.connectionTls = profile.tls;
|
|
60876
61144
|
if (profile.auth.type === "apigeeMtls") {
|
|
@@ -61239,6 +61507,9 @@ ${preview.text}` } : {}
|
|
|
61239
61507
|
name: info.name,
|
|
61240
61508
|
summary: info.summary,
|
|
61241
61509
|
prompt: cachedAgentRoles?.[role]?.prompt ?? info.prompt,
|
|
61510
|
+
// What a reset restores. `info.prompt` is the definition's for a custom role and the
|
|
61511
|
+
// shipped text for a built-in one, in both cases ignoring any edit on top.
|
|
61512
|
+
originalPrompt: info.prompt,
|
|
61242
61513
|
usesTools: cachedAgentRoles?.[role]?.tools ?? info.usesTools,
|
|
61243
61514
|
custom: cachedAgentDefinitions.some((definition) => definition.id === role)
|
|
61244
61515
|
};
|
|
@@ -61604,7 +61875,14 @@ ${preview.text}` } : {}
|
|
|
61604
61875
|
cachedToolTimeoutSeconds = config2.tools?.timeoutSeconds;
|
|
61605
61876
|
cachedToolTimeouts = config2.tools?.timeouts;
|
|
61606
61877
|
cachedExpertColor = config2.ui?.expertColor ?? "#D97757";
|
|
61607
|
-
|
|
61878
|
+
const junior = (() => {
|
|
61879
|
+
try {
|
|
61880
|
+
return resolveActiveProfile(config2);
|
|
61881
|
+
} catch {
|
|
61882
|
+
return void 0;
|
|
61883
|
+
}
|
|
61884
|
+
})();
|
|
61885
|
+
cachedAssessment = junior === void 0 ? void 0 : assessmentFor(allAssessments(config2.expert ?? {}), junior.model, junior.label ?? junior.model);
|
|
61608
61886
|
cachedReportsCost = config2.expert?.reportsCost;
|
|
61609
61887
|
cachedPricing = config2.expert?.pricing;
|
|
61610
61888
|
cachedKeepAlive = config2.expert?.keepAlive === true;
|
|
@@ -62225,7 +62503,11 @@ ${preview.text}` } : {}
|
|
|
62225
62503
|
pythonNestedContext = toolContext;
|
|
62226
62504
|
pythonNestedCallsAllowed = schedule === void 0;
|
|
62227
62505
|
const mentions = await resolveMentions(text, { fs: toolContext.fs, workspaceRoot, denylist });
|
|
62228
|
-
const
|
|
62506
|
+
const directed = findDirectedRoles(text, cachedTeam);
|
|
62507
|
+
const direction = describeDirectedRoles(directed, cachedTeam);
|
|
62508
|
+
const messageText = direction.length > 0 ? `${attachMentions(text, mentions)}
|
|
62509
|
+
|
|
62510
|
+
${direction}` : attachMentions(text, mentions);
|
|
62229
62511
|
const turnOptions = {
|
|
62230
62512
|
signal: activeAbortController.signal,
|
|
62231
62513
|
truncationStore,
|
|
@@ -62538,6 +62820,8 @@ ${preview.text}` } : {}
|
|
|
62538
62820
|
};
|
|
62539
62821
|
if (input.modelCapabilities !== void 0)
|
|
62540
62822
|
saved.modelCapabilities = input.modelCapabilities;
|
|
62823
|
+
if (input.thinking !== void 0)
|
|
62824
|
+
saved.thinking = input.thinking;
|
|
62541
62825
|
const connectionTls = stripEmpty(input.connectionTls ?? {});
|
|
62542
62826
|
if (Object.keys(connectionTls).length > 0)
|
|
62543
62827
|
saved.tls = connectionTls;
|
|
@@ -62717,7 +63001,25 @@ ${preview.text}` } : {}
|
|
|
62717
63001
|
maxConsultations: settings?.maxConsultations ?? 0,
|
|
62718
63002
|
keepAlive: settings?.keepAlive === true,
|
|
62719
63003
|
...settings?.model !== void 0 ? { model: settings.model } : {},
|
|
62720
|
-
|
|
63004
|
+
// The one that applies to the active junior, chosen through the module that owns both
|
|
63005
|
+
// config shapes - not `settings.assessment`, which is only the legacy slot.
|
|
63006
|
+
...cachedAssessment !== void 0 ? { assessment: cachedAssessment } : {},
|
|
63007
|
+
assessments: allAssessments(settings ?? {}),
|
|
63008
|
+
/*
|
|
63009
|
+
* What the probes predict about each seat, and who grades them.
|
|
63010
|
+
*
|
|
63011
|
+
* Sent rather than duplicated in the UI: the mapping is reasoned about beside the probes,
|
|
63012
|
+
* in `agents/seats.ts`, and a copy in a React component is the second declaration of one
|
|
63013
|
+
* fact that this repository keeps paying for.
|
|
63014
|
+
*/
|
|
63015
|
+
seatFits: SEAT_FITS.map((fit) => ({
|
|
63016
|
+
role: fit.role,
|
|
63017
|
+
name: roleInfo(fit.role, cachedAgentDefinitions).name,
|
|
63018
|
+
probes: [...fit.probes],
|
|
63019
|
+
lookFor: fit.lookFor
|
|
63020
|
+
})),
|
|
63021
|
+
expertGuidance: EXPERT_GUIDANCE,
|
|
63022
|
+
assessor: describeAssessor(),
|
|
62721
63023
|
...settings?.reportsCost !== void 0 ? { reportsCost: settings.reportsCost } : {},
|
|
62722
63024
|
...settings?.pricing !== void 0 ? { pricing: settings.pricing } : {},
|
|
62723
63025
|
...measuringStep !== void 0 ? { measuringStep } : {},
|
|
@@ -62759,7 +63061,11 @@ ${preview.text}` } : {}
|
|
|
62759
63061
|
// resolution `resolveTeam` does, so the switch in the tab shows what will actually happen.
|
|
62760
63062
|
usesTools: config2.agents?.roles?.[info.role]?.tools ?? info.usesTools,
|
|
62761
63063
|
canWrite: config2.agents?.roles?.[info.role]?.write ?? info.canWrite,
|
|
62762
|
-
enabled: config2.agents?.roles?.[info.role]?.enabled !== false
|
|
63064
|
+
enabled: config2.agents?.roles?.[info.role]?.enabled !== false,
|
|
63065
|
+
...(() => {
|
|
63066
|
+
const level = config2.agents?.roles?.[info.role]?.thinking;
|
|
63067
|
+
return level !== void 0 ? { thinking: level } : {};
|
|
63068
|
+
})()
|
|
62763
63069
|
};
|
|
62764
63070
|
});
|
|
62765
63071
|
const guidance = config2.agents?.teamGuidance;
|
|
@@ -62770,6 +63076,14 @@ ${preview.text}` } : {}
|
|
|
62770
63076
|
cliAvailable: teamContext.cliAvailable,
|
|
62771
63077
|
...cli?.available === false && cli.reason !== void 0 ? { cliReason: cli.reason } : {},
|
|
62772
63078
|
budgetMatters: budgetMatters(teamContext),
|
|
63079
|
+
/*
|
|
63080
|
+
* Assigned, rather than assigned *and* detected.
|
|
63081
|
+
*
|
|
63082
|
+
* Somebody who put Claude in a seat on a machine where it is momentarily missing has still
|
|
63083
|
+
* said they intend to spend money there, and taking the budget controls away from them
|
|
63084
|
+
* because a probe failed would be the panel arguing with the user.
|
|
63085
|
+
*/
|
|
63086
|
+
claudeSeated: [...assigned.values()].some((agent) => agent.kind === "cli"),
|
|
62773
63087
|
teamGuidance: guidance ?? DEFAULT_TEAM_GUIDANCE,
|
|
62774
63088
|
defaultTeamGuidance: DEFAULT_TEAM_GUIDANCE,
|
|
62775
63089
|
teamGuidanceIsDefault: guidance === void 0,
|
|
@@ -62995,24 +63309,89 @@ ${preview.text}` } : {}
|
|
|
62995
63309
|
await postExpert({ redetect: false });
|
|
62996
63310
|
}
|
|
62997
63311
|
}
|
|
62998
|
-
|
|
63312
|
+
function describeAssessor() {
|
|
63313
|
+
const expert = cachedTeam.find((agent) => agent.role === "expert");
|
|
63314
|
+
if (expert === void 0) {
|
|
63315
|
+
return { label: "Nobody is in the expert seat", available: false };
|
|
63316
|
+
}
|
|
63317
|
+
return { label: expert.label, available: expert.available };
|
|
63318
|
+
}
|
|
63319
|
+
async function askExpertSeat(question, config2, expert) {
|
|
63320
|
+
if (expert.kind === "cli") {
|
|
63321
|
+
const cli = await detectCli(config2.expert?.path ?? "claude");
|
|
63322
|
+
if (!cli.available)
|
|
63323
|
+
throw new Error("The Claude CLI is not available.");
|
|
63324
|
+
const graded = await consultExpert(cli, {
|
|
63325
|
+
question,
|
|
63326
|
+
cwd: workspaceRoot ?? process.cwd(),
|
|
63327
|
+
...config2.expert?.model !== void 0 ? { model: config2.expert.model } : {}
|
|
63328
|
+
});
|
|
63329
|
+
recordConsultation({
|
|
63330
|
+
isError: graded.isError,
|
|
63331
|
+
...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
|
|
63332
|
+
});
|
|
63333
|
+
if (graded.isError)
|
|
63334
|
+
throw new Error(graded.text);
|
|
63335
|
+
return {
|
|
63336
|
+
text: graded.text,
|
|
63337
|
+
...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
|
|
63338
|
+
};
|
|
63339
|
+
}
|
|
63340
|
+
const profile = config2.profiles?.find((candidate) => candidate.id === expert.profileId);
|
|
63341
|
+
if (profile === void 0) {
|
|
63342
|
+
throw new Error(`No profile "${expert.profileId ?? ""}" exists any more.`);
|
|
63343
|
+
}
|
|
63344
|
+
const seatProfile = expert.thinking === void 0 ? profile : {
|
|
63345
|
+
...profile,
|
|
63346
|
+
thinking: {
|
|
63347
|
+
...profile.thinking ?? { level: expert.thinking },
|
|
63348
|
+
level: expert.thinking
|
|
63349
|
+
}
|
|
63350
|
+
};
|
|
63351
|
+
const provider = createChatProvider(seatProfile, httpClient, authStrategyFor(config2, profile), logger);
|
|
63352
|
+
let text = "";
|
|
63353
|
+
for await (const chunk of provider.streamChat([
|
|
63354
|
+
{ role: "system", content: expert.prompt },
|
|
63355
|
+
{ role: "user", content: question }
|
|
63356
|
+
])) {
|
|
63357
|
+
if (chunk.type === "text")
|
|
63358
|
+
text += chunk.text;
|
|
63359
|
+
if (chunk.type === "error")
|
|
63360
|
+
throw new Error(chunk.error);
|
|
63361
|
+
}
|
|
63362
|
+
if (text.trim().length === 0)
|
|
63363
|
+
throw new Error("The expert replied with nothing.");
|
|
63364
|
+
return { text };
|
|
63365
|
+
}
|
|
63366
|
+
async function handleAssessJunior(profileId) {
|
|
62999
63367
|
if (assessmentStep !== void 0)
|
|
63000
63368
|
return;
|
|
63001
63369
|
try {
|
|
63002
63370
|
const { config: config2 } = await configManager.load();
|
|
63003
|
-
const cli = await
|
|
63004
|
-
|
|
63371
|
+
const cli = await detectCli(config2.expert?.path ?? "claude").catch(() => void 0);
|
|
63372
|
+
const team = resolveTeam({
|
|
63373
|
+
config: config2.agents,
|
|
63374
|
+
profiles: (config2.profiles ?? []).map((entry) => ({ id: entry.id, label: entry.label })),
|
|
63375
|
+
cliAvailable: cli?.available === true
|
|
63376
|
+
});
|
|
63377
|
+
const expert = team.find((agent) => agent.role === "expert" && agent.available);
|
|
63378
|
+
if (expert === void 0) {
|
|
63005
63379
|
post({
|
|
63006
63380
|
type: "error",
|
|
63007
|
-
message: "
|
|
63381
|
+
message: "Nothing is in the expert seat. Assign one in the Agents tab - the assessment is its judgement, not ours."
|
|
63008
63382
|
});
|
|
63009
63383
|
return;
|
|
63010
63384
|
}
|
|
63011
|
-
const
|
|
63385
|
+
const chosen = profileId === void 0 ? void 0 : config2.profiles?.find((candidate) => candidate.id === profileId);
|
|
63386
|
+
if (profileId !== void 0 && chosen === void 0) {
|
|
63387
|
+
post({ type: "error", message: "That profile no longer exists." });
|
|
63388
|
+
return;
|
|
63389
|
+
}
|
|
63390
|
+
const profile = chosen ?? resolveActiveProfile(config2);
|
|
63012
63391
|
const provider = createChatProvider(profile, httpClient, authStrategyFor(config2, profile), logger);
|
|
63013
63392
|
const results = [];
|
|
63014
63393
|
for (const [index, probe2] of ASSESSMENT_PROBES.entries()) {
|
|
63015
|
-
assessmentStep = `Asking
|
|
63394
|
+
assessmentStep = `Asking ${profile.label ?? profile.model}: ${probe2.measures} (${String(index + 1)}/${String(ASSESSMENT_PROBES.length)})`;
|
|
63016
63395
|
await postExpert({ redetect: false });
|
|
63017
63396
|
let answer = "";
|
|
63018
63397
|
try {
|
|
@@ -63035,21 +63414,9 @@ ${preview.text}` } : {}
|
|
|
63035
63414
|
});
|
|
63036
63415
|
}
|
|
63037
63416
|
}
|
|
63038
|
-
assessmentStep =
|
|
63417
|
+
assessmentStep = `Asking ${expert.label} to grade the answers`;
|
|
63039
63418
|
await postExpert({ redetect: false });
|
|
63040
|
-
const graded = await
|
|
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
|
-
}
|
|
63419
|
+
const graded = await askExpertSeat(buildAssessmentQuestion(profile.model, results), config2, expert);
|
|
63053
63420
|
const assessment = {
|
|
63054
63421
|
model: profile.model,
|
|
63055
63422
|
profileLabel: profile.label ?? profile.model,
|
|
@@ -63059,7 +63426,12 @@ ${preview.text}` } : {}
|
|
|
63059
63426
|
...graded.costUsd !== void 0 ? { costUsd: graded.costUsd } : {}
|
|
63060
63427
|
};
|
|
63061
63428
|
const latest = (await configManager.load()).config;
|
|
63062
|
-
await configManager.save("user", {
|
|
63429
|
+
await configManager.save("user", {
|
|
63430
|
+
expert: {
|
|
63431
|
+
...latest.expert,
|
|
63432
|
+
assessments: recordAssessment(allAssessments(latest.expert ?? {}), assessment)
|
|
63433
|
+
}
|
|
63434
|
+
});
|
|
63063
63435
|
} catch (error51) {
|
|
63064
63436
|
post({ type: "error", message: error51 instanceof Error ? error51.message : String(error51) });
|
|
63065
63437
|
} finally {
|
|
@@ -63067,10 +63439,16 @@ ${preview.text}` } : {}
|
|
|
63067
63439
|
await postExpert({ redetect: false });
|
|
63068
63440
|
}
|
|
63069
63441
|
}
|
|
63070
|
-
async function handleClearAssessment() {
|
|
63442
|
+
async function handleClearAssessment(model, profileLabel) {
|
|
63071
63443
|
const { config: config2 } = await configManager.load();
|
|
63072
63444
|
const expert = { ...config2.expert };
|
|
63073
|
-
|
|
63445
|
+
if (model === void 0 || profileLabel === void 0) {
|
|
63446
|
+
delete expert.assessment;
|
|
63447
|
+
delete expert.assessments;
|
|
63448
|
+
} else {
|
|
63449
|
+
expert.assessments = forgetAssessment(allAssessments(expert), model, profileLabel);
|
|
63450
|
+
delete expert.assessment;
|
|
63451
|
+
}
|
|
63074
63452
|
await configManager.save("user", { expert });
|
|
63075
63453
|
await postExpert();
|
|
63076
63454
|
}
|
|
@@ -64921,7 +65299,11 @@ ${preview.text}` } : {}
|
|
|
64921
65299
|
if (profile === void 0) {
|
|
64922
65300
|
throw new Error(`No profile "${agent.profileId ?? ""}" exists any more.`);
|
|
64923
65301
|
}
|
|
64924
|
-
const
|
|
65302
|
+
const seatProfile = agent.thinking === void 0 ? profile : {
|
|
65303
|
+
...profile,
|
|
65304
|
+
thinking: { ...profile.thinking ?? { level: agent.thinking }, level: agent.thinking }
|
|
65305
|
+
};
|
|
65306
|
+
const provider = createChatProvider(seatProfile, httpClient, authStrategyFor(config2, profile), logger);
|
|
64925
65307
|
const extraTools = new Set(agent.role === "librarian" ? ["write_skill"] : []);
|
|
64926
65308
|
if (agent.canWrite) {
|
|
64927
65309
|
extraTools.add("write_to_file");
|
|
@@ -65665,9 +66047,9 @@ ${preview.text}` } : {}
|
|
|
65665
66047
|
await postExpert({ redetect: false });
|
|
65666
66048
|
}).catch((error51) => post({ type: "error", message: String(error51) }));
|
|
65667
66049
|
} else if (message3.type === "assessJunior") {
|
|
65668
|
-
void handleAssessJunior();
|
|
66050
|
+
void handleAssessJunior(message3.profileId);
|
|
65669
66051
|
} else if (message3.type === "clearAssessment") {
|
|
65670
|
-
void handleClearAssessment();
|
|
66052
|
+
void handleClearAssessment(message3.model, message3.profileLabel);
|
|
65671
66053
|
} else if (message3.type === "restartScheduler") {
|
|
65672
66054
|
restartScheduleTimer();
|
|
65673
66055
|
logger.info("schedule timer restarted by the user");
|
|
@@ -65774,6 +66156,24 @@ ${preview.text}` } : {}
|
|
|
65774
66156
|
void handleSaveCustomRole(message3);
|
|
65775
66157
|
} else if (message3.type === "deleteCustomRole") {
|
|
65776
66158
|
void handleDeleteCustomRole(message3.id);
|
|
66159
|
+
} else if (message3.type === "setRoleThinking") {
|
|
66160
|
+
const role = message3.role;
|
|
66161
|
+
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
66162
|
+
post({ type: "error", message: `There is no "${role}" role.` });
|
|
66163
|
+
return;
|
|
66164
|
+
}
|
|
66165
|
+
void saveAgents((current) => {
|
|
66166
|
+
const roles = { ...current.roles ?? {} };
|
|
66167
|
+
const existing = roles[role] ?? { kind: "profile" };
|
|
66168
|
+
if (message3.level === void 0) {
|
|
66169
|
+
const rest = { ...existing };
|
|
66170
|
+
delete rest.thinking;
|
|
66171
|
+
roles[role] = rest;
|
|
66172
|
+
} else {
|
|
66173
|
+
roles[role] = { ...existing, thinking: message3.level };
|
|
66174
|
+
}
|
|
66175
|
+
return { ...current, roles };
|
|
66176
|
+
});
|
|
65777
66177
|
} else if (message3.type === "setRoleEnabled") {
|
|
65778
66178
|
const role = message3.role;
|
|
65779
66179
|
if (!isAgentRole(role, cachedAgentDefinitions)) {
|
|
@@ -69912,7 +70312,7 @@ function respondJson(response, status, body) {
|
|
|
69912
70312
|
}
|
|
69913
70313
|
|
|
69914
70314
|
// src/cli.ts
|
|
69915
|
-
var VERSION = true ? "0.
|
|
70315
|
+
var VERSION = true ? "0.59.1" : "unknown (not a packaged build)";
|
|
69916
70316
|
var compat = installNodeCompat();
|
|
69917
70317
|
function lastMeaningfulLine(problem) {
|
|
69918
70318
|
const lines = problem.split(String.fromCharCode(10)).map((line) => line.trim()).filter((line) => line.length > 0 && !line.endsWith(":"));
|