lcode-cli 0.59.0__py3-none-any.whl → 0.60.0__py3-none-any.whl

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 (83) hide show
  1. lcode/__init__.py +1 -1
  2. lcode/acp.py +22 -2
  3. lcode/agent.py +14 -1106
  4. lcode/agent_base.py +211 -0
  5. lcode/agent_checks.py +136 -0
  6. lcode/agent_context.py +165 -0
  7. lcode/agent_model.py +318 -0
  8. lcode/agent_prompt.py +304 -0
  9. lcode/agent_sessions.py +157 -0
  10. lcode/api.py +3 -3
  11. lcode/assistant.py +2 -1
  12. lcode/bench.py +3 -671
  13. lcode/bench_backend.py +1 -1
  14. lcode/bench_budgets.py +1 -1
  15. lcode/bench_checks.py +61 -0
  16. lcode/bench_dedupe.py +1 -1
  17. lcode/bench_flaky.py +2 -2
  18. lcode/bench_logsum.py +1 -1
  19. lcode/bench_quick.py +650 -0
  20. lcode/bench_quotes.py +1 -1
  21. lcode/bench_runtime.py +1 -1
  22. lcode/catalog.py +1 -1
  23. lcode/checks.py +1 -1
  24. lcode/cli.py +19 -491
  25. lcode/cli_args.py +230 -0
  26. lcode/clips.py +68 -0
  27. lcode/comfy.py +5 -4
  28. lcode/config.py +1 -1
  29. lcode/docs/how-it-works.md +8 -5
  30. lcode/docs/public-benchmarks.md +11 -1
  31. lcode/docs/quickstart.md +1 -1
  32. lcode/doctor.py +275 -0
  33. lcode/edits.py +3 -2
  34. lcode/escalate.py +2 -2
  35. lcode/extensions.py +2 -2
  36. lcode/film.py +4 -4
  37. lcode/harbor.py +6 -5
  38. lcode/harbor_bench.py +100 -9
  39. lcode/hooks.py +1 -1
  40. lcode/imageopts.py +5 -4
  41. lcode/lsp.py +6 -5
  42. lcode/manual.py +5 -4
  43. lcode/matching.py +2 -2
  44. lcode/mcp/auth.py +2 -1
  45. lcode/mcp/catalog.py +4 -3
  46. lcode/mcp/config.py +9 -7
  47. lcode/mcp/manager.py +2 -1
  48. lcode/mcp/server.py +4 -4
  49. lcode/media.py +6 -394
  50. lcode/media_catalog.py +1 -1
  51. lcode/media_cloud.py +2 -2
  52. lcode/media_video.py +377 -0
  53. lcode/permissions.py +1 -1
  54. lcode/qt_hook.py +317 -0
  55. lcode/repl.py +14 -1002
  56. lcode/repl_history.py +297 -0
  57. lcode/repl_media.py +334 -0
  58. lcode/repl_models.py +311 -0
  59. lcode/repl_sessions.py +137 -0
  60. lcode/replay.py +6 -5
  61. lcode/review.py +2 -1
  62. lcode/screenshots.py +4 -689
  63. lcode/screenshots_web.py +400 -0
  64. lcode/servers/encord.py +3 -2
  65. lcode/servers/valohai.py +1 -1
  66. lcode/sessions.py +3 -2
  67. lcode/steer.py +16 -9
  68. lcode/subagents.py +3 -3
  69. lcode/tool_helpers.py +128 -0
  70. lcode/tool_schemas.py +319 -0
  71. lcode/tools.py +27 -902
  72. lcode/tools_base.py +78 -0
  73. lcode/tools_edit.py +222 -0
  74. lcode/tools_shell.py +248 -0
  75. lcode/trace_export.py +184 -0
  76. lcode/trace_view.py +313 -0
  77. lcode/traces.py +9 -452
  78. {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/METADATA +1 -1
  79. lcode_cli-0.60.0.dist-info/RECORD +156 -0
  80. lcode_cli-0.59.0.dist-info/RECORD +0 -131
  81. {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/WHEEL +0 -0
  82. {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/entry_points.txt +0 -0
  83. {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/licenses/LICENSE +0 -0
lcode/__init__.py CHANGED
@@ -3,7 +3,7 @@
3
3
  From a program: `from lcode import Session` (see lcode.api).
4
4
  """
5
5
 
6
- __version__ = "0.59.0"
6
+ __version__ = "0.60.0"
7
7
 
8
8
  API = ("Session", "Result", "Options", "SetupError")
9
9
 
lcode/acp.py CHANGED
@@ -19,11 +19,13 @@ the file in LCODE_ACP_LOG), and stdin is the protocol channel only.
19
19
  from __future__ import annotations
20
20
 
21
21
  import base64
22
+ import contextlib
22
23
  import hashlib
23
24
  import json
24
25
  import os
25
26
  import sys
26
27
  import threading
28
+ from collections.abc import Callable
27
29
  from pathlib import Path
28
30
  from typing import IO, TYPE_CHECKING, Any
29
31
  from urllib.parse import unquote, urlparse
@@ -76,6 +78,9 @@ class Connection:
76
78
  self.pending: dict[int, tuple[threading.Event, dict]] = {}
77
79
  self.next_id = 0
78
80
  self.closed = False
81
+ # Called with each message from the editor in the order they came, before it's handled in a thread of
82
+ # its own: for what has to happen in that order (Server.received).
83
+ self.on_message: Callable[[dict], None] | None = None
79
84
 
80
85
  def send(self, message: dict) -> None:
81
86
  data = (json.dumps({"jsonrpc": "2.0", **message}, ensure_ascii=False) + "\n").encode()
@@ -112,6 +117,9 @@ class Connection:
112
117
  self.send({"id": None, "error": {"code": -32700, "message": "parse error"}})
113
118
  continue
114
119
  if "method" in message:
120
+ if self.on_message is not None:
121
+ with contextlib.suppress(Exception): # never stop reading
122
+ self.on_message(message)
115
123
  threading.Thread(target=self._dispatch, args=(handle, message), daemon=True).start()
116
124
  elif message.get("id") in self.pending:
117
125
  done, slot = self.pending.pop(message["id"])
@@ -373,8 +381,7 @@ class Session:
373
381
  return {"stopReason": "end_turn"}
374
382
  if command is not None:
375
383
  text = command
376
- self.agent.cancel.clear()
377
- result = api.run_request(self.agent, text)
384
+ result = api.run_request(self.agent, text) # its cancel was reset when the prompt arrived (Server.received)
378
385
  self.update({"sessionUpdate": "usage_update", "used": self.agent.ctx_used, "size": self.agent.settings.context})
379
386
  self.update({"sessionUpdate": "session_info_update", "title": self.agent.session_title or None})
380
387
  if result.status == "error":
@@ -472,6 +479,19 @@ class Server:
472
479
  self.conn, self.console = conn, console
473
480
  self.client_caps: dict = {}
474
481
  self.sessions: dict[str, Session] = {}
482
+ conn.on_message = self.received
483
+
484
+ def received(self, message: dict) -> None:
485
+ """A new prompt resets its session's cancel as soon as it arrives, in the order the editor sent things.
486
+
487
+ Each message is then handled in a thread of its own, so a cancel sent right after a prompt can run before
488
+ the prompt's thread starts; the cancel then holds, instead of being reset by a prompt that starts late.
489
+ """
490
+ if message.get("method") == "session/prompt":
491
+ params = message.get("params") or {}
492
+ session = self.sessions.get(str(params.get("sessionId", "")))
493
+ if session is not None and session.agent.cancel is not None:
494
+ session.agent.cancel.clear()
475
495
 
476
496
  def handle(self, method: str, params: dict) -> dict | None:
477
497
  handlers = {