@chosengeneration/light-code 0.189.0 → 0.190.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.
Files changed (3) hide show
  1. package/dist/cli.cjs +222 -27
  2. package/dist/server.cjs +219 -24
  3. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -39550,6 +39550,7 @@ function describeStrategy(strategy, roleName) {
39550
39550
  return `the box "${groupName(group)}" (step${inside.length === 1 ? "" : "s"} ${inside.join(", ")})`;
39551
39551
  };
39552
39552
  const onward = (edge) => `${label(edge.to)}${edge.contract !== void 0 && edge.contract.trim().length > 0 ? ` (passing on: ${firstLine(edge.contract)})` : ""}${requiredOf(edge).length > 0 && !groups.some((g) => g.id === edge.from) ? ` [required: ${requiredOf(edge).join(", ")}]` : ""}`;
39553
+ const askAs = (role) => roleName(role).trim().toLowerCase() === role ? "" : ` (ask_agent role "${role}")`;
39553
39554
  const lines2 = [`## Strategy: ${strategy.name}`, "", "The user drew how this work must be done. Steps, each done by consulting that role with ask_agent:"];
39554
39555
  const announced = /* @__PURE__ */ new Set();
39555
39556
  for (const node of order2) {
@@ -39560,7 +39561,7 @@ function describeStrategy(strategy, roleName) {
39560
39561
  lines2.push(`${label(group.id)[0].toUpperCase()}${label(group.id).slice(1)} - ${groupKind(group) === "parallel" ? "consulted together, in ONE ask_agents call" : "done as a group, in the order below"}${into.length > 0 ? `, after ${into.join(" and ")}` : ""}:`);
39561
39562
  }
39562
39563
  const next = strategy.edges.filter((edge) => edge.from === node.id && edge.twoWay !== true).map(onward);
39563
- lines2.push(`${group !== void 0 ? " " : ""}${String(number5.get(node.id))}. ${roleName(node.role)}${node.readOnly === true ? " - read-only: may not change anything" : ""}${node.instructions !== void 0 && node.instructions.trim().length > 0 ? ` - the user's instructions for it: "${firstLine(node.instructions)}"` : " - what it does here is yours to plan"}` + (next.length > 0 ? `; then ${next.join(" and ")}` : ""));
39564
+ lines2.push(`${group !== void 0 ? " " : ""}${String(number5.get(node.id))}. ${roleName(node.role)}${askAs(node.role)}${node.readOnly === true ? " - read-only: may not change anything" : ""}${node.instructions !== void 0 && node.instructions.trim().length > 0 ? ` - the user's instructions for it: "${firstLine(node.instructions)}"` : " - what it does here is yours to plan"}` + (next.length > 0 ? `; then ${next.join(" and ")}` : ""));
39564
39565
  if (group !== void 0) {
39565
39566
  const members = groupMembers(strategy, group.id);
39566
39567
  const last = order2.filter((n) => members.some((m) => m.id === n.id)).at(-1);
@@ -39589,7 +39590,7 @@ function describeStrategy(strategy, roleName) {
39589
39590
  if (boxes.length > 0) {
39590
39591
  lines2.push("", "A connector leaving a box is followed only once every step inside it has answered. A connector into a box gives every step inside what arrives along it.");
39591
39592
  }
39592
- lines2.push("", "How to follow it:", "- This strategy applies to every piece of work asked for in this chat, not only the first. Before doing anything else for a request - including a new topic after an earlier one is finished - propose a plan with update_plan that carries out every step above in order for that request, naming the role for each step and writing each back-and-forth as one step with its condition and its maximum rounds. Then follow the plan. A new plan for a new topic starts the loops afresh; do not reuse an earlier topic's plan or skip the specialists because they were consulted before.", "- Give each specialist what it needs from the earlier steps: it does not see this conversation, only what you send it. A step's own instructions from the user reach it with every question; plan the steps that have none.", "- Connectors with no contract: before starting, propose what should pass along them with set_strategy_contracts (the user approves it). Light Code checks every required item after each answer, asks the specialist again for what is missing, and tells you if it is still missing - pass on what arrived, and say what did not.", "- In a back-and-forth, Light Code counts the rounds and tells you after each answer where the loop stands; it refuses a round past the maximum. If the maximum is reached without the condition, stop and tell the user what is still open rather than working around it.", "- A question from the user that is not part of the strategy is answered normally.");
39593
+ lines2.push("", "How to follow it:", "- This strategy applies to every piece of work asked for in this chat, not only the first. Before doing anything else for a request - including a new topic after an earlier one is finished - propose a plan with update_plan that carries out every step above in order for that request, naming the role for each step and writing each back-and-forth as one step with its condition and its maximum rounds. Then follow the plan. A new plan for a new topic starts the loops afresh; do not reuse an earlier topic's plan or skip the specialists because they were consulted before.", "- Each specialist works in its own context and does not see this conversation. Light Code hands each step the latest full answers of the steps connected into it, directly - do not paste earlier specialists' answers into your question. Say what this step should do now, and add only what it cannot get that way: the user's request and anything from this conversation it needs. You are given each specialist's summary, not its whole answer; read the full one with strategy_history only when you need the detail. A step's own instructions from the user reach it with every question; plan the steps that have none.", "- Connectors with no contract: before starting, propose what should pass along them with set_strategy_contracts (the user approves it). Light Code checks every required item after each answer, asks the specialist again for what is missing, and tells you if it is still missing - pass on what arrived, and say what did not.", "- In a back-and-forth, Light Code counts the rounds and tells you after each answer where the loop stands; it refuses a round past the maximum. If the maximum is reached without the condition, stop and tell the user what is still open rather than working around it.", "- A question from the user that is not part of the strategy is answered normally.");
39593
39594
  return lines2.join("\n");
39594
39595
  }
39595
39596
  function readVerdict(answer) {
@@ -39754,6 +39755,48 @@ function askForMissing(missing, previous) {
39754
39755
  previous.length > 6e3 ? `${previous.slice(0, 6e3)}\u2026` : previous
39755
39756
  ].join("\n");
39756
39757
  }
39758
+ function handOverSources(strategy, role) {
39759
+ const mine = strategy.nodes.filter((node) => node.role === role);
39760
+ if (mine.length === 0)
39761
+ return [];
39762
+ const ids = new Set(mine.map((node) => node.id));
39763
+ const groups = new Set(mine.map((node) => node.group).filter((group) => group !== void 0));
39764
+ const into = (edge) => ids.has(edge.to) || groups.has(edge.to);
39765
+ const sources = /* @__PURE__ */ new Set();
39766
+ for (const edge of strategy.edges) {
39767
+ if (into(edge))
39768
+ for (const node of endpointNodes(strategy, edge.from))
39769
+ sources.add(node.role);
39770
+ if (edge.twoWay === true && (ids.has(edge.from) || groups.has(edge.from)))
39771
+ for (const node of endpointNodes(strategy, edge.to))
39772
+ sources.add(node.role);
39773
+ }
39774
+ sources.delete(role);
39775
+ return [...sources];
39776
+ }
39777
+ var SUMMARY_HEADING = "Summary for the main agent";
39778
+ var SUMMARY_REQUEST = `Your full answer is kept and passed on to the next step of the strategy directly. End it with a section headed "${SUMMARY_HEADING}:" - at most eight short lines: what you did or found, any decision the main agent must make, and anything blocking. Only that section reaches the main agent.`;
39779
+ var SUMMARY_LIMIT = 2e3;
39780
+ var SHORT_ANSWER = 2500;
39781
+ function answerForMain(answer, role) {
39782
+ const lines2 = answer.split(/\r?\n/);
39783
+ const heading = lines2.findIndex((line) => /^\s*(?:#+\s*)?(?:\*\*)?\s*summary for the main agent\b/i.test(line));
39784
+ if (heading >= 0) {
39785
+ const first = lines2[heading].replace(/^\s*(?:#+\s*)?(?:\*\*)?\s*summary for the main agent\s*:?\s*(?:\*\*)?\s*:?\s*/i, "");
39786
+ const summary = [first, ...lines2.slice(heading + 1)].join("\n").trim();
39787
+ if (summary.length > 0) {
39788
+ const cut = summary.length > SUMMARY_LIMIT ? `${summary.slice(0, SUMMARY_LIMIT)}\u2026` : summary;
39789
+ return `${cut}
39790
+
39791
+ [The ${role}'s full answer (${String(answer.length)} characters) was passed to the next step directly and is in the strategy record; read it with strategy_history only if you need the detail.]`;
39792
+ }
39793
+ }
39794
+ if (answer.length <= SHORT_ANSWER)
39795
+ return answer;
39796
+ return `${answer.slice(0, SUMMARY_LIMIT)}\u2026
39797
+
39798
+ [Shortened for you: the ${role}'s full answer (${String(answer.length)} characters) was passed to the next step directly and is in the strategy record; read it with strategy_history only if you need the detail.]`;
39799
+ }
39757
39800
 
39758
39801
  // ../../packages/core/dist/mcp/types.js
39759
39802
  var mcpDenyRuleSchema = external_exports.object({
@@ -41300,6 +41343,20 @@ var configSchema = external_exports.object({
41300
41343
  * and a provider refusing an over-long conversation says so and points there.
41301
41344
  */
41302
41345
  autoCompact: external_exports.boolean(),
41346
+ /**
41347
+ * Start a new chat from a handoff by itself when this one reaches the context limit, instead of compacting it.
41348
+ * Asked for: "a checkbox, when enabled it should auto handoff to new session when context limit is hit". The
41349
+ * handoff note and the user's own messages carry the work over, and the new chat carries on by itself; the old
41350
+ * chat stays in History. Compacting automatically wins when both are ticked - it was asked for first and keeps
41351
+ * the chat. Off unless set to true.
41352
+ */
41353
+ autoHandoff: external_exports.boolean(),
41354
+ /**
41355
+ * No step limit for a chat's replies: the agent runs until it finishes, is stopped, or fails the same way three times
41356
+ * in a row. Asked for, with the Anti Hallucinator watching and guiding it. Scheduled runs keep `maxIterations` -
41357
+ * nobody is there to press Stop. Off unless set to true.
41358
+ */
41359
+ unlimitedSteps: external_exports.boolean(),
41303
41360
  /**
41304
41361
  * Model requests that fail or go silent. `stallSeconds`: how long a request may send nothing at
41305
41362
  * all before it is stopped and sent again (0 = never; default 300). `retries`: how many times a
@@ -46705,7 +46762,7 @@ ${withBudget}` : withBudget;
46705
46762
 
46706
46763
  // ../../packages/core/dist/tools/askAgent.js
46707
46764
  var paramsSchema3 = external_exports.object({
46708
- role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}. Only the ones assigned in Settings \u2192 Agents can answer.`),
46765
+ role: external_exports.string().describe(`Which specialist to ask: ${AGENT_ROLES.join(", ")}, or a custom role from Settings \u2192 Agents by its id. Only the ones assigned there can answer.`),
46709
46766
  question: external_exports.string().min(1).describe("The question, with the code, error or output needed to answer it. The specialist cannot see this conversation or read files \u2014 paste what matters."),
46710
46767
  files: external_exports.array(external_exports.string()).optional().describe("Workspace-relative paths you are working in, so it knows what you are looking at.")
46711
46768
  });
@@ -46730,11 +46787,11 @@ Files named as relevant: ${params3.files.join(", ")}` : "")
46730
46787
  },
46731
46788
  async execute(params3, context) {
46732
46789
  const team = options.agents();
46733
- const role = params3.role.trim().toLowerCase();
46734
- if (!isAgentRole(role)) {
46790
+ const agent = find(team, params3.role);
46791
+ const role = agent?.role ?? params3.role.trim().toLowerCase();
46792
+ if (agent === void 0 && !isAgentRole(role)) {
46735
46793
  return { content: unknownRole(role, team), isError: true };
46736
46794
  }
46737
- const agent = find(team, role);
46738
46795
  if (agent === void 0) {
46739
46796
  return {
46740
46797
  content: `No ${role} is assigned. ${describeTeam(team)} Assign one in Settings \u2192 Agents, or ask a different role.`,
@@ -46778,11 +46835,13 @@ ${trailerFor(agent, team)}`
46778
46835
  };
46779
46836
  }
46780
46837
  function find(team, role) {
46781
- const wanted = role.trim().toLowerCase();
46782
- return team.find((agent) => agent.role === wanted);
46838
+ const squash = (text2) => text2.trim().toLowerCase().replace(/[\s_-]+/g, "-");
46839
+ const wanted = squash(role);
46840
+ return team.find((agent) => agent.role === wanted) ?? team.find((agent) => squash(agent.name) === wanted);
46783
46841
  }
46784
46842
  function unknownRole(role, team) {
46785
- return `There is no "${role}" role. The roles are: ${AGENT_ROLES.join(", ")}. ${describeTeam(team)}`;
46843
+ const roles = [.../* @__PURE__ */ new Set([...AGENT_ROLES, ...team.map((agent) => agent.role)])];
46844
+ return `There is no "${role}" role. The roles are: ${roles.join(", ")}. ${describeTeam(team)}`;
46786
46845
  }
46787
46846
  function describeTeam(team) {
46788
46847
  const usable = team.filter((agent) => agent.available).map((agent) => agent.role);
@@ -62197,7 +62256,7 @@ var SHARE_SECTIONS = [
62197
62256
  id: "workspace",
62198
62257
  label: "Workspace behaviour",
62199
62258
  description: "Mode, step cap, automatic compaction, retries, folders tools may read, and folders hidden from the @ picker.",
62200
- keys: ["modeId", "maxIterations", "autoCompact", "connection", "filesystem"],
62259
+ keys: ["modeId", "maxIterations", "autoCompact", "autoHandoff", "unlimitedSteps", "connection", "filesystem"],
62201
62260
  machineSpecific: true
62202
62261
  },
62203
62262
  {
@@ -64530,6 +64589,11 @@ async function prepareModelMessages(conversation, provider, tools, options, even
64530
64589
  const contextWindow = options.contextWindow ?? 0;
64531
64590
  const ratio = calibrationFor(options.usageKey ?? "");
64532
64591
  let messages = repairUnansweredToolCalls(conversation.toModelMessages());
64592
+ if (options.onContextFull !== void 0 && options.autoCompact === false && options.compactionEnabled !== false && contextWindow > 0 && options.contextWindowKnown !== false && meter !== void 0) {
64593
+ const estimated = scaleBreakdown(computeBreakdown(messages, tools, contextWindow), ratio).total;
64594
+ if (shouldCompact(messages, estimated, contextWindow, { ...options.compaction ?? {}, minimumToCompact: 0 }))
64595
+ meter.contextFull = true;
64596
+ }
64533
64597
  if (options.compactionEnabled !== false && options.autoCompact !== false && contextWindow > 0 && options.contextWindowKnown !== false) {
64534
64598
  const estimated = scaleBreakdown(computeBreakdown(messages, tools, contextWindow), ratio).total;
64535
64599
  if (shouldCompact(messages, estimated, contextWindow, options.compaction ?? {})) {
@@ -64736,6 +64800,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
64736
64800
  streamOptions.signal = options.signal;
64737
64801
  const meter = { estimated: 0, dropped: 0 };
64738
64802
  const modelMessages = await prepareModelMessages(conversation, provider, tools, options, events, meter);
64803
+ if (meter.contextFull === true && options.onContextFull !== void 0) {
64804
+ options.onContextFull();
64805
+ events.onDone();
64806
+ return;
64807
+ }
64739
64808
  const stallSeconds = options.stallSeconds ?? DEFAULT_STALL_SECONDS;
64740
64809
  const maxRetries = Math.max(0, options.retries ?? DEFAULT_RETRIES);
64741
64810
  const cancelled = () => options.signal?.aborted === true;
@@ -64777,6 +64846,11 @@ async function runAgentTurn(provider, conversation, userMessage, toolRegistry, t
64777
64846
  events.onContextWindowLearned?.(statedWindow);
64778
64847
  }
64779
64848
  if (streamError !== void 0 && assistantText.length === 0 && toolCall === void 0 && options.autoCompact === false && isContextOverflow(streamError)) {
64849
+ if (options.onContextFull !== void 0) {
64850
+ options.onContextFull();
64851
+ events.onDone();
64852
+ return;
64853
+ }
64780
64854
  events.onError(`${streamError}
64781
64855
 
64782
64856
  The conversation is longer than this model accepts. Press **Compact now** under the token bar to summarise the older part (the saved transcript keeps everything), then send again - or tick "Compact automatically" there to have this done for you. Or press **New chat with a handoff** (beside + at the top): the assistant writes up this chat - goal, decisions, what is done, next steps - and a new chat starts from it, a clean start that keeps the thread.`);
@@ -87476,6 +87550,7 @@ ${preview.text}` } : {}
87476
87550
  if (activeStrategy !== void 0 && startsNewWork(activePlan, activePlanProgress, nextPlan)) {
87477
87551
  strategyProgress = {};
87478
87552
  strategyLastRole = void 0;
87553
+ resetHandOvers();
87479
87554
  void postStrategies();
87480
87555
  }
87481
87556
  activePlan = nextPlan;
@@ -87610,6 +87685,9 @@ ${preview.text}` } : {}
87610
87685
  const commandToolset = () => probedTools ??= detectCommandTools();
87611
87686
  let cachedMaxIterations = 25;
87612
87687
  let cachedAutoCompact = false;
87688
+ let cachedAutoHandoff = false;
87689
+ let cachedUnlimitedSteps = false;
87690
+ let handoffAtLimit = false;
87613
87691
  let cachedStallSeconds = DEFAULT_STALL_SECONDS;
87614
87692
  let cachedRetries = DEFAULT_RETRIES;
87615
87693
  let cachedAccentColor = "#22C55E";
@@ -87971,6 +88049,8 @@ ${preview.text}` } : {}
87971
88049
  cachedModeId = config2.modeId;
87972
88050
  cachedMaxIterations = config2.maxIterations ?? 25;
87973
88051
  cachedAutoCompact = config2.autoCompact === true;
88052
+ cachedAutoHandoff = config2.autoHandoff === true;
88053
+ cachedUnlimitedSteps = config2.unlimitedSteps === true;
87974
88054
  cachedStallSeconds = config2.connection?.stallSeconds ?? DEFAULT_STALL_SECONDS;
87975
88055
  cachedRetries = config2.connection?.retries ?? DEFAULT_RETRIES;
87976
88056
  cachedAccentColor = config2.ui?.accentColor ?? "#22C55E";
@@ -88063,6 +88143,8 @@ ${preview.text}` } : {}
88063
88143
  approvals,
88064
88144
  maxIterations: cachedMaxIterations,
88065
88145
  autoCompact: cachedAutoCompact,
88146
+ autoHandoff: cachedAutoHandoff,
88147
+ unlimitedSteps: cachedUnlimitedSteps,
88066
88148
  stallSeconds: cachedStallSeconds,
88067
88149
  retries: cachedRetries,
88068
88150
  accentColor: cachedAccentColor,
@@ -88183,11 +88265,47 @@ ${preview.text}` } : {}
88183
88265
  mcpConfigs = servers;
88184
88266
  mcpJson = JSON.stringify({ mcpServers: servers }, null, 2);
88185
88267
  }
88268
+ const startupWaits = /* @__PURE__ */ new Map();
88269
+ const mcpStartingSince = /* @__PURE__ */ new Map();
88270
+ let lastStartupPosted = "";
88271
+ function postStartupProgress(force = false) {
88272
+ const now = Date.now();
88273
+ let states = [];
88274
+ try {
88275
+ states = mcp.states_();
88276
+ } catch {
88277
+ }
88278
+ const blocking = new Set(states.filter((state) => state.enabled && state.status === "connecting" && state.tools.length === 0).map((state) => state.name));
88279
+ for (const name of [...mcpStartingSince.keys()])
88280
+ if (!blocking.has(name))
88281
+ mcpStartingSince.delete(name);
88282
+ for (const name of blocking)
88283
+ if (!mcpStartingSince.has(name))
88284
+ mcpStartingSince.set(name, now);
88285
+ const waiting = [
88286
+ ...[...mcpStartingSince].map(([name, since2]) => ({ label: `MCP server "${name}" starting`, since: since2 })),
88287
+ ...[...startupWaits].map(([label, since2]) => ({ label, since: since2 }))
88288
+ ].sort((a, b) => a.since - b.since);
88289
+ const key3 = JSON.stringify(waiting);
88290
+ if (!force && key3 === lastStartupPosted)
88291
+ return;
88292
+ lastStartupPosted = key3;
88293
+ post({ type: "startupProgress", waiting });
88294
+ }
88295
+ function trackStartup(label, work) {
88296
+ startupWaits.set(label, Date.now());
88297
+ postStartupProgress();
88298
+ return work.finally(() => {
88299
+ startupWaits.delete(label);
88300
+ postStartupProgress();
88301
+ });
88302
+ }
88186
88303
  const mcp = new McpRegistry(
88187
88304
  secrets,
88188
88305
  {
88189
88306
  onStateChanged: () => {
88190
88307
  postMcp();
88308
+ postStartupProgress();
88191
88309
  void postSchedules();
88192
88310
  void postTools();
88193
88311
  void postDatasetStatus();
@@ -89592,6 +89710,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
89592
89710
  strategyProgress = {};
89593
89711
  strategyExchanges = [];
89594
89712
  strategyLastRole = void 0;
89713
+ resetHandOvers();
89595
89714
  await persistActiveTask();
89596
89715
  await postStrategies();
89597
89716
  }
@@ -89743,6 +89862,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
89743
89862
  strategyProgress = source.strategyProgress ?? {};
89744
89863
  strategyExchanges = source.strategyExchanges ?? [];
89745
89864
  strategyLastRole = void 0;
89865
+ resetHandOvers(0);
89746
89866
  stopRoleProcesses();
89747
89867
  }
89748
89868
  function postSteering() {
@@ -89769,6 +89889,7 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
89769
89889
  strategyProgress = {};
89770
89890
  strategyExchanges = [];
89771
89891
  strategyLastRole = void 0;
89892
+ resetHandOvers();
89772
89893
  stopRoleProcesses();
89773
89894
  await setActiveTaskId(void 0);
89774
89895
  const pending = pendingSteeringPath();
@@ -89797,6 +89918,10 @@ ${error51.stack.split("\n").slice(1, 6).join("\n")}`;
89797
89918
  userTurnRunning = false;
89798
89919
  userTurnWindingDown = false;
89799
89920
  onSettled?.();
89921
+ if (handoffAtLimit) {
89922
+ handoffAtLimit = false;
89923
+ void handleHandoff();
89924
+ }
89800
89925
  }
89801
89926
  })();
89802
89927
  }
@@ -90227,13 +90352,26 @@ ${direction}` : attachMentions(text2, mentions);
90227
90352
  // So images a tool returns (a Confluence page's pictures) reach a model that can see them.
90228
90353
  supportsVision: capabilities.supportsVision,
90229
90354
  // CLAUDE.md §5 has called this configurable since Phase 0; until now it was not.
90230
- maxIterations: cachedMaxIterations,
90355
+ // No limit when the user switched it off - never for a scheduled run, which nobody is watching to stop.
90356
+ maxIterations: cachedUnlimitedSteps && schedule === void 0 ? Number.POSITIVE_INFINITY : cachedMaxIterations,
90231
90357
  /*
90232
90358
  * Off unless switched on: compaction loses detail, and when is the user's call. A scheduled
90233
90359
  * run always may, because nobody is there to press "Compact now" and a run that stops at
90234
90360
  * the limit overnight reports nothing useful in the morning.
90235
90361
  */
90236
90362
  autoCompact: cachedAutoCompact || schedule !== void 0,
90363
+ // A chat at its limit hands off by itself, when that is switched on (never a scheduled run: nobody is there).
90364
+ /*
90365
+ * Only once the chat holds an earlier message of the user's: a chat that is full on its first message (a handoff's
90366
+ * own opening, or one enormous paste) would hand off into a chat just as full, and again, for ever. That case
90367
+ * gets the ordinary message saying what to do.
90368
+ */
90369
+ ...cachedAutoHandoff && !cachedAutoCompact && schedule === void 0 && conversation.toArray().filter((m) => m.role === "user" && !isObserverNote(m.content)).length >= 1 ? {
90370
+ onContextFull: () => {
90371
+ handoffAtLimit = true;
90372
+ logger.info("the conversation reached the context limit: handing off to a new chat");
90373
+ }
90374
+ } : {},
90237
90375
  stallSeconds: cachedStallSeconds,
90238
90376
  retries: cachedRetries,
90239
90377
  drainQueuedMessages: () => {
@@ -96195,9 +96333,10 @@ ${last}` : ""}`);
96195
96333
  if (mentioned.length > 0)
96196
96334
  stepNotes = attachMentions(stepNotes, mentioned);
96197
96335
  }
96198
- const question = stepNotes.length > 0 ? `${request2.question}
96336
+ const handed = handOverSources(strategy, agent.role).map((role) => ({ role, answer: latestStrategyAnswer(role) })).filter((entry) => entry.answer !== void 0).map((entry) => `## Handed over from ${name(entry.role)} (its latest answer, passed on directly)
96199
96337
 
96200
- ${stepNotes}` : request2.question;
96338
+ ${entry.answer.length > HANDOVER_LIMIT ? `${entry.answer.slice(0, HANDOVER_LIMIT)}\u2026 [cut at ${String(HANDOVER_LIMIT)} characters]` : entry.answer}`);
96339
+ const question = [request2.question, ...handed, ...stepNotes.length > 0 ? [stepNotes] : [], SUMMARY_REQUEST].join("\n\n");
96201
96340
  strategyRunning.add(agent.role);
96202
96341
  strategyLastRole = agent.role;
96203
96342
  void postStrategies();
@@ -96226,14 +96365,30 @@ ${more.advice}` };
96226
96365
  strategyProgress = recorded.progress;
96227
96366
  const exchange2 = exchangeOf(agent.role, request2.question, answer.advice, before, recorded.progress, request2.parallel === true);
96228
96367
  recordExchange(checks.length > 0 ? { ...exchange2, contracts: checks.map((check2) => ({ ...check2, askedAgain: askedAgain.get(check2.edgeId) ?? 0 })) } : exchange2);
96368
+ strategyAnswers.set(agent.role, answer.advice);
96229
96369
  strategyLastRole = agent.role;
96230
96370
  persistSoon();
96231
96371
  void postStrategies();
96232
96372
  const contractNotes = checks.filter((check2) => check2.missing.length > 0 || (askedAgain.get(check2.edgeId) ?? 0) > 0).map((check2) => check2.missing.length > 0 ? `[Strategy] The hand-over to ${name(check2.to)} is incomplete even after asking again: missing ${check2.missing.join(", ")}. Pass on what arrived and say plainly what is missing.` : `[Strategy] The hand-over to ${name(check2.to)} is complete (${check2.required.join(", ")}), after asking ${name(agent.role)} again for what it had left out.`);
96233
96373
  const notes = [...contractNotes, ...recorded.note !== void 0 ? [recorded.note] : []];
96234
- return notes.length > 0 ? { ...answer, advice: `${answer.advice}
96374
+ const forMain = answerForMain(answer.advice, name(agent.role));
96375
+ return { ...answer, advice: notes.length > 0 ? `${forMain}
96235
96376
 
96236
- ${notes.join("\n")}` } : answer;
96377
+ ${notes.join("\n")}` : forMain };
96378
+ }
96379
+ const strategyAnswers = /* @__PURE__ */ new Map();
96380
+ let strategyTopicSince = 0;
96381
+ const HANDOVER_LIMIT = 24e3;
96382
+ function resetHandOvers(since2 = Date.now()) {
96383
+ strategyAnswers.clear();
96384
+ strategyTopicSince = since2;
96385
+ }
96386
+ function latestStrategyAnswer(role) {
96387
+ const kept = strategyAnswers.get(role);
96388
+ if (kept !== void 0)
96389
+ return kept;
96390
+ const logged = [...strategyExchanges].reverse().find((exchange2) => exchange2.role === role && exchange2.at >= strategyTopicSince && exchange2.refused === void 0 && exchange2.answer.length > 0);
96391
+ return logged?.answer;
96237
96392
  }
96238
96393
  function recordExchange(exchange2) {
96239
96394
  strategyExchanges = [...strategyExchanges, exchange2].slice(-MAX_EXCHANGES);
@@ -96880,6 +97035,12 @@ ${notes.join("\n")}` } : answer;
96880
97035
  void configManager.save("user", { connection: { stallSeconds: message6.stallSeconds, retries: message6.retries } }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
96881
97036
  } else if (message6.type === "setAutoCompact") {
96882
97037
  void configManager.save("user", { autoCompact: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
97038
+ } else if (message6.type === "setUnlimitedSteps") {
97039
+ void configManager.save("user", { unlimitedSteps: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
97040
+ } else if (message6.type === "requestStartupProgress") {
97041
+ postStartupProgress(true);
97042
+ } else if (message6.type === "setAutoHandoff") {
97043
+ void configManager.save("user", { autoHandoff: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
96883
97044
  } else if (message6.type === "setMaxIterations") {
96884
97045
  void configManager.save("user", { maxIterations: message6.value }).then(() => postSettings()).catch((error51) => post({ type: "error", message: String(error51) }));
96885
97046
  } else if (message6.type === "setProgrammingProfile") {
@@ -97520,22 +97681,22 @@ ${notes.join("\n")}` } : answer;
97520
97681
  try {
97521
97682
  const config2 = await loadSettings();
97522
97683
  const startedAt = Date.now();
97523
- const timed = (label, work) => work.finally(() => {
97684
+ const timed = (label, work, shown2 = true) => (shown2 ? trackStartup(label, work) : work).finally(() => {
97524
97685
  const seconds = (Date.now() - startedAt) / 1e3;
97525
97686
  if (seconds >= 2)
97526
97687
  logger.info(`[startup] ${label} ready after ${seconds.toFixed(1)}s`);
97527
97688
  });
97528
97689
  const parts = [
97529
- timed("secrets", knownSecretValues()),
97530
- timed("skills", refreshSkills()),
97690
+ timed("Stored credentials", knownSecretValues()),
97691
+ timed("Skills", refreshSkills()),
97531
97692
  timed("Python tools", configurePython(config2)),
97532
- timed("git check", gitAvailable()),
97533
- timed("expert", resolveExpert(config2)),
97534
- timed("MCP tools", mcpStarted)
97693
+ timed("Git", gitAvailable()),
97694
+ timed("Expert", resolveExpert(config2)),
97695
+ timed("MCP servers", mcpStarted, false)
97535
97696
  ];
97536
97697
  if ((config2.profiles ?? []).length > 0) {
97537
97698
  const profile = resolveActiveProfile(config2);
97538
- parts.push(timed("model gateway (sign-in and context window)", (async () => {
97699
+ parts.push(timed("Model gateway sign-in", (async () => {
97539
97700
  if (profile.wireFormat !== "vscode-lm")
97540
97701
  await authStrategyFor(config2, profile).resolveHeaders();
97541
97702
  await reportedWindowFor(config2, profile);
@@ -102089,8 +102250,10 @@ between chats - but what they offer can. Every chat of a codebase remembers each
102089
102250
  one shared file, so a chat started after a crash or a sleep offers those tools at once and replies
102090
102251
  without waiting for the servers; a server keeps starting in the background, and a call to one of its
102091
102252
  tools waits for it. A server with no remembered list is waited for at most 45 seconds, after which the
102092
- reply goes ahead and its tools join the next message. When starting is still slow, the agent log
102093
- (\`host.log\`) names each slow part with a \`[startup]\` line - the server, Python, skills or the gateway.
102253
+ reply goes ahead and its tools join the next message. While anything is still getting ready, a bar over
102254
+ the message box names it with how long it has taken - each MCP server still starting, Python tools, skills, the model
102255
+ gateway's sign-in - and goes when nothing is left; a message sent meanwhile waits for what it needs. The agent log
102256
+ (\`host.log\`) also names each slow part with a \`[startup]\` line.
102094
102257
 
102095
102258
  **Not in Fire Code**: editor file pickers \u2014 paths are typed. Fire Code's
102096
102259
  Settings \u2192 Export source code saves the whole repository as a zip that builds offline.
@@ -102378,6 +102541,12 @@ morning, by which time a toast is long gone. The run log keeps a Report button.
102378
102541
  "parallel",
102379
102542
  "parallel box",
102380
102543
  "contract",
102544
+ "custom role",
102545
+ "custom roles",
102546
+ "own context",
102547
+ "context filling up",
102548
+ "hand over",
102549
+ "handover between agents",
102381
102550
  "strategy per chat",
102382
102551
  "different strategy",
102383
102552
  "strategy lost",
@@ -102465,6 +102634,16 @@ handoff** carries it into the new chat. **Stop using** in the Strategy window ta
102465
102634
  the chat follows it, not only the first: for a new topic the agent proposes a new plan that goes through the strategy
102466
102635
  again, and the back-and-forth loops start afresh for it, with their full number of rounds.
102467
102636
 
102637
+ **Custom roles work in a strategy** like the built-in ones: a role made in Settings \u2192 Agents is consulted by its id
102638
+ or its name, and the strategy tells the agent the id beside a custom role's name.
102639
+
102640
+ **Each specialist keeps its own context, and the main chat stays lean.** A specialist runs in its own process with
102641
+ its own memory. When a step is consulted, Light Code hands it the latest full answer of every step connected into it -
102642
+ a box's steps for a connector from a box, and in a back-and-forth the other side's latest - so the main agent does not
102643
+ paste one specialist's answer into the next one's question. Each specialist ends with a short "Summary for the main
102644
+ agent", and that summary (with any loop verdict or contract note) is all the main chat receives; the full answer stays
102645
+ in the strategy record, readable with strategy_history. A new topic starts these hand-overs afresh.
102646
+
102468
102647
  **Connecting a box.** A box is one step of the flow: connect it like a step, from its own dot on the right edge or with
102469
102648
  **Connect to...** when it is selected, to a step or to another box - and connect a step or a box into it. A connector
102470
102649
  out of a box is followed only once every step inside has answered; a connector into a box gives every step inside what
@@ -102627,6 +102806,13 @@ called at all.
102627
102806
  "forgets",
102628
102807
  "auto compact",
102629
102808
  "compact automatically",
102809
+ "auto handoff",
102810
+ "hand off automatically",
102811
+ "handoff at limit",
102812
+ "no step limit",
102813
+ "unlimited steps",
102814
+ "disable step limit",
102815
+ "step limit",
102630
102816
  "retry",
102631
102817
  "retries",
102632
102818
  "stuck thinking",
@@ -102686,6 +102872,10 @@ shortened transcript.
102686
102872
  older part (highlighted near the limit); the stored transcript keeps everything, only what is sent to
102687
102873
  the model is shortened, and never in the middle of a tool call. Your own messages are kept **word for
102688
102874
  word** inside the summary, every time, so what you asked for is never paraphrased away.
102875
+ Or tick **Hand off automatically** (config:autoHandoff) instead: when the chat reaches the limit the reply stops,
102876
+ the assistant writes a handoff, and a new chat starts from it and carries on by itself - this chat stays in History,
102877
+ nothing in it summarised. The two are one or the other; ticking one unticks the other. It applies once the chat holds an
102878
+ earlier message of yours, so a chat full on its very first message is not handed over and over.
102689
102879
  Tick **Compact automatically** beside the button (config:autoCompact) to have it done near the limit,
102690
102880
  keeping roughly the last third of the window verbatim - and only for a model whose window Light Code
102691
102881
  knows: from the table, from the model's own server (a self-hosted vLLM or SGLang reports its real
@@ -102720,6 +102910,9 @@ Light Code chat**. Typing \`@\` does the same from the keyboard, everywhere.
102720
102910
  something. If it trips, nothing is lost: send another message and it carries on with the full
102721
102911
  transcript. Typing **while a turn is running** grants a fresh 25 as well \u2014 the cap exists to stop a
102722
102912
  model looping unattended, and somebody typing is evidence that this is not that.
102913
+ **No step limit** (Settings \u2192 Approvals, config:unlimitedSteps) lets a chat's reply run until the job is done, you
102914
+ press Stop, or the same thing fails three times in a row - pair it with the Anti Hallucinator (Settings \u2192 Project),
102915
+ which watches each step and steers the agent back when it drifts. Scheduled runs keep the limit.
102723
102916
 
102724
102917
  **Prompt caching is why tool definitions do not change mid-session.** They sit at the front of the
102725
102918
  prompt, so swapping them to "save context" would throw away the cached prefix *and all the history
@@ -105302,6 +105495,8 @@ var PERSONAL_SETTINGS = /* @__PURE__ */ new Set([
105302
105495
  "setMaxIterations",
105303
105496
  // Whether *this user's* chats compact by themselves - their own conversations, nobody else's.
105304
105497
  "setAutoCompact",
105498
+ "setAutoHandoff",
105499
+ "setUnlimitedSteps",
105305
105500
  // How patiently *this user's* requests are retried.
105306
105501
  "setConnectionRetry",
105307
105502
  "setTaskExpertLimits",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chosengeneration/light-code",
3
- "version": "0.189.0",
3
+ "version": "0.190.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",