@letta-ai/letta-code 0.6.2 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,6 +12,9 @@ import StdoutContext from './StdoutContext.js';
12
12
  const tab = '\t';
13
13
  const shiftTab = '\u001B[Z';
14
14
  const escape = '\u001B';
15
+ // Maximum number of event listeners to allow on stdin and internal_eventEmitter.
16
+ const MAX_INPUT_LISTENERS = 20;
17
+
15
18
  export default class App extends PureComponent {
16
19
  static displayName = 'InternalApp';
17
20
  static getDerivedStateFromError(error) {
@@ -24,7 +27,12 @@ export default class App extends PureComponent {
24
27
  error: undefined,
25
28
  };
26
29
  rawModeEnabledCount = 0;
27
- internal_eventEmitter = new EventEmitter();
30
+ // Increase max listeners to accommodate multiple useInput hooks across components
31
+ internal_eventEmitter = (() => {
32
+ const emitter = new EventEmitter();
33
+ emitter.setMaxListeners(MAX_INPUT_LISTENERS);
34
+ return emitter;
35
+ })();
28
36
  isRawModeSupported() {
29
37
  return this.props.stdin.isTTY;
30
38
  }
@@ -37,6 +45,10 @@ export default class App extends PureComponent {
37
45
  }
38
46
  componentDidMount() {
39
47
  cliCursor.hide(this.props.stdout);
48
+ // Increase max listeners on stdin to accommodate multiple useInput hooks
49
+ if (this.props.stdin?.setMaxListeners) {
50
+ this.props.stdin.setMaxListeners(MAX_INPUT_LISTENERS);
51
+ }
40
52
  }
41
53
  componentWillUnmount() {
42
54
  cliCursor.show(this.props.stdout);
@@ -57,6 +69,8 @@ export default class App extends PureComponent {
57
69
  throw new Error('Raw mode is not supported on the stdin provided to Ink.\nRead about how to prevent this error on https://github.com/vadimdemedes/ink/#israwmodesupported');
58
70
  }
59
71
  }
72
+ // Increase max listeners on stdin to accommodate multiple useInput hooks
73
+ stdin.setMaxListeners(MAX_INPUT_LISTENERS);
60
74
  stdin.setEncoding('utf8');
61
75
  if (isEnabled) {
62
76
  if (this.rawModeEnabledCount === 0) {
@@ -1,12 +1,17 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useRef } from 'react';
2
2
  import parseKeypress, { nonAlphanumericKeys } from '../parse-keypress.js';
3
3
  import reconciler from '../reconciler.js';
4
4
  import useStdin from './use-stdin.js';
5
5
 
6
6
  // Patched for bracketed paste: propagate "isPasted" and avoid leaking ESC sequences
7
+ // Also patched to use ref for inputHandler to avoid effect churn with inline handlers
7
8
  const useInput = (inputHandler, options = {}) => {
8
9
  const { stdin, setRawMode, internal_exitOnCtrlC, internal_eventEmitter } = useStdin();
9
10
 
11
+ // Store handler in ref to avoid re-subscribing when handler identity changes
12
+ const handlerRef = useRef(inputHandler);
13
+ handlerRef.current = inputHandler;
14
+
10
15
  useEffect(() => {
11
16
  if (options.isActive === false) {
12
17
  return;
@@ -43,7 +48,7 @@ const useInput = (inputHandler, options = {}) => {
43
48
  isPasted: true
44
49
  };
45
50
  reconciler.batchedUpdates(() => {
46
- inputHandler(data.sequence || data.raw || '', key);
51
+ handlerRef.current(data.sequence || data.raw || '', key);
47
52
  });
48
53
  return;
49
54
  }
@@ -84,7 +89,7 @@ const useInput = (inputHandler, options = {}) => {
84
89
 
85
90
  if (!(input === 'c' && key.ctrl) || !internal_exitOnCtrlC) {
86
91
  reconciler.batchedUpdates(() => {
87
- inputHandler(input, key);
92
+ handlerRef.current(input, key);
88
93
  });
89
94
  }
90
95
  };
@@ -93,7 +98,7 @@ const useInput = (inputHandler, options = {}) => {
93
98
  return () => {
94
99
  internal_eventEmitter?.removeListener('input', handleData);
95
100
  };
96
- }, [options.isActive, stdin, internal_exitOnCtrlC, inputHandler]);
101
+ }, [options.isActive, stdin, internal_exitOnCtrlC]);
97
102
  };
98
103
 
99
104
  export default useInput;