@chosengeneration/light-code 0.60.0 → 0.62.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/server.js CHANGED
@@ -48207,15 +48207,15 @@ ${record2.preview}`.toLowerCase();
48207
48207
  const hits = await options.semantic.searcher.searchByVector(options.semantic.collection, vector, {
48208
48208
  size: Math.min(100, Math.max(limit * 4, 40))
48209
48209
  });
48210
- const rank2 = /* @__PURE__ */ new Map();
48210
+ const rank3 = /* @__PURE__ */ new Map();
48211
48211
  hits.forEach((hit, position) => {
48212
48212
  const id = hit.path.startsWith("mail:") ? hit.path.slice("mail:".length) : hit.path;
48213
- if (!rank2.has(id))
48214
- rank2.set(id, position);
48213
+ if (!rank3.has(id))
48214
+ rank3.set(id, position);
48215
48215
  });
48216
48216
  ordered = [...candidates].sort((a, b) => {
48217
- const left = rank2.get(a.id);
48218
- const right = rank2.get(b.id);
48217
+ const left = rank3.get(a.id);
48218
+ const right = rank3.get(b.id);
48219
48219
  if (left !== void 0 && right !== void 0)
48220
48220
  return left - right;
48221
48221
  if (left !== void 0)
@@ -60862,8 +60862,8 @@ function coerceFormValue(field, raw) {
60862
60862
  if (field.required !== false && chosen.length === 0) {
60863
60863
  return { error: `"${field.label}" needs at least one selection.` };
60864
60864
  }
60865
- const order = (field.options ?? []).map((option) => option.value);
60866
- return { value: order.filter((value) => chosen.includes(value)) };
60865
+ const order2 = (field.options ?? []).map((option) => option.value);
60866
+ return { value: order2.filter((value) => chosen.includes(value)) };
60867
60867
  }
60868
60868
  if (field.type === "number") {
60869
60869
  const parsed = typeof raw === "number" ? raw : Number(String(raw ?? "").trim());
@@ -62785,6 +62785,8 @@ ${direction}` : attachMentions(text, mentions);
62785
62785
  return;
62786
62786
  if (chartFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
62787
62787
  return;
62788
+ if (diagramFromToolCall(toolCall.name, toolCall.arguments) !== void 0)
62789
+ return;
62788
62790
  const summary = toolCallSummary(toolCall);
62789
62791
  post({
62790
62792
  type: "toolCall",
@@ -62797,6 +62799,15 @@ ${direction}` : attachMentions(text, mentions);
62797
62799
  post({ type: "textChunk", text: result.content });
62798
62800
  return;
62799
62801
  }
62802
+ const diagram = diagramFromToolCall(toolCall.name, toolCall.arguments);
62803
+ if (diagram !== void 0) {
62804
+ post(diagram.kind === "diagram" ? {
62805
+ type: "diagram",
62806
+ diagram: diagram.diagram,
62807
+ ...informedBy !== void 0 ? { expertInformed: true, informedBy } : {}
62808
+ } : { type: "diagramError", message: diagram.message });
62809
+ return;
62810
+ }
62800
62811
  const chart = chartFromToolCall(toolCall.name, toolCall.arguments);
62801
62812
  if (chart !== void 0) {
62802
62813
  post(chart.kind === "chart" ? {
@@ -66450,6 +66461,22 @@ ${entry.content}`);
66450
66461
  lines.push(`## Chart
66451
66462
 
66452
66463
  Could not be drawn: ${entry.message}`);
66464
+ } else if (entry.kind === "diagramError") {
66465
+ lines.push(`## Diagram
66466
+
66467
+ Could not be drawn: ${entry.message}`);
66468
+ } else if (entry.kind === "diagram") {
66469
+ const diagram = entry.diagram;
66470
+ const labels = new Map(diagram.nodes.map((node) => [node.id, node.label]));
66471
+ lines.push([
66472
+ `## ${diagram.title ?? "Diagram"}`,
66473
+ "",
66474
+ ...diagram.edges.map((edge) => {
66475
+ const via = edge.label === void 0 ? "" : ` \u2014 ${edge.label}`;
66476
+ return `- ${labels.get(edge.from) ?? edge.from} \u2192 ${labels.get(edge.to) ?? edge.to}${via}`;
66477
+ }),
66478
+ ...diagram.note === void 0 ? [] : ["", diagram.note]
66479
+ ].join("\n"));
66453
66480
  } else {
66454
66481
  const call = entry.toolCall;
66455
66482
  lines.push([
@@ -67033,6 +67060,99 @@ function chartTotals(spec) {
67033
67060
  return { series, grand: series.reduce((sum, entry) => sum + entry.total, 0) };
67034
67061
  }
67035
67062
 
67063
+ // ../../packages/core/dist/diagrams/types.js
67064
+ var DIAGRAM_MAX_NODES = 40;
67065
+ var DIAGRAM_MAX_EDGES = 80;
67066
+ var NODE_TONES = [
67067
+ "neutral",
67068
+ "accent",
67069
+ "info",
67070
+ "success",
67071
+ "warning",
67072
+ "danger",
67073
+ "muted"
67074
+ ];
67075
+ var NODE_ICONS = [
67076
+ "service",
67077
+ "database",
67078
+ "user",
67079
+ "file",
67080
+ "cloud",
67081
+ "lock",
67082
+ "clock",
67083
+ "queue",
67084
+ "code",
67085
+ "mail",
67086
+ "check",
67087
+ "cross",
67088
+ "warning",
67089
+ "gear"
67090
+ ];
67091
+ var NODE_SHAPES = ["box", "round", "diamond", "cylinder"];
67092
+ var diagramNodeSchema = external_exports.object({
67093
+ id: external_exports.string().min(1).max(64).describe("A short identifier, referenced by edges. Not shown."),
67094
+ label: external_exports.string().min(1).max(120).describe("The text in the box. Keep it to a few words."),
67095
+ shape: external_exports.enum(NODE_SHAPES).optional().describe("box (a step, the default), round (a start or end), diamond (a decision), cylinder (a store or database)."),
67096
+ /** Shown under the label, smaller. For the qualifier that would otherwise bloat the label. */
67097
+ note: external_exports.string().max(120).optional().describe("A second, smaller line under the label."),
67098
+ tone: external_exports.enum(NODE_TONES).optional().describe("What the box means, as a colour: success for a good outcome, danger for a failure, warning for a risk, info for an external system, accent for the thing being explained, muted for context. Resolved against the theme, so it stays legible in light and dark."),
67099
+ icon: external_exports.enum(NODE_ICONS).optional().describe("A small glyph in the corner of the box: service, database, user, file, cloud, lock, clock, queue, code, mail, check, cross, warning, gear.")
67100
+ });
67101
+ var diagramEdgeSchema = external_exports.object({
67102
+ from: external_exports.string().min(1).describe("The id of the node the arrow leaves."),
67103
+ to: external_exports.string().min(1).describe("The id of the node the arrow enters."),
67104
+ label: external_exports.string().max(60).optional().describe('Text on the arrow \u2014 the condition, or what flows along it. "yes", "on failure".'),
67105
+ style: external_exports.enum(["solid", "dashed"]).optional().describe("dashed for something conditional, asynchronous or secondary.")
67106
+ });
67107
+ var diagramLegendSchema = external_exports.object({
67108
+ label: external_exports.string().min(1).max(80).describe("What this appearance means in this diagram."),
67109
+ tone: external_exports.enum(NODE_TONES).optional(),
67110
+ shape: external_exports.enum(NODE_SHAPES).optional(),
67111
+ icon: external_exports.enum(NODE_ICONS).optional()
67112
+ });
67113
+ var DIAGRAM_MAX_LEGEND = 8;
67114
+ var diagramSpecSchema = external_exports.object({
67115
+ title: external_exports.string().max(120).optional(),
67116
+ legend: external_exports.array(diagramLegendSchema).max(DIAGRAM_MAX_LEGEND).optional().describe("A key under the diagram. Give an entry only where the meaning is not obvious from the label \u2014 a colour that stands for something, a shape used in a particular way. Explain the diagram, not the palette."),
67117
+ direction: external_exports.enum(["down", "right"]).optional().describe("Which way the flow runs. down is the default and suits most flows."),
67118
+ nodes: external_exports.array(diagramNodeSchema).min(1).max(DIAGRAM_MAX_NODES),
67119
+ edges: external_exports.array(diagramEdgeSchema).max(DIAGRAM_MAX_EDGES),
67120
+ note: external_exports.string().max(400).optional().describe("A line under the diagram. Say what it leaves out, or where it came from.")
67121
+ }).superRefine((spec, context) => {
67122
+ const ids = /* @__PURE__ */ new Set();
67123
+ for (const [index, node] of spec.nodes.entries()) {
67124
+ if (ids.has(node.id)) {
67125
+ context.addIssue({
67126
+ code: "custom",
67127
+ path: ["nodes", index, "id"],
67128
+ /*
67129
+ * Named rather than de-duplicated. Two nodes sharing an id means the edges meant for one
67130
+ * of them are pointing at the other, and silently keeping the first would draw a diagram
67131
+ * that is wrong in a way nobody can see.
67132
+ */
67133
+ message: `Two nodes share the id "${node.id}". Ids must be unique \u2014 edges are resolved by them.`
67134
+ });
67135
+ }
67136
+ ids.add(node.id);
67137
+ }
67138
+ for (const [index, edge] of spec.edges.entries()) {
67139
+ for (const [end, id] of [
67140
+ ["from", edge.from],
67141
+ ["to", edge.to]
67142
+ ]) {
67143
+ if (!ids.has(id)) {
67144
+ context.addIssue({
67145
+ code: "custom",
67146
+ path: ["edges", index, end],
67147
+ // The available ids are listed: the usual cause is a typo, and a message that names
67148
+ // the candidates is one the model can act on without another round trip.
67149
+ message: `No node has the id "${id}". Known ids: ${[...ids].join(", ")}.`
67150
+ });
67151
+ }
67152
+ }
67153
+ }
67154
+ });
67155
+
67036
67156
  // ../../packages/core/dist/history/transcript.js
67037
67157
  var CONTROL_TOOLS = /* @__PURE__ */ new Set([
67038
67158
  "attempt_completion",
@@ -67142,6 +67262,16 @@ function consultationFromToolCall(name, rawArguments) {
67142
67262
  const role = typeof decoded === "object" && decoded !== null ? decoded.role : void 0;
67143
67263
  return typeof role === "string" && role.trim().length > 0 ? role.trim().toLowerCase() : "unknown";
67144
67264
  }
67265
+ function diagramFromToolCall(name, rawArguments) {
67266
+ const call = throughDispatch(name, rawArguments);
67267
+ if (call.name !== "show_diagram")
67268
+ return void 0;
67269
+ const parsed = diagramSpecSchema.safeParse(call.args);
67270
+ return parsed.success ? { kind: "diagram", diagram: parsed.data } : {
67271
+ kind: "diagramError",
67272
+ message: parsed.error.issues.map((issue2) => `${issue2.path.join(".")}: ${issue2.message}`).join("; ")
67273
+ };
67274
+ }
67145
67275
  function chartFromToolCall(name, rawArguments) {
67146
67276
  const call = throughDispatch(name, rawArguments);
67147
67277
  if (call.name !== "show_chart")
@@ -67216,6 +67346,264 @@ function createShowChartTool() {
67216
67346
  };
67217
67347
  }
67218
67348
 
67349
+ // ../../packages/core/dist/diagrams/layout.js
67350
+ var NODE_HEIGHT = 52;
67351
+ var NOTE_EXTRA = 14;
67352
+ var MIN_WIDTH = 96;
67353
+ var MAX_WIDTH = 260;
67354
+ var CHAR_WIDTH = 7.4;
67355
+ var PADDING_X = 28;
67356
+ var GAP_WITHIN_RANK = 28;
67357
+ var GAP_BETWEEN_RANKS = 64;
67358
+ var MARGIN = 28;
67359
+ var TITLE_HEIGHT = 40;
67360
+ var SWATCH_WIDTH = 26;
67361
+ var SWATCH_HEIGHT = 16;
67362
+ var SWATCH_GAP = 7;
67363
+ var LEGEND_ITEM_GAP = 22;
67364
+ var LEGEND_ROW_HEIGHT = 24;
67365
+ var LEGEND_TOP_GAP = 18;
67366
+ function widthFor(label, note) {
67367
+ const longest = Math.max(label.length, note?.length ?? 0);
67368
+ return Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, Math.round(longest * CHAR_WIDTH) + PADDING_X * 2));
67369
+ }
67370
+ function backEdges(spec) {
67371
+ const outgoing = /* @__PURE__ */ new Map();
67372
+ for (const [index, edge] of spec.edges.entries()) {
67373
+ const list = outgoing.get(edge.from) ?? [];
67374
+ list.push({ to: edge.to, index });
67375
+ outgoing.set(edge.from, list);
67376
+ }
67377
+ const back = /* @__PURE__ */ new Set();
67378
+ const state = /* @__PURE__ */ new Map();
67379
+ const visit = (id) => {
67380
+ state.set(id, "open");
67381
+ for (const edge of outgoing.get(id) ?? []) {
67382
+ const seen = state.get(edge.to);
67383
+ if (seen === "open")
67384
+ back.add(edge.index);
67385
+ else if (seen === void 0)
67386
+ visit(edge.to);
67387
+ }
67388
+ state.set(id, "done");
67389
+ };
67390
+ for (const node of spec.nodes)
67391
+ if (!state.has(node.id))
67392
+ visit(node.id);
67393
+ return back;
67394
+ }
67395
+ function rank2(spec, back) {
67396
+ const incoming = /* @__PURE__ */ new Map();
67397
+ for (const node of spec.nodes)
67398
+ incoming.set(node.id, []);
67399
+ for (const [index, edge] of spec.edges.entries()) {
67400
+ if (back.has(index))
67401
+ continue;
67402
+ incoming.get(edge.to)?.push(edge.from);
67403
+ }
67404
+ const ranks = /* @__PURE__ */ new Map();
67405
+ const resolving = /* @__PURE__ */ new Set();
67406
+ const rankOf = (id) => {
67407
+ const known = ranks.get(id);
67408
+ if (known !== void 0)
67409
+ return known;
67410
+ if (resolving.has(id))
67411
+ return 0;
67412
+ resolving.add(id);
67413
+ const parents = incoming.get(id) ?? [];
67414
+ const depth = parents.length === 0 ? 0 : Math.max(...parents.map((parent) => rankOf(parent) + 1));
67415
+ resolving.delete(id);
67416
+ ranks.set(id, depth);
67417
+ return depth;
67418
+ };
67419
+ for (const node of spec.nodes)
67420
+ rankOf(node.id);
67421
+ return ranks;
67422
+ }
67423
+ function order(spec, ranks, back) {
67424
+ const byRank = [];
67425
+ for (const node of spec.nodes) {
67426
+ const depth = ranks.get(node.id) ?? 0;
67427
+ while (byRank.length <= depth)
67428
+ byRank.push([]);
67429
+ byRank[depth]?.push(node.id);
67430
+ }
67431
+ const parents = /* @__PURE__ */ new Map();
67432
+ for (const [index, edge] of spec.edges.entries()) {
67433
+ if (back.has(index))
67434
+ continue;
67435
+ const list = parents.get(edge.to) ?? [];
67436
+ list.push(edge.from);
67437
+ parents.set(edge.to, list);
67438
+ }
67439
+ for (let depth = 1; depth < byRank.length; depth += 1) {
67440
+ const above = byRank[depth - 1] ?? [];
67441
+ const positions = new Map(above.map((id, index) => [id, index]));
67442
+ const row = byRank[depth] ?? [];
67443
+ const keyed = row.map((id, index) => {
67444
+ const known = (parents.get(id) ?? []).map((parent) => positions.get(parent)).filter((value) => value !== void 0);
67445
+ const barycentre = known.length === 0 ? index : known.reduce((a, b) => a + b, 0) / known.length;
67446
+ return { id, barycentre, index };
67447
+ });
67448
+ keyed.sort((a, b) => a.barycentre - b.barycentre || a.index - b.index);
67449
+ byRank[depth] = keyed.map((entry) => entry.id);
67450
+ }
67451
+ return byRank;
67452
+ }
67453
+ function layoutDiagram(spec) {
67454
+ const sideways = spec.direction === "right";
67455
+ const back = backEdges(spec);
67456
+ const ranks = rank2(spec, back);
67457
+ const rows = order(spec, ranks, back);
67458
+ const byId = new Map(spec.nodes.map((node) => [node.id, node]));
67459
+ const sizes = /* @__PURE__ */ new Map();
67460
+ for (const node of spec.nodes) {
67461
+ sizes.set(node.id, {
67462
+ width: widthFor(node.label, node.note),
67463
+ height: NODE_HEIGHT + (node.note === void 0 ? 0 : NOTE_EXTRA)
67464
+ });
67465
+ }
67466
+ const rankExtent = rows.map((row) => Math.max(...row.map((id) => sizes.get(id)?.height ?? NODE_HEIGHT)));
67467
+ const rowWidths = rows.map((row) => row.reduce((total, id) => total + (sizes.get(id)?.width ?? MIN_WIDTH), 0) + GAP_WITHIN_RANK * Math.max(0, row.length - 1));
67468
+ const widest = Math.max(...rowWidths, 1);
67469
+ const placed = [];
67470
+ let cursor = MARGIN + (spec.title === void 0 ? 0 : TITLE_HEIGHT);
67471
+ for (const [depth, row] of rows.entries()) {
67472
+ const extent = rankExtent[depth] ?? NODE_HEIGHT;
67473
+ let x = MARGIN + (widest - (rowWidths[depth] ?? 0)) / 2;
67474
+ for (const id of row) {
67475
+ const node = byId.get(id);
67476
+ const size2 = sizes.get(id);
67477
+ if (node === void 0 || size2 === void 0)
67478
+ continue;
67479
+ placed.push({
67480
+ id,
67481
+ label: node.label,
67482
+ note: node.note,
67483
+ shape: node.shape ?? "box",
67484
+ // A start or an end is accented unless the model said otherwise: the entry and exit of a
67485
+ // flow are what a reader looks for first.
67486
+ tone: node.tone ?? (node.shape === "round" ? "accent" : "neutral"),
67487
+ icon: node.icon,
67488
+ x,
67489
+ // Centred in its rank, so a tall box beside a short one does not look misaligned.
67490
+ y: cursor + (extent - size2.height) / 2,
67491
+ width: size2.width,
67492
+ height: size2.height
67493
+ });
67494
+ x += size2.width + GAP_WITHIN_RANK;
67495
+ }
67496
+ cursor += extent + GAP_BETWEEN_RANKS;
67497
+ }
67498
+ const upright = {
67499
+ width: widest + MARGIN * 2,
67500
+ height: cursor - GAP_BETWEEN_RANKS + MARGIN
67501
+ };
67502
+ const nodes = sideways ? placed.map((node) => ({
67503
+ ...node,
67504
+ x: node.y,
67505
+ y: node.x
67506
+ // Size is not transposed: a box swapping its width for its height would wrap its text.
67507
+ })) : placed;
67508
+ const size = sideways ? { width: upright.height, height: upright.width } : { width: upright.width, height: upright.height };
67509
+ const positions = new Map(nodes.map((node) => [node.id, node]));
67510
+ const edges = spec.edges.flatMap((edge, index) => {
67511
+ const from = positions.get(edge.from);
67512
+ const to = positions.get(edge.to);
67513
+ if (from === void 0 || to === void 0)
67514
+ return [];
67515
+ const start = sideways ? { x: from.x + from.width, y: from.y + from.height / 2 } : { x: from.x + from.width / 2, y: from.y + from.height };
67516
+ const end = sideways ? { x: to.x, y: to.y + to.height / 2 } : { x: to.x + to.width / 2, y: to.y };
67517
+ const isBack = back.has(index);
67518
+ const points = isBack ? sideways ? [
67519
+ { x: from.x + from.width / 2, y: from.y + from.height },
67520
+ { x: from.x + from.width / 2, y: size.height - MARGIN / 2 },
67521
+ { x: to.x + to.width / 2, y: size.height - MARGIN / 2 },
67522
+ { x: to.x + to.width / 2, y: to.y + to.height }
67523
+ ] : [
67524
+ { x: from.x + from.width, y: from.y + from.height / 2 },
67525
+ { x: size.width - MARGIN / 2, y: from.y + from.height / 2 },
67526
+ { x: size.width - MARGIN / 2, y: to.y + to.height / 2 },
67527
+ { x: to.x + to.width, y: to.y + to.height / 2 }
67528
+ ] : [start, end];
67529
+ const midpoint = points.length === 2 ? 0 : 1;
67530
+ const a = points[midpoint] ?? start;
67531
+ const b = points[midpoint + 1] ?? end;
67532
+ return [
67533
+ {
67534
+ from: edge.from,
67535
+ to: edge.to,
67536
+ label: edge.label,
67537
+ dashed: edge.style === "dashed",
67538
+ points,
67539
+ labelAt: { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 }
67540
+ }
67541
+ ];
67542
+ });
67543
+ const legend = [];
67544
+ let legendHeight = 0;
67545
+ let canvasWidth = size.width;
67546
+ if (spec.legend !== void 0 && spec.legend.length > 0) {
67547
+ const entryWidths = spec.legend.map((entry) => SWATCH_WIDTH + SWATCH_GAP + Math.round(entry.label.length * 6.6));
67548
+ const available = Math.max(size.width - MARGIN * 2, Math.max(...entryWidths));
67549
+ let x = MARGIN;
67550
+ let y = size.height + LEGEND_TOP_GAP;
67551
+ let rows2 = 1;
67552
+ for (const [index, entry] of spec.legend.entries()) {
67553
+ const entryWidth = entryWidths[index] ?? 0;
67554
+ if (x > MARGIN && x + entryWidth - MARGIN > available) {
67555
+ x = MARGIN;
67556
+ y += LEGEND_ROW_HEIGHT;
67557
+ rows2 += 1;
67558
+ }
67559
+ legend.push({
67560
+ label: entry.label,
67561
+ shape: entry.shape ?? "box",
67562
+ tone: entry.tone ?? "neutral",
67563
+ icon: entry.icon,
67564
+ x,
67565
+ y,
67566
+ swatchWidth: SWATCH_WIDTH,
67567
+ swatchHeight: SWATCH_HEIGHT
67568
+ });
67569
+ x += entryWidth + LEGEND_ITEM_GAP;
67570
+ canvasWidth = Math.max(canvasWidth, x - LEGEND_ITEM_GAP + MARGIN);
67571
+ }
67572
+ legendHeight = LEGEND_TOP_GAP + rows2 * LEGEND_ROW_HEIGHT;
67573
+ }
67574
+ return {
67575
+ width: canvasWidth,
67576
+ height: size.height + legendHeight,
67577
+ title: spec.title,
67578
+ note: spec.note,
67579
+ nodes,
67580
+ edges,
67581
+ legend
67582
+ };
67583
+ }
67584
+
67585
+ // ../../packages/core/dist/tools/showDiagram.js
67586
+ function createShowDiagramTool() {
67587
+ return {
67588
+ name: "show_diagram",
67589
+ group: "always",
67590
+ description: 'Draw a technical diagram for the user: a flow chart, an architecture sketch, a sequence of steps, a state machine. Give `nodes` (each with an `id` and a `label`) and `edges` between those ids \u2014 the layout is worked out for you, so do not attempt coordinates. Use it when a structure is easier seen than described: how a request travels, what calls what, where a decision branches, what happens on failure. Shapes carry the usual meanings \u2014 `round` for a start or end, `diamond` for a decision, `cylinder` for a store, and the default box for a step. Put the condition on the edge (`label: "yes"`, `label: "on timeout"`) rather than inventing a node for it, and use `style: "dashed"` for anything conditional, asynchronous or secondary. `direction: "right"` suits a pipeline; the default runs downwards and suits most flows. Loops are fine \u2014 an edge pointing back is drawn round the outside. Keep it to the boxes that earn their place: a diagram of forty is a wall, not an explanation, and the limit is a refusal rather than a truncation.',
67591
+ parametersSchema: diagramSpecSchema,
67592
+ async execute(params) {
67593
+ const layout = layoutDiagram(params);
67594
+ const ranks = new Set(layout.nodes.map((node) => node.y)).size;
67595
+ const unreachable = params.nodes.filter((node) => node.id !== params.nodes[0]?.id && !params.edges.some((edge) => edge.to === node.id || edge.from === node.id));
67596
+ return {
67597
+ content: [
67598
+ `Drew a diagram${params.title === void 0 ? "" : ` titled "${params.title}"`} with ${String(params.nodes.length)} node(s) and ${String(params.edges.length)} edge(s), across ${String(ranks)} level(s), running ${params.direction ?? "down"}.`,
67599
+ unreachable.length === 0 ? "" : `${String(unreachable.length)} node(s) have no edges at all and float unconnected: ${unreachable.map((node) => node.id).join(", ")}. Connect them or drop them.`,
67600
+ "The diagram is now in the conversation. Describe what it shows rather than listing the boxes again \u2014 they are on screen."
67601
+ ].filter((line) => line !== "").join("\n")
67602
+ };
67603
+ }
67604
+ };
67605
+ }
67606
+
67219
67607
  // ../../packages/core/dist/tools/applyDiff/eol.js
67220
67608
  function detectEol(text) {
67221
67609
  const crlfCount = (text.match(/\r\n/g) ?? []).length;
@@ -67925,6 +68313,7 @@ function createDefaultToolRegistry() {
67925
68313
  registry2.register(askFollowupQuestionTool);
67926
68314
  registry2.register(createAskUserFormTool());
67927
68315
  registry2.register(createShowChartTool());
68316
+ registry2.register(createShowDiagramTool());
67928
68317
  registry2.register(attemptCompletionTool);
67929
68318
  return registry2;
67930
68319
  }
@@ -68222,14 +68611,14 @@ ${entry.record.text}`.toLowerCase();
68222
68611
  const hits = await options.semantic.searcher.searchByVector(options.semantic.collection, vector, {
68223
68612
  size: Math.min(100, Math.max(limit * 4, 40))
68224
68613
  });
68225
- const rank2 = /* @__PURE__ */ new Map();
68614
+ const rank3 = /* @__PURE__ */ new Map();
68226
68615
  hits.forEach((hit, position) => {
68227
- if (!rank2.has(hit.path))
68228
- rank2.set(hit.path, position);
68616
+ if (!rank3.has(hit.path))
68617
+ rank3.set(hit.path, position);
68229
68618
  });
68230
68619
  ordered = [...candidates].sort((a, b) => {
68231
- const left = rank2.get(`data:${a.datasetId}:${a.record.id}`);
68232
- const right = rank2.get(`data:${b.datasetId}:${b.record.id}`);
68620
+ const left = rank3.get(`data:${a.datasetId}:${a.record.id}`);
68621
+ const right = rank3.get(`data:${b.datasetId}:${b.record.id}`);
68233
68622
  if (left !== void 0 && right !== void 0)
68234
68623
  return left - right;
68235
68624
  if (left !== void 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.60.0",
3
+ "version": "0.62.0",
4
4
  "description": "A minimal agentic coding assistant, served to your browser from a local Node server",
5
5
  "license": "MIT",
6
6
  "type": "module",