@agent-api/cli 0.4.27 → 0.4.28

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.27";
3
+ export declare const cliVersion = "0.4.28";
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.27";
3
+ export const cliVersion = "0.4.28";
4
4
  export const legacyCliName = "agent-api-cli";
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
- import { useApp, useInput, useStdout } from "ink";
3
+ import { useApp, useInput, useStdin, useStdout } from "ink";
4
4
  import { createAgentEngine, defaultBaseURL, } from "@agent-api/app-engine/core";
5
5
  import { createWorkbenchAuthController, createWorkbenchAuthGateController, parseWorkbenchCommand, } from "@agent-api/app-engine/workbench";
6
6
  import { buildWorkbenchRenderModel, copyTextFromActivitySelection, copyTextFromHeaderSelection, copyTextFromRenderModel, copyTextFromTranscriptSelection, createWorkbenchTerminalController, initialWorkbenchTerminalState, normalizeTerminalState, selectedPanelRange, } from "@agent-api/app-engine/terminal";
@@ -132,6 +132,7 @@ function isAuthInputStatus(status) {
132
132
  function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSwitchProfile, options, profileName, }) {
133
133
  const app = useApp();
134
134
  const { stdout } = useStdout();
135
+ const lastRawInputRef = useLastRawInputRef();
135
136
  const terminalSize = useTerminalSize(stdout);
136
137
  const [clipboardCapabilities, setClipboardCapabilities] = useState(null);
137
138
  const [terminalState, setTerminalState] = useState(() => initialWorkbenchTerminalState());
@@ -301,7 +302,8 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
301
302
  setTerminalState(result.state);
302
303
  return;
303
304
  }
304
- const result = terminalController.handle(input, key, terminalState, {
305
+ const normalizedKey = normalizeInkTerminalKey(key, lastRawInputRef.current);
306
+ const result = terminalController.handle(input, normalizedKey, terminalState, {
305
307
  busy: state.busy,
306
308
  renderModel,
307
309
  });
@@ -391,6 +393,29 @@ function useTerminalSize(stdout) {
391
393
  }, [stdout]);
392
394
  return size;
393
395
  }
396
+ function useLastRawInputRef() {
397
+ const { internal_eventEmitter } = useStdin();
398
+ const lastRawInputRef = useRef("");
399
+ useEffect(() => {
400
+ const recordRawInput = (data) => {
401
+ lastRawInputRef.current = Buffer.isBuffer(data) ? data.toString("utf8") : String(data);
402
+ };
403
+ internal_eventEmitter?.on("input", recordRawInput);
404
+ return () => {
405
+ internal_eventEmitter?.removeListener("input", recordRawInput);
406
+ };
407
+ }, [internal_eventEmitter]);
408
+ return lastRawInputRef;
409
+ }
410
+ function normalizeInkTerminalKey(key, rawInput) {
411
+ if (key.delete && !key.backspace && isRawBackspace(rawInput)) {
412
+ return { ...key, backspace: true, delete: false };
413
+ }
414
+ return key;
415
+ }
416
+ function isRawBackspace(rawInput) {
417
+ return rawInput === "\x7f" || rawInput === "\x1b\x7f";
418
+ }
394
419
  function userFacingError(error) {
395
420
  if (error instanceof Error)
396
421
  return error.message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/cli",
3
- "version": "0.4.27",
3
+ "version": "0.4.28",
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",