@aerovato/operator-helper 1.5.0 → 1.6.1
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 +25 -68
- package/dist/index.js +13352 -16089
- package/package.json +1 -1
|
@@ -43,33 +43,31 @@ except ImportError:
|
|
|
43
43
|
CustomCommandResult = None
|
|
44
44
|
|
|
45
45
|
_RENDER_TIMEOUT_SECONDS = 30
|
|
46
|
-
_COMMAND_TIMEOUT_SECONDS = 60
|
|
47
46
|
_render_tasks: dict[str, asyncio.Task[str]] = {}
|
|
48
47
|
_update_launched = False
|
|
49
48
|
|
|
50
49
|
_COMMANDS = {
|
|
51
50
|
"operator:user-init": (
|
|
52
51
|
"Initialize Operator User Instructions",
|
|
53
|
-
|
|
54
|
-
"Follow the
|
|
52
|
+
"user init",
|
|
53
|
+
"Follow the User Setup guide in its output, including when initialization reports failures.",
|
|
55
54
|
),
|
|
56
55
|
"operator:project-init": (
|
|
57
56
|
"Initialize Operator Project",
|
|
58
|
-
|
|
59
|
-
"Follow the
|
|
57
|
+
"project init",
|
|
58
|
+
"Follow the Project Setup guide in its output, including when initialization reports failures.",
|
|
60
59
|
),
|
|
61
60
|
"operator:index": (
|
|
62
61
|
"Build or refresh the Operator Project Index",
|
|
63
|
-
|
|
64
|
-
"Follow the
|
|
62
|
+
"index init",
|
|
63
|
+
"Follow the Project Index Setup guide in its output, including when inspection reports failures.",
|
|
65
64
|
),
|
|
66
65
|
"operator:repair": (
|
|
67
66
|
"Repair Operator",
|
|
68
|
-
|
|
69
|
-
"If
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"then read the applicable Operator memory before continuing.",
|
|
67
|
+
"memory check",
|
|
68
|
+
"If no issues are detected, stop. Otherwise, repair only the reported load "
|
|
69
|
+
"failures without initializing absent partitions. Rerun `operator-helper memory "
|
|
70
|
+
"check` to confirm the repair, then read the applicable Operator memory documents.",
|
|
73
71
|
),
|
|
74
72
|
}
|
|
75
73
|
|
|
@@ -145,8 +143,6 @@ async def _get_preamble(conversation_key: str) -> str:
|
|
|
145
143
|
|
|
146
144
|
|
|
147
145
|
async def _render_preamble(conversation_key: str) -> str:
|
|
148
|
-
environment = os.environ.copy()
|
|
149
|
-
environment["OPERATOR_HELPER_SKIP_UPDATE"] = "1"
|
|
150
146
|
process: asyncio.subprocess.Process | None = None
|
|
151
147
|
try:
|
|
152
148
|
process = await asyncio.create_subprocess_exec(
|
|
@@ -154,7 +150,6 @@ async def _render_preamble(conversation_key: str) -> str:
|
|
|
154
150
|
"preamble",
|
|
155
151
|
stdout=asyncio.subprocess.PIPE,
|
|
156
152
|
stderr=asyncio.subprocess.PIPE,
|
|
157
|
-
env=environment,
|
|
158
153
|
)
|
|
159
154
|
stdout, stderr = await asyncio.wait_for(
|
|
160
155
|
process.communicate(), timeout=_RENDER_TIMEOUT_SECONDS
|
|
@@ -284,62 +279,24 @@ def _custom_command(_command: str, name: str) -> CustomCommandResult | None:
|
|
|
284
279
|
if definition is None:
|
|
285
280
|
return None
|
|
286
281
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
_, operations, instructions = definition
|
|
304
|
-
outputs = []
|
|
305
|
-
for operation in operations:
|
|
306
|
-
arguments = tuple(operation.split())
|
|
307
|
-
result = _run_helper(arguments)
|
|
308
|
-
outputs.append(_command_output(f"operator-helper {operation} 2>&1", result[1]))
|
|
309
|
-
outputs.append(_tag("operator-instructions", instructions))
|
|
310
|
-
return CustomCommandResult("\n\n".join(outputs))
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
def _run_helper(arguments: tuple[str, ...]) -> tuple[int, str]:
|
|
314
|
-
try:
|
|
315
|
-
result = subprocess.run(
|
|
316
|
-
("operator-helper", *arguments),
|
|
317
|
-
stdout=subprocess.PIPE,
|
|
318
|
-
stderr=subprocess.STDOUT,
|
|
319
|
-
text=True,
|
|
320
|
-
timeout=_COMMAND_TIMEOUT_SECONDS,
|
|
321
|
-
check=False,
|
|
322
|
-
)
|
|
323
|
-
return result.returncode, _remove_process_newline(result.stdout)
|
|
324
|
-
except (OSError, subprocess.TimeoutExpired) as error:
|
|
325
|
-
return 1, str(error)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
def _command_output(command: str, output: str) -> str:
|
|
329
|
-
return (
|
|
330
|
-
"<operator-command>\n"
|
|
331
|
-
f"<command>{command}</command>\n"
|
|
332
|
-
"<output>\n"
|
|
333
|
-
f"{output}\n"
|
|
334
|
-
"</output>\n"
|
|
335
|
-
"</operator-command>"
|
|
282
|
+
description, operation, instructions = definition
|
|
283
|
+
return CustomCommandResult(
|
|
284
|
+
f"# {description}\n\n"
|
|
285
|
+
"1. Run `operator-helper version`. If an update is available, run "
|
|
286
|
+
"`operator-helper upgrade` before continuing.\n"
|
|
287
|
+
f"2. Run `operator-helper {operation}`. {instructions}\n\n"
|
|
288
|
+
"## Recovery\n\n"
|
|
289
|
+
"- If Helper cannot start, install or repair the npm package "
|
|
290
|
+
"`@aerovato/operator-helper` globally and retry the failed command.\n"
|
|
291
|
+
"- If the version check or upgrade fails, diagnose the error and retry.\n"
|
|
292
|
+
f"- If `operator-helper {operation}` reports a failure, use its output to "
|
|
293
|
+
"resolve it and rerun it as needed.\n"
|
|
294
|
+
"- If you cannot resolve a problem, report the blocker.\n\n"
|
|
295
|
+
"Use Helper output as working context. Do not reproduce it wholesale or "
|
|
296
|
+
"reimplement Helper logic."
|
|
336
297
|
)
|
|
337
298
|
|
|
338
299
|
|
|
339
|
-
def _tag(name: str, content: str) -> str:
|
|
340
|
-
return f"<{name}>\n{content}\n</{name}>"
|
|
341
|
-
|
|
342
|
-
|
|
343
300
|
def _custom_command_help() -> list[tuple[str, str]]:
|
|
344
301
|
return [(name, definition[0]) for name, definition in _COMMANDS.items()]
|
|
345
302
|
|