agent, gui: omp's plan, vision and advisor roles are picked on its row, and each role but the default one has its own thinking level (#1397, KKKKKKKEM)

KKKKKKKEM (#1397): omp 18.x runs plan mode, images and the advisor on
roles of their own that don't follow the default model, and magpie
offered no way to set them; then, setting slow, they asked to set its
thinking level too (slow at high while sessions start at medium).

omp reads a role's thinking level off the end of its model, "model:level"
(splitThinkingSuffix / parseModelPattern in model-resolver.ts, with
:auto and :max allowed for role values). magpie now has:
- plan, vision and advisor beside subagents, smol and slow (all written
  under modelRoles in ~/.omp/agent/config.yml as before);
- a "<role> thinking" field for each of them: the level rewrites the
  role's value through the role's own Set, so magpie's provider prefix
  and the stash are kept. Offered while the role is one model (auto,
  off, minimal…max); a role left unset or set to a list says to pick its
  model first, and an unknown level is refused. Unset, the role runs at
  the session's level.
In the GUI the roles move into the tiers square ("roles") with each
role's level in its menu; unset roles say what omp does instead (the
advisor: the slow role's model, else omp's own pick). The same holds
for a named profile (omp#<name>) and omp in a WSL distro: ompAgent now
matches those ids, so their rows don't list the roles as loose fields.
New strings in zh, zh-TW, ja and de.

Tests:
- TestOmpRoleThinking (Go): level read and written for each role,
  provider prefix kept, unset and list roles refused, unknown level
  refused, clearing the level leaves the model.
- omp-roles.test.cjs: the roles square, a role's level picked and
  written, and an omp#work profile row drawn the same way. Broken by
  hand (ompAgent on the bare id), the profile case goes red.
This commit is contained in:
yetone
2026-10-10 20:04:49 +08:00
parent 167f133166
commit fc5dfa3c63
5 changed files with 411 additions and 81 deletions
+81 -29
View File
@@ -10,6 +10,7 @@ package agent
// like may name them as well (ompRefKeys); magpie stays while any does.
import (
"fmt"
"os"
"path/filepath"
"regexp"
@@ -337,6 +338,71 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
},
}
}
roles := []Field{
role("model", "model", "default", false),
// omp's own agents run on its roles (src/task/agents.ts,
// prompts/agents): task on @task; scout and sonic on @smol;
// reviewer on @slow, also the eval tool's "slow" tier. Unset,
// task gives its agent the parent session's model, and smol
// and slow take the default role's (model-resolver.ts,
// shouldInheritDefaultBeforePriority). The designer role went
// in omp 18.1.5. smol is labelled as omp names it: "small" is
// other agents' picker of its own
role("subagent", "subagents", "task", true),
role("small", "smol", "smol", true),
role("slow", "slow", "slow", true),
// plan mode's role (omp's "Architect"), images handed to a model
// that sees them, and the second opinion the advisor gives. Unset,
// omp picks for each from its own list; the advisor takes the slow
// role first (model-resolver.ts, ROLE_CONFIGURED_FALLBACK), never
// the default's (#1397)
role("plan", "plan", "plan", true),
role("vision", "vision", "vision", true),
role("advisor", "advisor", "advisor", true),
}
// each role but the default one has a thinking level of its own, the
// ":level" omp reads off the end of the role's model
// (splitThinkingSuffix, resolveModelRoleValue): #1397, the slow role at
// high while sessions start at medium. It is the role's value written
// again, so it goes through the role's own Set (magpie's provider, the
// stash). Offered while the role is one model: a role that follows
// another, or a list omp falls back through, has no level here. Unset,
// the role runs at the session's level
fields := []Field{roles[0]}
for _, r := range roles[1:] {
fields = append(fields, r, Field{
Key: r.Key + "_thinking", Label: r.Label + " thinking", Quiet: true,
Get: func() string {
if _, level, one := ompSplit(r.Get()); one {
return strings.TrimPrefix(level, ":")
}
return ""
},
Set: func(v string) error {
cur := r.Get()
model, _, one := ompSplit(cur)
if cur == "" || !one {
if v == "" {
return nil
}
return fmt.Errorf("omp's %s role is not on one model: pick its model first", r.Label)
}
if v != "" && v != "off" && v != "auto" && !slices.Contains(ompEfforts, v) {
return fmt.Errorf("%q is not one of omp's thinking levels", v)
}
if v != "" {
model += ":" + v
}
return r.Set(model)
},
Options: func(cur map[string]string) []Option {
if _, _, one := ompSplit(cur[r.Key]); cur[r.Key] == "" || !one {
return nil
}
return static(append([]string{"auto", "off"}, ompEfforts...)...)
},
})
}
return &Agent{
ID: "omp", Name: "omp", Icon: "omp", Aliases: []string{"oh-my-pi"}, Spelled: prefixed,
UA: []string{"oh-my-pi"},
@@ -401,36 +467,22 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
return wiringOff("omp", models, func(k string) (string, bool) { return edit.GetYAML(models, "providers."+magpieID+"."+k) },
"baseUrl", at.v1())
},
Fields: []Field{
role("model", "model", "default", false),
// omp's own agents run on its roles (src/task/agents.ts,
// prompts/agents): task on @task; scout and sonic on @smol;
// reviewer on @slow, also the eval tool's "slow" tier. Unset,
// task gives its agent the parent session's model, and smol
// and slow take the default role's (model-resolver.ts,
// shouldInheritDefaultBeforePriority). The designer role went
// in omp 18.1.5. smol is labelled as omp names it: "small" is
// other agents' picker of its own
role("subagent", "subagents", "task", true),
role("small", "smol", "smol", true),
role("slow", "slow", "slow", true),
{
// the thinking level sessions start with, as omp's settings save
// it; unset omp takes high. auto has omp pick a level each turn:
// not a level a model lists, so it is offered here and kept out of
// ompEfforts, which a model's thinking levels are filtered by. First,
// as omp's own picker has it (16.3.5 and 18.4.4 alike)
Key: "effort", Label: "thinking",
Get: func() string { v, _ := edit.GetYAML(path, "defaultThinkingLevel"); return v },
Set: func(v string) error {
if v == "" {
return edit.DelYAML(path, "defaultThinkingLevel")
}
return edit.SetYAML(path, edit.KV{Path: "defaultThinkingLevel", Value: v})
},
Options: func(map[string]string) []Option { return static(append([]string{"auto"}, ompEfforts...)...) },
Fields: append(fields, Field{
// the thinking level sessions start with, as omp's settings save
// it; unset omp takes high. auto has omp pick a level each turn:
// not a level a model lists, so it is offered here and kept out of
// ompEfforts, which a model's thinking levels are filtered by. First,
// as omp's own picker has it (16.3.5 and 18.4.4 alike)
Key: "effort", Label: "thinking",
Get: func() string { v, _ := edit.GetYAML(path, "defaultThinkingLevel"); return v },
Set: func(v string) error {
if v == "" {
return edit.DelYAML(path, "defaultThinkingLevel")
}
return edit.SetYAML(path, edit.KV{Path: "defaultThinkingLevel", Value: v})
},
},
Options: func(map[string]string) []Option { return static(append([]string{"auto"}, ompEfforts...)...) },
}),
}
}
+130
View File
@@ -0,0 +1,130 @@
package agent
import (
"os"
"path/filepath"
"slices"
"testing"
"github.com/yetone/magpie/internal/edit"
"github.com/yetone/magpie/internal/provider"
)
// #1397 (KKKKKKKEM): omp's plan, vision and advisor roles can be put on a
// model as its other roles can, and every role but the default one has a
// thinking level of its own, written as omp 18.8.6 reads it: the role's
// model with ":<level>" after it (splitThinkingSuffix). The level stays
// when the role's model changes, goes with the role when it is reset, and
// is none to set while the role follows another or is a list of models.
func TestOmpRoleThinking(t *testing.T) {
home := t.TempDir()
t.Setenv("HOME", home)
t.Setenv("USERPROFILE", home)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config"))
t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache"))
t.Setenv("PATH", t.TempDir())
for _, k := range []string{"PI_CODING_AGENT_DIR", "PI_CONFIG_DIR", "OMP_PROFILE", "PI_PROFILE"} {
t.Setenv(k, "")
}
if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash"}}); err != nil {
t.Fatal(err)
}
dir := filepath.Join(home, ".omp", "agent")
configPath := filepath.Join(dir, "config.yml")
os.MkdirAll(dir, 0o755)
os.WriteFile(configPath, []byte("defaultThinkingLevel: medium\nmodelRoles:\n default: anthropic/claude-opus-5\n task: openai/gpt-6,anthropic/claude-opus-5:high\n"), 0o644)
a := omp(home)
role := func(name string) string { v, _ := edit.GetYAML(configPath, "modelRoles."+name); return v }
apply := func(k, v string) {
t.Helper()
if err := a.Apply(k, v); err != nil {
t.Fatalf("%s = %q: %v", k, v, err)
}
}
for _, k := range []string{"plan", "vision", "advisor"} {
f := a.Field(k)
if f == nil || !f.Quiet || f.Label != k {
t.Fatalf("role %s: %+v", k, f)
}
apply(k, "magpie/deepseek/pro")
if got := role(k); got != "magpie/deepseek/pro" {
t.Fatalf("modelRoles.%s: %q", k, got)
}
}
if a.Field("model_thinking") != nil {
t.Fatal("the default role's level is the session's, not a field of its own")
}
// unset, a role has no level to pick; on one model it has omp's
slow := a.Field("slow_thinking")
if slow == nil || slow.Label != "slow thinking" || !slow.Quiet {
t.Fatalf("slow thinking: %+v", slow)
}
if o := slow.Options(a.Values()); len(o) != 0 {
t.Fatalf("slow unset offers levels: %+v", o)
}
if err := slow.Set("high"); err == nil {
t.Fatal("a level set on a role with no model")
}
apply("slow", "magpie/deepseek/pro")
var levels []string
for _, o := range slow.Options(a.Values()) {
levels = append(levels, o.Value)
}
if want := []string{"auto", "off", "minimal", "low", "medium", "high", "xhigh", "max"}; !slices.Equal(levels, want) {
t.Fatalf("levels %v, want %v", levels, want)
}
apply("slow_thinking", "high")
if got := role("slow"); got != "magpie/deepseek/pro:high" {
t.Fatalf("modelRoles.slow: %q", got)
}
if got := slow.Get(); got != "high" {
t.Fatalf("slow thinking reads %q", got)
}
if v, _ := edit.GetYAML(configPath, "defaultThinkingLevel"); v != "medium" {
t.Fatalf("the session's level moved: %q", v)
}
// the level stays with the role on another model
apply("slow", "magpie/deepseek/flash")
if got := role("slow"); got != "magpie/deepseek/flash:high" {
t.Fatalf("slow on another model: %q", got)
}
apply("advisor_thinking", "max")
if got := role("advisor"); got != "magpie/deepseek/pro:max" {
t.Fatalf("modelRoles.advisor: %q", got)
}
// none: the role at the session's level again
apply("slow_thinking", "")
if got := role("slow"); got != "magpie/deepseek/flash" {
t.Fatalf("slow's level cleared: %q", got)
}
if err := slow.Set("loud"); err == nil {
t.Fatal("a level omp doesn't read was written")
}
// a list of models omp falls back through is the user's own: no level
sub := a.Field("subagent_thinking")
if o := sub.Options(a.Values()); len(o) != 0 || sub.Get() != "" {
t.Fatalf("a list offers levels: %+v, reads %q", o, sub.Get())
}
if err := sub.Set("low"); err == nil || role("task") != "openai/gpt-6,anthropic/claude-opus-5:high" {
t.Fatalf("a level written onto a list: %v, %q", err, role("task"))
}
// reset, the role and its level go, and magpie's provider with the
// last role on it
for _, k := range []string{"slow", "plan", "vision", "advisor"} {
apply(k, "")
}
if got := role("advisor"); got != "" {
t.Fatalf("advisor reset: %q", got)
}
if a.Field("advisor_thinking").Get() != "" {
t.Fatal("advisor's level outlived it")
}
if v, ok := edit.GetYAML(filepath.Join(dir, "models.yml"), "providers.magpie.baseUrl"); ok && v != "" {
t.Fatal("magpie's provider stayed with no role on it")
}
}
+44 -18
View File
@@ -302,7 +302,7 @@ function renderAgents() {
// a small model with none to pick (Snow CLI's, on a profile of the
// user's own)
const none = (f) => (f.key === "effort" || f.key === "ultracode" || f.label === "subagents" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === MEMORIES || f.label === "sign-in" || f.key === "small") && !f.options.length && !f.value;
const shownFields = a.fields.filter((f) => !TIERS.includes(f.label) && !TIER_EFFORTS.includes(f.label) && !none(f));
const shownFields = a.fields.filter((f) => !grouped(a, f) && !none(f));
const tiers = tierMenu(a);
if (tiers) shownFields.push(tiers);
const sorted = shownFields.sort((x, y) => wide(y) - wide(x) || extra(x) - extra(y));
@@ -500,7 +500,7 @@ function renderAgents() {
// pickers keep lining up down the list
list.classList.toggle("extras", state.agents.some((a) => a.fields.some(extra) || tierMenu(a) || a.launch));
// as wide as the row with the most squares
list.style.setProperty("--extras", Math.max(1, ...state.agents.map((a) => a.fields.filter((f) => extra(f) && !TIERS.includes(f.label)).length + (tierMenu(a) ? 1 : 0) + (a.launch ? 1 : 0))));
list.style.setProperty("--extras", Math.max(1, ...state.agents.map((a) => a.fields.filter((f) => extra(f) && !grouped(a, f)).length + (tierMenu(a) ? 1 : 0) + (a.launch ? 1 : 0))));
if (!folded.length) {
for (const a of used) list.append(agentRow(a));
} else {
@@ -2933,6 +2933,22 @@ const TIER_EFFORTS = TIERS.map((tier) => tier + " effort");
// slow roles take the session's, as its subagents do ("smol", not "small":
// other agents' small model is a picker of its own)
const FOLLOWS_MODEL = [...TIERS, "subagents", "smol", "slow"];
// omp's roles share one square as Claude Code's tiers do (#1397), each
// with its thinking level under its model: the level omp reads off the end
// of the role's model ("…:high"). plan, vision and advisor don't follow
// the model: unset, omp picks for each itself, the advisor the slow
// role's model first
const OMP_ROLES = ["subagents", "smol", "slow", "plan", "vision", "advisor"];
const OMP_OWN_PICK = ["plan", "vision", "advisor"];
// omp, a named profile of it (omp#<name>) or either in a WSL distro
const ompAgent = (a) => a.id.split("@wsl:")[0].split("#")[0] === "omp";
// the roles an agent's square lists, and whether a field is one of them or
// one of their levels
const menuRoles = (a) => ompAgent(a) ? OMP_ROLES : TIERS;
const roleLevel = (label) => TIER_EFFORTS.includes(label) || OMP_ROLES.some((r) => label === r + " thinking");
const grouped = (a, f) => menuRoles(a).includes(f.label) || roleLevel(f.label);
// fields that take a model, as the model picker opens for them
const ROLE_MODELS = [...FOLLOWS_MODEL, ...OMP_OWN_PICK];
// agents with no default model of their own, whose Default leaves the pick
// to them (#709)
const PICKS_ITSELF = ["pi", "omo"];
@@ -3036,33 +3052,41 @@ function launchSolo(a) {
const LAUNCH_GLYPH = "M2.5 3.5h11v9h-11zM5 6.5l2 1.75L5 10M8.5 10h2.5";
function tierMenu(a) {
const tiers = a.fields.filter((f) => TIERS.includes(f.label));
const omp = ompAgent(a);
const tiers = a.fields.filter((f) => menuRoles(a).includes(f.label));
if (!tiers.length || !tiers.some((f) => f.options.length)) return null;
// Claude Desktop has no model of its own here: a tier unset runs on a
// Claude model of that tier magpie serves, else on the chat's model
const main = a.fields.find((f) => f.key === "model");
const mainName = main && (optionFor(main, main.value)?.label || main.value);
const unset = main ? t("same as model ({model})", { model: mainName }) : t("a Claude model of the tier, else the chat's model");
const unset = (f) => omp && f.label === "advisor" ? t("the slow role's model, else omp's own pick")
: omp && OMP_OWN_PICK.includes(f.label) ? t("omp's own pick")
: main ? t("same as model ({model})", { model: mainName }) : t("a Claude model of the tier, else the chat's model");
// a tier's effort, offered while there are levels to pick (Claude Code
// through magpie); unset, the tier runs at the effort Claude Code asks
const effortOf = (f) => a.fields.find((e) => e.label === f.label + " effort" && (e.options.length || e.value));
// through magpie); unset, the tier runs at the effort Claude Code asks.
// An omp role's thinking level, while the role is on one model; unset,
// it runs at the session's level
const effortOf = (f) => a.fields.find((e) => (e.label === f.label + " effort" || e.label === f.label + " thinking") && (e.options.length || e.value));
const level = (e) => e?.value ? effortName(optionFor(e, e.value) || { value: e.value }) : "";
const custom = tiers.filter((f) => f.value || effortOf(f)?.value);
const name = (f) => optionFor(f, f.value)?.label || f.value;
return {
key: "tiers", label: "tiers", value: "", menu: true, custom: custom.length > 0,
summary: custom.length ? custom.map((f) => level(effortOf(f)) ? `${f.label} (${level(effortOf(f))})` : f.label).join(", ") : main ? t("same as model") : t("not set"),
key: "tiers", label: omp ? "roles" : "tiers", value: "", menu: true, custom: custom.length > 0,
summary: custom.length ? custom.map((f) => level(effortOf(f)) ? `${t(f.label)} (${level(effortOf(f))})` : t(f.label)).join(", ") : main ? t("same as model") : t("not set"),
options: tiers.flatMap((f) => {
const model = {
value: f.key, label: f.label, icon: optionFor(f, f.value)?.icon || (main && optionFor(main, main.value)?.icon),
note: f.value ? name(f) : unset,
value: f.key, label: t(f.label), icon: optionFor(f, f.value)?.icon || (main && optionFor(main, main.value)?.icon),
note: f.value ? name(f) : unset(f),
};
const e = effortOf(f);
return e ? [model, { value: e.key, label: t(e.label), effortOf: e, note: level(e) || t("the effort Claude Code asks for") }] : [model];
return e ? [model, { value: e.key, label: t(e.label), effortOf: e, note: level(e) || levelUnset(a) }] : [model];
}),
};
}
// levelUnset: what a role's level is when none is set
const levelUnset = (a) => ompAgent(a) ? t("the session's thinking level") : t("the effort Claude Code asks for");
// The tray panel has no scrollbars to speak of, so it grows to fit instead.
// The agents' scroll unrolls and rolls up on these, in app.css as in the
// panel's own height.
@@ -3721,7 +3745,7 @@ function openPicker(agent, field, anchor, ev, only) {
// routing groups come first, before the agent's own models and each
// provider's; only the picker's own choices (Automatic, Off) above them
options = [...options.filter((o) => o.reset), ...options.filter((o) => !o.reset && o.group === ROUTING_GROUPS), ...options.filter((o) => !o.reset && o.group !== ROUTING_GROUPS)];
const effortPicker = !only && (field.key === "effort" || field.label === "effort" || field.label === "thinking" || field.label === SUB_EFFORT || TIER_EFFORTS.includes(field.label));
const effortPicker = !only && (field.key === "effort" || field.label === "effort" || field.label === "thinking" || field.label === SUB_EFFORT || roleLevel(field.label));
options = oneRowPerModel(options, cur);
// Current model first, then the rest in catalog order. Effort levels keep
// their natural low → high order because their position is meaningful.
@@ -3749,6 +3773,8 @@ function openPicker(agent, field, anchor, ev, only) {
: PICKS_ITSELF.includes(agent.id) && field.key === "model" ? "clears the default model; {agent} picks one on its own"
: field.label === MEMORIES ? MEMORIES_DEFAULT
: field.label === SUB_MODEL ? "each subagent on the model {agent}'s lead asks for"
: ompAgent(agent) && field.label === "advisor" ? "the slow role's model, else omp's own pick"
: ompAgent(agent) && OMP_OWN_PICK.includes(field.label) ? "omp's own pick"
: "what {agent} ships with";
options.unshift({ value: "", label: t("Default"), note: t(note, { agent: agent.name, field: t(field.label) }), icon: agent.icon, reset: true });
}
@@ -3758,7 +3784,7 @@ function openPicker(agent, field, anchor, ev, only) {
const at = options.findIndex((o) => !o.reset);
options.splice(at < 0 ? options.length : at, 0, { value: "\0disconnect", label: t("Disconnect from magpie"), note: t("put back what {agent} had before magpie", { agent: agent.name }), svg: UNPLUG, reset: true, run: () => askDisconnect(agent) });
}
const modelPicker = ["model", "small", "large", MEMORIES, SUB_MODEL, "executor", "planner", ...FOLLOWS_MODEL].includes(field.label) && !only;
const modelPicker = ["model", "small", "large", MEMORIES, SUB_MODEL, "executor", "planner", ...ROLE_MODELS].includes(field.label) && !only;
pick = { agent, field, options, groups, anchor, cursor: 0, free: !only && !field.menu, modelPicker, effortPicker, groupFilter: "all" };
anchor.classList.add("open");
const pop = $("#pop");
@@ -3974,10 +4000,10 @@ function renderEffortPicker() {
}
// a tier's effort, opened from the tiers' square: that square's title
// and light follow the level
if (TIER_EFFORTS.includes(opened.field.label) && opened.anchor.classList.contains("ag-eff")) {
opened.anchor.title = t("{label}: {value}", { label: t(opened.field.label), value: option.value ? effortName(option) : t("the effort Claude Code asks for") });
if (roleLevel(opened.field.label) && opened.anchor.classList.contains("ag-eff")) {
opened.anchor.title = t("{label}: {value}", { label: t(opened.field.label), value: option.value ? effortName(option) : levelUnset(opened.agent) });
opened.anchor.setAttribute("aria-label", opened.anchor.title);
} else if (TIER_EFFORTS.includes(opened.field.label)) {
} else if (roleLevel(opened.field.label)) {
const menu = tierMenu(opened.agent);
if (menu) {
opened.anchor.classList.toggle("set", menu.custom);
@@ -4013,7 +4039,7 @@ function filter(keep) {
if (q) scored.sort((a, b) => b.s - a.s || a.i - b.i);
pick.items = scored.map((x) => x.o);
const typed = $("#q").value.trim();
if (typed && pick.free && ["model", "small", "large", "executor", "planner", ...FOLLOWS_MODEL].includes(pick.field.label) && !pick.items.some((o) => o.value === typed)) {
if (typed && pick.free && ["model", "small", "large", "executor", "planner", ...ROLE_MODELS].includes(pick.field.label) && !pick.items.some((o) => o.value === typed)) {
pick.items.push({ value: typed, note: t("use as typed"), custom: true });
}
pick.items = foldSame(pick.items);
@@ -4488,7 +4514,7 @@ async function setPick(agent, field, value, opt) {
const picked = performance.now();
// the green flash runs on through the row drawn again with the answer
const flash = () => {
const b = document.querySelector(`.agent[data-id="${CSS.escape(agent.id)}"] .field[data-key="${TIERS.includes(field.label) ? "tiers" : field.key}"]`);
const b = document.querySelector(`.agent[data-id="${CSS.escape(agent.id)}"] .field[data-key="${grouped(agent, field) ? "tiers" : field.key}"]`);
const gone = performance.now() - picked;
if (!b || gone > 1200) return;
b.style.animationDelay = `${-gone}ms`;
+52
View File
@@ -15,6 +15,19 @@ const I18N = {
"Pick the first day, then the last": "先选第一天,再选最后一天",
"No calls on the days picked.": "所选日期内没有调用。",
"{n} on {date}": "{date} {n}",
"roles": "角色",
"plan": "规划",
"vision": "视觉",
"advisor": "顾问",
"subagents thinking": "子代理思考",
"smol thinking": "小模型思考",
"slow thinking": "慢模型思考",
"plan thinking": "规划思考",
"vision thinking": "视觉思考",
"advisor thinking": "顾问思考",
"omp's own pick": "由 omp 自己挑选",
"the slow role's model, else omp's own pick": "慢模型角色的模型,未设置时由 omp 自己挑选",
"the session's thinking level": "跟随会话的思考强度",
"You set {value}; the model's {window} comes first": "你设置的是 {value},但模型的 {window} 优先",
"Auto-compact": "自动压缩",
"Prompt cache · main conversation": "提示缓存 · 主对话",
@@ -4070,6 +4083,19 @@ const I18N = {
"Pick the first day, then the last": "先選第一天,再選最後一天",
"No calls on the days picked.": "所選日期內沒有呼叫。",
"{n} on {date}": "{date} {n}",
"roles": "角色",
"plan": "規劃",
"vision": "視覺",
"advisor": "顧問",
"subagents thinking": "子代理思考",
"smol thinking": "小模型思考",
"slow thinking": "慢模型思考",
"plan thinking": "規劃思考",
"vision thinking": "視覺思考",
"advisor thinking": "顧問思考",
"omp's own pick": "由 omp 自己挑選",
"the slow role's model, else omp's own pick": "慢模型角色的模型,未設定時由 omp 自己挑選",
"the session's thinking level": "跟隨工作階段的思考強度",
"You set {value}; the model's {window} comes first": "你設定的是 {value},但模型的 {window} 優先",
"Auto-compact": "自動壓縮",
"Prompt cache · main conversation": "提示快取 · 主對話",
@@ -8108,6 +8134,19 @@ const I18N = {
"Pick the first day, then the last": "最初の日、次に最終日を選択",
"No calls on the days picked.": "選んだ日付の呼び出しはありません。",
"{n} on {date}": "{date} {n}",
"roles": "ロール",
"plan": "プラン",
"vision": "ビジョン",
"advisor": "アドバイザー",
"subagents thinking": "サブエージェントの思考",
"smol thinking": "小の思考",
"slow thinking": "低速の思考",
"plan thinking": "プランの思考",
"vision thinking": "ビジョンの思考",
"advisor thinking": "アドバイザーの思考",
"omp's own pick": "omp が自分で選ぶ",
"the slow role's model, else omp's own pick": "slow ロールのモデル、未設定なら omp が自分で選ぶ",
"the session's thinking level": "セッションの思考レベル",
"You set {value}; the model's {window} comes first": "設定は {value} ですが、モデルの {window} が優先されます",
"Auto-compact": "自動コンパクト",
"Prompt cache · main conversation": "プロンプトキャッシュ · メイン会話",
@@ -12148,6 +12187,19 @@ const I18N = {
"Pick the first day, then the last": "Erst den ersten Tag, dann den letzten wählen",
"No calls on the days picked.": "An den gewählten Tagen keine Aufrufe.",
"{n} on {date}": "{n} am {date}",
"roles": "Rollen",
"plan": "Planung",
"vision": "Vision",
"advisor": "Berater",
"subagents thinking": "Thinking Subagenten",
"smol thinking": "Thinking klein (smol)",
"slow thinking": "Thinking langsam",
"plan thinking": "Thinking Planung",
"vision thinking": "Thinking Vision",
"advisor thinking": "Thinking Berater",
"omp's own pick": "wählt omp selbst",
"the slow role's model, else omp's own pick": "das Modell der Rolle slow, sonst wählt omp selbst",
"the session's thinking level": "das Thinking-Level der Sitzung",
"You set {value}; the model's {window} comes first": "Du hast {value} gesetzt; das Fenster des Modells ({window}) hat Vorrang",
"Auto-compact": "Auto-Kompaktierung",
"Prompt cache · main conversation": "Prompt-Cache · Hauptunterhaltung",
+104 -34
View File
@@ -1,10 +1,14 @@
// Run with Node's test runner and Playwright on the module path; see README.md.
// omp's subagents, smol and slow roles fall back to its model when unset
// (#325), so each is a square after the pickers, not a picker of its own:
// unset it says it follows the model, its picker opens on "Same as model",
// and set it names the model it is on. OpenCode's small model, which
// doesn't follow the model, stays a picker. Both read in the connected
// agent's opened row. In English and Chinese.
// omp's roles share one square after the model picker, as Claude Code's
// tiers do (#325, #1397): subagents, smol, slow, plan, vision and advisor,
// each with the model it is on or what it takes unset, and a role on one
// model has its thinking level under it (KKKKKKKEM: the slow role at its
// own level). Picking a role opens the model picker for it, "Same as model"
// first for a role that follows the model; picking its level opens the
// level slider, which writes that role's level. OpenCode's small model,
// which doesn't follow the model, stays a picker; a named profile of omp
// (omp#work) has the same square. In the connected agent's
// opened row, in English and Chinese, wide and at 390px.
// No backend: the API is faked here.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
@@ -17,13 +21,28 @@ const options = [
{ value: "magpie/deepseek/pro", label: "DeepSeek Pro", ref: "deepseek/pro" },
{ value: "magpie/deepseek/flash", label: "DeepSeek Flash", ref: "deepseek/flash" },
];
const LEVELS = ["auto", "off", "minimal", "low", "medium", "high", "xhigh", "max"].map((value) => ({ value }));
const field = (key, label, value) => ({ key, label, value, options });
// a role's level is offered while the role is on a model, as omp.go does
const level = (key, label, on) => ({ key: key + "_thinking", label: label + " thinking", value: "", options: on ? LEVELS : [] });
const fresh = () => ({
agents: [
{
id: "omp", name: "omp", path: "/test/config.yml", icon: "omp", wired: true,
fields: [field("model", "model", "magpie/deepseek/pro"), field("subagent", "subagents", ""), field("small", "smol", ""), field("slow", "slow", "magpie/deepseek/flash")],
fields: [
field("model", "model", "magpie/deepseek/pro"),
field("subagent", "subagents", ""), level("subagent", "subagents", false),
field("small", "smol", ""), level("small", "smol", false),
field("slow", "slow", "magpie/deepseek/flash"), level("slow", "slow", true),
field("plan", "plan", ""), level("plan", "plan", false),
field("vision", "vision", ""), level("vision", "vision", false),
field("advisor", "advisor", ""), level("advisor", "advisor", false),
{ key: "effort", label: "thinking", value: "", options: LEVELS.filter((l) => l.value !== "off") },
],
},
// a named profile of omp (#1233) has the same roles
{ id: "omp#work", name: "omp · work", path: "/test/profiles/work/config.yml", icon: "omp", wired: true,
fields: [field("model", "model", "magpie/deepseek/pro"), field("slow", "slow", "magpie/deepseek/flash"), level("slow", "slow", true), field("plan", "plan", ""), level("plan", "plan", false)] },
{ id: "opencode", name: "OpenCode", path: "/test/opencode.json", wired: true, fields: [field("model", "model", "magpie/deepseek/pro"), field("small", "small", "")] },
],
profiles: [],
@@ -38,9 +57,12 @@ function server(lang, sets) {
if (url.pathname === "/api/state") return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
if (url.pathname === "/api/set") {
const body = req.postDataJSON();
sets.push(body);
sets.push({ agent: body.agent, field: body.field, value: body.value });
cur = JSON.parse(JSON.stringify(cur));
cur.agents.find((a) => a.id === body.agent).fields.find((f) => f.key === body.field).value = body.value;
const fields = cur.agents.find((a) => a.id === body.agent).fields;
fields.find((f) => f.key === body.field).value = body.value;
const lv = fields.find((f) => f.key === body.field + "_thinking");
if (lv) lv.options = body.value ? LEVELS : [];
return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
}
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
@@ -57,18 +79,27 @@ function server(lang, sets) {
// the words as i18n.js has them
const W = {
en: { follows: (l) => `${l}: same as model`, on: (l, m) => `${l}: ${m}`, same: "Same as model", subagents: "subagents", smol: "smol", slow: "slow" },
zh: { follows: (l) => `${l}:同主模型`, on: (l, m) => `${l}:${m}`, same: "同主模型", subagents: "子代理", smol: "小模型", slow: "慢模型" },
en: {
roles: ["subagents", "smol", "slow", "slow thinking", "plan", "vision", "advisor"],
follows: "same as model (DeepSeek Pro)", own: "omp's own pick", advisor: "the slow role's model, else omp's own pick",
session: "the session's thinking level", same: "Same as model", summary: "roles: slow", high: "high", summarySet: "roles: slow (high)",
},
zh: {
roles: ["子代理", "小模型", "慢模型", "慢模型思考", "规划", "视觉", "顾问"],
follows: "同主模型(DeepSeek Pro)", own: "由 omp 自己挑选", advisor: "慢模型角色的模型,未设置时由 omp 自己挑选",
session: "跟随会话的思考强度", same: "同主模型", summary: "角色:慢模型", high: "高", summarySet: "角色:慢模型 (高)",
},
};
const omp = '.row.agent[data-id="omp"]';
const items = (page) => page.locator("#pop:not([hidden]) #list li").evaluateAll((es) => es.map((e) => [e.querySelector(".v")?.textContent, e.querySelector(".n")?.textContent || ""]));
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
for (const lang of ["en", "zh"]) {
test(`${engine} ${lang}: omp's roles follow the model as squares, OpenCode's small model is a picker`, async (t) => {
for (const width of [1100, 390]) for (const lang of ["en", "zh"]) {
test(`${engine} ${lang} ${width}px: omp's roles and their thinking levels are one square, OpenCode's small model is a picker`, async (t) => {
const w = W[lang];
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
const page = await browser.newPage({ viewport: { width: 1100, height: 700 } });
const page = await browser.newPage({ viewport: { width, height: 760 } });
page.setDefaultTimeout(5000);
const errors = [], sets = [];
page.on("pageerror", (e) => errors.push(e.message));
@@ -76,7 +107,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
t.after(async () => {
if (process.env.ARTIFACT_DIR) {
await fs.mkdir(process.env.ARTIFACT_DIR, { recursive: true });
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-omp-roles.png`) });
await page.screenshot({ path: path.join(process.env.ARTIFACT_DIR, `${engine}-${lang}-${width}-omp-roles.png`) });
}
await browser.close();
});
@@ -84,26 +115,65 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await page.locator(omp).waitFor();
await page.locator(`${omp} .ag-link`).click();
// the three roles are squares in the row's squares cell; the model alone is a picker
const square = (key) => page.locator(`${omp} .extras-cell .field.extra[data-key="${key}"]`);
for (const key of ["subagent", "small", "slow"]) assert.equal(await square(key).count(), 1, `${key} is a square`);
assert.deepEqual(await page.locator(`${omp} .field:not(.extra)`).evaluateAll((es) => es.map((e) => e.dataset.key)), ["model"]);
// unset: following the model; set: the model it is on
assert.equal(await square("subagent").getAttribute("aria-label"), w.follows(w.subagents));
assert.equal(await square("small").getAttribute("aria-label"), w.follows(w.smol));
assert.equal(await square("small").evaluate((e) => e.classList.contains("set")), false);
assert.equal(await square("slow").getAttribute("aria-label"), w.on(w.slow, "DeepSeek Flash"));
assert.equal(await square("slow").evaluate((e) => e.classList.contains("set")), true);
// one square for the roles; the model and the session's thinking are the pickers
const square = page.locator(`${omp} .extras-cell .field.extra[data-key="tiers"]`);
assert.equal(await square.count(), 1, "no roles square");
assert.equal(await page.locator(`${omp} .field.extra`).count(), 1, "a role kept a square of its own");
const pickers = await page.locator(`${omp} .field:not(.extra)`).evaluateAll((es) => es.map((e) => e.dataset.key));
assert.ok(pickers.includes("model") && pickers.every((k) => k === "model" || k === "effort"), String(pickers));
assert.ok((await square.getAttribute("aria-label")).startsWith(w.summary), await square.getAttribute("aria-label"));
assert.equal(await square.evaluate((e) => e.classList.contains("set")), true);
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "the row scrolls sideways");
const y = await page.evaluate(() => scrollY);
// smol's picker opens on following the model, the model named beside it
await square("small").click();
const first = page.locator("#pop:not([hidden]) #list li").first();
await first.waitFor();
assert.match(await first.innerText(), new RegExp(`${w.same}[\\s\\S]*DeepSeek Pro`));
await page.locator("#pop:not([hidden]) #list li").filter({ hasText: "DeepSeek Flash" }).first().click();
await page.waitForFunction(() => document.querySelector('.row.agent[data-id="omp"] .field.extra.set[data-key="small"]'));
assert.deepEqual(sets, [{ ...sets[0], agent: "omp", field: "small", value: "magpie/deepseek/flash" }]);
assert.equal(await square("small").getAttribute("aria-label"), w.on(w.smol, "DeepSeek Flash"));
// each role, with its model or what it takes unset; slow's level under it
await square.click();
await page.locator("#pop:not([hidden]) #list li").first().waitFor();
const rows = await items(page);
assert.deepEqual(rows.map((r) => r[0]), w.roles);
assert.deepEqual(rows.map((r) => r[1]), [w.follows, w.follows, "DeepSeek Flash", w.session, w.own, w.own, w.advisor]);
// slow's level: the slider, which writes slow_thinking
await page.locator("#pop:not([hidden]) #list li").nth(3).click();
const range = page.locator("#effortRange");
await range.waitFor({ state: "attached" });
await page.waitForFunction(() => document.querySelector("#effortRange")?.offsetParent);
const at = await page.evaluate(() => Number(document.querySelector("#effortRange").max));
const high = LEVELS.findIndex((l) => l.value === "high") + (at === LEVELS.length ? 1 : 0);
await range.evaluate((r, i) => { r.value = String(i); r.dispatchEvent(new Event("input", { bubbles: true })); r.dispatchEvent(new Event("change", { bubbles: true })); }, high);
await page.waitForFunction(() => document.querySelector("#status")?.textContent);
assert.deepEqual(sets, [{ agent: "omp", field: "slow_thinking", value: "high" }]);
await page.keyboard.press("Escape");
await page.waitForFunction((s) => document.querySelector('.row.agent[data-id="omp"] .field.extra[data-key="tiers"]')?.getAttribute("aria-label").startsWith(s), w.summarySet);
// smol: the model picker, following the model first
await square.click();
await page.locator("#pop:not([hidden]) #list li").nth(1).click();
await page.locator("#pop:not([hidden]) #list li", { hasText: "DeepSeek Flash" }).first().waitFor();
assert.match(await page.locator("#pop:not([hidden]) #list li").first().innerText(), new RegExp(`${w.same}[\\s\\S]*DeepSeek Pro`));
await page.locator("#pop:not([hidden]) #list li", { hasText: "DeepSeek Flash" }).first().click();
await page.waitForFunction(() => document.querySelectorAll("#status").length && !document.querySelector("#pop:not([hidden])"));
assert.deepEqual(sets[1], { agent: "omp", field: "small", value: "magpie/deepseek/flash" });
// plan: no "Same as model", omp picks unset
await square.click();
await page.locator("#pop:not([hidden]) #list li").first().waitFor();
const planAt = (await items(page)).findIndex((r) => r[0] === w.roles[4]);
await page.locator("#pop:not([hidden]) #list li").nth(planAt).click();
await page.locator("#pop:not([hidden]) #list li", { hasText: "DeepSeek Flash" }).first().waitFor();
const first = await page.locator("#pop:not([hidden]) #list li").first().innerText();
assert.doesNotMatch(first, new RegExp(w.same));
assert.match(first, new RegExp(w.own));
await page.keyboard.press("Escape");
assert.equal(await page.evaluate(() => scrollY), y, "a click scrolled the page");
// omp's named profile: its roles share the square as well
const work = '.row.agent[data-id="omp#work"]';
await page.locator(`${work} .ag-link`).click();
const workSquare = page.locator(`${work} .extras-cell .field.extra[data-key="tiers"]`);
await workSquare.waitFor();
assert.ok((await workSquare.getAttribute("aria-label")).startsWith(w.summary), await workSquare.getAttribute("aria-label"));
assert.equal(await page.locator(`${work} .field[data-key="plan"]`).count(), 0, "a profile's role kept a picker of its own");
// OpenCode's small model doesn't follow the model: a picker, not a square
const oc = '.row.agent[data-id="opencode"]';