panopticon-cli 1.1.2__tar.gz → 1.1.3__tar.gz

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.
Files changed (22) hide show
  1. {panopticon_cli-1.1.2/panopticon_cli.egg-info → panopticon_cli-1.1.3}/PKG-INFO +1 -1
  2. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/cli.py +38 -6
  3. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3/panopticon_cli.egg-info}/PKG-INFO +1 -1
  4. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/pyproject.toml +1 -1
  5. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/LICENSE +0 -0
  6. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/README.md +0 -0
  7. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/__init__.py +0 -0
  8. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/memory.py +0 -0
  9. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/observer.py +0 -0
  10. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/policies.py +0 -0
  11. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon/sentinel.py +0 -0
  12. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/SOURCES.txt +0 -0
  13. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/dependency_links.txt +0 -0
  14. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/entry_points.txt +0 -0
  15. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/requires.txt +0 -0
  16. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/panopticon_cli.egg-info/top_level.txt +0 -0
  17. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/setup.cfg +0 -0
  18. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_cli.py +0 -0
  19. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_memory.py +0 -0
  20. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_observer.py +0 -0
  21. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_policies.py +0 -0
  22. {panopticon_cli-1.1.2 → panopticon_cli-1.1.3}/tests/test_sentinel.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: panopticon-cli
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Summary: The Cognitive Immune System for Autonomous CLI Agents.
5
5
  Author: Ak
6
6
  License: MIT
@@ -36,7 +36,7 @@ class CLIWrapper:
36
36
  self.running = False
37
37
  self.lock = threading.Lock()
38
38
  self.threads = []
39
- self.stdin_reader = None
39
+ self._stop_event = threading.Event()
40
40
 
41
41
  def run(self):
42
42
  self.running = True
@@ -61,15 +61,15 @@ class CLIWrapper:
61
61
  env=env,
62
62
  )
63
63
 
64
- t_out = threading.Thread(target=self._read_stdout, daemon=True)
64
+ t_out = threading.Thread(target=self._read_stdout)
65
65
  t_out.start()
66
66
  self.threads.append(t_out)
67
67
 
68
- t_eval = threading.Thread(target=self._eval_loop, daemon=True)
68
+ t_eval = threading.Thread(target=self._eval_loop)
69
69
  t_eval.start()
70
70
  self.threads.append(t_eval)
71
71
 
72
- t_in = threading.Thread(target=self._read_stdin, daemon=True)
72
+ t_in = threading.Thread(target=self._read_stdin)
73
73
  t_in.start()
74
74
  self.threads.append(t_in)
75
75
 
@@ -87,6 +87,7 @@ class CLIWrapper:
87
87
  def _cleanup(self):
88
88
  """Cleanly shutdown all threads and resources."""
89
89
  self.running = False
90
+ self._stop_event.set()
90
91
 
91
92
  # Close subprocess pipes FIRST before thread cleanup
92
93
  if self.process:
@@ -117,6 +118,24 @@ class CLIWrapper:
117
118
  if thread.is_alive():
118
119
  thread.join(timeout=1)
119
120
 
121
+ def _stdin_ready(self) -> bool:
122
+ stdin_obj = sys.stdin
123
+ if sys.platform == "win32":
124
+ try:
125
+ import msvcrt
126
+ except ImportError:
127
+ pass
128
+ else:
129
+ if stdin_obj.isatty():
130
+ return msvcrt.kbhit()
131
+
132
+ try:
133
+ import select
134
+
135
+ return bool(select.select([stdin_obj], [], [], 0.1)[0])
136
+ except Exception:
137
+ return False
138
+
120
139
  def _read_stdout(self):
121
140
  # Flaw 2 Fix: Safely decode multi-byte UTF-8 emojis incrementally
122
141
  decoder = codecs.getincrementaldecoder("utf-8")(errors="replace")
@@ -151,10 +170,23 @@ class CLIWrapper:
151
170
  pass
152
171
 
153
172
  def _read_stdin(self):
173
+ stdin_buffer = getattr(sys.stdin, "buffer", None)
174
+ if stdin_buffer is None:
175
+ return
176
+
154
177
  try:
155
- while self.running and self.process and self.process.poll() is None:
178
+ while (
179
+ self.running
180
+ and self.process
181
+ and self.process.poll() is None
182
+ and not self._stop_event.is_set()
183
+ ):
184
+ if not self._stdin_ready():
185
+ time.sleep(0.1)
186
+ continue
187
+
156
188
  try:
157
- data = sys.stdin.buffer.read1(1024)
189
+ data = stdin_buffer.read1(1024)
158
190
  if not data:
159
191
  break
160
192
  if self.process.stdin and not self.process.stdin.closed:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: panopticon-cli
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Summary: The Cognitive Immune System for Autonomous CLI Agents.
5
5
  Author: Ak
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "panopticon-cli"
7
- version = "1.1.2"
7
+ version = "1.1.3"
8
8
  description = "The Cognitive Immune System for Autonomous CLI Agents."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes