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.
- lcode/__init__.py +1 -1
- lcode/acp.py +22 -2
- lcode/agent.py +14 -1106
- lcode/agent_base.py +211 -0
- lcode/agent_checks.py +136 -0
- lcode/agent_context.py +165 -0
- lcode/agent_model.py +318 -0
- lcode/agent_prompt.py +304 -0
- lcode/agent_sessions.py +157 -0
- lcode/api.py +3 -3
- lcode/assistant.py +2 -1
- lcode/bench.py +3 -671
- lcode/bench_backend.py +1 -1
- lcode/bench_budgets.py +1 -1
- lcode/bench_checks.py +61 -0
- lcode/bench_dedupe.py +1 -1
- lcode/bench_flaky.py +2 -2
- lcode/bench_logsum.py +1 -1
- lcode/bench_quick.py +650 -0
- lcode/bench_quotes.py +1 -1
- lcode/bench_runtime.py +1 -1
- lcode/catalog.py +1 -1
- lcode/checks.py +1 -1
- lcode/cli.py +19 -491
- lcode/cli_args.py +230 -0
- lcode/clips.py +68 -0
- lcode/comfy.py +5 -4
- lcode/config.py +1 -1
- lcode/docs/how-it-works.md +8 -5
- lcode/docs/public-benchmarks.md +11 -1
- lcode/docs/quickstart.md +1 -1
- lcode/doctor.py +275 -0
- lcode/edits.py +3 -2
- lcode/escalate.py +2 -2
- lcode/extensions.py +2 -2
- lcode/film.py +4 -4
- lcode/harbor.py +6 -5
- lcode/harbor_bench.py +100 -9
- lcode/hooks.py +1 -1
- lcode/imageopts.py +5 -4
- lcode/lsp.py +6 -5
- lcode/manual.py +5 -4
- lcode/matching.py +2 -2
- lcode/mcp/auth.py +2 -1
- lcode/mcp/catalog.py +4 -3
- lcode/mcp/config.py +9 -7
- lcode/mcp/manager.py +2 -1
- lcode/mcp/server.py +4 -4
- lcode/media.py +6 -394
- lcode/media_catalog.py +1 -1
- lcode/media_cloud.py +2 -2
- lcode/media_video.py +377 -0
- lcode/permissions.py +1 -1
- lcode/qt_hook.py +317 -0
- lcode/repl.py +14 -1002
- lcode/repl_history.py +297 -0
- lcode/repl_media.py +334 -0
- lcode/repl_models.py +311 -0
- lcode/repl_sessions.py +137 -0
- lcode/replay.py +6 -5
- lcode/review.py +2 -1
- lcode/screenshots.py +4 -689
- lcode/screenshots_web.py +400 -0
- lcode/servers/encord.py +3 -2
- lcode/servers/valohai.py +1 -1
- lcode/sessions.py +3 -2
- lcode/steer.py +16 -9
- lcode/subagents.py +3 -3
- lcode/tool_helpers.py +128 -0
- lcode/tool_schemas.py +319 -0
- lcode/tools.py +27 -902
- lcode/tools_base.py +78 -0
- lcode/tools_edit.py +222 -0
- lcode/tools_shell.py +248 -0
- lcode/trace_export.py +184 -0
- lcode/trace_view.py +313 -0
- lcode/traces.py +9 -452
- {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/METADATA +1 -1
- lcode_cli-0.60.0.dist-info/RECORD +156 -0
- lcode_cli-0.59.0.dist-info/RECORD +0 -131
- {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/WHEEL +0 -0
- {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/entry_points.txt +0 -0
- {lcode_cli-0.59.0.dist-info → lcode_cli-0.60.0.dist-info}/licenses/LICENSE +0 -0
lcode/__init__.py
CHANGED
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
|
|
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 = {
|