chore: import upstream snapshot with attribution
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""CLI command tool."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from core.agent_harness.tools.tool_context import (
|
||||
ActionToolContext,
|
||||
capability_available_from_sources,
|
||||
execute_with_action_context,
|
||||
object_schema,
|
||||
string_property,
|
||||
)
|
||||
from core.tool_framework.registered_tool import RegisteredTool
|
||||
from tools.interactive_shell.cli import run_opensre_cli_command
|
||||
from tools.interactive_shell.subprocess import require_subprocess_presenter
|
||||
|
||||
|
||||
def execute_cli_command_tool(args: dict[str, Any], ctx: ActionToolContext) -> bool:
|
||||
payload = str(args.get("payload", "")).strip()
|
||||
if not payload:
|
||||
return False
|
||||
run_opensre_cli_command(payload, require_subprocess_presenter(ctx))
|
||||
return True
|
||||
|
||||
|
||||
def run_cli_command(*, payload: str, context: Any) -> dict[str, Any]:
|
||||
return execute_with_action_context({"payload": payload}, context, execute_cli_command_tool)
|
||||
|
||||
|
||||
cli_exec_tool = RegisteredTool(
|
||||
name="cli_exec",
|
||||
description=(
|
||||
"Run an `opensre` CLI subcommand payload (without the leading `opensre ` prefix). "
|
||||
"Prefer allowed operational families such as health/status/list/show/integrations/"
|
||||
"synthetic checks; avoid unrelated or dangerous payloads."
|
||||
),
|
||||
input_schema=object_schema(
|
||||
properties={
|
||||
"payload": string_property(
|
||||
description=(
|
||||
"CLI payload passed to `opensre` without the leading command prefix "
|
||||
"(for example: `integrations list`, `health`, `synthetic run ...`). "
|
||||
"Must not start with `opensre `."
|
||||
),
|
||||
min_length=1,
|
||||
)
|
||||
},
|
||||
required=("payload",),
|
||||
),
|
||||
source="interactive_shell",
|
||||
surfaces=("action",),
|
||||
parallel_safe=False,
|
||||
accepts_runtime_context=True,
|
||||
run=run_cli_command,
|
||||
is_available=lambda sources: capability_available_from_sources(sources, "cli_commands"),
|
||||
)
|
||||
|
||||
|
||||
__all__ = ["cli_exec_tool", "execute_cli_command_tool"]
|
||||
Reference in New Issue
Block a user