@chosengeneration/light-code 0.209.0 → 0.211.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.cjs +263 -48
- package/dist/server.cjs +260 -45
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -41436,6 +41436,11 @@ var configSchema = external_exports.object({
|
|
|
41436
41436
|
* whole suggestion. Every pause in typing is a request to the gateway, so off unless set to true.
|
|
41437
41437
|
*/
|
|
41438
41438
|
composerCompletion: external_exports.boolean(),
|
|
41439
|
+
/**
|
|
41440
|
+
* Which provider profile suggests, when not the chat's own - a small, fast model. Reported: a large model
|
|
41441
|
+
* (gemini-4-argon) never produced its first words within the time limit, so no suggestion ever appeared.
|
|
41442
|
+
*/
|
|
41443
|
+
composerCompletionProfileId: external_exports.string().min(1),
|
|
41439
41444
|
/**
|
|
41440
41445
|
* The decision model (D3 from vLLM Semantic Router, or any OpenAI-compatible model that returns probabilities): a
|
|
41441
41446
|
* provider profile, and what it decides. Nothing here does anything until `profileId` names a profile - Agent team
|
|
@@ -45645,6 +45650,8 @@ function capEvent(event) {
|
|
|
45645
45650
|
return { ...event, text: cap(event.text, 4e4) };
|
|
45646
45651
|
case "consultation":
|
|
45647
45652
|
return event;
|
|
45653
|
+
case "behind":
|
|
45654
|
+
return { ...event, summary: cap(event.summary, EVENT_LIMITS.result) };
|
|
45648
45655
|
}
|
|
45649
45656
|
}
|
|
45650
45657
|
var REFUSALS = [
|
|
@@ -50244,7 +50251,9 @@ async function reorder(reranking, query, items, text2, limit, signal) {
|
|
|
50244
50251
|
if (items.length === 0)
|
|
50245
50252
|
return { items: [], reranked: false, dropped: 0, ms: 0 };
|
|
50246
50253
|
const result = await reranking.scores(query, items.map(text2), signal);
|
|
50254
|
+
const label = (item2) => (text2(item2).split("\n")[0] ?? "").slice(0, 80);
|
|
50247
50255
|
if (!result.ok || result.scores === void 0) {
|
|
50256
|
+
reranking.report?.({ query, candidates: items.length, first: [], kept: Math.min(limit, items.length), dropped: 0, ok: false, error: result.error ?? "no scores", ms: result.ms });
|
|
50248
50257
|
return {
|
|
50249
50258
|
items: items.slice(0, limit).map((item2) => ({ item: item2 })),
|
|
50250
50259
|
reranked: false,
|
|
@@ -50256,6 +50265,15 @@ async function reorder(reranking, query, items, text2, limit, signal) {
|
|
|
50256
50265
|
const scored = items.map((item2, index) => ({ item: item2, score: result.scores?.[index] ?? 0 }));
|
|
50257
50266
|
scored.sort((a, b) => b.score - a.score);
|
|
50258
50267
|
const kept = scored.filter((entry) => entry.score >= reranking.minScore);
|
|
50268
|
+
reranking.report?.({
|
|
50269
|
+
query,
|
|
50270
|
+
candidates: items.length,
|
|
50271
|
+
first: kept.slice(0, 5).map((entry) => ({ label: label(entry.item), score: entry.score })),
|
|
50272
|
+
kept: Math.min(limit, kept.length),
|
|
50273
|
+
dropped: scored.length - kept.length,
|
|
50274
|
+
ok: true,
|
|
50275
|
+
ms: result.ms
|
|
50276
|
+
});
|
|
50259
50277
|
return { items: kept.slice(0, limit), reranked: true, dropped: scored.length - kept.length, ms: result.ms };
|
|
50260
50278
|
}
|
|
50261
50279
|
|
|
@@ -62861,7 +62879,7 @@ var SHARE_SECTIONS = [
|
|
|
62861
62879
|
id: "workspace",
|
|
62862
62880
|
label: "Workspace behaviour",
|
|
62863
62881
|
description: "Mode, step cap, automatic compaction, retries, folders tools may read, and folders hidden from the @ picker.",
|
|
62864
|
-
keys: ["modeId", "maxIterations", "autoCompact", "autoHandoff", "unlimitedSteps", "composerCompletion", "connection", "filesystem"],
|
|
62882
|
+
keys: ["modeId", "maxIterations", "autoCompact", "autoHandoff", "unlimitedSteps", "composerCompletion", "composerCompletionProfileId", "connection", "filesystem"],
|
|
62865
62883
|
machineSpecific: true
|
|
62866
62884
|
},
|
|
62867
62885
|
{
|
|
@@ -69367,8 +69385,10 @@ function renderCodebaseInstructions(text2) {
|
|
|
69367
69385
|
var import_node_crypto14 = require("node:crypto");
|
|
69368
69386
|
var import_promises19 = __toESM(require("node:fs/promises"), 1);
|
|
69369
69387
|
var import_node_path38 = __toESM(require("node:path"), 1);
|
|
69370
|
-
var MEMORY_LIMIT =
|
|
69388
|
+
var MEMORY_LIMIT = 500;
|
|
69371
69389
|
var MEMORY_TEXT_LIMIT = 300;
|
|
69390
|
+
var MEMORY_SHOWN_CHARS = 6e3;
|
|
69391
|
+
var MEMORY_SHOWN_MAX = 40;
|
|
69372
69392
|
function memoryPath(options) {
|
|
69373
69393
|
if (options.codebaseDir !== void 0)
|
|
69374
69394
|
return import_node_path38.default.join(options.codebaseDir, "memory", "memory.json");
|
|
@@ -69436,8 +69456,11 @@ async function addMemory(file2, points) {
|
|
|
69436
69456
|
added.push(entry);
|
|
69437
69457
|
}
|
|
69438
69458
|
while (entries.length > MEMORY_LIMIT) {
|
|
69439
|
-
const
|
|
69440
|
-
|
|
69459
|
+
const candidates = entries.map((entry, index) => ({ entry, index })).filter(({ entry }) => entry.by !== "you");
|
|
69460
|
+
if (candidates.length === 0)
|
|
69461
|
+
break;
|
|
69462
|
+
candidates.sort((a, b) => a.entry.uses - b.entry.uses || a.entry.at - b.entry.at);
|
|
69463
|
+
entries.splice(candidates[0].index, 1);
|
|
69441
69464
|
}
|
|
69442
69465
|
return entries;
|
|
69443
69466
|
});
|
|
@@ -69454,13 +69477,44 @@ async function noteMemoryUsed(file2, ids) {
|
|
|
69454
69477
|
return;
|
|
69455
69478
|
await change(file2, (entries) => entries.map((entry) => ids.includes(entry.id) ? { ...entry, uses: entry.uses + 1, lastUsed: Date.now() } : entry));
|
|
69456
69479
|
}
|
|
69457
|
-
function
|
|
69480
|
+
function selectMemory(entries, request2, scores) {
|
|
69481
|
+
const size = entries.reduce((sum, entry) => sum + entry.text.length + 3, 0);
|
|
69482
|
+
if (size <= MEMORY_SHOWN_CHARS && entries.length <= MEMORY_SHOWN_MAX)
|
|
69483
|
+
return { shown: [...entries], left: 0 };
|
|
69484
|
+
const asked = words(request2);
|
|
69485
|
+
const overlap = (text2) => {
|
|
69486
|
+
const own = words(text2);
|
|
69487
|
+
if (own.size === 0 || asked.size === 0)
|
|
69488
|
+
return 0;
|
|
69489
|
+
let shared = 0;
|
|
69490
|
+
for (const word of own)
|
|
69491
|
+
if (asked.has(word))
|
|
69492
|
+
shared += 1;
|
|
69493
|
+
return shared / own.size;
|
|
69494
|
+
};
|
|
69495
|
+
const ranked = entries.map((entry, index) => ({ entry, index, score: (scores?.[index] ?? overlap(entry.text)) + (entry.by === "you" ? 0.05 : 0) + Math.min(entry.uses, 5) * 0.02 })).sort((a, b) => b.score - a.score || b.entry.at - a.entry.at);
|
|
69496
|
+
const chosen = [];
|
|
69497
|
+
let used = 0;
|
|
69498
|
+
for (const candidate of ranked) {
|
|
69499
|
+
if (chosen.length >= MEMORY_SHOWN_MAX)
|
|
69500
|
+
break;
|
|
69501
|
+
const cost = candidate.entry.text.length + 3;
|
|
69502
|
+
if (used + cost > MEMORY_SHOWN_CHARS)
|
|
69503
|
+
continue;
|
|
69504
|
+
chosen.push(candidate);
|
|
69505
|
+
used += cost;
|
|
69506
|
+
}
|
|
69507
|
+
chosen.sort((a, b) => a.index - b.index);
|
|
69508
|
+
return { shown: chosen.map((c2) => c2.entry), left: entries.length - chosen.length };
|
|
69509
|
+
}
|
|
69510
|
+
function renderMemoryForAgent(entries, left = 0) {
|
|
69458
69511
|
if (entries.length === 0)
|
|
69459
69512
|
return "";
|
|
69460
69513
|
return [
|
|
69461
69514
|
"## Remembered guidance",
|
|
69462
69515
|
"",
|
|
69463
69516
|
"The user told you these in earlier chats on this codebase, and they still apply. Follow them as you would the user's own words; when one conflicts with what the user asks now, the user's request now wins - say that you are setting the remembered point aside.",
|
|
69517
|
+
...left > 0 ? [`(These are the ones that bear on this request; ${String(left)} more are remembered for other work.)`] : [],
|
|
69464
69518
|
"",
|
|
69465
69519
|
...entries.map((entry) => `- ${entry.text}`)
|
|
69466
69520
|
].join("\n");
|
|
@@ -88179,6 +88233,8 @@ var ObserverHub = class {
|
|
|
88179
88233
|
} else {
|
|
88180
88234
|
this.guard = started;
|
|
88181
88235
|
this.guardProblem = void 0;
|
|
88236
|
+
if (this.memoryText !== void 0)
|
|
88237
|
+
started.pin({ kind: "memory", at: Date.now(), text: this.memoryText });
|
|
88182
88238
|
}
|
|
88183
88239
|
started.start();
|
|
88184
88240
|
}
|
|
@@ -88198,18 +88254,23 @@ var ObserverHub = class {
|
|
|
88198
88254
|
this.alert(signal.level, signal.message, "rules", signal.notify);
|
|
88199
88255
|
}
|
|
88200
88256
|
}
|
|
88201
|
-
if (guard.enabled && event.kind !== "decision")
|
|
88257
|
+
if (guard.enabled && event.kind !== "decision" && event.kind !== "behind")
|
|
88202
88258
|
this.toGuard(event);
|
|
88203
88259
|
if (event.kind === "turnEnd")
|
|
88204
88260
|
this.auditor?.flush();
|
|
88205
88261
|
}
|
|
88206
|
-
/** The memory as last given (`setMemory`)
|
|
88262
|
+
/** The memory as last given (`setMemory`); the user's latest request. */
|
|
88207
88263
|
memoryText;
|
|
88208
|
-
memorySent;
|
|
88209
88264
|
lastUserText = "";
|
|
88210
|
-
/**
|
|
88265
|
+
/**
|
|
88266
|
+
* The codebase's memory, numbered, for the Anti Hallucinator: pinned to it (`ObserverAgent.pin`), so it is sent now
|
|
88267
|
+
* when it changed, and first to every process it starts later - after a handoff, a crash or a restart.
|
|
88268
|
+
*/
|
|
88211
88269
|
setMemory(text2) {
|
|
88270
|
+
if (text2 === this.memoryText)
|
|
88271
|
+
return;
|
|
88212
88272
|
this.memoryText = text2;
|
|
88273
|
+
this.guard?.pin(text2 === void 0 ? void 0 : { kind: "memory", at: Date.now(), text: text2 });
|
|
88213
88274
|
}
|
|
88214
88275
|
/** Events since the Anti Hallucinator's last step, and the request it is checking against. */
|
|
88215
88276
|
guardStep = [];
|
|
@@ -88224,13 +88285,8 @@ var ObserverHub = class {
|
|
|
88224
88285
|
* that needs one rather than on its own. A helper that predates `quiet` reviews it anyway, as before.
|
|
88225
88286
|
*/
|
|
88226
88287
|
toGuard(event) {
|
|
88227
|
-
if (event.kind === "turnStart")
|
|
88288
|
+
if (event.kind === "turnStart")
|
|
88228
88289
|
this.lastUserText = event.text;
|
|
88229
|
-
if (this.memoryText !== void 0 && this.memoryText !== this.memorySent) {
|
|
88230
|
-
this.memorySent = this.memoryText;
|
|
88231
|
-
this.guard?.send({ kind: "memory", at: event.at, text: this.memoryText });
|
|
88232
|
-
}
|
|
88233
|
-
}
|
|
88234
88290
|
const firstPass = this.deps.firstPass;
|
|
88235
88291
|
if (firstPass === void 0) {
|
|
88236
88292
|
this.guard?.send(event);
|
|
@@ -88420,6 +88476,8 @@ function redactEvent(event, secrets) {
|
|
|
88420
88476
|
return { ...event, question: r(event.question), outcome: r(event.outcome) };
|
|
88421
88477
|
case "consultation":
|
|
88422
88478
|
return event;
|
|
88479
|
+
case "behind":
|
|
88480
|
+
return { ...event, summary: r(event.summary) };
|
|
88423
88481
|
}
|
|
88424
88482
|
}
|
|
88425
88483
|
|
|
@@ -88468,6 +88526,18 @@ ${this.recent.map((r) => `- ${r}`).join("\n")}`);
|
|
|
88468
88526
|
this.stopped = false;
|
|
88469
88527
|
this.launch(void 0);
|
|
88470
88528
|
}
|
|
88529
|
+
/**
|
|
88530
|
+
* An event every process of this observer must have, whatever came before it: sent now, and first to each process
|
|
88531
|
+
* started later - after a handoff, a crash or a restart. The codebase's memory is one (asked: "when anti halucinator
|
|
88532
|
+
* starts, will it read the full memory to context?"); a handoff carries only the observer's own notes, so without
|
|
88533
|
+
* this a new process would not know the memory until it changed. `undefined` clears it.
|
|
88534
|
+
*/
|
|
88535
|
+
pin(event) {
|
|
88536
|
+
this.pinned = event;
|
|
88537
|
+
if (event !== void 0)
|
|
88538
|
+
this.send(event);
|
|
88539
|
+
}
|
|
88540
|
+
pinned;
|
|
88471
88541
|
/** `quiet`: the decision model's first pass was sure of this step - kept in context, reviewed with the next one. */
|
|
88472
88542
|
send(event, quiet = false) {
|
|
88473
88543
|
if (this.stopped)
|
|
@@ -88603,7 +88673,9 @@ ${this.recent.map((r) => `- ${r}`).join("\n")}`);
|
|
|
88603
88673
|
model: this.options.model,
|
|
88604
88674
|
handoff: this.handoffText()
|
|
88605
88675
|
});
|
|
88606
|
-
|
|
88676
|
+
if (this.pinned !== void 0)
|
|
88677
|
+
this.writeTo(child, { type: "event", event: this.pinned });
|
|
88678
|
+
const waiting = [...pending ?? [], ...this.buffered].filter((event) => event !== this.pinned);
|
|
88607
88679
|
this.buffered = [];
|
|
88608
88680
|
for (const event of waiting)
|
|
88609
88681
|
this.writeTo(child, { type: "event", event });
|
|
@@ -88663,25 +88735,45 @@ function guardPrompt(context) {
|
|
|
88663
88735
|
}
|
|
88664
88736
|
|
|
88665
88737
|
// ../../packages/core/dist/observers/report.js
|
|
88738
|
+
var LINES_PER_REQUEST = 40;
|
|
88666
88739
|
function rolesReport(records) {
|
|
88667
88740
|
const main = /* @__PURE__ */ new Map();
|
|
88668
88741
|
const specialists = /* @__PURE__ */ new Map();
|
|
88669
88742
|
const decisions = /* @__PURE__ */ new Map();
|
|
88670
88743
|
const tools = /* @__PURE__ */ new Map();
|
|
88671
88744
|
const participants = {};
|
|
88745
|
+
const timeline = [];
|
|
88746
|
+
const line = (at2, text2) => {
|
|
88747
|
+
let current = timeline.at(-1);
|
|
88748
|
+
if (current === void 0) {
|
|
88749
|
+
current = { at: at2, request: "(before the first request)", lines: [] };
|
|
88750
|
+
timeline.push(current);
|
|
88751
|
+
}
|
|
88752
|
+
if (current.lines.length < LINES_PER_REQUEST)
|
|
88753
|
+
current.lines.push(text2);
|
|
88754
|
+
else if (current.lines.length === LINES_PER_REQUEST)
|
|
88755
|
+
current.lines.push("\u2026 (more not shown - read_audit_log with action records has them all)");
|
|
88756
|
+
};
|
|
88672
88757
|
let requests = 0;
|
|
88673
88758
|
let from;
|
|
88674
88759
|
let until;
|
|
88675
88760
|
const reviews = { findings: 0, alerts: 0, notes: 0 };
|
|
88676
|
-
for (const record2 of records) {
|
|
88761
|
+
for (const record2 of [...records].sort((a, b) => a.at - b.at)) {
|
|
88677
88762
|
from = from === void 0 ? record2.at : Math.min(from, record2.at);
|
|
88678
88763
|
until = until === void 0 ? record2.at : Math.max(until, record2.at);
|
|
88679
|
-
if (record2.finding !== void 0)
|
|
88764
|
+
if (record2.finding !== void 0) {
|
|
88680
88765
|
reviews.findings += 1;
|
|
88681
|
-
|
|
88766
|
+
if (record2.finding.risk !== "none")
|
|
88767
|
+
line(record2.at, `Auditor (${record2.finding.risk} risk): ${record2.finding.summary.slice(0, 200)}`);
|
|
88768
|
+
}
|
|
88769
|
+
if (record2.alert !== void 0) {
|
|
88682
88770
|
reviews.alerts += 1;
|
|
88683
|
-
|
|
88771
|
+
line(record2.at, `Alert (${record2.alert.level}): ${record2.alert.message.slice(0, 200)}`);
|
|
88772
|
+
}
|
|
88773
|
+
if (record2.note !== void 0) {
|
|
88684
88774
|
reviews.notes += 1;
|
|
88775
|
+
line(record2.at, `Anti Hallucinator: ${record2.note.note.slice(0, 240)}`);
|
|
88776
|
+
}
|
|
88685
88777
|
const e = record2.event;
|
|
88686
88778
|
if (e === void 0)
|
|
88687
88779
|
continue;
|
|
@@ -88693,6 +88785,7 @@ function rolesReport(records) {
|
|
|
88693
88785
|
main.set(key4, entry);
|
|
88694
88786
|
for (const [who, model] of Object.entries(e.participants ?? {}))
|
|
88695
88787
|
participants[who] = model;
|
|
88788
|
+
timeline.push({ at: record2.at, request: e.text.replace(/\s+/g, " ").slice(0, 120), lines: [`${e.model}, ${e.mode} mode`] });
|
|
88696
88789
|
} else if (e.kind === "consultation") {
|
|
88697
88790
|
const key4 = `${e.role}|${e.model}`;
|
|
88698
88791
|
const entry = specialists.get(key4) ?? { role: e.role, name: e.name, model: e.model, consultations: 0, failed: 0, seconds: 0, readOnly: 0 };
|
|
@@ -88703,10 +88796,19 @@ function rolesReport(records) {
|
|
|
88703
88796
|
entry.readOnly += 1;
|
|
88704
88797
|
entry.seconds += Math.round(e.ms / 1e3);
|
|
88705
88798
|
specialists.set(key4, entry);
|
|
88799
|
+
line(record2.at, `Consulted ${e.name} (${e.model})${e.readOnly === true ? ", read-only" : ""} - ${String(Math.round(e.ms / 1e3))} s${e.ok ? "" : ", failed"}`);
|
|
88706
88800
|
} else if (e.kind === "decision") {
|
|
88707
88801
|
decisions.set(e.purpose, (decisions.get(e.purpose) ?? 0) + 1);
|
|
88802
|
+
const best = Object.entries(e.probabilities ?? {}).sort((a, b) => b[1] - a[1])[0];
|
|
88803
|
+
line(record2.at, `Decision model - ${e.purpose}: ${e.outcome}${best !== void 0 ? ` (${best[0]} ${best[1].toFixed(2)})` : ""}`);
|
|
88804
|
+
} else if (e.kind === "behind") {
|
|
88805
|
+
line(record2.at, e.summary);
|
|
88708
88806
|
} else if (e.kind === "toolCall") {
|
|
88709
88807
|
tools.set(e.tool, (tools.get(e.tool) ?? 0) + 1);
|
|
88808
|
+
} else if (e.kind === "approval" && e.decision === "denied") {
|
|
88809
|
+
line(record2.at, `You denied ${e.tool}`);
|
|
88810
|
+
} else if (e.kind === "refused") {
|
|
88811
|
+
line(record2.at, `Refused: ${e.tool} - ${e.reason.slice(0, 160)}`);
|
|
88710
88812
|
}
|
|
88711
88813
|
}
|
|
88712
88814
|
const task = records.find((record2) => record2.task !== void 0)?.task;
|
|
@@ -88720,14 +88822,16 @@ function rolesReport(records) {
|
|
|
88720
88822
|
decisions: [...decisions.entries()].map(([purpose, count3]) => ({ purpose, count: count3 })).sort((a, b) => b.count - a.count),
|
|
88721
88823
|
participants,
|
|
88722
88824
|
reviews,
|
|
88723
|
-
tools: [...tools.entries()].map(([tool, calls]) => ({ tool, calls })).sort((a, b) => b.calls - a.calls).slice(0, 15)
|
|
88825
|
+
tools: [...tools.entries()].map(([tool, calls]) => ({ tool, calls })).sort((a, b) => b.calls - a.calls).slice(0, 15),
|
|
88826
|
+
timeline
|
|
88724
88827
|
};
|
|
88725
88828
|
}
|
|
88726
|
-
function renderRolesReport(report, title = "
|
|
88727
|
-
if (report.requests === 0 && report.specialists.length === 0)
|
|
88829
|
+
function renderRolesReport(report, title = "What happened in this task") {
|
|
88830
|
+
if (report.requests === 0 && report.specialists.length === 0 && report.timeline.length === 0) {
|
|
88728
88831
|
return `## ${title}
|
|
88729
88832
|
|
|
88730
88833
|
Nothing recorded for it. The Auditor records only while it is switched on (Settings \u2192 Project \u2192 Auditor).`;
|
|
88834
|
+
}
|
|
88731
88835
|
const when4 = (at2) => at2 === void 0 ? "?" : new Date(at2).toLocaleString();
|
|
88732
88836
|
const lines2 = [`## ${title}`, "", `${String(report.requests)} request(s), ${when4(report.from)} to ${when4(report.until)}.`, "", "### Main agent", "", "| Model | Mode | Requests |", "| --- | --- | --- |"];
|
|
88733
88837
|
for (const entry of report.main)
|
|
@@ -88751,6 +88855,14 @@ Nothing recorded for it. The Auditor records only while it is switched on (Setti
|
|
|
88751
88855
|
lines2.push("", `Reviews: ${String(report.reviews.findings)} Auditor finding(s), ${String(report.reviews.alerts)} alert(s), ${String(report.reviews.notes)} Anti Hallucinator note(s).`);
|
|
88752
88856
|
if (report.tools.length > 0)
|
|
88753
88857
|
lines2.push("", `Tools used most: ${report.tools.map((t) => `${t.tool} (${String(t.calls)})`).join(", ")}.`);
|
|
88858
|
+
if (report.timeline.length > 0) {
|
|
88859
|
+
lines2.push("", "### Behind the scenes, request by request");
|
|
88860
|
+
for (const entry of report.timeline) {
|
|
88861
|
+
lines2.push("", `**${new Date(entry.at).toLocaleTimeString()} - ${entry.request}**`);
|
|
88862
|
+
for (const text2 of entry.lines)
|
|
88863
|
+
lines2.push(`- ${text2}`);
|
|
88864
|
+
}
|
|
88865
|
+
}
|
|
88754
88866
|
return lines2.join("\n");
|
|
88755
88867
|
}
|
|
88756
88868
|
|
|
@@ -88803,6 +88915,9 @@ function auditRow(record2) {
|
|
|
88803
88915
|
} else if (e.kind === "decision") {
|
|
88804
88916
|
row["decision"] = e.outcome;
|
|
88805
88917
|
row["text"] = `${e.purpose}: ${e.question}${e.probabilities !== void 0 ? ` ${JSON.stringify(e.probabilities)}` : ""}`;
|
|
88918
|
+
} else if (e.kind === "behind") {
|
|
88919
|
+
row["area"] = e.area;
|
|
88920
|
+
row["text"] = e.summary;
|
|
88806
88921
|
} else if (e.kind === "consultation") {
|
|
88807
88922
|
row["role"] = e.role;
|
|
88808
88923
|
row["model"] = e.model;
|
|
@@ -92545,10 +92660,18 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
|
|
|
92545
92660
|
const found2 = cachedReranker;
|
|
92546
92661
|
if (found2 === void 0 || found2.settings[use] === false)
|
|
92547
92662
|
return void 0;
|
|
92663
|
+
const what = { docs: "Tool and skill search", teamSkills: "Team skills search", codebase: "Codebase search", picks: "Skill and tool picks" }[use];
|
|
92548
92664
|
return {
|
|
92549
92665
|
scores: (query, texts, signal) => rerank(found2.model, query, texts, { ...signal !== void 0 ? { signal } : {}, ...timeoutMs !== void 0 ? { timeoutMs } : {} }),
|
|
92550
92666
|
minScore: found2.settings.minScore ?? DEFAULT_MIN_SCORE,
|
|
92551
|
-
candidates: found2.settings.candidates ?? DEFAULT_CANDIDATES
|
|
92667
|
+
candidates: found2.settings.candidates ?? DEFAULT_CANDIDATES,
|
|
92668
|
+
// For the Auditor: what it put first, what it set aside, or that it did not answer and the search kept its order.
|
|
92669
|
+
report: (outcome) => observerHub.event({
|
|
92670
|
+
kind: "behind",
|
|
92671
|
+
at: Date.now(),
|
|
92672
|
+
area: "reranker",
|
|
92673
|
+
summary: outcome.ok ? `${what}: the reranker (${found2.model.profile.model}) reordered ${String(outcome.candidates)} candidates for "${outcome.query.slice(0, 80)}" in ${(outcome.ms / 1e3).toFixed(1)} s - first ${outcome.first.map((f) => `${f.label} (${f.score.toFixed(2)})`).join(", ") || "none"}${outcome.dropped > 0 ? `; set aside ${String(outcome.dropped)} below ${String(found2.settings.minScore ?? DEFAULT_MIN_SCORE)}` : ""}.` : `${what}: the reranker (${found2.model.profile.model}) did not answer (${outcome.error ?? "no scores"}), so the search kept its own order.`
|
|
92674
|
+
})
|
|
92552
92675
|
};
|
|
92553
92676
|
}
|
|
92554
92677
|
const withReranking = (use) => {
|
|
@@ -92856,6 +92979,8 @@ ${answer.slice(0, 12e3)}` }
|
|
|
92856
92979
|
if (added.length === 0)
|
|
92857
92980
|
return;
|
|
92858
92981
|
logger.info(`memory: kept ${String(added.length)} point(s) from the user's guidance`);
|
|
92982
|
+
for (const entry of added)
|
|
92983
|
+
observerHub.event({ kind: "behind", at: Date.now(), area: "memory", summary: `Memory: the Anti Hallucinator kept "${entry.text}"` });
|
|
92859
92984
|
await postMemory();
|
|
92860
92985
|
}).catch((error51) => logger.warn(`memory: could not save - ${error51 instanceof Error ? error51.message : String(error51)}`));
|
|
92861
92986
|
},
|
|
@@ -92863,6 +92988,11 @@ ${answer.slice(0, 12e3)}` }
|
|
|
92863
92988
|
if (memoryFile === void 0)
|
|
92864
92989
|
return;
|
|
92865
92990
|
const ids = numbers.map((n) => memoryShown[n - 1]?.id).filter((id) => id !== void 0);
|
|
92991
|
+
for (const n of numbers) {
|
|
92992
|
+
const entry = memoryShown[n - 1];
|
|
92993
|
+
if (entry !== void 0)
|
|
92994
|
+
observerHub.event({ kind: "behind", at: Date.now(), area: "memory", summary: `Memory: the Anti Hallucinator redirected the agent with "${entry.text}"` });
|
|
92995
|
+
}
|
|
92866
92996
|
void noteMemoryUsed(memoryFile, ids).then(() => postMemory()).catch(() => void 0);
|
|
92867
92997
|
}
|
|
92868
92998
|
});
|
|
@@ -93777,10 +93907,16 @@ ${answer.slice(0, 12e3)}` }
|
|
|
93777
93907
|
const mailSearch = mailCollection === void 0 ? void 0 : await resolveMailSearch(config2);
|
|
93778
93908
|
const searchIndexes = search?.opensearch !== void 0 ? await indexNamesFor(search.opensearch) : [];
|
|
93779
93909
|
await boundedWait(skillsReady, "Skills");
|
|
93780
|
-
const
|
|
93910
|
+
const remembered = memoryOn(config2) ? await readMemory(memoryFile) : [];
|
|
93911
|
+
const memoryRanker = remembered.length > MEMORY_SHOWN_MAX || remembered.reduce((sum, e) => sum + e.text.length + 3, 0) > MEMORY_SHOWN_CHARS ? rerankingFor("docs", 3e3) : void 0;
|
|
93912
|
+
const memoryScores = memoryRanker === void 0 ? void 0 : await memoryRanker.scores(text2, remembered.map((entry) => entry.text)).then((result) => result.ok ? result.scores : void 0);
|
|
93913
|
+
const { shown: memory, left: memoryLeft } = selectMemory(remembered, text2, memoryScores);
|
|
93914
|
+
if (memoryLeft > 0) {
|
|
93915
|
+
observerHub.event({ kind: "behind", at: Date.now(), area: "memory", summary: `Memory: gave ${String(memory.length)} of ${String(remembered.length)} remembered points, chosen for this request ${memoryScores !== void 0 ? "by the reranker" : "by shared words"}.` });
|
|
93916
|
+
}
|
|
93781
93917
|
memoryShown = memory;
|
|
93782
|
-
observerHub.setMemory(memoryOn(config2) ? renderMemoryForGuard(memory) : void 0);
|
|
93783
|
-
const codebaseInstructions = [renderCodebaseInstructions(await instructionsReady), renderMemoryForAgent(memory)].filter((part) => part.length > 0).join("\n\n");
|
|
93918
|
+
observerHub.setMemory(memoryOn(config2) && memory.length > 0 ? renderMemoryForGuard(memory) : void 0);
|
|
93919
|
+
const codebaseInstructions = [renderCodebaseInstructions(await instructionsReady), renderMemoryForAgent(memory, memoryLeft)].filter((part) => part.length > 0).join("\n\n");
|
|
93784
93920
|
const activeMode = findMode(config2.modeId);
|
|
93785
93921
|
turnModeId = activeMode.id;
|
|
93786
93922
|
juniorTurnWithoutExpert = activeMode.id === "junior" && schedule === void 0;
|
|
@@ -94182,7 +94318,10 @@ ${suggestion}`;
|
|
|
94182
94318
|
post({ type: "contextUsage", usage: { ...breakdown, supersededCount, compactedCount } });
|
|
94183
94319
|
persistSoon();
|
|
94184
94320
|
},
|
|
94185
|
-
onCompacted: (summarisedCount) =>
|
|
94321
|
+
onCompacted: (summarisedCount) => {
|
|
94322
|
+
observerHub.event({ kind: "behind", at: Date.now(), area: "context", summary: `Conversation compacted: ${String(summarisedCount)} older messages summarised to fit the model's window.` });
|
|
94323
|
+
post({ type: "compacted", summarisedCount });
|
|
94324
|
+
},
|
|
94186
94325
|
onUsage: (counted) => recordTokens(profile.model, counted),
|
|
94187
94326
|
onContextWindowLearned: (tokens) => {
|
|
94188
94327
|
if (profile.modelCapabilities?.contextWindow !== void 0)
|
|
@@ -94200,6 +94339,7 @@ ${suggestion}`;
|
|
|
94200
94339
|
},
|
|
94201
94340
|
onRetry: (info) => {
|
|
94202
94341
|
logger.warn(`model request retry ${String(info.retry)}/${String(info.maxRetries)}: ${info.reason}`);
|
|
94342
|
+
observerHub.event({ kind: "behind", at: Date.now(), area: "retry", summary: `Model request retried (${String(info.retry)} of ${String(info.maxRetries)}): ${info.reason}` });
|
|
94203
94343
|
cumulativeText = "";
|
|
94204
94344
|
cumulativeReasoning = "";
|
|
94205
94345
|
post({
|
|
@@ -94655,8 +94795,27 @@ ${suggestion}`;
|
|
|
94655
94795
|
post({ type: "commitMessageSuggestion", error: error51 instanceof Error ? error51.message : String(error51) });
|
|
94656
94796
|
}
|
|
94657
94797
|
}
|
|
94798
|
+
let completionProblem;
|
|
94799
|
+
let completionOk;
|
|
94800
|
+
async function postCompletionSettings() {
|
|
94801
|
+
const config2 = await loadSettings();
|
|
94802
|
+
let chatModel;
|
|
94803
|
+
try {
|
|
94804
|
+
chatModel = resolveActiveProfile(config2).model;
|
|
94805
|
+
} catch {
|
|
94806
|
+
chatModel = void 0;
|
|
94807
|
+
}
|
|
94808
|
+
post({
|
|
94809
|
+
type: "completionSettings",
|
|
94810
|
+
...config2.composerCompletionProfileId !== void 0 ? { profileId: config2.composerCompletionProfileId } : {},
|
|
94811
|
+
...chatModel !== void 0 ? { chatModel } : {},
|
|
94812
|
+
profiles: (config2.profiles ?? []).map((p) => ({ id: p.id, label: p.label, model: p.model })),
|
|
94813
|
+
...completionProblem !== void 0 ? { lastProblem: completionProblem } : {},
|
|
94814
|
+
...completionOk !== void 0 ? { lastOk: completionOk } : {}
|
|
94815
|
+
});
|
|
94816
|
+
}
|
|
94658
94817
|
async function suggestCompletion(id, typed) {
|
|
94659
|
-
completionAbort?.abort();
|
|
94818
|
+
completionAbort?.abort("superseded");
|
|
94660
94819
|
const controller = new AbortController();
|
|
94661
94820
|
completionAbort = controller;
|
|
94662
94821
|
const answer = (text2) => {
|
|
@@ -94666,13 +94825,17 @@ ${suggestion}`;
|
|
|
94666
94825
|
};
|
|
94667
94826
|
if (!cachedComposerCompletion || typed.trim().length < TYPE_AHEAD_MIN_CHARS || typed.length > 4e3)
|
|
94668
94827
|
return answer("");
|
|
94669
|
-
const timer = setTimeout(() => controller.abort(),
|
|
94828
|
+
const timer = setTimeout(() => controller.abort("timeout"), 12e3);
|
|
94829
|
+
const started = Date.now();
|
|
94830
|
+
let asking = "";
|
|
94670
94831
|
let reply = "";
|
|
94671
94832
|
try {
|
|
94672
94833
|
const config2 = await loadSettings();
|
|
94673
|
-
const
|
|
94834
|
+
const chosen = config2.composerCompletionProfileId === void 0 ? void 0 : (config2.profiles ?? []).find((p) => p.id === config2.composerCompletionProfileId);
|
|
94835
|
+
const profile = chosen ?? resolveActiveProfile(config2);
|
|
94836
|
+
asking = profile.model;
|
|
94674
94837
|
const style = profile.thinking?.style ?? (/qwen/i.test(profile.model) ? "qwen" : void 0);
|
|
94675
|
-
const quick = { ...profile, ...style !== void 0 || profile.thinking !== void 0 ? { thinking: { level: "off", ...style !== void 0 ? { style } : {} } } : {} };
|
|
94838
|
+
const quick = { ...profile, ...style !== void 0 || profile.thinking !== void 0 || profile.wireFormat === "gemini" ? { thinking: { level: "off", ...style !== void 0 ? { style } : {} } } : {} };
|
|
94676
94839
|
const messages = typeAheadMessages(redact(typed, cachedSecretValues), conversation.toArray());
|
|
94677
94840
|
const ask = async (asked) => {
|
|
94678
94841
|
const provider = createChatProvider(asked, httpClient, authStrategyFor(config2, asked), logger, services.languageModels);
|
|
@@ -94691,11 +94854,25 @@ ${suggestion}`;
|
|
|
94691
94854
|
let failed2 = await ask(quick);
|
|
94692
94855
|
if (failed2 !== void 0 && reply.length === 0 && quick !== profile && !controller.signal.aborted)
|
|
94693
94856
|
failed2 = await ask(profile);
|
|
94694
|
-
if (
|
|
94695
|
-
|
|
94857
|
+
if (controller.signal.reason === "superseded")
|
|
94858
|
+
return;
|
|
94859
|
+
if (controller.signal.reason === "timeout") {
|
|
94860
|
+
completionProblem = `${asking} did not start answering within 12 seconds - too slow for suggestions. Choose a small, fast model for them below.`;
|
|
94861
|
+
} else if (failed2 !== void 0) {
|
|
94862
|
+
completionProblem = `${asking} answered with an error: ${failed2.slice(0, 200)}`;
|
|
94863
|
+
} else if (reply.trim().length > 0) {
|
|
94864
|
+
completionProblem = void 0;
|
|
94865
|
+
completionOk = { model: asking, ms: Date.now() - started };
|
|
94866
|
+
}
|
|
94867
|
+
if (completionProblem !== void 0 && (failed2 !== void 0 || controller.signal.reason === "timeout"))
|
|
94868
|
+
logger.info(`suggestion while typing: ${completionProblem}`);
|
|
94696
94869
|
} catch (error51) {
|
|
94697
|
-
if (
|
|
94698
|
-
|
|
94870
|
+
if (controller.signal.reason === "timeout")
|
|
94871
|
+
completionProblem = `${asking} did not start answering within 12 seconds - too slow for suggestions. Choose a small, fast model for them below.`;
|
|
94872
|
+
else if (!controller.signal.aborted)
|
|
94873
|
+
completionProblem = `${asking}: ${error51 instanceof Error ? error51.message : String(error51)}`;
|
|
94874
|
+
if (completionProblem !== void 0 && controller.signal.reason !== "superseded")
|
|
94875
|
+
logger.info(`suggestion while typing: ${completionProblem}`);
|
|
94699
94876
|
} finally {
|
|
94700
94877
|
clearTimeout(timer);
|
|
94701
94878
|
}
|
|
@@ -100936,6 +101113,11 @@ ${answer.slice(0, 16e3)}` } }, (d) => d.best !== void 0 && d.best.probability >=
|
|
|
100936
101113
|
void writeWebChatSetup(webChatFile, void 0).then(() => postWebChat("Removed."));
|
|
100937
101114
|
} else if (message6.type === "requestAuditRolesReport") {
|
|
100938
101115
|
reportFailure("auditRolesReport", readAuditTool.execute({ action: "roles", source: "local" }, {}).then((result) => post({ type: "auditRolesReport", text: result.content })));
|
|
101116
|
+
} else if (message6.type === "requestCompletionSettings") {
|
|
101117
|
+
reportFailure("postCompletionSettings", postCompletionSettings());
|
|
101118
|
+
} else if (message6.type === "setCompletionProfile") {
|
|
101119
|
+
const profileId = message6.profileId;
|
|
101120
|
+
reportFailure("setCompletionProfile", configManager.save("user", { composerCompletionProfileId: profileId }).then(() => postCompletionSettings()));
|
|
100939
101121
|
} else if (message6.type === "requestCodebaseMemory") {
|
|
100940
101122
|
reportFailure("postMemory", postMemory());
|
|
100941
101123
|
} else if (message6.type === "addCodebaseMemory" || message6.type === "editCodebaseMemory" || message6.type === "deleteCodebaseMemory") {
|
|
@@ -103447,8 +103629,10 @@ install contacts nothing until a provider is configured.
|
|
|
103447
103629
|
MCP, Add-ons, Search, Agents, Schedules, Python, Tools, DevOps, Outlook, Custom data, Skills, Usage, Network and
|
|
103448
103630
|
Appearance - plus **Team reviews** for team admins and owners with a change to decide, an add-on's own tab while it
|
|
103449
103631
|
is enabled, and Review and Variables on a shared server (\`light-code --server\`) only. **Project** also holds Team
|
|
103450
|
-
admins, the Auditor
|
|
103451
|
-
|
|
103632
|
+
admins, the Auditor (with **Report on this chat**: which roles and models took part), the Anti Hallucinator and the
|
|
103633
|
+
codebase's **Memory**. **Agents** holds the **Decision model** (D3) and the **Web chat**; **Search** holds the
|
|
103634
|
+
**Reranker**. Beside the mode picker (Auto, Ask, Agent team) is **Strategy**, once a specialist is assigned, and
|
|
103635
|
+
**Picks** (skill and tool for each request), once a decision model is set up.
|
|
103452
103636
|
|
|
103453
103637
|
**Everything the panel writes goes into one JSON file**, and that file can be hand-edited \u2014 the UI
|
|
103454
103638
|
and the loader share one schema, so a bad hand-edit and a bad save fail identically.
|
|
@@ -105159,7 +105343,13 @@ still change files by hand.
|
|
|
105159
105343
|
"roles report",
|
|
105160
105344
|
"report on this chat",
|
|
105161
105345
|
"who worked on",
|
|
105162
|
-
"models used"
|
|
105346
|
+
"models used",
|
|
105347
|
+
"behind the scenes",
|
|
105348
|
+
"what happened",
|
|
105349
|
+
"task report",
|
|
105350
|
+
"audit report",
|
|
105351
|
+
"how the reranker was used",
|
|
105352
|
+
"how the decision model was used"
|
|
105163
105353
|
],
|
|
105164
105354
|
body: `
|
|
105165
105355
|
**Settings \u2192 Project \u2192 Auditor** and **Anti Hallucinator**, saved for the open project (\`observers\` in
|
|
@@ -105180,10 +105370,15 @@ them becomes one notice. With a model chosen, the Auditor also reviews each batc
|
|
|
105180
105370
|
alerts. Agents can read the record back with **read_audit_log** (summary first, then records with filters;
|
|
105181
105371
|
rows go straight into the dataframe tool for custom analysis).
|
|
105182
105372
|
|
|
105183
|
-
**
|
|
105184
|
-
\`read_audit_log\` with action \`roles\`. It lists the main agent's model and mode
|
|
105185
|
-
consulted with its model, how often and how long (and which failed), the decision model
|
|
105186
|
-
|
|
105373
|
+
**What happened in a task:** **Report on this chat** (in the Auditor panel), or ask the agent - it uses
|
|
105374
|
+
\`read_audit_log\` with action \`roles\`. It lists who took part - the main agent's model and mode, every specialist
|
|
105375
|
+
consulted with its model, how often and how long (and which failed), the decision model, the reranker and the
|
|
105376
|
+
reviewers - and then, **request by request, everything that happened behind the scenes**: each decision model choice
|
|
105377
|
+
with its probability (routing, picks, loop verdicts, first passes), each time the reranker reordered a search (which
|
|
105378
|
+
search, how many candidates, what it put first with scores, what it set aside - or that it did not answer and the
|
|
105379
|
+
search kept its own order), the memory kept, selected or used to redirect the agent, specialists consulted, retried
|
|
105380
|
+
model requests, compaction, denials, refusals, alerts and the Anti Hallucinator's notes. Read from the record as it
|
|
105381
|
+
happened, so you can check things went the way you wanted. Recorded while the Auditor is on.
|
|
105187
105382
|
|
|
105188
105383
|
**With a decision model** (Settings \u2192 Agents \u2192 Decision model, e.g. D3), the Anti Hallucinator gets a **first pass**:
|
|
105189
105384
|
the decision model is asked, for each step, whether it is grounded in its tool results and still on your request. A
|
|
@@ -107531,6 +107726,11 @@ Also, each with its own switch in the same panel (all on once a decision model i
|
|
|
107531
107726
|
approved as always. **Speed:** once per message (not per step); with both, the two questions go at once, and D3
|
|
107532
107727
|
generates no text, so it is usually a fraction of a second before the reply starts; it never waits more than 4
|
|
107533
107728
|
seconds, and a late answer is simply not used. A chat with Picks off asks nothing. Not for scheduled runs.
|
|
107729
|
+
**With a reranker too** (Settings \u2192 Search \u2192 Reranker, config:reranker.picks): the reranker first narrows every skill
|
|
107730
|
+
and tool to the ten most relevant to the request, and the decision model chooses among those - a choice between ten it
|
|
107731
|
+
can be sure about, where among a hundred and thirty the probability spread too thin to pass the threshold. The
|
|
107732
|
+
reranker gets 2 seconds; if it does not answer, the decision model chooses among all of them as before. See the
|
|
107733
|
+
reranker topic.
|
|
107534
107734
|
- **Anti Hallucinator first pass** (config:decisionModel.firstPass): a step it is sure is grounded and on course
|
|
107535
107735
|
(config:decisionModel.firstPassThreshold, default 0.85) is reviewed with the next one instead of on its own.
|
|
107536
107736
|
- **Decision steps** in the Strategy window: a step whose next step it picks (see the strategies topic).
|
|
@@ -107581,6 +107781,16 @@ with -x", "we never edit generated files"), so they apply in every later chat. S
|
|
|
107581
107781
|
- **You manage it**: every entry can be edited or removed, and you can add your own. Switch it off there
|
|
107582
107782
|
(config:observers.antiHallucination.memory); nothing is then added or given to the agent.
|
|
107583
107783
|
|
|
107784
|
+
**Where it is kept:** a plain file per codebase, not a vector store - so it works with no search connection set up,
|
|
107785
|
+
and nothing about it is sent anywhere except to your own chat's model and the Anti Hallucinator.
|
|
107786
|
+
|
|
107787
|
+
**As it grows:** every entry is given while they fit (about 6,000 characters, 40 entries). Past that, each request gets
|
|
107788
|
+
the entries that bear on it - by the reranker when one is set up, otherwise shared words, with a little weight for
|
|
107789
|
+
entries you added and ones that redirected the agent before - so an old entry about this request is used and a new one
|
|
107790
|
+
about something else waits. The agent is told how many others there are. The Anti Hallucinator gets the same ones, and
|
|
107791
|
+
gets them again whenever its process is replaced (a handoff, a crash, a restart). Up to 500 are kept; an entry you
|
|
107792
|
+
added is never removed to make room.
|
|
107793
|
+
|
|
107584
107794
|
Kept on this computer, outside the repository, one per codebase and shared by its chats. It is not part of an export.
|
|
107585
107795
|
`
|
|
107586
107796
|
},
|
|
@@ -107622,8 +107832,13 @@ output), and is cut to one line. Each pause is one request to that model's gatew
|
|
|
107622
107832
|
slow or failing request shows nothing; it never puts an error in the chat. While the \`@\` or \`#\` picker is open,
|
|
107623
107833
|
Tab and the arrows belong to the picker.
|
|
107624
107834
|
|
|
107625
|
-
**With a thinking model** (Qwen3 and
|
|
107626
|
-
spend the whole time limit thinking, so nothing appeared. A
|
|
107835
|
+
**With a thinking model** (Qwen3, Gemini 2.5 and later) the request asks it not to think (\`enable_thinking: false\`
|
|
107836
|
+
for Qwen, \`thinkingBudget: 0\` for Gemini) - it used to spend the whole time limit thinking, so nothing appeared. A
|
|
107837
|
+
suggestion has 12 seconds.
|
|
107838
|
+
|
|
107839
|
+
**No suggestion appears?** The panel says why under **Last suggestion** - most often that the model did not start
|
|
107840
|
+
answering within 12 seconds. A large model is usually too slow for this: choose a small, fast one under **Model for
|
|
107841
|
+
suggestions** (config:composerCompletionProfileId) - a Flash or mini model - and the chat keeps its own model. A gateway that refuses that option is asked again without
|
|
107627
107842
|
it. Why a suggestion did not come is written to the log.
|
|
107628
107843
|
`
|
|
107629
107844
|
},
|