@aerovato/operator-helper 1.1.1 → 1.1.2
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/dist/code-puppy/register_callbacks.py +49 -3
- package/dist/index.js +1413 -1585
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ from collections.abc import AsyncGenerator
|
|
|
10
10
|
from contextlib import asynccontextmanager, suppress
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
|
-
from code_puppy.callbacks import
|
|
13
|
+
from code_puppy.callbacks import register_callback
|
|
14
14
|
from code_puppy.config import get_current_session_name
|
|
15
15
|
from code_puppy.messaging import emit_warning
|
|
16
16
|
from code_puppy.tools.subagent_context import get_conversation_root_id
|
|
@@ -27,6 +27,19 @@ from pydantic_ai.settings import ModelSettings
|
|
|
27
27
|
|
|
28
28
|
_MARKER_KEY = "operator_memory"
|
|
29
29
|
_MARKER_VALUE = "synthetic-preamble-v1"
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
from code_puppy.callbacks import CustomCommandResult
|
|
33
|
+
except ImportError:
|
|
34
|
+
try:
|
|
35
|
+
# Code Puppy < 0.0.698 exposes the same contract in the
|
|
36
|
+
# customizable-commands plugin.
|
|
37
|
+
from code_puppy.plugins.customizable_commands.register_callbacks import (
|
|
38
|
+
MarkdownCommandResult as CustomCommandResult,
|
|
39
|
+
)
|
|
40
|
+
except ImportError:
|
|
41
|
+
CustomCommandResult = None
|
|
42
|
+
|
|
30
43
|
_RENDER_TIMEOUT_SECONDS = 30
|
|
31
44
|
_COMMAND_TIMEOUT_SECONDS = 60
|
|
32
45
|
_render_tasks: dict[str, asyncio.Task[str]] = {}
|
|
@@ -195,10 +208,36 @@ async def _agent_run_context(
|
|
|
195
208
|
if model is None:
|
|
196
209
|
yield
|
|
197
210
|
return
|
|
211
|
+
if _is_dbos_agent(pydantic_agent):
|
|
212
|
+
_warn_dbos_incompatible()
|
|
213
|
+
yield
|
|
214
|
+
return
|
|
198
215
|
with pydantic_agent.override(model=OperatorModel(model, _conversation_key())):
|
|
199
216
|
yield
|
|
200
217
|
|
|
201
218
|
|
|
219
|
+
def _is_dbos_agent(pydantic_agent: Any) -> bool:
|
|
220
|
+
# DBOSAgent installs its own captured DBOSModel through a nested
|
|
221
|
+
# override inside run(), which supersedes any override applied here.
|
|
222
|
+
# Duck-type: avoid importing the optional durable_exec module.
|
|
223
|
+
return hasattr(pydantic_agent, "_dbos_overrides")
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
_DBOS_WARNED = False
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _warn_dbos_incompatible() -> None:
|
|
230
|
+
global _DBOS_WARNED
|
|
231
|
+
if _DBOS_WARNED:
|
|
232
|
+
return
|
|
233
|
+
_DBOS_WARNED = True
|
|
234
|
+
emit_warning(
|
|
235
|
+
"Operator Memory preamble injection is disabled: DBOS durable execution "
|
|
236
|
+
"supersedes the model override it relies on. Disable DBOS to restore "
|
|
237
|
+
"Operator Memory: /set enable_dbos false, then restart Code Puppy."
|
|
238
|
+
)
|
|
239
|
+
|
|
240
|
+
|
|
202
241
|
async def _session_end() -> None:
|
|
203
242
|
tasks = tuple(_render_tasks.values())
|
|
204
243
|
_render_tasks.clear()
|
|
@@ -363,8 +402,15 @@ async def _agent_run_end(*_args: Any) -> None:
|
|
|
363
402
|
|
|
364
403
|
register_callback("agent_run_context", _agent_run_context)
|
|
365
404
|
register_callback("session_end", _session_end)
|
|
366
|
-
|
|
367
|
-
register_callback("
|
|
405
|
+
if CustomCommandResult is not None:
|
|
406
|
+
register_callback("custom_command", _custom_command)
|
|
407
|
+
register_callback("custom_command_help", _custom_command_help)
|
|
408
|
+
else:
|
|
409
|
+
emit_warning(
|
|
410
|
+
"Operator commands are disabled: this Code Puppy version is too old to "
|
|
411
|
+
"process command output as user input. Preamble injection still works. "
|
|
412
|
+
"Upgrade Code Puppy to enable the /operator:* commands."
|
|
413
|
+
)
|
|
368
414
|
register_callback("startup", _show_status_indicator)
|
|
369
415
|
register_callback("agent_run_start", _agent_run_start)
|
|
370
416
|
register_callback("agent_run_end", _agent_run_end)
|