feat: add versioned execution profiles
This commit is contained in:
parent
641e85f5a8
commit
1cd890d871
34 changed files with 2087 additions and 471 deletions
|
|
@ -10,8 +10,14 @@ 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 rein inside a sand-boxer sandbox")
|
||||
run.add_argument("--sandbox-profile", required=True, help="e.g. profile.bwrap-local")
|
||||
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)
|
||||
|
|
@ -19,25 +25,56 @@ def main(argv: list[str] | None = None) -> int:
|
|||
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.gateway import run_task_through_rein
|
||||
from glas_harness.contract import ExecutionRequest
|
||||
from glas_harness.gateway import run_execution
|
||||
|
||||
channel = CLIChannel()
|
||||
invocation = channel.parse_invocation(args)
|
||||
result = run_task_through_rein(
|
||||
sandbox_profile=invocation.sandbox_profile,
|
||||
repo=invocation.repo,
|
||||
title=invocation.title,
|
||||
description=invocation.description,
|
||||
actor=invocation.actor,
|
||||
project=invocation.project,
|
||||
report_to_hub=invocation.report_to_hub,
|
||||
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))
|
||||
return 0 if result["tool_ok"] else 1
|
||||
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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue