agent: omp's advisor turns on with its model, and its review, wait and call-back are set in magpie (#6408, Awad_Yoo on X)
Awad_Yoo wants omp's advisor gated: one model executes, another reviews
only at key points. omp's advisor (src/advisor, advisor/settings.ts) runs
only while advisor.enabled is true, and omp leaves it off, so a model
picked for the advisor role in magpie reviewed nothing.
- A model picked for the advisor role writes advisor.enabled: true when
the user hasn't set it. The role's reset takes back only what that pick
wrote (a stash mark); the user's own on or off stays.
- Three Quiet fields write the rest of config.yml's advisor block, as omp
reads it (omp_advisor.go):
- advisor_review: off, turn, agent-end (enabled + reviewMode; off keeps
the mode);
- advisor_wait: syncBacklog off, "1", "3", "5", strict, written as
strings, since omp's enum settings take only strings;
- advisor_wake: continueSeverity nit, concern, blocker.
- GUI: omp's opened row and its panel sheet get three rows (Advisor; Waits
for its review; Calls a finished agent back on). The last two show only
while it reviews, and the rows redraw in place. They live in
ompadvisor.js, imported the first time. The roles square's advisor line
says " · off" when the advisor is off. Strings in zh, zh-TW, ja and de.
- Core script budget: +717 for what is left in app.js, after the rows
moved out.
- docs/subsystems/agent-wiring.md has an "omp's advisor" row.
Not magpie's: taking over from the executor after repeated failures of
the same kind. omp has no such setting; "escalate" in its source is only a
note's severity. An omp extension can do it (pi.on("tool_result") with
pi.setModel), and that keeps the session's trace and completed tool
results. Said on the issue.
Run:
- mica-run go test -count=1 ./internal/agent/: ok.
- go vet ./internal/agent/ ./internal/gui/ for darwin, linux (nogui) and
windows: clean. gofmt -l: nothing.
- internal/gui Go tests: on mote (below).
- GUI, on mote and mica: omp-advisor.test.cjs (new: chromium + webkit;
1100 and 390px; en, zh, zh-TW, ja, de; panel sheet at 360) passes, as do
agent-prefs, old-webkit's own check, i18n-en-no-cjk,
omp-profile-connect and agent-row-disclose.
- Reds that fail the same on a clean worktree at origin/main 743001128
(45 of 45, the same tests):
- agent-details-ready: #6373;
- i18n-keys "a plugin's words are its own": #6422;
- old-webkit headerpresets.js: #6030;
- old-webkit :has(): #5919;
- omp-roles in Chromium, "no roles square": filed as #6432.
- The real omp 18.9.1, in a sandbox HOME (omp config get), reads
enabled=true, reviewMode=agent-end and syncBacklog=1 as written.
Broken by hand:
- No auto-enable on the pick: TestOmpAdvisorPickTurnsItOn went red.
- No in-place redraw: the panel sheet cases went red, 3 of 3.
Not tried:
- A real omp session with the advisor reviewing.
- continueSeverity needs omp 18.12.1 or later; 18.9.1 doesn't know it.
- A WATCHDOG.yml roster's per-advisor settings aren't shown; omp uses them
over these.
This commit is contained in:
@@ -36,6 +36,7 @@ something else shows up as drift.
|
||||
| Codex: DeepSeek models | A DeepSeek model's entry (`codexcat.deepSeek`: deepseek-v4*, -flash, -pro, -chat, -reasoner after any provider or relay prefix; not a routing group, not a distill) takes what DeepSeek's own Codex setup (cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh, its models.json) says of its models: `shell_type` `shell_command` (Codex 0.165 reads it as `unified_exec`, its only shell; older Codex had a one-shot `shell_command` tool), `support_verbosity` with `default_verbosity` low, `default_reasoning_summary` none (no `reasoning.summary` sent), `multi_agent_version` v2, and `supports_image_detail_original` on a model whose entry takes images. Not taken: its `base_instructions`/`model_messages` (magpie never rewrites a Codex prompt), its `auto_compact_token_limit` null (magpie's 272K default stays, from e950eb080's DeepSeek latency report; Full window or the model's Compact at gives the whole window), `supports_search_tool` false on v4-pro (#258), its reasoning levels (the provider's). `default_reasoning_summary` is tagged `keep:"unset"`, so a value the user put in another model's entry stays (`Keep`). Other vendors' entries are unchanged. `TestCodexCatalogDeepSeekAsDeepSeekSays`, `TestCodexCatalogKeepsUsersSummary`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| Codex: Ultra on other vendors' models | An entry of a model that lists reasoning levels, from a vendor other than OpenAI, ends its levels with `ultra` and says `multi_agent_version` v2 (`codexcat.ultraHere`; pingqipai3 on X: Codex offers Ultra only where a model's entry lists it). Codex never sends Ultra itself: `ModelInfo::resolve_reasoning_effort` sends the entry's `multi_agent_reasoning_effort`, else `max`, else its highest other level, so the model is asked its own top level; and under V2 Ultra is what turns subagents to proactive (`effective_multi_agent_mode`). Not given it: GPT, o-series and Codex models (their own Ultra is `provider.OffersUltra`'s), a model with no levels, a Fast or Seals entry (V1 stays theirs), a vendor's own Codex entry (`listedEntry`). The default level is never Ultra. `catalogFormat` v3 makes Codex fetch the list again. `TestUltraOnOtherVendorsModels`. | [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| Named omp profiles | omp keeps a profile's settings under `~/.omp/profiles/<name>` (or under `PI_CONFIG_DIR`), each with its own `config.yml` and `models.yml`. Every such profile is an agent of its own — `omp#<name>` on Windows, `omp#<name>@wsl:<distro>` in a distro — so each can be connected, drifted and disconnected on its own. They share omp's model lists (`ListsFor`), and the default `omp` row is the folder `ompDir`/`ompIn` already pick, so an `OMP_PROFILE` that row is already pointed at is not listed twice. A name omp refuses is not a row: `default`, a trailing dot, or a Windows reserved device name (`aux`, `nul`, `com1`, `lpt9.x`, `con.work`), on every platform (`ompProfileOK`). A distro's profile names come from its probe and are kept in `wsl.json`; a stopped distro is never started to list them, its profile rows showing what was last seen (`asleep`). | [`omp.go`](../../internal/agent/omp.go), [`wsl.go`](../../internal/agent/wsl.go) |
|
||||
| omp's advisor | omp's advisor (`src/advisor`) is a second model, on the `advisor` role, that reviews the main agent's work and sends it notes; it runs only while `advisor.enabled` is true, which omp leaves off (#6408, Awad_Yoo on X). A model picked for the advisor role turns it on when the user hasn't set it, and the role's reset takes back only what that pick wrote (`ompAdvisorTurnedOn`, a stash mark). Three Quiet fields write the rest of `config.yml`'s `advisor` block as omp reads it (`ompAdvisorFields` in [`omp_advisor.go`](../../internal/agent/omp_advisor.go)): `advisor_review` (off, `turn`, `agent-end`: `enabled` with `reviewMode`; off keeps the mode), `advisor_wait` (`syncBacklog`: `off`, `"1"`, `"3"`, `"5"`, `strict`, written as strings since omp's enum settings take strings only) and `advisor_wake` (`continueSeverity`: `nit`, `concern`, `blocker`, omp 18.12.1 or later). They show in omp's opened row and sheet as three rows (`ompAdvisorIn`, drawn by `ompadvisor.js`, imported the first time), the last two only while it reviews; the roles square's advisor line says " · off" when it is off. A `WATCHDOG.yml` roster sets each advisor's own review and wait over these, and is not shown. Taking over from the main model after repeated failures is not omp's advisor's: omp has no such setting, and an omp extension (`pi.on("tool_result")`, `pi.setModel`) is where it goes. `TestOmpAdvisorPickTurnsItOn`, `TestOmpAdvisorSettings`, `omp-advisor.test.cjs`. |
|
||||
| Claude Code in more than one folder | A Claude Code kept elsewhere with `CLAUDE_CONFIG_DIR` (an alias per account or workspace) has its own settings.json. The claude row is the folder the variable names, else `~/.claude`; every other folder under the home folder named `.claude…` that holds Claude Code's own files (`settings.json`, `.credentials.json` or `projects/`) is a row of its own, `claude#<name>` (`.claude-work` → `Claude Code · work`; the default `~/.claude` is `claude#default` while the variable points elsewhere), made by `claudeIn` at that folder (`place.dir`, as the `claude#launch` file is) and connected, set and checked there alone. The file `~/.claude.json`, another tool's `.claude-…` folder with none of those files and the launch file's folder are not listed. A folder outside the home folder is not found (BieJian21872 on X; `TestClaudeCodeInMoreThanOneFolder`). | [`claude_dirs.go`](../../internal/agent/claude_dirs.go) |
|
||||
| WSL twins | On Windows each running distro is probed once, without starting a stopped one. The `wslKinds` agents found there become agents of their own, `<id>@wsl:<distro>`, edited through `\\wsl.localhost\<distro>`. A kind is found by its folder under the distro's home or by its command there (not one on a Windows drive). The probe runs `sh -l`, which reads `~/.profile` but not `~/.bashrc`, so a command off its PATH is looked for where Node's managers and installers keep one, as `proc.UserBinDirs` does here (`wslbin`): bun, `~/.local/bin`, volta, pnpm, nvm's default then the highest, fnm's default then the highest (`FNM_DIR`, `~/.local/share/fnm`, `~/.fnm`), mise's installs and shims, asdf, `~/.npmrc`'s prefix, cargo, deno and Homebrew (千里不再 on Discord: a Pi from fnm, not run yet so with no `~/.pi`, wasn't found). One on a Windows drive, which WSL's PATH reaches first when the distro's isn't on it, is looked past rather than taken as the only one (`wslcmd`, `wslwin`; `TestWSLProbeFindsNodeManagersBins`, `TestWSLProbeLooksPastWindowsCommand`). The shell isn't asked interactively for `~/.bashrc`'s PATH: under `timeout` such a bash stops itself on WSL and outlives the timeout. Where another tool shares one of them, the kind leaves it out: Gemini CLI is found by its command alone, because Antigravity keeps `~/.gemini` too. Antigravity CLI is found by its own `~/.gemini/antigravity-cli` or its `agy` command (mimi001234 on Discord). Goose is found by its folder alone, because a `goose` command can be pressly's migration tool. Reasonix also needs the version its command gives (`accept`), because the old npm client is named `reasonix` too. The gateway address and key follow the distro's networking: mirrored or NAT (`place`, `keyAt`). Under NAT the key is the gateway's WSL key (`gateway.WSLKey`, `-<agent>` after it where the agent's key names it), sharing on or off; the gateway listens at that address itself (gateway-routing's WSL under NAT). `ListsFor` keeps a twin's model picks under the Windows twin's id (#927). While Codex on Windows is connected, `ConnectCodexTwins` (run by `SyncCatalog`, [`codex_wsl_auto.go`](../../internal/agent/codex_wsl_auto.go)) connects each running distro's Codex once, because the Codex app's work mode on a WSL project runs its app-server on the distro's `~/.codex`, not Windows': the twin is skipped when it is already connected or disconnected, when its config names a provider or base URL of the user's own, or when the distro is stopped; a mark in the stash (`<id>.autoconnected`) keeps it from being done again after a Disconnect. With Settings' Detect agents in WSL off (`NoWSLAgents`, #1264) magpie starts no wsl.exe at all: `proc.Command`, `CommandContext` and `ProbeContext` refuse one by any name or path with `proc.ErrWSLOff` (`wslOff` in [`proc/wsl.go`](../../internal/proc/wsl.go)), where every command magpie runs is made, so a path past agent's and wslrun's own gates (a request's Claude Code stand-in and classifier, #4872: on a computer without WSL each ask put up Windows' install window) asks nothing either (`TestWSLOffStartsNoWSL`, `TestWSLRunnerRefusedWhenOff`, `TestRunRefusedWhenOff`, `TestWSLStandInAsksNothingWhenOff`). With detection on, the same gate refuses wsl.exe with `proc.ErrNoWSLDistro` while the registry has no distro for the user (`HKCU\Software\Microsoft\Windows\CurrentVersion\Lxss`, a key with a `DistributionName` each, read at every start, so one installed later is listed at once; a read that fails is unknown and wsl.exe is asked as before), and agent's and wslrun's listings take that as none (TraderX219 on X: Windows' own wsl.exe without WSL's package put up its update console every 20 to 30 seconds). A failed run whose output says WSL must be installed or updated (`wsl.exe --update`, the inbox prompt, the optional component missing; `proc.WSLSaid`, told by agent's and wslrun's runners) writes `wsl-update` beside settings.json, and wsl.exe is then refused with `proc.ErrWSLNeedsUpdate` for six hours, by every magpie process, unless WSL's package version or the registered distros change; a refused listing is unknown, so nothing remembered of a distro is forgotten (`TestNoWSLDistroStartsNoWSL`, `TestWSLUpdateBacksOff`, `TestNoWSLDistroRunsNoWSL`, `TestWSLUpdateKeepsDistros`). | [`wsl.go`](../../internal/agent/wsl.go), [`gatewaykey.go`](../../internal/agent/gatewaykey.go), [`proc/wsl.go`](../../internal/proc/wsl.go) |
|
||||
| WSL folders that are links | Through `\\wsl.localhost` Windows can't follow a link the distro has: with `~/.codex` a link to `/mnt/c/Users/<user>/.codex`, a mkdir of it says it exists and nothing below it can be made, written, read or listed (#4502, linusxiong). The probe asks `readlink -f` there where each agent folder, its `skills` and the folders beside them lead (`wslLinkPaths`, `distro.Links`; a `$HOME` that is itself through a link is left as it was) and which drive each Windows mount is (`distro.Drives`). `distro.open` opens a path at or below a link where it leads: on a Windows drive the drive's own path (`C:\Users\<user>\.codex`), elsewhere in the distro through its root again; `native` spells such a path back through the link for the agent. A link `readlink -f` couldn't resolve is never guessed at: its agent is unreached (`Agent.Unreached`), says why in its notice and refuses each change and sync. Every writer goes through it: the agents' own files (`place.join`, `place.open`), the library's targets (`wslOpen`, a `wsl` problem per agent), RTK (`rtkAt`, `agent.WSLOpen`), the Sessions page's reads (`sessions.WSLHome.Open`) and the Copilot CLI's sign-in (`provider.CopilotWSLDirs`). Links deeper than the probed paths aren't resolved (`TestWSLOpenThroughLinks`, `TestWSLAgentFolderIsALink`, `TestWSLAgentFolderLinkUnresolved`, `TestWSLProbeLinks`, `TestWSLFolderIsALinkToC`, `TestRTKWSLFolderIsALink`). | [`wsl.go`](../../internal/agent/wsl.go), [`targets.go`](../../internal/library/targets.go), [`rtk_wsl.go`](../../internal/library/rtk_wsl.go) |
|
||||
|
||||
+27
-2
@@ -406,6 +406,31 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// a model picked for the advisor is one the user wants reviewing: omp
|
||||
// runs none while advisor.enabled is unset (its default is off), so the
|
||||
// pick turns it on then (#6408, #5019), and the role reset takes back
|
||||
// what the pick turned on. One the user set either way stays theirs
|
||||
advisor := slices.IndexFunc(roles, func(f Field) bool { return f.Key == "advisor" })
|
||||
setAdvisor := roles[advisor].Set
|
||||
roles[advisor].Set = func(v string) error {
|
||||
if err := setAdvisor(v); err != nil {
|
||||
return err
|
||||
}
|
||||
if v == "" {
|
||||
if unstash(ompAdvisorTurnedOn(path)) != "" && ompAdvisorOn(path) == "true" {
|
||||
return edit.DelYAML(path, "advisor.enabled")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if ompAdvisorOn(path) != "" {
|
||||
return nil
|
||||
}
|
||||
if err := edit.SetYAML(path, edit.KV{Path: "advisor.enabled", Value: true}); err != nil {
|
||||
return err
|
||||
}
|
||||
stash(map[string]string{ompAdvisorTurnedOn(path): "1"})
|
||||
return nil
|
||||
}
|
||||
// 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
|
||||
@@ -534,7 +559,7 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
|
||||
}
|
||||
return ""
|
||||
},
|
||||
Fields: append(fields, Field{
|
||||
Fields: append(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
|
||||
@@ -549,7 +574,7 @@ func ompAt(at place, dir string, entry func() ompProviderEntry) *Agent {
|
||||
return edit.SetYAML(path, edit.KV{Path: "defaultThinkingLevel", Value: v})
|
||||
},
|
||||
Options: func(map[string]string) []Option { return static(append([]string{"auto"}, ompEfforts...)...) },
|
||||
}),
|
||||
}), ompAdvisorFields(path)...),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
)
|
||||
|
||||
// omp's advisor (src/advisor in @oh-my-pi/pi-coding-agent): a second model,
|
||||
// on the advisor role, that reviews the main agent's turns and sends it
|
||||
// notes. Its model is a role (omp.go); whether it runs, when it reviews,
|
||||
// how long the main agent waits for it and which note calls a finished
|
||||
// agent back are these settings of config.yml (advisor/settings.ts, omp
|
||||
// 18.20.0). A WATCHDOG.yml roster with advisors in it sets each one's own
|
||||
// review and wait instead; omp reads the global ones only without one
|
||||
// (#6408).
|
||||
//
|
||||
// omp's enum settings take strings only (config/registry.ts accepts), so
|
||||
// syncBacklog's "1" is written as the string, never the number.
|
||||
var (
|
||||
ompAdvisorReviews = []string{"off", "turn", "agent-end"}
|
||||
ompAdvisorWaits = []string{"off", "1", "3", "5", "strict"}
|
||||
ompAdvisorWakes = []string{"nit", "concern", "blocker"}
|
||||
)
|
||||
|
||||
// ompAdvisorOn reads advisor.enabled: "" while unset (omp's default, off)
|
||||
func ompAdvisorOn(path string) string {
|
||||
v, _ := edit.GetYAML(path, "advisor.enabled")
|
||||
return v
|
||||
}
|
||||
|
||||
// ompAdvisorTurnedOn is the stash's mark that magpie turned the advisor on
|
||||
// at the config.yml at path, picking its model: the role's reset turns it
|
||||
// off again, and the user setting it themselves takes the mark away
|
||||
func ompAdvisorTurnedOn(path string) string { return "omp:" + path + ":advisor.enabled" }
|
||||
|
||||
// ompAdvisorFields are the advisor's settings in the config.yml at path.
|
||||
// Each is Quiet: a row lists none of them until set.
|
||||
func ompAdvisorFields(path string) []Field {
|
||||
setting := func(key, label, setting string, values []string) Field {
|
||||
return Field{
|
||||
Key: key, Label: label, Quiet: true,
|
||||
Get: func() string { v, _ := edit.GetYAML(path, setting); return v },
|
||||
Set: func(v string) error {
|
||||
if v == "" {
|
||||
return edit.DelYAML(path, setting)
|
||||
}
|
||||
if !slices.Contains(values, v) {
|
||||
return fmt.Errorf("%q is not one of omp's values for %s: %v", v, setting, values)
|
||||
}
|
||||
return edit.SetYAML(path, edit.KV{Path: setting, Value: v})
|
||||
},
|
||||
Options: func(map[string]string) []Option { return static(values...) },
|
||||
}
|
||||
}
|
||||
return []Field{
|
||||
{
|
||||
// whether it runs and when it reviews, in one: off, each turn
|
||||
// (each tool-call round) or only when the agent ends its run.
|
||||
// Turned off, the review mode it had stays for the next time
|
||||
Key: "advisor_review", Label: "advisor review", Quiet: true,
|
||||
Get: func() string {
|
||||
switch ompAdvisorOn(path) {
|
||||
case "":
|
||||
return ""
|
||||
case "true":
|
||||
if mode, _ := edit.GetYAML(path, "advisor.reviewMode"); mode == "agent-end" {
|
||||
return mode
|
||||
}
|
||||
return "turn"
|
||||
}
|
||||
return "off"
|
||||
},
|
||||
Set: func(v string) error {
|
||||
forget(ompAdvisorTurnedOn(path))
|
||||
switch v {
|
||||
case "":
|
||||
return edit.DelYAML(path, "advisor.enabled")
|
||||
case "off":
|
||||
return edit.SetYAML(path, edit.KV{Path: "advisor.enabled", Value: false})
|
||||
case "turn", "agent-end":
|
||||
return edit.SetYAML(path, edit.KV{Path: "advisor.enabled", Value: true}, edit.KV{Path: "advisor.reviewMode", Value: v})
|
||||
}
|
||||
return fmt.Errorf("%q is not one of omp's advisor reviews: %v", v, ompAdvisorReviews)
|
||||
},
|
||||
Options: func(map[string]string) []Option { return static(ompAdvisorReviews...) },
|
||||
},
|
||||
// how far the main agent waits for a review it is owed before going
|
||||
// on: not at all, up to 30 seconds while 1, 3 or 5 are behind, or
|
||||
// until every review is in (strict, no time limit)
|
||||
setting("advisor_wait", "advisor wait", "advisor.syncBacklog", ompAdvisorWaits),
|
||||
// the least note that calls back an agent that has finished; one
|
||||
// below it waits for the user's next message
|
||||
setting("advisor_wake", "advisor wakes on", "advisor.continueSeverity", ompAdvisorWakes),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/yetone/magpie/internal/edit"
|
||||
"github.com/yetone/magpie/internal/provider"
|
||||
)
|
||||
|
||||
func ompAdvisorHome(t *testing.T, config string) (string, string) {
|
||||
t.Helper()
|
||||
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")
|
||||
os.MkdirAll(dir, 0o755)
|
||||
path := filepath.Join(dir, "config.yml")
|
||||
if config != "" {
|
||||
os.WriteFile(path, []byte(config), 0o644)
|
||||
}
|
||||
return home, path
|
||||
}
|
||||
|
||||
// #6408 (Awad_Yoo on X), #5019: omp runs no advisor while advisor.enabled
|
||||
// is unset, its default being off (advisor/settings.ts), so a model picked
|
||||
// for the advisor role in magpie reviewed nothing. The pick turns it on,
|
||||
// the role's reset takes that back, and a value the user set stays.
|
||||
func TestOmpAdvisorPickTurnsItOn(t *testing.T) {
|
||||
home, path := ompAdvisorHome(t, "modelRoles:\n default: anthropic/claude-opus-5\n")
|
||||
a := omp(home)
|
||||
on := func() string { return ompAdvisorOn(path) }
|
||||
|
||||
if err := a.Apply("advisor", "magpie/deepseek/pro"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if on() != "true" {
|
||||
t.Fatalf("advisor picked, advisor.enabled = %q", on())
|
||||
}
|
||||
if got := a.Values()["advisor_review"]; got != "turn" {
|
||||
t.Fatalf("advisor_review = %q, want omp's default review, turn", got)
|
||||
}
|
||||
// its level is the role's value written again: still on
|
||||
if err := a.Apply("advisor_thinking", "high"); err != nil || on() != "true" {
|
||||
t.Fatalf("level: %v, enabled %q", err, on())
|
||||
}
|
||||
if err := a.Apply("advisor", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if on() != "" {
|
||||
t.Fatalf("the reset left advisor.enabled = %q, which only magpie's pick had set", on())
|
||||
}
|
||||
|
||||
// the user's own off stays off when a model is picked
|
||||
if err := a.Apply("advisor_review", "off"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Apply("advisor", "magpie/deepseek/pro"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if on() != "false" {
|
||||
t.Fatalf("the user's off became %q", on())
|
||||
}
|
||||
// and the user's on stays on when the role is reset
|
||||
if err := a.Apply("advisor_review", "agent-end"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.Apply("advisor", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if on() != "true" {
|
||||
t.Fatalf("the user's on became %q after the role's reset", on())
|
||||
}
|
||||
}
|
||||
|
||||
// The gating omp has, written as omp reads it: whether and when the
|
||||
// advisor reviews (advisor.enabled with reviewMode), how long the main
|
||||
// agent waits on it (syncBacklog: a string, as omp's enum settings accept
|
||||
// only strings) and which note calls a finished agent back
|
||||
// (continueSeverity).
|
||||
func TestOmpAdvisorSettings(t *testing.T) {
|
||||
home, path := ompAdvisorHome(t, "# mine\nadvisor:\n maxNotesPerUpdate: 2\n")
|
||||
a := omp(home)
|
||||
for _, k := range []string{"advisor_review", "advisor_wait", "advisor_wake"} {
|
||||
f := a.Field(k)
|
||||
if f == nil || !f.Quiet {
|
||||
t.Fatalf("%s: %+v", k, f)
|
||||
}
|
||||
if v := a.Values()[k]; v != "" {
|
||||
t.Fatalf("%s unset reads %q", k, v)
|
||||
}
|
||||
}
|
||||
for _, kv := range [][2]string{{"advisor_review", "agent-end"}, {"advisor_wait", "1"}, {"advisor_wake", "blocker"}} {
|
||||
if err := a.Apply(kv[0], kv[1]); err != nil {
|
||||
t.Fatalf("%s = %s: %v", kv[0], kv[1], err)
|
||||
}
|
||||
if got := a.Values()[kv[0]]; got != kv[1] {
|
||||
t.Fatalf("%s reads %q, want %q", kv[0], got, kv[1])
|
||||
}
|
||||
}
|
||||
b, _ := os.ReadFile(path)
|
||||
text := string(b)
|
||||
for _, want := range []string{"# mine", "maxNotesPerUpdate: 2", "enabled: true", "reviewMode: agent-end", `syncBacklog: "1"`, "continueSeverity: blocker"} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("config.yml lacks %q:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
for _, kv := range [][2]string{{"advisor_review", "sometimes"}, {"advisor_wait", "30s"}, {"advisor_wake", "nitpick"}} {
|
||||
if err := a.Apply(kv[0], kv[1]); err == nil {
|
||||
t.Fatalf("%s took %q", kv[0], kv[1])
|
||||
}
|
||||
}
|
||||
// off keeps the review mode for the next time
|
||||
if err := a.Apply("advisor_review", "off"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, _ := edit.GetYAML(path, "advisor.reviewMode"); v != "agent-end" || a.Values()["advisor_review"] != "off" {
|
||||
t.Fatalf("off: reviewMode %q, field %q", v, a.Values()["advisor_review"])
|
||||
}
|
||||
for _, k := range []string{"advisor_review", "advisor_wait", "advisor_wake"} {
|
||||
if err := a.Apply(k, ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
for _, k := range []string{"advisor.enabled", "advisor.syncBacklog", "advisor.continueSeverity"} {
|
||||
if v, ok := edit.GetYAML(path, k); ok {
|
||||
t.Fatalf("%s left at %q", k, v)
|
||||
}
|
||||
}
|
||||
if v, _ := edit.GetYAML(path, "advisor.maxNotesPerUpdate"); v != "2" {
|
||||
t.Fatalf("the user's maxNotesPerUpdate became %q", v)
|
||||
}
|
||||
}
|
||||
@@ -515,7 +515,7 @@ function renderAgents() {
|
||||
const wide = (f) => f.label === "model" || f.label === "large" || f.label === "executor" || f.label === "planner";
|
||||
// a field with nothing to pick and nothing set isn't drawn (#1499)
|
||||
const none = (f) => (f.key === "effort" || toggled(f) || f.label === "subagents" || f.label === "gateway" || f.label === SUB_EFFORT || f.label === SUB_MODEL || f.label === AUTO_MODE || f.label === MEMORIES || f.label === COMPACT_MODEL || f.label === "sign-in" || f.key === "small" || asideAccount(a, f)) && !f.options.length && !f.value;
|
||||
const shownFields = a.fields.filter((f) => !grouped(a, f) && !none(f) && !codexOwnSub(a, f) && !codexRowed(a, f) && !hermesBot(f));
|
||||
const shownFields = a.fields.filter((f) => !grouped(a, f) && !none(f) && !codexOwnSub(a, f) && !codexRowed(a, f) && !hermesBot(f) && !ompAdvisorKey(f));
|
||||
const tiers = tierMenu(a);
|
||||
if (tiers) shownFields.push(tiers);
|
||||
const sorted = shownFields.sort((x, y) => wide(y) - wide(x) || extra(x) - extra(y));
|
||||
@@ -2284,6 +2284,7 @@ function connectPanel(a, { fields, fieldBtn }) {
|
||||
homeAgentPrefRows();
|
||||
list.append(...own.map((id) => $("#" + id)));
|
||||
if (a.telemetry) list.append(telemetryRow(a));
|
||||
ompAdvisorIn(list, a);
|
||||
kv(t("Settings"), list);
|
||||
agentCompactIn(list, own, a);
|
||||
if (!prefs) {
|
||||
@@ -4036,6 +4037,7 @@ function agentPrefsButton(a) {
|
||||
homeAgentPrefRows();
|
||||
const names = agentPrefsOf(a).map((id) => $("#" + id)).filter((r) => !r.hidden).map((r) => r.querySelector(".name").textContent);
|
||||
if (a.telemetry) names.push(t("Telemetry"));
|
||||
if (ompAdvisorHas(a)) names.push(t("Advisor"));
|
||||
b.append(el("span", "k", t("Settings")), el("span", "v", names.join(" · ")), c);
|
||||
b.title = t("{agent} settings", { agent: a.name });
|
||||
b.setAttribute("aria-label", b.title);
|
||||
@@ -4091,6 +4093,8 @@ function tierMenu(a) {
|
||||
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;
|
||||
// omp's advisor on a model, turned off (#6408)
|
||||
const advisorOff = (f) => omp && f.key === "advisor" && f.value && a.fields.find((x) => x.key === "advisor_review")?.value === "off";
|
||||
return {
|
||||
key: "tiers", label: omp ? "roles" : "tiers", value: "", menu: true, custom: custom.length > 0,
|
||||
foot: a.id === "claude-desktop" ? DESKTOP_TIERS_FOOT : "",
|
||||
@@ -4100,7 +4104,7 @@ function tierMenu(a) {
|
||||
// an omp role: one line, its level picked after its model (hongzaitou on X)
|
||||
const model = {
|
||||
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)) + (omp && level(e) ? " · " + level(e) : ""),
|
||||
note: (f.value ? name(f) : unset(f)) + (omp && level(e) ? " · " + level(e) : "") + (advisorOff(f) ? " · " + t("off") : ""),
|
||||
};
|
||||
return e && !omp ? [model, { value: e.key, label: t(e.label), effortOf: e, note: level(e) || levelUnset(a) }] : [model];
|
||||
}),
|
||||
@@ -21269,6 +21273,19 @@ function telemetryRow(a) {
|
||||
row.append(who, box);
|
||||
return row;
|
||||
}
|
||||
// omp's advisor (#6408): whether it reviews and when, how long the agent
|
||||
// waits on it, and which note calls a finished agent back, as omp's
|
||||
// config.yml has them (omp_advisor.go), drawn by ompadvisor.js, imported
|
||||
// the first time an omp's settings show. Its model is a role in the roles
|
||||
// square
|
||||
const OMP_ADVISOR = ["advisor_review", "advisor_wait", "advisor_wake"], ompAdvisorKey = (f) => OMP_ADVISOR.includes(f.key), ompAdvisorHas = (a) => a.fields.some((f) => f.key === OMP_ADVISOR[0]);
|
||||
function ompAdvisorIn(list, a) {
|
||||
if (!ompAdvisorHas(a)) return;
|
||||
const at = el("span");
|
||||
at.hidden = true;
|
||||
list.append(at);
|
||||
import("./ompadvisor.js").then(() => at.replaceWith(...ompAdvisorRows(a)), () => {});
|
||||
}
|
||||
const PREFS_GLYPH = "M2.75 4.75h10.5M2.75 11.25h10.5M5.75 3.25v3M10.25 9.75v3";
|
||||
let agentPrefRowEls = null;
|
||||
// an agent's own Long conversations, under every agent's (agentcompact.js)
|
||||
@@ -21294,6 +21311,7 @@ async function openAgentPrefs(a) {
|
||||
for (const id of ids) list.append($("#" + id));
|
||||
agentCompactIn(list, ids, a);
|
||||
if (a.telemetry) list.append(telemetryRow(a));
|
||||
ompAdvisorIn(list, a);
|
||||
const bar = el("div", "bar");
|
||||
const done = el("button", "primary", t("Done"));
|
||||
done.type = "button";
|
||||
|
||||
@@ -4882,6 +4882,21 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "从「应用程序」打开 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 保持 Anthropic 登录。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在运行,请退出它:它已不再使用 magpie。",
|
||||
"Telemetry": "遥测",
|
||||
"Advisor": "顾问",
|
||||
"Every turn": "每轮",
|
||||
"At the end": "结束时",
|
||||
"Don't wait": "不等",
|
||||
"Up to 30s": "最多 30 秒",
|
||||
"Until done": "等到审完",
|
||||
"{n} behind": "落后 {n} 次",
|
||||
"Waits for its review": "等它审完",
|
||||
"Calls a finished agent back on": "叫回已结束的 agent",
|
||||
"Any note": "任何建议",
|
||||
"Concern": "问题",
|
||||
"Blocker": "阻断",
|
||||
"A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead": "另一个模型(顾问角色上的模型)审查 agent 的工作并给它建议。WATCHDOG.yml 里列了顾问时,以其中每个顾问自己的审查设置为准",
|
||||
"Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in": "继续之前,agent 等它该得到的审查:最多 30 秒,或不限时等到所有审查完成",
|
||||
"The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later": "能把已结束的 agent 叫回来的最低级别建议;更低的会等你下一条消息再带上。需要 omp 18.12.1 或更新",
|
||||
"Turned off in your own config too: {keys}": "你自己的配置里也关了:{keys}",
|
||||
"Turn off telemetry for all agents": "关闭所有 Agent 的遥测",
|
||||
"Over each agent's own Telemetry switch, an agent found later too": "优先于每个 Agent 自己的遥测开关,之后接入的 Agent 也一样",
|
||||
@@ -10030,6 +10045,21 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "從「應用程式」打開 Claude Magpie,即可在 magpie 上使用 Claude Desktop。你自己的 Claude Desktop 維持 Anthropic 登入。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "如果 Claude Magpie 正在執行,請結束它:它已不再使用 magpie。",
|
||||
"Telemetry": "遙測",
|
||||
"Advisor": "顧問",
|
||||
"Every turn": "每輪",
|
||||
"At the end": "結束時",
|
||||
"Don't wait": "不等",
|
||||
"Up to 30s": "最多 30 秒",
|
||||
"Until done": "等到審完",
|
||||
"{n} behind": "落後 {n} 次",
|
||||
"Waits for its review": "等它審完",
|
||||
"Calls a finished agent back on": "叫回已結束的 agent",
|
||||
"Any note": "任何建議",
|
||||
"Concern": "問題",
|
||||
"Blocker": "阻斷",
|
||||
"A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead": "另一個模型(顧問角色上的模型)審查 agent 的工作並給它建議。WATCHDOG.yml 裡列了顧問時,以其中每個顧問自己的審查設定為準",
|
||||
"Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in": "繼續之前,agent 等它該得到的審查:最多 30 秒,或不限時等到所有審查完成",
|
||||
"The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later": "能把已結束的 agent 叫回來的最低級別建議;更低的會等你下一則訊息再帶上。需要 omp 18.12.1 或更新",
|
||||
"Turned off in your own config too: {keys}": "你自己的設定裡也關了:{keys}",
|
||||
"Turn off telemetry for all agents": "關閉所有 Agent 的遙測",
|
||||
"Over each agent's own Telemetry switch, an agent found later too": "優先於每個 Agent 自己的遙測開關,之後接入的 Agent 也一樣",
|
||||
@@ -15180,6 +15210,21 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "「アプリケーション」から Claude Magpie を開くと、magpie で Claude Desktop を使えます。ご自身の Claude Desktop は Anthropic にサインインしたままです。",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Claude Magpie を開いている場合は終了してください。もう magpie では動きません。",
|
||||
"Telemetry": "テレメトリ",
|
||||
"Advisor": "アドバイザー",
|
||||
"Every turn": "毎ターン",
|
||||
"At the end": "終了時",
|
||||
"Don't wait": "待たない",
|
||||
"Up to 30s": "最大 30 秒",
|
||||
"Until done": "完了まで",
|
||||
"{n} behind": "{n} 件遅れ",
|
||||
"Waits for its review": "レビューを待つ",
|
||||
"Calls a finished agent back on": "終了した agent を呼び戻す",
|
||||
"Any note": "すべての指摘",
|
||||
"Concern": "懸念",
|
||||
"Blocker": "ブロッカー",
|
||||
"A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead": "アドバイザーロールの別モデルが agent の作業をレビューし、メモを送ります。WATCHDOG.yml にアドバイザーがある場合は、各アドバイザー自身のレビュー設定が使われます",
|
||||
"Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in": "先に進む前に、agent は受けるべきレビューを待ちます:最大 30 秒、または時間制限なしですべてのレビューが終わるまで",
|
||||
"The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later": "終了した agent を呼び戻す最低レベルのメモ。それ未満は次のメッセージで届きます。omp 18.12.1 以降",
|
||||
"Turned off in your own config too: {keys}": "ご自身の設定でもオフです:{keys}",
|
||||
"Turn off telemetry for all agents": "すべてのエージェントのテレメトリをオフ",
|
||||
"Over each agent's own Telemetry switch, an agent found later too": "各エージェントのテレメトリ設定より優先し、後から見つかったエージェントにも適用します",
|
||||
@@ -20330,6 +20375,21 @@ const I18N = {
|
||||
"Open Claude Magpie from Applications to use Claude Desktop on magpie. Your own Claude Desktop stays signed in with Anthropic.": "Öffne Claude Magpie unter Programme, um Claude Desktop über magpie zu nutzen. Dein eigenes Claude Desktop bleibt bei Anthropic angemeldet.",
|
||||
"Quit Claude Magpie if it is open: it no longer runs on magpie.": "Beende Claude Magpie, falls es offen ist: Es läuft nicht mehr über magpie.",
|
||||
"Telemetry": "Telemetrie",
|
||||
"Advisor": "Berater",
|
||||
"Every turn": "Jede Runde",
|
||||
"At the end": "Am Ende",
|
||||
"Don't wait": "Nicht warten",
|
||||
"Up to 30s": "Bis zu 30 s",
|
||||
"Until done": "Bis fertig",
|
||||
"{n} behind": "{n} im Rückstand",
|
||||
"Waits for its review": "Wartet auf seine Prüfung",
|
||||
"Calls a finished agent back on": "Holt einen fertigen Agenten zurück bei",
|
||||
"Any note": "Jedem Hinweis",
|
||||
"Concern": "Bedenken",
|
||||
"Blocker": "Blocker",
|
||||
"A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead": "Ein zweites Modell auf der Berater-Rolle prüft die Arbeit des Agenten und schickt ihm Hinweise. Eine WATCHDOG.yml mit Beratern legt stattdessen die Prüfung jedes einzelnen fest",
|
||||
"Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in": "Bevor er weitermacht, wartet der Agent auf eine fällige Prüfung: bis zu 30 Sekunden oder ohne Grenze, bis jede Prüfung da ist",
|
||||
"The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later": "Der geringste Hinweis, der einen fertigen Agenten zurückholt; ein geringerer wartet auf deine nächste Nachricht. omp 18.12.1 oder neuer",
|
||||
"Turned off in your own config too: {keys}": "Auch in deiner eigenen Konfiguration aus: {keys}",
|
||||
"Turn off telemetry for all agents": "Telemetrie aller Agents ausschalten",
|
||||
"Over each agent's own Telemetry switch, an agent found later too": "Gilt vor dem Telemetrie-Schalter jedes Agents, auch für später gefundene Agents",
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// omp's advisor's rows (#6408, Awad_Yoo on X), in an omp's settings:
|
||||
// whether it reviews and when, how long the agent waits for its review,
|
||||
// and which note calls a finished agent back, as omp's config.yml has them
|
||||
// (omp_advisor.go). The last two only once it reviews. app.js imports this
|
||||
// the first time an omp's settings show (ompAdvisorIn), so it weighs
|
||||
// nothing on the core.
|
||||
window.ompAdvisorRows = function (a) {
|
||||
const val = (k) => a.fields.find((f) => f.key === k)?.value || "";
|
||||
// the rows answer in place, in a sheet too, as telemetryRow does
|
||||
const again = () => {
|
||||
const now = state.agents.find((x) => x.id === a.id);
|
||||
if (now && rows[0].isConnected) {
|
||||
rows[0].before(...ompAdvisorRows(now));
|
||||
for (const r of rows) r.remove();
|
||||
}
|
||||
if (view === "agents") renderAgents();
|
||||
};
|
||||
const set = (key, v) => api("set", { agent: a.id, field: key, value: v }).then((ns) => {
|
||||
state = ns;
|
||||
status(t("Takes effect when {agent} next starts", { agent: a.name }), "ok");
|
||||
again();
|
||||
}, (e) => { statusErr(e); again(); });
|
||||
const row = (name, tip, items, cur, key) => {
|
||||
const r = el("div", "row pref ag-advisor");
|
||||
r.dataset.key = key;
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", t(name)));
|
||||
who.title = t(tip);
|
||||
r.append(who, segs(items.map(([id, label]) => [id, t(label)]), cur, (v) => { if (v !== cur) set(key, v); }));
|
||||
return r;
|
||||
};
|
||||
const review = val("advisor_review") || "off";
|
||||
const rows = [row("Advisor", "A second model, on the advisor role, reviews the agent's work and sends it notes. A WATCHDOG.yml with advisors sets each one's own review instead",
|
||||
[["off", "Off"], ["turn", "Every turn"], ["agent-end", "At the end"]], review, "advisor_review")];
|
||||
if (review === "off") return rows;
|
||||
// 3 and 5 are omp's too, written by hand or in omp itself
|
||||
const wait = val("advisor_wait") || "off";
|
||||
const waits = [["off", "Don't wait"], ["1", "Up to 30s"], ["strict", "Until done"]];
|
||||
if (wait === "3" || wait === "5") waits.splice(2, 0, [wait, t("{n} behind", { n: wait })]);
|
||||
rows.push(row("Waits for its review", "Before going on, the agent waits for a review it is owed: up to 30 seconds, or with no limit until every review is in",
|
||||
waits, wait, "advisor_wait"));
|
||||
rows.push(row("Calls a finished agent back on", "The least note that brings back an agent that has finished; a lesser one waits for your next message. omp 18.12.1 or later",
|
||||
[["nit", "Any note"], ["concern", "Concern"], ["blocker", "Blocker"]], val("advisor_wake") || "concern", "advisor_wake"));
|
||||
return rows;
|
||||
};
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// `git log -L` of this file.
|
||||
const (
|
||||
appScriptBudget = 1_086_267 // app.js: 1,080,614 at 8016205e3, with the 5,653 of room it had
|
||||
coreScriptBudget = 1_266_577 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to
|
||||
coreScriptBudget = 1_267_294 // every core script at 8016205e3, the old measure 682 over its cap there (#5918); +367 for the model test on a chosen account (tmr11235), no page left to move it to; +151 for the provider menu's "Only on this device" item and its four translations; +458 for Settings › About's Report a problem row and its translations; +113 for withScheme, the one rule every typed address goes through (eachg0 on X), cut to the shortest form that keeps it whole; +10 for the kept whole's tooltip (Musikrv77852 on X), the past-cycle line reused for it, no page left to move it to; +1,112 for Codex's Open button and its Open Codex with menu (Yink88564391 on X), packed to the shortest form, no page left to move them to; +168 for Discover's long lists drawn in part (the owner, 11-13), after the rest of its hook moved into plugingrid.js, imported when Plugins first draws; +296 for the cap toggle and Smart sentences that say what they do and the Sign in on another computer row (Wing8Aqua on X), packed to the shortest form, no page left to move them to; +333 for In turn's figure in a provider's editor and its words naming the message that goes round (Wing8Aqua on X), the figure itself in rotfig.js, imported when In turn is first shown, the hook packed to the shortest form; +236 for a lone capped Codex account's row saying its turns go to the fallbacks when Codex is connected (not_4O4 on X), the two helpers inlined, no page left to move it to; +717 for omp's advisor (Awad_Yoo on X, #6408): its three rows moved into ompadvisor.js, imported when an omp's settings show, and what is left is the import, the role's " · off" and the Settings line's name, packed to the shortest form
|
||||
)
|
||||
|
||||
// codeBytes is how many bytes of b are code: its blank lines, its lines
|
||||
|
||||
@@ -179,9 +179,10 @@ test("compat.js is the first of the page's own scripts", async () => {
|
||||
// addfloat.js when the Providers page's add sheet first opens;
|
||||
// plugingrid.js when Plugins first draws;
|
||||
// rotfig.js when a routing's In turn is first shown;
|
||||
// ompadvisor.js when an omp's settings first show;
|
||||
// the checks above
|
||||
// still read them
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "rotfig.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
for (const f of await scripts()) if (!["webfonts.js", "cfgblocked.js", "signsheets.js", "ruleedit.js", "ratewindows.js", "traywindows.js", "autoresetown.js", "registry.js", "navlamp.js", "whatsnew.js", "claudemode.js", "ctxtext.js", "resetask.js", "quotaall.js", "quotatable.js", "quitask.js", "checkinnow.js", "proxies.js", "autobackup.js", "scrollends.js", "profilerename.js", "settingshints.js", "keyspend.js", "syncfiles.js", "agentcompact.js", "agentwindow.js", "balfound.js", "passerrors.js", "tlscerts.js", "keybalance.js", "modellimits.js", "notices.js", "videogen.js", "provlinks.js", "setfeats.js", "pageshare.js", "panelfirst.js", "panelarrange.js", "modelfind.js", "agentsmanager.js", "agentsuffix.js", "phonetabs.js", "pluginmd.js", "bark.js", "acctexport.js", "plugincounts.js", "navicons.js", "autoswitchtip.js", "codexprojects.js", "pipecheck.js", "addfloat.js", "plugingrid.js", "rotfig.js", "ompadvisor.js"].includes(f)) assert(all.includes(f), f + " is not loaded by index.html");
|
||||
});
|
||||
|
||||
test("the styles hold up in Safari 15.0", async () => {
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// Run with Node's test runner and Playwright on the module path; see README.md.
|
||||
// omp's advisor (#6408, Awad_Yoo on X): in omp's own settings, in the
|
||||
// window's opened row and in the panel's sheet, three rows as omp's
|
||||
// config.yml has them (omp_advisor.go): whether it reviews and when
|
||||
// (Off, Every turn, At the end), how long the agent waits for its review,
|
||||
// and which note calls a finished agent back. The last two show only while
|
||||
// it reviews, and a pick writes its field. With the advisor off, its role's
|
||||
// line in the roles square says so. English, both Chinese, Japanese and
|
||||
// German, wide and at 390px, Chromium and WebKit. The API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
const path = require("node:path");
|
||||
const { test } = require("node:test");
|
||||
const { chromium, webkit } = require("playwright");
|
||||
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const options = [{ value: "magpie/deepseek/pro", label: "DeepSeek Pro", ref: "deepseek/pro" }];
|
||||
const st = (...v) => v.map((value) => ({ value }));
|
||||
const fresh = (review) => ({
|
||||
agents: [{
|
||||
id: "omp", name: "omp", path: "/test/config.yml", icon: "omp", wired: true,
|
||||
fields: [
|
||||
{ key: "model", label: "model", value: "magpie/deepseek/pro", options },
|
||||
{ key: "advisor", label: "advisor", value: "magpie/deepseek/pro", options },
|
||||
{ key: "advisor_thinking", label: "advisor thinking", value: "", options: st("auto", "low", "high") },
|
||||
{ key: "advisor_review", label: "advisor review", value: review, options: st("off", "turn", "agent-end") },
|
||||
{ key: "advisor_wait", label: "advisor wait", value: "", options: st("off", "1", "3", "5", "strict") },
|
||||
{ key: "advisor_wake", label: "advisor wakes on", value: "", options: st("nit", "concern", "blocker") },
|
||||
],
|
||||
}],
|
||||
profiles: [],
|
||||
});
|
||||
|
||||
function server(lang, sets, review) {
|
||||
let cur = fresh(review);
|
||||
const settings = { theme: "light", lang, tray: "panel", currency: "usd", version: "0.1.400", dir: "~/.config/magpie", gateway: "http://127.0.0.1:3425", redactWords: [], fx: { rate: 7.2, at: new Date().toISOString(), stale: false } };
|
||||
return async (route) => {
|
||||
const req = route.request(), url = new URL(req.url());
|
||||
if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
|
||||
if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
|
||||
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({ agent: body.agent, field: body.field, value: body.value });
|
||||
cur = JSON.parse(JSON.stringify(cur));
|
||||
cur.agents[0].fields.find((f) => f.key === body.field).value = body.value;
|
||||
return route.fulfill({ json: { ...cur, settings: { lang, theme: "light" } } });
|
||||
}
|
||||
if (url.pathname === "/api/settings") return route.fulfill({ json: settings });
|
||||
if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
|
||||
if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
|
||||
if (url.pathname === "/api/agents/cli") return route.fulfill({ json: { agents: {}, pending: false } });
|
||||
if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], gateway: { running: true } } });
|
||||
if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
|
||||
if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
|
||||
const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
|
||||
const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
|
||||
try {
|
||||
await route.fulfill({ body: await fs.readFile(file), contentType });
|
||||
} catch {
|
||||
await route.fulfill({ status: 404, body: "" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// the words as i18n.js has them
|
||||
const W = {
|
||||
en: { names: ["Advisor", "Waits for its review", "Calls a finished agent back on"], review: ["Off", "Every turn", "At the end"], wait: ["Don't wait", "Up to 30s", "Until done"], wake: ["Any note", "Concern", "Blocker"], off: "off", role: "advisor" },
|
||||
zh: { names: ["顾问", "等它审完", "叫回已结束的 agent"], review: ["关闭", "每轮", "结束时"], wait: ["不等", "最多 30 秒", "等到审完"], wake: ["任何建议", "问题", "阻断"], off: "关闭", role: "顾问" },
|
||||
"zh-TW": { names: ["顧問", "等它審完", "叫回已結束的 agent"], review: ["關閉", "每輪", "結束時"], wait: ["不等", "最多 30 秒", "等到審完"], wake: ["任何建議", "問題", "阻斷"], off: "關閉", role: "顧問" },
|
||||
ja: { names: ["アドバイザー", "レビューを待つ", "終了した agent を呼び戻す"], review: ["オフ", "毎ターン", "終了時"], wait: ["待たない", "最大 30 秒", "完了まで"], wake: ["すべての指摘", "懸念", "ブロッカー"], off: "オフ", role: "アドバイザー" },
|
||||
de: { names: ["Berater", "Wartet auf seine Prüfung", "Holt einen fertigen Agenten zurück bei"], review: ["Aus", "Jede Runde", "Am Ende"], wait: ["Nicht warten", "Bis zu 30 s", "Bis fertig"], wake: ["Jedem Hinweis", "Bedenken", "Blocker"], off: "aus", role: "Berater" },
|
||||
};
|
||||
|
||||
const omp = '.row.agent[data-id="omp"]';
|
||||
// each advisor row: its name, its options and the one on
|
||||
const rowsIn = (page, box) => page.locator(`${box} .row.pref.ag-advisor`).evaluateAll((rs) => rs.map((r) => [
|
||||
r.dataset.key, r.querySelector(".name").textContent, [...r.querySelectorAll(".segs .opt")].map((o) => o.textContent),
|
||||
r.querySelector(".segs .opt.on")?.dataset.seg || "",
|
||||
]));
|
||||
const waitRows = (page, box, n) => page.waitForFunction(([box, n]) => document.querySelectorAll(box + " .row.pref.ag-advisor").length === n, [box, n]);
|
||||
const opt = (page, box, key, seg) => page.locator(`${box} .row.pref.ag-advisor[data-key="${key}"] .segs .opt[data-seg="${seg}"]`);
|
||||
|
||||
async function open(engine, width, lang, t, review, url = "http://magpie.test/") {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await browser.newPage({ viewport: { width, height: 760 } });
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [], sets = [];
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, sets, review));
|
||||
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}-${width}-omp-advisor.png`) });
|
||||
}
|
||||
await browser.close();
|
||||
});
|
||||
await page.goto(url);
|
||||
await page.locator(omp).waitFor();
|
||||
return { page, errors, sets };
|
||||
}
|
||||
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
for (const width of [1100, 390]) for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
test(`${engine} ${lang} ${width}px: omp's advisor, off, then reviewing at the end, its wait and its call-back`, async (t) => {
|
||||
const w = W[lang];
|
||||
const { page, errors, sets } = await open(engine, width, lang, t, "off");
|
||||
await page.locator(`${omp} .ag-link`).click();
|
||||
await waitRows(page, omp, 1);
|
||||
// off: one row, and the roles square's advisor line says so
|
||||
assert.deepEqual(await rowsIn(page, omp), [["advisor_review", w.names[0], w.review, "off"]]);
|
||||
assert.equal(await page.locator(`${omp} .field:not(.extra)[data-key^="advisor_"]`).count(), 0, "an advisor setting got a picker of its own");
|
||||
const square = page.locator(`${omp} .field.extra[data-key="tiers"]`);
|
||||
await square.click();
|
||||
await page.locator("#pop:not([hidden]) #list li").first().waitFor();
|
||||
const line = await page.locator("#pop:not([hidden]) #list li", { hasText: w.role }).first().innerText();
|
||||
assert.ok(line.includes("DeepSeek Pro · " + w.off), line);
|
||||
await page.keyboard.press("Escape");
|
||||
await page.waitForFunction(() => !document.querySelector("#pop:not([hidden])"));
|
||||
|
||||
// At the end: written, and the wait and call-back rows come
|
||||
await opt(page, omp, "advisor_review", "agent-end").click();
|
||||
await waitRows(page, omp, 3);
|
||||
assert.deepEqual(sets, [{ agent: "omp", field: "advisor_review", value: "agent-end" }]);
|
||||
assert.deepEqual(await rowsIn(page, omp), [
|
||||
["advisor_review", w.names[0], w.review, "agent-end"],
|
||||
["advisor_wait", w.names[1], w.wait, "off"],
|
||||
["advisor_wake", w.names[2], w.wake, "concern"],
|
||||
]);
|
||||
await opt(page, omp, "advisor_wait", "1").click();
|
||||
await page.waitForFunction(() => document.querySelector('.row.pref.ag-advisor[data-key="advisor_wait"] .opt.on')?.dataset.seg === "1" && document.querySelectorAll('.row.pref.ag-advisor').length === 3);
|
||||
await opt(page, omp, "advisor_wake", "blocker").click();
|
||||
await page.waitForFunction(() => document.querySelector('.row.pref.ag-advisor[data-key="advisor_wake"] .opt.on')?.dataset.seg === "blocker");
|
||||
for (let i = 0; sets.length < 3 && i < 100; i++) await page.waitForTimeout(50);
|
||||
assert.deepEqual(sets.slice(1), [{ agent: "omp", field: "advisor_wait", value: "1" }, { agent: "omp", field: "advisor_wake", value: "blocker" }]);
|
||||
// its own value picked again writes nothing
|
||||
await opt(page, omp, "advisor_wake", "blocker").click();
|
||||
await page.waitForTimeout(150);
|
||||
assert.equal(sets.length, 3);
|
||||
assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), true, "the row scrolls sideways");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
for (const lang of ["en", "zh", "de"]) {
|
||||
test(`${engine} ${lang}: in the panel the agent's sheet has the advisor's rows, and they answer in place`, async (t) => {
|
||||
const w = W[lang];
|
||||
const { page, errors, sets } = await open(engine, 360, lang, t, "", "http://magpie.test/?mode=panel&view=agents");
|
||||
await page.locator(`${omp} .ag-sum`).click();
|
||||
const line = page.locator(`${omp} .agent-prefs-open`);
|
||||
await line.waitFor();
|
||||
assert.ok((await line.textContent()).includes(w.names[0]), await line.textContent());
|
||||
await line.click();
|
||||
const sheet = "#modal .editor.agent-prefs";
|
||||
await page.locator(sheet).waitFor();
|
||||
await waitRows(page, sheet, 1);
|
||||
// unset reads as omp's default, off
|
||||
assert.deepEqual(await rowsIn(page, sheet), [["advisor_review", w.names[0], w.review, "off"]]);
|
||||
await opt(page, sheet, "advisor_review", "turn").click();
|
||||
await waitRows(page, sheet, 3);
|
||||
assert.deepEqual(sets, [{ agent: "omp", field: "advisor_review", value: "turn" }]);
|
||||
await opt(page, sheet, "advisor_wait", "strict").click();
|
||||
await page.waitForFunction((s) => document.querySelector(s + ' .row.pref.ag-advisor[data-key="advisor_wait"] .opt.on')?.dataset.seg === "strict", sheet);
|
||||
for (let i = 0; sets.length < 2 && i < 100; i++) await page.waitForTimeout(50);
|
||||
assert.deepEqual(sets[1], { agent: "omp", field: "advisor_wait", value: "strict" });
|
||||
// off again: the two go
|
||||
await opt(page, sheet, "advisor_review", "off").click();
|
||||
await waitRows(page, sheet, 1);
|
||||
assert.deepEqual(sets[2], { agent: "omp", field: "advisor_review", value: "off" });
|
||||
assert(await page.locator("#modal .dialog").evaluate((d) => d.scrollWidth <= d.clientWidth + 1), `${lang}: the sheet fits 360`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user