Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:26:21.623Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

interactive.py

164 lines · 5.2 KB · python
1from __future__ import annotations
2
3import argparse
4import sys
5
6from .common import dedupe_preserving_order, deployed_function
7
8INTERACTIVE_BENCHMARK_CHOICES = [
9    "qna",
10    "rf",
11    "tw",
12    "terminal-bench-2.1",
13    "deepswe",
14]
15INTERACTIVE_BENCHMARK_ALIASES = {
16    "terminal-bench": "terminal-bench-2.1",
17    "tb21": "terminal-bench-2.1",
18    "deep-swe": "deepswe",
19}
20INTERACTIVE_MODEL_CHOICES = [
21    "sonnet-4.6",
22    "opus-4.5",
23    "baseten:kimi-k2.7-code",
24    "baseten:deepseek-v4-pro",
25    "custom-zed-model",
26    "custom-baseten-model",
27]
28
29
30def prompt(label: str, default: str | None = None) -> str:
31    suffix = f" [{default}]" if default else ""
32    value = input(f"{label}{suffix}: ").strip()
33    return value or (default or "")
34
35
36def prompt_required(label: str) -> str:
37    while True:
38        value = prompt(label)
39        if value:
40            return value
41        print("Enter a value", file=sys.stderr)
42
43
44def prompt_choice(label: str, choices: list[str], default: str) -> str:
45    print(label)
46    for index, choice in enumerate(choices, start=1):
47        marker = " (default)" if choice == default else ""
48        print(f"  {index}. {choice}{marker}")
49    while True:
50        value = prompt("Choose", default)
51        if value in choices:
52            return value
53        if value.isdigit():
54            index = int(value) - 1
55            if 0 <= index < len(choices):
56                return choices[index]
57        print(f"Enter one of: {', '.join(choices)}", file=sys.stderr)
58
59
60def prompt_multi(
61    label: str,
62    choices: list[str],
63    default: list[str],
64    aliases: dict[str, str] | None = None,
65) -> list[str]:
66    default_text = ",".join(default)
67    canonical_choices = {choice.lower(): choice for choice in choices}
68    aliases = aliases or {}
69    print(label)
70    for choice in choices:
71        print(f"  - {choice}")
72    while True:
73        value = prompt("Comma-separated choices, or all", default_text)
74        selections = []
75        for selection in (part.strip().lower() for part in value.split(",")):
76            if not selection:
77                continue
78            if selection == "all":
79                return list(choices)
80            canonical = aliases.get(selection) or canonical_choices.get(selection)
81            if canonical is None:
82                valid = ", ".join([*choices, *sorted(aliases)])
83                print(f"unknown choice '{selection}' (valid: {valid})", file=sys.stderr)
84                break
85            selections.append(canonical)
86        else:
87            selections = dedupe_preserving_order(selections)
88            if selections:
89                return selections
90            print("Choose at least one benchmark", file=sys.stderr)
91
92
93def should_prompt(args: argparse.Namespace) -> bool:
94    if getattr(args, "interactive", False):
95        return True
96    if getattr(args, "yes", False):
97        return False
98    return sys.stdin.isatty() and not getattr(args, "parts", None)
99
100
101def choose_existing_build(args: argparse.Namespace) -> str:
102    try:
103        rows = deployed_function(args, "list_builds").remote(20)
104    except Exception as error:
105        print(
106            f"Could not list builds ({error}); falling back to manual entry.",
107            file=sys.stderr,
108        )
109        return prompt("Existing build id")
110    if not rows:
111        return prompt("No builds found; enter build id")
112    print("Existing builds")
113    for index, row in enumerate(rows, start=1):
114        build_id = row.get("build_id")
115        base = str(row.get("base_sha") or "")[:12]
116        patch = "dirty" if row.get("patch_sha256") else "clean"
117        ready = "ready" if row.get("ready") else "not-ready"
118        print(f"  {index}. {build_id}  {base}  {patch}  {ready}")
119    while True:
120        value = prompt("Choose build number or id", "1")
121        if value.isdigit():
122            index = int(value) - 1
123            if 0 <= index < len(rows):
124                return rows[index]["build_id"]
125        if value:
126            return value
127
128
129def configure_interactive_suite(args: argparse.Namespace) -> None:
130    if not should_prompt(args):
131        return
132
133    args.benchmark = prompt_multi(
134        "Which benchmarks should run?",
135        INTERACTIVE_BENCHMARK_CHOICES,
136        ["qna", "rf"],
137        aliases=INTERACTIVE_BENCHMARK_ALIASES,
138    )
139
140    if not getattr(args, "build", None):
141        build_choice = prompt_choice(
142            "Build selection",
143            ["auto", "existing-build"],
144            "auto",
145        )
146        if build_choice == "existing-build":
147            args.build = choose_existing_build(args)
148
149    model_choice = prompt_choice("Base model", INTERACTIVE_MODEL_CHOICES, "sonnet-4.6")
150    if model_choice == "custom-zed-model":
151        args.model = prompt("Zed model id (provider/model)", args.model)
152    elif model_choice == "custom-baseten-model":
153        args.model_provider = "baseten"
154        args.baseten_model = prompt_required("Baseten model id")
155    else:
156        args.model = model_choice
157
158    judge_choice = prompt_choice(
159        "Judge preset",
160        ["auto", "leaderboard", "deepseek-v4-pro", "kimi-k2.7-code", "gpt55"],
161        args.judge or "auto",
162    )
163    args.judge = judge_choice
164
Served at tenant.openagents/omega Member data and write actions are omitted.