Files
Elydora-Open-Source/sdks/python/elydora/plugins/qwen_command.py
T
雷电芽衣 bc6983a62e chore(oss): audit the server package and resync the SDK mirrors
Split the 657-line operation service into eor, submit, and verify
modules, add the AGENT_REVOKED and KEY_RETIRED codes the Backend already
emits, and condense every multi-line comment. Mirror Node, Python, and
Go at 2.1.0 with the deep-health 503, non-idempotent retry, rotation
grace, and path-encoding fixes. Document which routes and response
fields the self-hosted server does not provide.

Claude-Session: https://claude.ai/code/session_01Agoc9bRVE9KL7mmWtey9Vq
2026-09-03 20:48:20 -04:00

45 lines
1.2 KiB
Python

"""Qwen Code command construction and exact runtime ownership."""
from __future__ import annotations
from dataclasses import dataclass
import os
import sys
from typing import Optional
from ._runtime import managed_script_reference, same_path
from ._shell_command import (
parse_posix_command,
parse_powershell_source,
posix_source,
powershell_source,
)
@dataclass(frozen=True)
class QwenRuntimeReference:
agent_id: str
script_path: str
def build_qwen_command(script_path: str) -> str:
if not os.path.isabs(sys.executable) or not os.path.isabs(script_path):
raise ValueError(
"Qwen Code hook commands require absolute executable and script paths"
)
return powershell_source(script_path) if os.name == "nt" else posix_source(script_path)
def qwen_runtime_reference(
command: str, script_name: str
) -> Optional[QwenRuntimeReference]:
parsed = (
parse_powershell_source(command)
if os.name == "nt"
else parse_posix_command(command)
)
if parsed is None or not same_path(parsed[0], sys.executable):
return None
reference = managed_script_reference(parsed[1], script_name)
return None if reference is None else QwenRuntimeReference(*reference)