@agent-api/cli 0.4.34 → 0.4.36

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/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export declare const cliName = "agent-tui";
2
2
  export declare const cliAuthor = "AgentsWay";
3
- export declare const cliVersion = "0.4.34";
3
+ export declare const cliVersion = "0.4.36";
4
4
  export declare const legacyCliName = "agent-api-cli";
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export const cliName = "agent-tui";
2
2
  export const cliAuthor = "AgentsWay";
3
- export const cliVersion = "0.4.34";
3
+ export const cliVersion = "0.4.36";
4
4
  export const legacyCliName = "agent-api-cli";
@@ -137,6 +137,7 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
137
137
  const terminalSize = useTerminalSize(stdout);
138
138
  const [clipboardCapabilities, setClipboardCapabilities] = useState(null);
139
139
  const [terminalState, setTerminalState] = useState(() => initialWorkbenchTerminalState());
140
+ const terminalStateRef = useRef(terminalState);
140
141
  const [spinnerFrame, setSpinnerFrame] = useState(0);
141
142
  const agentEngineRef = useRef(null);
142
143
  const transcriptStoreRef = useRef(undefined);
@@ -183,8 +184,17 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
183
184
  },
184
185
  workdirFallback: options.workdir || process.cwd(),
185
186
  }), [options.workdir, profileName, spinnerFrame, state, terminalSize.columns, terminalSize.rows, terminalState.cursor, terminalState.draft, terminalState.selectionAnchor, terminalState.transcriptOffset]);
187
+ function commitTerminalState(next) {
188
+ terminalStateRef.current = next;
189
+ setTerminalState(next);
190
+ }
191
+ function updateTerminalState(updater) {
192
+ const next = updater(terminalStateRef.current);
193
+ terminalStateRef.current = next;
194
+ setTerminalState(next);
195
+ }
186
196
  useEffect(() => {
187
- setTerminalState((current) => {
197
+ updateTerminalState((current) => {
188
198
  const next = normalizeTerminalState(current, renderModel);
189
199
  return sameTerminalState(current, next) ? current : next;
190
200
  });
@@ -226,7 +236,7 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
226
236
  dispatch({ type: "activity.add", level: "warning", text: "Clipboard paste unavailable" });
227
237
  return;
228
238
  }
229
- setTerminalState((current) => {
239
+ updateTerminalState((current) => {
230
240
  const normalized = normalizeTerminalState({ ...current, focusedPanel: "input" }, renderModel);
231
241
  const result = terminalController.handle(text, {}, normalized, {
232
242
  busy: state.busy,
@@ -321,34 +331,35 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
321
331
  };
322
332
  }, [agentEngine, options.profile]);
323
333
  useInput((input, key) => {
334
+ const currentTerminalState = terminalStateRef.current;
324
335
  const mouse = parseMouseEvent(input);
325
336
  if (mouse) {
326
- const result = terminalController.handleMouse(mouse, terminalState, {
337
+ const result = terminalController.handleMouse(mouse, currentTerminalState, {
327
338
  busy: state.busy,
328
339
  renderModel,
329
340
  });
330
- if (!sameTerminalState(result.state, terminalState))
331
- setTerminalState(result.state);
341
+ if (!sameTerminalState(result.state, currentTerminalState))
342
+ commitTerminalState(result.state);
332
343
  return;
333
344
  }
334
345
  const normalizedKey = normalizeInkTerminalKey(key, lastRawInputRef.current);
335
- const result = terminalController.handle(input, normalizedKey, terminalState, {
346
+ const result = terminalController.handle(input, normalizedKey, currentTerminalState, {
336
347
  busy: state.busy,
337
348
  renderModel,
338
349
  });
339
- if (!sameTerminalState(result.state, terminalState))
340
- setTerminalState(result.state);
350
+ if (!sameTerminalState(result.state, currentTerminalState))
351
+ commitTerminalState(result.state);
341
352
  if (shouldLoadOlderTranscript(normalizedKey, result.state, renderModel)) {
342
353
  void agentEngine.loadOlderTranscript().then((count) => {
343
354
  if (count > 0) {
344
- setTerminalState((current) => ({ ...current, focusedPanel: "transcript", transcriptOffset: Number.MAX_SAFE_INTEGER }));
355
+ updateTerminalState((current) => ({ ...current, focusedPanel: "transcript", transcriptOffset: Number.MAX_SAFE_INTEGER }));
345
356
  }
346
357
  });
347
358
  }
348
359
  if (shouldLoadNewerTranscript(normalizedKey, result.state)) {
349
360
  void agentEngine.loadNewerTranscript().then((count) => {
350
361
  if (count > 0) {
351
- setTerminalState((current) => ({ ...current, focusedPanel: "transcript", transcriptOffset: 0 }));
362
+ updateTerminalState((current) => ({ ...current, focusedPanel: "transcript", transcriptOffset: 0 }));
352
363
  }
353
364
  });
354
365
  }
@@ -358,19 +369,19 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
358
369
  app.exit();
359
370
  break;
360
371
  case "scroll":
361
- setTerminalState((current) => normalizeTerminalState({
372
+ updateTerminalState((current) => normalizeTerminalState({
362
373
  ...current,
363
374
  transcriptOffset: current.transcriptOffset + effect.delta,
364
375
  }, renderModel));
365
376
  break;
366
377
  case "scroll_top":
367
- setTerminalState((current) => normalizeTerminalState({
378
+ updateTerminalState((current) => normalizeTerminalState({
368
379
  ...current,
369
380
  transcriptOffset: renderModel.transcript.maxOffset,
370
381
  }, renderModel));
371
382
  break;
372
383
  case "scroll_bottom":
373
- setTerminalState((current) => ({ ...current, transcriptOffset: 0 }));
384
+ updateTerminalState((current) => ({ ...current, transcriptOffset: 0 }));
374
385
  break;
375
386
  case "abort":
376
387
  void agentEngine.abortActiveTurn("Abort requested.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/cli",
3
- "version": "0.4.34",
3
+ "version": "0.4.36",
4
4
  "description": "First-class command line interface for Agent API",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/scalebox-dev/agent-tui#readme",
@@ -36,7 +36,7 @@
36
36
  "test": "npm run sync-version && npm run build && npm run smoke -w @agent-api/app-engine && node --test test/*.test.mjs"
37
37
  },
38
38
  "dependencies": {
39
- "@agent-api/app-engine": "^0.1.31",
39
+ "@agent-api/app-engine": "^0.1.33",
40
40
  "better-sqlite3": "^12.11.1",
41
41
  "commander": "^14.0.3",
42
42
  "ink": "^6.8.0",