@llmist/cli 12.3.4 → 12.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -76,7 +76,7 @@ import { Command, InvalidArgumentError as InvalidArgumentError2 } from "commande
76
76
  // package.json
77
77
  var package_default = {
78
78
  name: "@llmist/cli",
79
- version: "12.3.4",
79
+ version: "12.3.5",
80
80
  description: "CLI for llmist - run LLM agents from the command line",
81
81
  type: "module",
82
82
  main: "dist/cli.js",
@@ -132,7 +132,7 @@ var package_default = {
132
132
  node: ">=22.0.0"
133
133
  },
134
134
  dependencies: {
135
- llmist: "^12.3.4",
135
+ llmist: "^12.3.5",
136
136
  "@unblessed/node": "^1.0.0-alpha.23",
137
137
  chalk: "^5.6.2",
138
138
  commander: "^12.1.0",
@@ -146,7 +146,7 @@ var package_default = {
146
146
  zod: "^4.1.12"
147
147
  },
148
148
  devDependencies: {
149
- "@llmist/testing": "^12.3.4",
149
+ "@llmist/testing": "^12.3.5",
150
150
  "@types/diff": "^8.0.0",
151
151
  "@types/js-yaml": "^4.0.9",
152
152
  "@types/marked-terminal": "^6.1.1",
@@ -3952,6 +3952,10 @@ var BlockRenderer = class _BlockRenderer {
3952
3952
  gadgetByInvocationId = /* @__PURE__ */ new Map();
3953
3953
  /** Track nested LLM calls by parentId_iteration for idempotency */
3954
3954
  nestedLLMCallByKey = /* @__PURE__ */ new Map();
3955
+ /** Current session ID (increments each new REPL turn) */
3956
+ currentSessionId = 0;
3957
+ /** Previous session ID (for deferred cleanup) */
3958
+ previousSessionId = null;
3955
3959
  constructor(container, renderCallback, renderNowCallback) {
3956
3960
  this.container = container;
3957
3961
  this.renderCallback = renderCallback;
@@ -3993,6 +3997,7 @@ var BlockRenderer = class _BlockRenderer {
3993
3997
  type: "llm_call",
3994
3998
  depth,
3995
3999
  parentId: parentGadgetId ?? null,
4000
+ sessionId: this.currentSessionId,
3996
4001
  iteration,
3997
4002
  model,
3998
4003
  isComplete: false,
@@ -4059,6 +4064,7 @@ var BlockRenderer = class _BlockRenderer {
4059
4064
  type: "gadget",
4060
4065
  depth,
4061
4066
  parentId: parentLLMCallId,
4067
+ sessionId: this.currentSessionId,
4062
4068
  invocationId,
4063
4069
  name,
4064
4070
  isComplete: false,
@@ -4127,6 +4133,7 @@ var BlockRenderer = class _BlockRenderer {
4127
4133
  type: "text",
4128
4134
  depth: 0,
4129
4135
  parentId: null,
4136
+ sessionId: this.currentSessionId,
4130
4137
  content,
4131
4138
  children: []
4132
4139
  };
@@ -4151,6 +4158,7 @@ var BlockRenderer = class _BlockRenderer {
4151
4158
  type: "text",
4152
4159
  depth: 0,
4153
4160
  parentId: null,
4161
+ sessionId: this.currentSessionId,
4154
4162
  content: message,
4155
4163
  children: []
4156
4164
  };
@@ -4222,6 +4230,51 @@ var BlockRenderer = class _BlockRenderer {
4222
4230
  }
4223
4231
  this.renderCallback();
4224
4232
  }
4233
+ /**
4234
+ * Start a new session. Called at the start of each REPL turn.
4235
+ * Increments the session counter so new blocks get the new sessionId.
4236
+ */
4237
+ startNewSession() {
4238
+ this.previousSessionId = this.currentSessionId;
4239
+ this.currentSessionId++;
4240
+ }
4241
+ /**
4242
+ * Clear blocks from the previous session only.
4243
+ * Called when the current session finishes, keeping its content visible.
4244
+ * The previous session's content was kept visible during this session for context.
4245
+ */
4246
+ clearPreviousSession() {
4247
+ if (this.previousSessionId === null) return;
4248
+ const prevSessionId = this.previousSessionId;
4249
+ const nodesToRemove = [];
4250
+ for (const [id, node] of this.nodes.entries()) {
4251
+ if (node.sessionId === prevSessionId) {
4252
+ nodesToRemove.push(id);
4253
+ }
4254
+ }
4255
+ for (const id of nodesToRemove) {
4256
+ this.nodes.delete(id);
4257
+ const block = this.blocks.get(id);
4258
+ if (block?.box) {
4259
+ block.box.detach();
4260
+ }
4261
+ this.blocks.delete(id);
4262
+ this.expandedStates.delete(id);
4263
+ }
4264
+ this.rootIds = this.rootIds.filter((id) => !nodesToRemove.includes(id));
4265
+ this.selectableIds = this.selectableIds.filter((id) => !nodesToRemove.includes(id));
4266
+ if (this.selectedIndex >= this.selectableIds.length) {
4267
+ this.selectedIndex = this.selectableIds.length - 1;
4268
+ }
4269
+ this.previousSessionId = null;
4270
+ this.renderCallback();
4271
+ }
4272
+ /**
4273
+ * Get the current session ID (for node creation).
4274
+ */
4275
+ getCurrentSessionId() {
4276
+ return this.currentSessionId;
4277
+ }
4225
4278
  // ───────────────────────────────────────────────────────────────────────────
4226
4279
  // Public API - Selection & Navigation
4227
4280
  // ───────────────────────────────────────────────────────────────────────────
@@ -6893,6 +6946,21 @@ var TUIApp = class _TUIApp {
6893
6946
  clearStatusBar() {
6894
6947
  this.statusBar.clearActivity();
6895
6948
  }
6949
+ /**
6950
+ * Start a new session. Called at the start of each REPL turn.
6951
+ * Increments the session counter so new blocks get the new sessionId.
6952
+ */
6953
+ startNewSession() {
6954
+ this.blockRenderer.startNewSession();
6955
+ }
6956
+ /**
6957
+ * Clear blocks from the previous session only.
6958
+ * Called when the current session finishes, keeping its content visible.
6959
+ * The previous session's content was kept visible during this session for context.
6960
+ */
6961
+ clearPreviousSession() {
6962
+ this.blockRenderer.clearPreviousSession();
6963
+ }
6896
6964
  // ─────────────────────────────────────────────────────────────────────────────
6897
6965
  // Abort Control (delegated to controller)
6898
6966
  // ─────────────────────────────────────────────────────────────────────────────
@@ -7378,6 +7446,7 @@ ${ctx.gadgetName} requires interactive approval. Run in a terminal to approve.`
7378
7446
  const runAgentWithPrompt = async (userPrompt) => {
7379
7447
  if (tui) {
7380
7448
  tui.resetAbort();
7449
+ tui.startNewSession();
7381
7450
  builder.withSignal(tui.getAbortSignal());
7382
7451
  }
7383
7452
  if (currentAgent) {
@@ -7423,7 +7492,7 @@ ${ctx.gadgetName} requires interactive approval. Run in a terminal to approve.`
7423
7492
  unsubscribeTree();
7424
7493
  }
7425
7494
  if (tui) {
7426
- tui.clearBlockRenderer();
7495
+ tui.clearPreviousSession();
7427
7496
  tui.clearStatusBar();
7428
7497
  }
7429
7498
  };