@agent-api/cli 0.4.26 → 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.26";
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.26";
3
+ export const cliVersion = "0.4.28";
4
4
  export const legacyCliName = "agent-api-cli";
@@ -1,12 +1,12 @@
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";
7
7
  import { InkAuthGate, InkWorkbenchScreen } from "./components.js";
8
8
  import { detectClipboardCapabilities, formatClipboardCapabilities, readClipboard, writeClipboard, } from "../clipboard.js";
9
- import { disableMouseReporting, enableMouseReporting, parseMouseEvent } from "../mouse.js";
9
+ import { disableMouseReporting, parseMouseEvent } from "../mouse.js";
10
10
  export function ChatApp({ options }) {
11
11
  return _jsx(AuthenticatedChatApp, { options: options });
12
12
  }
@@ -33,7 +33,7 @@ function AuthenticatedChatApp({ options }) {
33
33
  }));
34
34
  useEffect(() => {
35
35
  hideTerminalCursor(stdout);
36
- enableTerminalMouse(stdout);
36
+ disableTerminalMouse(stdout);
37
37
  return () => {
38
38
  disableTerminalMouse(stdout);
39
39
  showTerminalCursor(stdout);
@@ -118,10 +118,6 @@ function showTerminalCursor(stdout) {
118
118
  if (stdout.isTTY)
119
119
  stdout.write("\x1b[?25h");
120
120
  }
121
- function enableTerminalMouse(stdout) {
122
- if (stdout.isTTY)
123
- stdout.write(enableMouseReporting);
124
- }
125
121
  function disableTerminalMouse(stdout) {
126
122
  if (stdout.isTTY)
127
123
  stdout.write(disableMouseReporting);
@@ -136,6 +132,7 @@ function isAuthInputStatus(status) {
136
132
  function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSwitchProfile, options, profileName, }) {
137
133
  const app = useApp();
138
134
  const { stdout } = useStdout();
135
+ const lastRawInputRef = useLastRawInputRef();
139
136
  const terminalSize = useTerminalSize(stdout);
140
137
  const [clipboardCapabilities, setClipboardCapabilities] = useState(null);
141
138
  const [terminalState, setTerminalState] = useState(() => initialWorkbenchTerminalState());
@@ -305,7 +302,8 @@ function WorkbenchApp({ authController, onLogin, onLogout, onDeleteProfile, onSw
305
302
  setTerminalState(result.state);
306
303
  return;
307
304
  }
308
- const result = terminalController.handle(input, key, terminalState, {
305
+ const normalizedKey = normalizeInkTerminalKey(key, lastRawInputRef.current);
306
+ const result = terminalController.handle(input, normalizedKey, terminalState, {
309
307
  busy: state.busy,
310
308
  renderModel,
311
309
  });
@@ -395,6 +393,29 @@ function useTerminalSize(stdout) {
395
393
  }, [stdout]);
396
394
  return size;
397
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
+ }
398
419
  function userFacingError(error) {
399
420
  if (error instanceof Error)
400
421
  return error.message;
@@ -1,4 +1,3 @@
1
1
  import type { WorkbenchTerminalMouseEvent } from "@agent-api/app-engine/terminal";
2
- export declare const enableMouseReporting = "\u001B[?1000h\u001B[?1006h";
3
2
  export declare const disableMouseReporting = "\u001B[?1000l\u001B[?1002l\u001B[?1006l";
4
3
  export declare function parseMouseEvent(input: string): WorkbenchTerminalMouseEvent | null;
package/dist/tui/mouse.js CHANGED
@@ -1,4 +1,3 @@
1
- export const enableMouseReporting = "\x1b[?1000h\x1b[?1006h";
2
1
  export const disableMouseReporting = "\x1b[?1000l\x1b[?1002l\x1b[?1006l";
3
2
  export function parseMouseEvent(input) {
4
3
  const match = /(?:\x1b)?\[<(\d+);(\d+);(\d+)([mM])/.exec(input);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/cli",
3
- "version": "0.4.26",
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",
@@ -35,7 +35,7 @@
35
35
  "test": "npm run sync-version && npm run build && npm run smoke -w @agent-api/app-engine && node --test test/*.test.mjs"
36
36
  },
37
37
  "dependencies": {
38
- "@agent-api/app-engine": "^0.1.25",
38
+ "@agent-api/app-engine": "^0.1.26",
39
39
  "commander": "^14.0.3",
40
40
  "ink": "^6.8.0",
41
41
  "react": "^19.2.7"