@aerovato/operator-helper 1.1.2 → 1.2.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/README.md +8 -0
- package/dist/code-puppy/register_callbacks.py +34 -1
- package/dist/index.js +6821 -23497
- package/dist/index.js.map +16 -61
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,12 @@ Install an adapter:
|
|
|
24
24
|
# OpenCode
|
|
25
25
|
operator-helper install opencode
|
|
26
26
|
|
|
27
|
+
# OpenCode V2 beta
|
|
28
|
+
operator-helper install opencode-v2
|
|
29
|
+
|
|
30
|
+
# Pi
|
|
31
|
+
operator-helper install pi
|
|
32
|
+
|
|
27
33
|
# Code Puppy
|
|
28
34
|
operator-helper install code-puppy
|
|
29
35
|
```
|
|
@@ -40,6 +46,8 @@ The direct user-facing Helper operation is adapter installation:
|
|
|
40
46
|
|
|
41
47
|
```sh
|
|
42
48
|
operator-helper install opencode
|
|
49
|
+
operator-helper install opencode-v2
|
|
50
|
+
operator-helper install pi
|
|
43
51
|
operator-helper install code-puppy
|
|
44
52
|
```
|
|
45
53
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
import importlib.metadata
|
|
6
7
|
import os
|
|
7
8
|
import subprocess
|
|
8
9
|
import threading
|
|
@@ -27,6 +28,7 @@ from pydantic_ai.settings import ModelSettings
|
|
|
27
28
|
|
|
28
29
|
_MARKER_KEY = "operator_memory"
|
|
29
30
|
_MARKER_VALUE = "synthetic-preamble-v1"
|
|
31
|
+
_MODEL_MESSAGE_TRANSFORM_VERSION = (0, 0, 753)
|
|
30
32
|
|
|
31
33
|
try:
|
|
32
34
|
from code_puppy.callbacks import CustomCommandResult
|
|
@@ -120,6 +122,12 @@ async def _inject_preamble(
|
|
|
120
122
|
return transformed
|
|
121
123
|
|
|
122
124
|
|
|
125
|
+
async def _transform_model_messages(
|
|
126
|
+
_agent_name: str | None, messages: list[ModelMessage]
|
|
127
|
+
) -> None:
|
|
128
|
+
messages[:] = await _inject_preamble(messages, _conversation_key())
|
|
129
|
+
|
|
130
|
+
|
|
123
131
|
def _is_operator_request(message: ModelMessage) -> bool:
|
|
124
132
|
return (
|
|
125
133
|
isinstance(message, ModelRequest)
|
|
@@ -200,6 +208,31 @@ def _conversation_key() -> str:
|
|
|
200
208
|
return get_conversation_root_id() or get_current_session_name()
|
|
201
209
|
|
|
202
210
|
|
|
211
|
+
def _installed_code_puppy_version() -> str | None:
|
|
212
|
+
try:
|
|
213
|
+
return importlib.metadata.version("code-puppy")
|
|
214
|
+
except Exception:
|
|
215
|
+
return None
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _supports_model_message_transform(version: str | None) -> bool:
|
|
219
|
+
if version is None:
|
|
220
|
+
return False
|
|
221
|
+
release = version.partition("+")[0].partition("-")[0]
|
|
222
|
+
try:
|
|
223
|
+
parts = tuple(int(part) for part in release.split("."))
|
|
224
|
+
except ValueError:
|
|
225
|
+
return False
|
|
226
|
+
return parts >= _MODEL_MESSAGE_TRANSFORM_VERSION
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _register_preamble_injection(version: str | None) -> None:
|
|
230
|
+
if _supports_model_message_transform(version):
|
|
231
|
+
register_callback("transform_model_messages", _transform_model_messages)
|
|
232
|
+
else:
|
|
233
|
+
register_callback("agent_run_context", _agent_run_context)
|
|
234
|
+
|
|
235
|
+
|
|
203
236
|
@asynccontextmanager
|
|
204
237
|
async def _agent_run_context(
|
|
205
238
|
_agent: Any, pydantic_agent: Any, _group_id: str, _mcp_servers: Any
|
|
@@ -400,7 +433,7 @@ async def _agent_run_end(*_args: Any) -> None:
|
|
|
400
433
|
_paint_status_indicator("")
|
|
401
434
|
|
|
402
435
|
|
|
403
|
-
|
|
436
|
+
_register_preamble_injection(_installed_code_puppy_version())
|
|
404
437
|
register_callback("session_end", _session_end)
|
|
405
438
|
if CustomCommandResult is not None:
|
|
406
439
|
register_callback("custom_command", _custom_command)
|