Some checks failed
ci / validate (push) Has been cancelled
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a0233b-178d-7162-b92f-31a31ea8ca9b
88 lines
3 KiB
Python
88 lines
3 KiB
Python
"""glas-harness CLI — thin wrapper around CLIChannel (GLAS-WP-0003)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
parser = argparse.ArgumentParser(prog="glas-harness")
|
|
sub = parser.add_subparsers(dest="command", required=True)
|
|
|
|
run = sub.add_parser(
|
|
"run", help="Run one task through a versioned Glas execution profile"
|
|
)
|
|
run.add_argument(
|
|
"--harness-profile",
|
|
required=True,
|
|
help="Explicit profile id[@version], e.g. harness.agent-dev-local@1.0.0",
|
|
)
|
|
run.add_argument("--repo", required=True, help="Local repo path to mirror into the sandbox")
|
|
run.add_argument("--title", required=True)
|
|
run.add_argument("--description", required=True)
|
|
run.add_argument(
|
|
"--actor",
|
|
choices=("adm", "agt", "atm"),
|
|
default="agt",
|
|
help="Governed execution actor type; queue worker identifiers belong upstream",
|
|
)
|
|
run.add_argument("--project", default="glas-harness")
|
|
run.add_argument("--no-hub", action="store_true", help="Skip the gateway's own hub reporting")
|
|
|
|
profiles = sub.add_parser("profiles", help="Validate and list executable Glas profiles")
|
|
profiles.add_argument("--json", action="store_true", help="Emit machine-readable JSON")
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
if args.command == "run":
|
|
from glas_harness.channels.cli_channel import CLIChannel
|
|
from glas_harness.contract import ExecutionRequest
|
|
from glas_harness.gateway import run_execution
|
|
|
|
channel = CLIChannel()
|
|
invocation = channel.parse_invocation(args)
|
|
result = run_execution(
|
|
ExecutionRequest(
|
|
harness_profile_ref=invocation.harness_profile,
|
|
repo=invocation.repo,
|
|
title=invocation.title,
|
|
description=invocation.description,
|
|
actor=invocation.actor,
|
|
project=invocation.project,
|
|
report_to_hub=invocation.report_to_hub,
|
|
)
|
|
)
|
|
print(channel.render_result(result.model_dump(mode="json")))
|
|
return 0 if result.ok else 1
|
|
|
|
if args.command == "profiles":
|
|
import json
|
|
|
|
from glas_harness.profiles import ProfileCatalog, ProfileError
|
|
|
|
try:
|
|
rows = [
|
|
context.model_dump(mode="json")
|
|
for context in ProfileCatalog().validate_all()
|
|
]
|
|
except ProfileError as exc:
|
|
print(f"invalid profile catalog: {exc}", file=sys.stderr)
|
|
return 2
|
|
if args.json:
|
|
print(json.dumps(rows, indent=2))
|
|
else:
|
|
for row in rows:
|
|
print(
|
|
f"{row['profile']['id']}@{row['profile']['version']}\t"
|
|
f"rein={row['rein_id']}@{row['rein_version']}\t"
|
|
f"model={row['model']['model']}\t"
|
|
f"sandbox={row['sandbox_profile']}"
|
|
)
|
|
return 0
|
|
|
|
return 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|