sumo-agents 0.7.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -0
- package/README.md +43 -20
- package/package.json +2 -1
- package/prompts/scribe.md +1 -1
- package/src/apply.mjs +16 -12
- package/src/auth.mjs +2 -2
- package/src/card.mjs +3 -2
- package/src/catalog.mjs +100 -13
- package/src/chat.mjs +71 -16
- package/src/check.mjs +17 -15
- package/src/cli.mjs +21 -11
- package/src/cost.mjs +2 -4
- package/src/cursor.mjs +405 -0
- package/src/db.mjs +24 -13
- package/src/dream.mjs +2 -2
- package/src/jobs.mjs +32 -14
- package/src/ledger.mjs +4 -3
- package/src/loop.mjs +124 -73
- package/src/mcp.mjs +7 -9
- package/src/memeval.mjs +2 -3
- package/src/memory.mjs +5 -4
- package/src/model.mjs +5 -0
- package/src/page.mjs +1 -0
- package/src/prime.mjs +11 -7
- package/src/rebuild.mjs +8 -3
- package/src/redact.mjs +13 -1
- package/src/route.mjs +263 -56
- package/src/sandbox.mjs +86 -20
- package/src/scan.mjs +4 -2
- package/src/scorecard.mjs +419 -0
- package/src/scribe.mjs +82 -38
- package/src/sessions.mjs +9 -7
- package/src/settings.mjs +114 -37
- package/src/setup.mjs +33 -14
- package/src/spool.mjs +68 -43
- package/src/tools.mjs +170 -77
- package/src/ui.mjs +14 -5
- package/src/verify.mjs +68 -12
- package/src/worktree.mjs +23 -16
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,94 @@ What each release changed for you. The commit of each version has the full detai
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## 0.8.0 — 2026-11-18
|
|
8
|
+
|
|
9
|
+
- **Cursor's models, for chats and jobs.** With `CURSOR_API_KEY` exported, Discover asks Cursor too and switches on
|
|
10
|
+
Composer 2.5 and Grok 4.7 when it lists them. They sit beside Claude's in `/model`, Chat › Model, the jobs' smallest
|
|
11
|
+
model and auto, and run through the Cursor SDK (`@cursor/sdk`, a new dependency) at their standard variants, never
|
|
12
|
+
Fast. Cursor runs the loop; Sumo's own tools — the shell, the editor, the job's tools, the MCP servers — answer it
|
|
13
|
+
through the same approvals, guard and sandbox as on Claude, with `/undo` keeping what the editor changed. Of Cursor's
|
|
14
|
+
own tools it keeps only web search and fetch, and only where Claude has them — the chat and scouts; its file and shell
|
|
15
|
+
tools are given no disk, and its agents live in a folder of Sumo's own, so nothing of the SDK runs git or a program
|
|
16
|
+
from your PATH in your project. A Cursor job gets the same warnings near its budget and time, and the same stops for
|
|
17
|
+
a repeated call, a loop or declined calls, as one on Claude; what you tell a running job reaches it; and nothing a
|
|
18
|
+
run started outlives it. Its web search is unseen, so a conversation or scout that has it is taken to have read the
|
|
19
|
+
web. Each request is priced at Cursor's list rates in the ledger. The key is kept from the model's shell and
|
|
20
|
+
redacted wherever it would be written, and `.cursor` joins the guarded files.
|
|
21
|
+
- **Claude and Cursor in one conversation.** `/model` and auto move a chat between the two at any turn. What a turn on
|
|
22
|
+
Cursor did joins the conversation as it would on Claude — each call and what came back, then the reply — so Claude
|
|
23
|
+
knows what was done and read; a turn back on Cursor is told what was said since, in words, by the same Cursor agent,
|
|
24
|
+
also after the chat moves into a project; an agent Cursor no longer has is replaced by a new one told the whole
|
|
25
|
+
conversation. Pictures you paste go to Cursor too. A `/handoff` from Cursor is written by
|
|
26
|
+
Sonnet. In a shell without `CURSOR_API_KEY` Cursor's models are not offered or routed to, and asking for one says why.
|
|
27
|
+
- **Routing reads published benchmarks, not a rule.** Discover, and the first `sumo setup`, fetch three benchmarks
|
|
28
|
+
once and save them: CursorBench as Epoch AI collects it, LMArena's agent board and Artificial Analysis's
|
|
29
|
+
Intelligence Index via modelgrep. No key is needed and no model reads them. Each is turned into a place among
|
|
30
|
+
Sumo's models before anything is averaged. The local router now only sorts the work; code picks the cheapest model
|
|
31
|
+
and effort whose score clears the bar for it, at the effort the work's size asks for, over Claude's and Cursor's
|
|
32
|
+
models alike. Harder, larger or risky work never gets a lower-scoring route than easier work of the same kind, and a
|
|
33
|
+
retry climbs to a route that scores above the one that failed. `sumo models` shows the scores, and every route says
|
|
34
|
+
why it was picked. `/scorecard` in the chat fetches them again and shows each step: every request with its status,
|
|
35
|
+
size and time, the rows kept and left out, and where each source placed the models. Without a scorecard the router
|
|
36
|
+
chooses Claude's models by the old rule.
|
|
37
|
+
- **A route is priced by what your jobs cost.** Neither API gives a cost back here, so routing reads the ledger: a
|
|
38
|
+
route's own average over its finished jobs of the same kind, else the benchmarks' cost of a task scaled to the size
|
|
39
|
+
of your jobs, else your typical job at the model's list prices. A job that failed before anything was billed is not
|
|
40
|
+
a price, and prices of different kinds are never compared. On today's benchmarks Claude's models win every kind of
|
|
41
|
+
work on score and price; Cursor's are picked once your own jobs show them cheaper.
|
|
42
|
+
- **The editor cannot be raced into writing elsewhere.** A file swapped for a link while the editor worked on it could
|
|
43
|
+
have its change written through the link — into `.git/config`, say, which git then runs outside the sandbox — and the
|
|
44
|
+
record `/undo` keeps could be pointed there the same way. Where a change lands is now decided once, at the checks,
|
|
45
|
+
the file is read and written through that one descriptor, and `/undo` keeps the file that was written. A hard link
|
|
46
|
+
reached through a link is asked about as the hard link is, and a FIFO or device is refused at once instead of
|
|
47
|
+
freezing the chat.
|
|
48
|
+
- **Sumo's home is no longer the sandboxed shell's to write.** The shell could plant what Sumo later trusts there: an
|
|
49
|
+
`/undo` record that your next `/undo` would write into `.git/config`, a saved session `/resume` would load as your
|
|
50
|
+
words, a memory-pass lock that stopped filing without a word, a backup, the record that a job read the web. Now the
|
|
51
|
+
shell writes the project (or scratch) and the temporary folders, never Sumo's home, and its logs, backups and
|
|
52
|
+
history are kept from it even where the home sits in a writable place. A saved session is picked up only when the
|
|
53
|
+
journal knows it, and a job's outside reads are kept in the database.
|
|
54
|
+
- **What the sandboxed shell may not write, it may not create either.** A guarded file that did not exist yet —
|
|
55
|
+
`.envrc`, `.claude/settings.json`, `.npmrc` and the rest — could be created by the shell, also through a link inside
|
|
56
|
+
the project. Now each is guarded by its path whether it exists or not, and by where it lands. A repository's config
|
|
57
|
+
and hooks are git's to run later outside the sandbox — your prompt's `git status`, an editor — so the shell makes
|
|
58
|
+
none: not a nested repository, not one in a project that has none (`git init`, which a template can fill); it is a
|
|
59
|
+
question for you, or a refusal where nobody can be asked. Sumo's own git never runs an fsmonitor, a hook or a submodule's
|
|
60
|
+
config, wherever they came from. The log of a command left in the background is made new in the temporary folder,
|
|
61
|
+
never through a link planted at its name, which would have had Sumo append the command's output wherever it led.
|
|
62
|
+
- **Sumo's own credentials stay out of everything written.** Each is redacted by its value, whatever its shape, and an
|
|
63
|
+
MCP server's `${NAME}` can no longer name one.
|
|
64
|
+
- **A new failure in an already-red suite is found, whatever the runner.** Failures are now named with their file or
|
|
65
|
+
package, pytest's `ERROR` lines and go's build failures are read, and the runner's own counts must be accounted for
|
|
66
|
+
by the names, or the worker stays open for you. `cargo test --no-fail-fast` runs every target, and vitest's timings
|
|
67
|
+
no longer make a test look new. A DONE that cannot be checked here is asked about, not finished FAILED and retried.
|
|
68
|
+
A broken link or an editable install pointing outside the project no longer makes a worktree look shared.
|
|
69
|
+
- **`/undo` never gets stuck.** A file rewritten in place by `sed -i`, a formatter or an editor's safe save blocked
|
|
70
|
+
every undo for good. Files are now compared by what they hold; a turn whose file you changed since is refused once,
|
|
71
|
+
and the next `/undo` lets it go and keeps your file, so earlier turns can still be undone.
|
|
72
|
+
- **Memory keeps what it should and says when it stops.** A statement a rebuild let go can be filed again; only your
|
|
73
|
+
letting go keeps it out. Rewording memories on the page no longer pauses filing, and a pause is said in the block.
|
|
74
|
+
A lock left by a pass that ended is taken over, `sumo memory run` exits 1 when another pass holds it, and the check
|
|
75
|
+
fails on one held over half an hour. Every call to a hosted model is in the ledger, and a rebuild from the model's
|
|
76
|
+
shell reads only the newest few conversations, never on a hosted model. A line a hook sets aside while the spool is
|
|
77
|
+
read is never lost. In a turn of three lines or more only the first and last line are quoted as yours. A database
|
|
78
|
+
that cannot be copied aside first is not migrated.
|
|
79
|
+
- **The settings page.** A new local model is downloaded before the setting changes, so the old one keeps working
|
|
80
|
+
meanwhile and a failed download changes nothing; `sumo config` waits for a download and says how it went. A change
|
|
81
|
+
of effort or model moves only that part of the chat's route. A server's tools changed elsewhere are said, never a
|
|
82
|
+
crash. A plain variable such as `LOG_LEVEL=info` is taken as it is. The cursor shows under `NO_COLOR`. `sumo doctor`
|
|
83
|
+
stops failing on an `mcp.json` you have removed.
|
|
84
|
+
- **A release is published by you, not by a merge.** Changes reach `main` only through a pull request, and merging one
|
|
85
|
+
only runs the suite. A version reaches
|
|
86
|
+
npm when you publish a GitHub Release tagged `v` and the version in package.json, on a commit on main: the suite runs
|
|
87
|
+
again on that commit, and the publish waits for your approval in the `release` environment. A prerelease goes to
|
|
88
|
+
npm's `next` tag, and carries a version like 0.9.0-rc.1.
|
|
89
|
+
- **Smaller.** A session started inside a project is told, in its first block, that it works there: told only the list
|
|
90
|
+
and where work with no project goes, a model once put a file for the project in scratch. `/context` counts turns and calls on every model, piped too. The editor's answer to a call without a
|
|
91
|
+
command names the commands it has. Output a check prints in a shape made to make a pattern backtrack is read at once.
|
|
92
|
+
The suite waits by the clock, not by a count of naps, so it no longer fails on a loaded machine, CI's or across
|
|
93
|
+
midnight UTC.
|
|
94
|
+
|
|
7
95
|
## 0.7.2 — 2026-11-18
|
|
8
96
|
|
|
9
97
|
- **A new failure can no longer hide in a suite that was already red.** A check failing when a worker began, and
|
package/README.md
CHANGED
|
@@ -7,9 +7,11 @@ you tell it, and hands big work to background jobs that are checked before they
|
|
|
7
7
|
- **Memory that lasts.** Your preferences, project rules and where you left off are kept locally and
|
|
8
8
|
loaded into every new session. You never explain the same thing twice.
|
|
9
9
|
- **Background jobs.** Big, parallel or reading-heavy work goes to scout, worker and reviewer jobs. A
|
|
10
|
-
local model
|
|
10
|
+
local model sorts each one and code picks the cheapest model and effort that published benchmarks score high
|
|
11
|
+
enough for it, so the dearest model is never the default.
|
|
11
12
|
- **Checked results.** A worker cannot report done until the project's own tests and linters agree.
|
|
12
|
-
- **Its own loop.** Sumo talks to the Anthropic API directly and owns its prompt, tools, context and cost.
|
|
13
|
+
- **Its own loop.** Sumo talks to the Anthropic API directly and owns its prompt, tools, context and cost. With a
|
|
14
|
+
Cursor key, Cursor's models run chats and jobs too, on Sumo's tools.
|
|
13
15
|
|
|
14
16
|
Everything it learns lives in `~/.sumo-agents/` on each machine, never in a repository, so a work laptop
|
|
15
17
|
and a personal one learn separately.
|
|
@@ -18,7 +20,7 @@ and a personal one learn separately.
|
|
|
18
20
|
|
|
19
21
|
You need Node 24.6+, [llama.cpp](https://github.com/ggml-org/llama.cpp) (`brew install llama.cpp`)
|
|
20
22
|
for the local model, and `ANTHROPIC_API_KEY` or a `CLAUDE_CODE_OAUTH_TOKEN` (from `claude setup-token`) in
|
|
21
|
-
your environment.
|
|
23
|
+
your environment. `CURSOR_API_KEY` is optional: it adds Cursor's models.
|
|
22
24
|
|
|
23
25
|
```sh
|
|
24
26
|
npm install -g sumo-agents
|
|
@@ -55,16 +57,16 @@ are covered in [Install](https://github.com/sumododda/sumo-agents/wiki/Install).
|
|
|
55
57
|
- Each step shows as `⏺ Bash(npm test)` with what came back under it: a failed run by the lines that say what
|
|
56
58
|
failed, a test run that passed in one row (`✓ 14 passed`). Your messages stand behind a bar, a question to
|
|
57
59
|
approve in a yellow frame. `chat.screen still` stops the colours flowing through the working line.
|
|
58
|
-
- Ctrl-R searches what you sent before. `/context` shows how full the context is and what
|
|
60
|
+
- Ctrl-R searches what you sent before. `/context` shows how full the context is, the session's turns and calls, and what it has cost.
|
|
59
61
|
`/export` writes the conversation to a Markdown file.
|
|
60
62
|
|
|
61
63
|
## Good to know
|
|
62
64
|
|
|
63
65
|
- Destructive commands (`rm -rf ~`, `git reset --hard`, dropping a table) and commands that print secrets
|
|
64
66
|
are refused in code before they run. `! <command>` runs one yourself.
|
|
65
|
-
- On macOS the agent's shell runs in a sandbox: it writes only in the project, the temporary folders
|
|
66
|
-
|
|
67
|
-
plain `sumo …` command it runs is run as Sumo itself, where what only you may change is refused. A write the
|
|
67
|
+
- On macOS the agent's shell runs in a sandbox: it writes only in the project (or scratch), the temporary folders
|
|
68
|
+
and the tool caches — never in Sumo's home, nor in git's hooks or config, nor a repository it makes (`git init`,
|
|
69
|
+
or a nested one). A plain `sumo …` command it runs is run as Sumo itself, where what only you may change is refused. A write the
|
|
68
70
|
sandbox blocks is put to you once to run outside it. Shell › Network, on the settings page, keeps it off the network.
|
|
69
71
|
- An MCP server that takes only a registered app's login, as Slack's official one does, is reached through
|
|
70
72
|
Claude Code's: `claude mcp add --transport http --scope user slack https://mcp.slack.com/mcp`, `claude mcp login slack`,
|
|
@@ -75,10 +77,12 @@ are covered in [Install](https://github.com/sumododda/sumo-agents/wiki/Install).
|
|
|
75
77
|
your home, say — is put to you with the change: once, or that file or its directory for the rest of the
|
|
76
78
|
session, where the shell may then write too. The home itself is never opened that way. A file something
|
|
77
79
|
else reads later — your shell's rc files, `.envrc`, `.npmrc`, `.vscode`, `.mcp.json` —
|
|
78
|
-
is changed only when you say so, each time, under any spelling of its name
|
|
80
|
+
is changed only when you say so, each time, under any spelling of its name; the sandboxed shell may not write
|
|
81
|
+
one, nor create one that is not there yet.
|
|
79
82
|
- Any of these questions can be refused with your reason: `r`, type why, Enter. The model reads it as what to
|
|
80
83
|
do instead. Questions from several jobs queue, and the one shown says how many wait behind it.
|
|
81
|
-
- The agent's shell gets your whole environment except
|
|
84
|
+
- The agent's shell gets your whole environment except Sumo's own credentials, Anthropic's and `CURSOR_API_KEY`,
|
|
85
|
+
which are also redacted by their value wherever they would be written. It never waits on a prompt,
|
|
82
86
|
stops a command silent for 2 minutes (`timeout 600 <cmd>` asks for longer), and runs a command ending in
|
|
83
87
|
`&` in the background with its own log.
|
|
84
88
|
- A worker's first DONE is answered with its task as a numbered checklist beside its change, one answer per
|
|
@@ -87,14 +91,30 @@ are covered in [Install](https://github.com/sumododda/sumo-agents/wiki/Install).
|
|
|
87
91
|
A second worker on a git project works in a worktree of its own. If no check runs, or a failing suite’s results cannot be compared with its baseline, the worker stays open. After inspecting the logs, you can record a manual acceptance with `sumo job finish <id> --status DONE --accept "<reason>"` and the report on stdin.
|
|
88
92
|
- A job's run stops at $10 or 60 minutes (`jobs.budget`, `jobs.minutes`). `sumo cost` shows where the money went,
|
|
89
93
|
and why the cache was written again when it was.
|
|
90
|
-
- `/undo` restores the last editor turn.
|
|
94
|
+
- `/undo` restores the last editor turn. A file changed since it was written, by you or a formatter, is named and the
|
|
95
|
+
turn kept; `/undo` again lets that turn go, keeps your file, and goes on to the turn before.
|
|
91
96
|
- Only your words become memory. Web pages, files and tool output are never filed as yours.
|
|
92
|
-
- The local model, Qwen3-4B through llama.cpp,
|
|
97
|
+
- The local model, Qwen3-4B through llama.cpp, sorts jobs for routing and writes memory for $0 and sleeps when idle.
|
|
98
|
+
- Routing reads a scorecard of published benchmarks, fetched once by Discover and the first `sumo setup`, and saved: [CursorBench](https://cursor.com/cursorbench)
|
|
99
|
+
as [Epoch AI](https://epoch.ai/benchmarks) collects it, [LMArena](https://huggingface.co/datasets/lmarena-ai/leaderboard-dataset)'s
|
|
100
|
+
agent board and [Artificial Analysis](https://artificialanalysis.ai)'s Intelligence Index via [modelgrep](https://modelgrep.com/api).
|
|
101
|
+
The local model sorts the work; code picks the cheapest model and effort, Claude's or Cursor's, that scores high enough, at the
|
|
102
|
+
effort the work's size asks for. Harder, larger or risky work never gets a lower-scoring route than easier work of its kind, and a
|
|
103
|
+
retry climbs above the route that failed. A route is priced by what your own jobs of that kind cost, from the ledger, else by the
|
|
104
|
+
benchmarks. `sumo models` shows the scores and every route says why; `/scorecard` in the chat fetches them again and shows each
|
|
105
|
+
step: every request, what was kept, where each source placed the models. Without a scorecard the router picks Claude's models by its old rule.
|
|
106
|
+
- With `CURSOR_API_KEY` exported, Discover (on the settings page) switches on Cursor's Composer 2.5 and Grok 4.7: `/model composer`,
|
|
107
|
+
Chat › Model, the jobs' smallest model and auto offer them beside Claude's. They run through the Cursor SDK at their standard
|
|
108
|
+
variants, never Fast, on Sumo's own shell, editor, job tools and MCP servers, behind the same approvals and sandbox. Of Cursor's
|
|
109
|
+
own tools only web search and fetch are kept, and only where Claude has them, in the chat and scouts; Sumo cannot see them, so
|
|
110
|
+
a conversation or scout on Cursor counts as having read the web. Its agents live in a folder of Sumo's own, so nothing of the
|
|
111
|
+
SDK runs git or a program from your PATH in your project. `/model` and auto move a chat between Claude and Cursor at any turn, each told what the other did. Each request
|
|
112
|
+
is priced at Cursor's list rates. Without the key they are not offered, and asking for one says why.
|
|
93
113
|
- A crash is written, redacted, to `~/.sumo-agents/logs/crash-*.log`. `sumo doctor --report` prints everything a
|
|
94
114
|
bug report needs, redacted, and sends nothing; the logs that hold what you said are counted there, not quoted.
|
|
95
115
|
`sumo doctor --fix` makes the home's files private again.
|
|
96
116
|
- The database is copied beside itself before an upgrade migrates it (`memory.db.pre-v<N>.bak`, the last three),
|
|
97
|
-
and weekly into `~/.sumo-agents/backups`. A database that will not open is said with the newest copy:
|
|
117
|
+
and is not migrated when the copy cannot be made; weekly it is copied into `~/.sumo-agents/backups`. A database that will not open is said with the newest copy:
|
|
98
118
|
`sumo backup restore` puts it back (or `sumo backup restore <file>`), keeping the damaged one aside. Over a
|
|
99
119
|
database that is fine, it says what would be lost and asks first (`--yes` in a script).
|
|
100
120
|
- `sumo forget <id> --purge` erases a memory for good, with the turn it came from and every turn and reply that says
|
|
@@ -103,7 +123,7 @@ are covered in [Install](https://github.com/sumododda/sumo-agents/wiki/Install).
|
|
|
103
123
|
that only mentions part of it stays: `sumo search "<words>" --turns` finds it, and `sumo forget --purge t12` erases
|
|
104
124
|
that one turn or reply (`r3`) the same way.
|
|
105
125
|
- `NO_COLOR=1` turns colour off everywhere, the chat screen included; the cursor in the box and the changed part of an
|
|
106
|
-
edit stay in reverse video, which is not colour. `sumo
|
|
126
|
+
edit stay in reverse video, which is not colour. `sumo version` (or `--version`) says which sumo this is; in the standalone binary only `sumo version` does, since Bun answers `--version` itself.
|
|
107
127
|
|
|
108
128
|
## Configuration
|
|
109
129
|
|
|
@@ -117,21 +137,23 @@ first. Piped, with a key (`sumo config jobs.review`) or `--json`, `sumo config`
|
|
|
117
137
|
|---|---|---|
|
|
118
138
|
| Chat › Spend notice (`chat.budget`) | `5` | Dollars a chat session costs before the screen says so; `0` never. |
|
|
119
139
|
| Chat › Effort (`chat.effort`) | `medium` | Effort when the chat model is fixed. |
|
|
120
|
-
| Chat › Model (`chat.model`) | `opus` | What the chat runs on. `auto`
|
|
140
|
+
| Chat › Model (`chat.model`) | `opus` | What the chat runs on. `auto` picks per turn, over Claude's and Cursor's models. Cursor's (`composer`, `grok`) need `CURSOR_API_KEY`. |
|
|
121
141
|
| Chat › Notify (`chat.notify`) | `on` | `off` stops the bell and the notification when a long turn ends behind another window. |
|
|
122
142
|
| Chat › Screen (`chat.screen`) | `full` | `still` keeps the working line's spinner still. `plain` draws the chat for a screen reader: words, not pictures (no logo), ASCII marks (`x` a failure, `*` at work, `>` your prompt), no rule over the box or bar beside a question, and nothing that moves or ticks. |
|
|
123
143
|
| Jobs › Advisor (`jobs.advisor`) | `off` | `on` lets a job ask the next model up for advice. |
|
|
124
144
|
| Jobs › Budget (`jobs.budget`) | `10` | Dollars one job may spend before it is stopped; `0` for no cap. |
|
|
125
|
-
| Jobs › Smallest model (`jobs.floor`) | `haiku` | The smallest model a job may run on
|
|
145
|
+
| Jobs › Smallest model (`jobs.floor`) | `haiku` | The smallest model a job may run on, up the ladder `haiku`, `composer`, `grok`, `sonnet`, `opus`, `fable`: `sonnet` keeps every job off Haiku and Cursor's models, `opus` puts them all on Opus or Fable. |
|
|
126
146
|
| Jobs › Time limit (`jobs.minutes`) | `60` | Minutes one job may run before it is stopped; `0` for no limit. |
|
|
127
147
|
| Jobs › Review (`jobs.review`) | `risky` | Which verified work gets a reviewer without asking: `risky`, `all` or `off`. |
|
|
128
148
|
| Memory › Filed by (`memory.model`) | `local` | What the memory pass runs on: `local`, a model name, or `off` (the chat then saves what lasts itself). |
|
|
129
|
-
| Memory › Local model (`model.url`) | `https://huggingface.co/Qwen/Qwen3-4B-GGUF/resolve/main/Qwen3-4B-Q4_K_M.gguf` | The local model's download address, a `.gguf` file — a mirror's too. Downloaded
|
|
149
|
+
| Memory › Local model (`model.url`) | `https://huggingface.co/Qwen/Qwen3-4B-GGUF/resolve/main/Qwen3-4B-Q4_K_M.gguf` | The local model's download address, a `.gguf` file — a mirror's too. Downloaded first: the model in use stays until it is here, and a failed download changes nothing. |
|
|
130
150
|
| Projects › New ones go in (`projects.home`) | `~` | Where new projects are created. |
|
|
131
151
|
| Shell › Network (`shell.network`) | `on` | `off` keeps the sandboxed shell to this machine. |
|
|
132
152
|
| Shell › Sandbox (`shell.sandbox`) | `on` | The agent's shell in the macOS sandbox. Read when a chat or job starts. |
|
|
133
153
|
|
|
134
|
-
Under them, **API models** has a switch for each model and **Discover**, which asks the API which this login can use
|
|
154
|
+
Under them, **API models** has a switch for each model and **Discover**, which asks the API which this login can use,
|
|
155
|
+
asks Cursor too when `CURSOR_API_KEY` is set, and fetches the scorecard routing reads. Cursor's models start off;
|
|
156
|
+
Discover turns on the ones Cursor lists for the key.
|
|
135
157
|
**MCP servers** lists each server: Enter shows its tools, each switched to run without asking or to ask first;
|
|
136
158
|
**+ add a server** takes a pasted command or address, or brings servers in from Claude Code. A token is never typed
|
|
137
159
|
into the page: a header or variable names it as `${NAME}`, filled from your shell. The environment variables are in
|
|
@@ -181,9 +203,10 @@ tests; `--hard` runs the harder set, `--no-guides` and `--advisor` change one th
|
|
|
181
203
|
`node probes/paired-eval.mjs --route sonnet/medium --budget-usd 2` runs the same tasks through sumo and Claude Code
|
|
182
204
|
for a side-by-side, within that total.
|
|
183
205
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
206
|
+
Changes reach `main` only through a pull request. Every pull request and merge runs the suite on macOS, the platform sumo runs on, with Node 24, and publishes nothing. A
|
|
207
|
+
version reaches npm only when the maintainer publishes a GitHub Release tagged `v` and the version in `package.json`, on a
|
|
208
|
+
commit on `main`: the suite runs again on that commit, the publish waits in the `release` environment for the maintainer's
|
|
209
|
+
approval, then goes to npm with provenance and no stored token. A prerelease (`0.9.0-rc.1`) goes to npm's `next` tag. How CI is locked down is in
|
|
187
210
|
[SECURITY.md](SECURITY.md#releases-and-the-supply-chain). Probes, the coding eval and the repository layout are in
|
|
188
211
|
[Development](https://github.com/sumododda/sumo-agents/wiki/Development).
|
|
189
212
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sumo-agents",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "One repo you talk to: a local memory engine and working process for coding agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@anthropic-ai/sdk": "^1.3.0",
|
|
42
|
+
"@cursor/sdk": "^1.4.1",
|
|
42
43
|
"ink": "^8.0.0",
|
|
43
44
|
"react": "^19.3.1"
|
|
44
45
|
}
|
package/prompts/scribe.md
CHANGED
|
@@ -6,7 +6,7 @@ The test for every operation: would a future conversation go better for knowing
|
|
|
6
6
|
From the USER's turns only:
|
|
7
7
|
- add — a standing rule, a decision or a durable fact the user stated. `type` is preference (how they want things done), decision (a choice that was made, with its reason if given) or fact (something true about them, their setup or a project that the code itself cannot tell you).
|
|
8
8
|
- supersede — the same fields, plus `old`: the number of the existing memory shown above that it replaces.
|
|
9
|
-
`turn` is the N of the [tN] it was said in. `quote` is the statement itself: copy the user's exact words from that turn, letter for letter, typos included. You do not rewrite, summarise, correct or translate: what the user typed around the quote — the turn, or its paragraph when the turn is long — is stored as the memory, whole and exactly as typed, so a quote that is not in that turn is no operation.
|
|
9
|
+
`turn` is the N of the [tN] it was said in. `quote` is the statement itself: copy the user's exact words from that turn, letter for letter, typos included. You do not rewrite, summarise, correct or translate: what the user typed around the quote — the turn, or its paragraph when the turn is long — is stored as the memory, whole and exactly as typed, so a quote that is not in that turn is no operation. In a turn of three lines or more, quote its first or last line: the lines between are taken for something pasted.
|
|
10
10
|
A quote is one statement on one line, at most 40 words, and says something by itself: "ok do that" and "yes sounds good" agree with the assistant and state nothing — no operation. One operation per paragraph.
|
|
11
11
|
`scope`: `project:<name>` when the statement is about that project, or was made while working in it and is not clearly general ("here", "this repo"); `global` only for how the user wants things done everywhere.
|
|
12
12
|
`keys`: up to 6 search terms the statement is about that its own words do not use (a rule about eslint: lint, linter), or [].
|
package/src/apply.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import { asksForWork, coverage, overlap, saysAs, sharedStems, standsAlone, words
|
|
|
24
24
|
* The rules below as a version: part of the extractor's version (ledger.mjs), so memories derived under other rules
|
|
25
25
|
* can be told apart and rebuilt. Bump it whenever what is accepted, dropped or replaced here changes.
|
|
26
26
|
*/
|
|
27
|
-
export const APPLY_RULES = '2026-11-18.
|
|
27
|
+
export const APPLY_RULES = '2026-11-18.7';
|
|
28
28
|
|
|
29
29
|
const STATED_TYPES = ['preference', 'fact', 'decision'];
|
|
30
30
|
const BODY_MAX = 300;
|
|
@@ -46,8 +46,8 @@ const SAME_MATTER = 0.75;
|
|
|
46
46
|
const QUOTE_MAX_WORDS = 40;
|
|
47
47
|
/** A memory the chat saved from a turn is in what is filed from that turn when this share of its words is. */
|
|
48
48
|
const SAID_HERE = 0.8;
|
|
49
|
-
/** A turn of this many
|
|
50
|
-
const
|
|
49
|
+
/** A turn of this many lines or more holds something pasted: only its first and last line are taken as the user's own. */
|
|
50
|
+
const PASTED_LINES = 3;
|
|
51
51
|
/** What stands for a line break in a memory's one line: a paragraph of several lines is kept as it was typed, on one. */
|
|
52
52
|
const LINE_BREAK = ' / ';
|
|
53
53
|
/** A turn past this length is mostly something pasted: only what opens or closes it is taken as the user's own. */
|
|
@@ -135,17 +135,19 @@ function standsApart(paragraphs, i) {
|
|
|
135
135
|
|
|
136
136
|
/**
|
|
137
137
|
* What of a turn a quote stands for, as the user's own words: `{ paragraph }`, the body to store — or `{ why }` it
|
|
138
|
-
* cannot be taken. A quote sits on one line, in a paragraph that holds nothing pasted
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* a turn long enough to be mostly a paste, and only one that stands apart
|
|
138
|
+
* cannot be taken. A quote sits on one line, in a paragraph that holds nothing pasted, and in a turn of three lines or
|
|
139
|
+
* more on the first or the last: a page pasted between what the user typed is lines like any other, however short
|
|
140
|
+
* ("the README says:", the page's line, "thoughts"). A turn that fits in one memory, and holds nothing pasted, is
|
|
141
|
+
* taken whole: a line break between what negates and what is negated cuts nothing off. Of a longer turn the quote's
|
|
142
|
+
* paragraph is taken — opening or closing a turn long enough to be mostly a paste, and only one that stands apart
|
|
143
|
+
* from the paragraph before it.
|
|
143
144
|
*/
|
|
144
145
|
function placeOf(text, quote) {
|
|
145
146
|
const sought = folded(quote);
|
|
146
147
|
const paragraphs = paragraphsOf(text);
|
|
147
148
|
const whole = paragraphs.map((p) => p.body).join(LINE_BREAK);
|
|
148
149
|
const fits = whole.length <= BODY_MAX && !paragraphs.some((p) => p.pasted);
|
|
150
|
+
const lines = paragraphs.flatMap((p) => p.lines);
|
|
149
151
|
const why = { pasted: false, inner: false, middle: false, leaning: false };
|
|
150
152
|
for (const [i, p] of paragraphs.entries()) {
|
|
151
153
|
for (const line of p.lines) {
|
|
@@ -153,8 +155,8 @@ function placeOf(text, quote) {
|
|
|
153
155
|
if (from === -1) continue;
|
|
154
156
|
const [starts, ends] = [line.start + from, line.start + from + sought.length];
|
|
155
157
|
if (p.pasted) why.pasted = true;
|
|
158
|
+
else if (lines.length >= PASTED_LINES && line !== lines[0] && line !== lines.at(-1)) why.inner = true;
|
|
156
159
|
else if (fits) return { paragraph: whole };
|
|
157
|
-
else if (paragraphs.length >= PASTED_PARAGRAPHS && i !== 0 && i !== paragraphs.length - 1) why.inner = true;
|
|
158
160
|
else if (text.length > LONG_TURN_CHARS && ends > LONG_TURN_OWN && starts < text.length - LONG_TURN_OWN) why.middle = true;
|
|
159
161
|
// One too long to keep is said to be that, below: the reason that needs no reading of its first letter.
|
|
160
162
|
else if (p.body.length <= BODY_MAX && !standsApart(paragraphs, i)) why.leaning = true;
|
|
@@ -162,7 +164,7 @@ function placeOf(text, quote) {
|
|
|
162
164
|
}
|
|
163
165
|
}
|
|
164
166
|
if (why.middle) return { why: `the quote is from the middle of a long turn: past ${LONG_TURN_CHARS.toLocaleString('en-US')} characters only its first and last ${LONG_TURN_OWN} are taken as the user's own` };
|
|
165
|
-
if (why.inner) return { why: "the quote is from a
|
|
167
|
+
if (why.inner) return { why: "the quote is from a line in the middle of a turn of three lines or more: only its first and last line are taken as the user's own" };
|
|
166
168
|
if (why.leaning) return { why: 'the paragraph does not stand by itself (it follows one that leads into it, is a list, or opens as a continuation), and the turn is too long to keep whole' };
|
|
167
169
|
if (why.pasted) return { why: 'the quote is from a pasted block — code, or a quoted line — or the paragraph it sits in holds one' };
|
|
168
170
|
return { why: 'the quote runs across a line break: a statement is on one line' };
|
|
@@ -249,11 +251,13 @@ function lookalike(db, scope, body, exclude) {
|
|
|
249
251
|
/**
|
|
250
252
|
* The same sentence is often proposed twice from one turn — once by a retry, once by the chat model saving it
|
|
251
253
|
* directly, once by an extractor from before memories were the user's own sentences. A repeat is the same statement,
|
|
252
|
-
* or one drawn from the same words: its quote holds this one's, or this one's holds its.
|
|
254
|
+
* or one drawn from the same words: its quote holds this one's, or this one's holds its. Only a memory that still
|
|
255
|
+
* holds it, or one a later statement replaced, is a repeat: one let go is the user's (`letGo` keeps that out) or else
|
|
256
|
+
* a rebuild's or a migration's, which must not keep the user's own words out for ever.
|
|
253
257
|
*/
|
|
254
258
|
function savedFromTurn(db, turnId, scope, body, exclude, quote) {
|
|
255
259
|
if (turnId === null) return null;
|
|
256
|
-
const fromTurn = db.prepare(`SELECT * FROM memories WHERE source_turn = ? AND scope = ? AND state
|
|
260
|
+
const fromTurn = db.prepare(`SELECT * FROM memories WHERE source_turn = ? AND scope = ? AND state IN ('active', 'superseded') AND id IS NOT ?`).all(turnId, scope, exclude ?? null);
|
|
257
261
|
const said = typeof quote === 'string' ? normalize(quote) : '';
|
|
258
262
|
const sameWords = (m) => {
|
|
259
263
|
const theirs = m.source_quote ? normalize(m.source_quote) : '';
|
package/src/auth.mjs
CHANGED
|
@@ -28,8 +28,8 @@ export const effortOnly = (m) => m.role === 'system' && Array.isArray(m.content)
|
|
|
28
28
|
// Pin the protocol version so authentication does not depend on a local Claude installation.
|
|
29
29
|
const CLAUDE_CODE_VERSION = '2.1.280';
|
|
30
30
|
|
|
31
|
-
/** The names
|
|
32
|
-
export const CREDENTIAL_NAMES = ['ANTHROPIC_API_KEY', 'CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_AUTH_TOKEN'];
|
|
31
|
+
/** The names Sumo's credentials are read from — Anthropic's, and Cursor's for jobs on its models — and the only names a command run for the model goes without. */
|
|
32
|
+
export const CREDENTIAL_NAMES = ['ANTHROPIC_API_KEY', 'CLAUDE_CODE_OAUTH_TOKEN', 'ANTHROPIC_AUTH_TOKEN', 'CURSOR_API_KEY'];
|
|
33
33
|
|
|
34
34
|
/** Resolve one credential without ever copying it into a child process or output. API keys keep their documented precedence. */
|
|
35
35
|
export function resolveAnthropicCredential(env = process.env) {
|
package/src/card.mjs
CHANGED
|
@@ -27,7 +27,8 @@ const HELD_ASKS = { outside: 'is this right?', shell: 'they never typed this —
|
|
|
27
27
|
* conversation they came from read the web or an MCP server, or because the model saved from its shell what the user
|
|
28
28
|
* never typed; nothing else is held: what the memory pass cannot tie to the user's own words is dropped, not queued
|
|
29
29
|
* as a guess — and notices whose two memories both still stand (superseding
|
|
30
|
-
* or forgetting either settles one)
|
|
30
|
+
* or forgetting either settles one), two that cannot both be true first: a look-alike the user left standing because
|
|
31
|
+
* both hold must not keep a clash out of view. The session-start block asks about everything and the session's own project; a
|
|
31
32
|
* project's card asks about that project, wherever the session was started.
|
|
32
33
|
*/
|
|
33
34
|
export function askLines(db, { scopes, now, held: maxHeld, notices: maxNotices }) {
|
|
@@ -40,7 +41,7 @@ export function askLines(db, { scopes, now, held: maxHeld, notices: maxNotices }
|
|
|
40
41
|
`SELECT n.* FROM notices n
|
|
41
42
|
JOIN memories a ON a.id = n.memory_a AND a.state = 'active' AND a.scope IN (${marks})
|
|
42
43
|
JOIN memories b ON b.id = n.memory_b AND b.state = 'active' AND b.scope IN (${marks})
|
|
43
|
-
ORDER BY n.id LIMIT ?`,
|
|
44
|
+
ORDER BY n.kind = 'contradiction' DESC, n.id LIMIT ?`,
|
|
44
45
|
)
|
|
45
46
|
.all(...scopes, ...scopes, maxNotices);
|
|
46
47
|
for (const n of notices) {
|
package/src/catalog.mjs
CHANGED
|
@@ -18,7 +18,26 @@ export const MODEL_IDS = {
|
|
|
18
18
|
};
|
|
19
19
|
export const MODELS = Object.keys(MODEL_IDS);
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The models Sumo runs through the Cursor SDK (src/cursor.mjs), for chat turns and jobs: the memory pass, the advisor,
|
|
23
|
+
* compaction and hand-offs stay on Claude. Each says what Cursor calls it and the settings it is asked with — the standard variant, never Fast, which
|
|
24
|
+
* Composer defaults to at six times the price; `effort` names the setting Sumo's effort goes in, where the model takes one.
|
|
25
|
+
*/
|
|
26
|
+
export const CURSOR_MODELS = {
|
|
27
|
+
composer: { id: 'composer-2.5', params: [{ id: 'fast', value: 'false' }] },
|
|
28
|
+
grok: { id: 'grok-4.7', params: [{ id: 'context', value: '256k' }, { id: 'fast', value: 'false' }], effort: 'reasoning_effort' },
|
|
29
|
+
};
|
|
30
|
+
/** Every model Sumo knows, Claude's then Cursor's: what the switches, `sumo models` and Discover cover. */
|
|
31
|
+
export const ALL_MODELS = [...MODELS, ...Object.keys(CURSOR_MODELS)];
|
|
32
|
+
/** The models a job may run on, weakest first: the ladder a retry climbs and `jobs.floor` cuts. Cursor's sit above haiku. */
|
|
33
|
+
export const JOB_MODELS = ['haiku', 'composer', 'grok', 'sonnet', 'opus', 'fable'];
|
|
34
|
+
/** How wide a model's name is set in a list, so the columns after it line up: the longest name. */
|
|
35
|
+
export const NAME_WIDTH = Math.max(...ALL_MODELS.map((name) => name.length));
|
|
36
|
+
export const modelId = (model) => MODEL_IDS[model] ?? CURSOR_MODELS[model]?.id ?? model;
|
|
37
|
+
/** A model by the name Sumo calls it, from its name or its API id; one the list does not know, as it was given. */
|
|
38
|
+
export const modelName = (model) => ALL_MODELS.find((name) => name === model || modelId(name) === model) ?? model;
|
|
39
|
+
/** Which way a model is run, by its name or its id: through the Anthropic API, or the Cursor SDK. */
|
|
40
|
+
export const laneOf = (model) => (Object.hasOwn(CURSOR_MODELS, modelName(model)) ? 'cursor' : 'claude');
|
|
22
41
|
|
|
23
42
|
const STATE_KEY = 'models.state';
|
|
24
43
|
const CHECKED_KEY = 'models.checked';
|
|
@@ -28,7 +47,10 @@ const OAUTH_BETA = 'oauth-2025-04-20';
|
|
|
28
47
|
|
|
29
48
|
const day = (now) => String(now).slice(0, 10);
|
|
30
49
|
|
|
31
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Every model's switch and the note that explains it. A Claude model is on, and "not checked", until something is recorded;
|
|
52
|
+
* a Cursor model is off until Discover finds it, since without CURSOR_API_KEY it cannot run at all.
|
|
53
|
+
*/
|
|
32
54
|
export function modelStates(db) {
|
|
33
55
|
let stored = {};
|
|
34
56
|
try {
|
|
@@ -36,29 +58,41 @@ export function modelStates(db) {
|
|
|
36
58
|
} catch {
|
|
37
59
|
stored = {};
|
|
38
60
|
}
|
|
39
|
-
|
|
61
|
+
const fresh = (name) => (laneOf(name) === 'cursor' ? { on: false, note: 'not discovered yet' } : { on: true, note: 'not checked' });
|
|
62
|
+
return Object.fromEntries(ALL_MODELS.map((name) => [name, stored[name] ? { on: stored[name].on !== false, note: stored[name].note ?? fresh(name).note } : fresh(name)]));
|
|
40
63
|
}
|
|
41
64
|
|
|
42
65
|
const writeStates = (db, states) => setMeta(db, STATE_KEY, JSON.stringify(states));
|
|
43
66
|
|
|
44
|
-
/** The models the chat, the router and the passes may use, cheapest first. */
|
|
67
|
+
/** The models the chat, the router and the passes may use, cheapest first: Claude's. */
|
|
45
68
|
export function usableModels(db) {
|
|
46
69
|
const states = modelStates(db);
|
|
47
70
|
return MODELS.filter((name) => states[name].on);
|
|
48
71
|
}
|
|
49
72
|
|
|
73
|
+
/** Whether this shell can run Cursor's models: they need CURSOR_API_KEY, and a switch left on by an earlier Discover does not. */
|
|
74
|
+
export const cursorKeyIn = (env = process.env) => Boolean(env.CURSOR_API_KEY?.trim());
|
|
75
|
+
|
|
76
|
+
/** The models a job or a chat turn may be routed to, weakest first: Claude's that are on, and Cursor's that are on while this shell has its key. */
|
|
77
|
+
export function usableJobModels(db, env = process.env) {
|
|
78
|
+
const states = modelStates(db);
|
|
79
|
+
return JOB_MODELS.filter((name) => states[name].on && (laneOf(name) === 'claude' || cursorKeyIn(env)));
|
|
80
|
+
}
|
|
81
|
+
|
|
50
82
|
/** When the API was last asked which models it has, or null while it never was. */
|
|
51
83
|
export const modelsChecked = (db) => getMeta(db, CHECKED_KEY);
|
|
52
84
|
|
|
53
85
|
/** `name` is a model Sumo knows, or a usage error listing them — after `also`, the other values the setting takes. */
|
|
54
|
-
export function knownModel(name, also = []) {
|
|
55
|
-
if (!
|
|
86
|
+
export function knownModel(name, also = [], models = MODELS) {
|
|
87
|
+
if (!models.includes(name)) throw new UsageError(`no such model "${name}" — one of: ${[...also, ...models].join(', ')}`);
|
|
56
88
|
}
|
|
57
89
|
|
|
58
|
-
/** Why `name` cannot be used right now, with the way out (`orElse` is another one), or null while it
|
|
59
|
-
export function offLine(db, name, orElse) {
|
|
60
|
-
|
|
61
|
-
return `${name} is off — turn it on under API models, on the settings page (sumo config)${
|
|
90
|
+
/** Why `name` cannot be used right now, with the way out (`orElse` is another one), or null while it can. */
|
|
91
|
+
export function offLine(db, name, orElse, env = process.env) {
|
|
92
|
+
const or = orElse ? `, or ${orElse}` : '';
|
|
93
|
+
if (!modelStates(db)[name].on) return `${name} is off — turn it on under API models, on the settings page (sumo config)${or}`;
|
|
94
|
+
if (laneOf(name) === 'cursor' && !cursorKeyIn(env)) return `${name} runs through Cursor, and this shell has no CURSOR_API_KEY — export it in the shell sumo starts from${or}`;
|
|
95
|
+
return null;
|
|
62
96
|
}
|
|
63
97
|
|
|
64
98
|
/** `name` is on, or a usage error saying how to turn it on. */
|
|
@@ -69,7 +103,7 @@ export function assertOn(db, name, orElse) {
|
|
|
69
103
|
|
|
70
104
|
/** Turns one model on or off by hand. */
|
|
71
105
|
export function setModel(db, name, on, now = new Date().toISOString()) {
|
|
72
|
-
knownModel(name);
|
|
106
|
+
knownModel(name, [], ALL_MODELS);
|
|
73
107
|
const states = modelStates(db);
|
|
74
108
|
states[name] = { on, note: `turned ${on ? 'on' : 'off'} ${day(now)}` };
|
|
75
109
|
writeStates(db, states);
|
|
@@ -77,9 +111,9 @@ export function setModel(db, name, on, now = new Date().toISOString()) {
|
|
|
77
111
|
}
|
|
78
112
|
|
|
79
113
|
/** One line per model: its name, its switch, the API id and the note — what `sumo models` prints. */
|
|
80
|
-
export function modelLines(db, names =
|
|
114
|
+
export function modelLines(db, names = ALL_MODELS) {
|
|
81
115
|
const states = modelStates(db);
|
|
82
|
-
return names.map((name) => `${name.padEnd(
|
|
116
|
+
return names.map((name) => `${name.padEnd(NAME_WIDTH)} ${states[name].on ? 'on ' : 'off'} ${modelId(name).padEnd(26)} ${states[name].note}${laneOf(name) === 'cursor' ? ' · through Cursor' : ''}`);
|
|
83
117
|
}
|
|
84
118
|
|
|
85
119
|
/** What went wrong with an API call, in one line a person can act on. */
|
|
@@ -168,3 +202,56 @@ export function discoverySummary({ found, missing, errors }) {
|
|
|
168
202
|
if (failed.length > 0) parts.push(`not checked: ${failed.map(([name, error]) => `${name} (${error})`).join(', ')}`);
|
|
169
203
|
return parts.join(' — ');
|
|
170
204
|
}
|
|
205
|
+
|
|
206
|
+
/** Which models Cursor has for this key: every id and alias it lists. Loaded only here, so a command that never asks never loads the SDK. */
|
|
207
|
+
async function listCursorModels(apiKey) {
|
|
208
|
+
const { Cursor } = await import('@cursor/sdk');
|
|
209
|
+
const models = await Cursor.models.list({ apiKey });
|
|
210
|
+
return models.flatMap((m) => [m.id, ...(m.aliases ?? [])]);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** The stand-in's answer to "which models has Cursor": `{ ids: [...] }`; anything else is a failed check. */
|
|
214
|
+
function askStandInCursor(standIn) {
|
|
215
|
+
const run = spawnSync(standIn, [], { input: JSON.stringify({ kind: 'cursor-models' }), encoding: 'utf8', timeout: TIMEOUT_MS });
|
|
216
|
+
try {
|
|
217
|
+
const answer = JSON.parse(run.stdout);
|
|
218
|
+
if (Array.isArray(answer?.ids)) return answer.ids;
|
|
219
|
+
} catch {
|
|
220
|
+
// Said below.
|
|
221
|
+
}
|
|
222
|
+
throw new Error((run.stderr || run.stdout || '').trim().slice(0, 200) || `exit ${run.status}`);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Asks Cursor which of Sumo's Cursor models this CURSOR_API_KEY can use, and sets their switches: found → on, unless the user
|
|
227
|
+
* turned it off by hand; not there → off. Without a key nothing is asked and nothing changes. Never throws. Cursor's list
|
|
228
|
+
* does not say what the account's plan covers: a model the plan leaves out is found here and refused when a job runs on it.
|
|
229
|
+
*/
|
|
230
|
+
export async function discoverCursor(db, { now = new Date().toISOString(), list = listCursorModels } = {}) {
|
|
231
|
+
const key = process.env.CURSOR_API_KEY?.trim();
|
|
232
|
+
if (!key) return { ok: false, error: 'no CURSOR_API_KEY in this shell — export it, then Discover again' };
|
|
233
|
+
let ids;
|
|
234
|
+
try {
|
|
235
|
+
const standIn = process.env.SUMO_AGENTS_MODEL_CMD;
|
|
236
|
+
ids = new Set(standIn ? askStandInCursor(standIn) : await list(key));
|
|
237
|
+
} catch (cause) {
|
|
238
|
+
return { ok: false, error: String(cause?.message ?? cause).replace(/\s+/g, ' ').slice(0, 200) };
|
|
239
|
+
}
|
|
240
|
+
const names = Object.keys(CURSOR_MODELS);
|
|
241
|
+
const found = names.filter((name) => ids.has(CURSOR_MODELS[name].id));
|
|
242
|
+
const missing = names.filter((name) => !ids.has(CURSOR_MODELS[name].id));
|
|
243
|
+
const states = modelStates(db);
|
|
244
|
+
const offByHand = (name) => !states[name].on && /^turned off /.test(states[name].note ?? '');
|
|
245
|
+
for (const name of found) if (!offByHand(name)) states[name] = { on: true, note: `found ${day(now)}` };
|
|
246
|
+
for (const name of missing) states[name] = { on: false, note: `not found ${day(now)}` };
|
|
247
|
+
writeStates(db, states);
|
|
248
|
+
return { ok: true, found, missing };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** Cursor's part of a discovery in one line. */
|
|
252
|
+
export function cursorSummary(result) {
|
|
253
|
+
if (!result.ok) return `Cursor: not checked — ${result.error}`;
|
|
254
|
+
const parts = [`Cursor: found ${result.found.length > 0 ? result.found.join(', ') : 'none of its models'}`];
|
|
255
|
+
if (result.missing.length > 0) parts.push(`not found, turned off: ${result.missing.join(', ')}`);
|
|
256
|
+
return parts.join(' — ');
|
|
257
|
+
}
|