opencode-agent-plus 0.5.0 → 0.5.1
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/README.md +40 -20
- package/package.json +1 -2
- package/src/clockwork.ts +60 -2
- package/src/frontmatter.test.ts +0 -2
- package/src/frontmatter.ts +7 -3
- package/src/httprequest.ts +8 -1
- package/src/index.ts +2 -0
- package/src/tooloverrides.ts +48 -0
- package/src/tui.tsx +11 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Per-agent reminders, request settings and safe-command auto-allow for [OpenCode](https://opencode.ai) v2.
|
|
4
4
|
|
|
5
|
-
Set `chat_template_kwargs` (like `enable_thinking`), sampling settings (`temperature`, `top_p`, `
|
|
5
|
+
Set `chat_template_kwargs` (like `enable_thinking`), sampling settings (`temperature`, `top_p`, `min_p`,
|
|
6
6
|
penalties) and a system reminder for each OpenCode agent. Works with llama.cpp, LiteLLM and other OpenAI-compatible
|
|
7
7
|
servers, and with thinking models like Qwen.
|
|
8
8
|
|
|
@@ -12,8 +12,6 @@ with `shell: ask` in your permissions you get no prompt window for them — ever
|
|
|
12
12
|
OpenCode v2 drops request settings such as `temperature` for OpenAI-compatible providers, and has no per-agent
|
|
13
13
|
reminder. agent-plus reads extra keys from the agent's `.md` file and applies them to every model request.
|
|
14
14
|
|
|
15
|
-
Tested with OpenCode 2.2.0 and llama.cpp behind LiteLLM.
|
|
16
|
-
|
|
17
15
|

|
|
18
16
|
|
|
19
17
|
## Install
|
|
@@ -83,22 +81,20 @@ You help the user write and edit text.
|
|
|
83
81
|
| `reminder` | `concise`, `ultra-concise`, `creative`, `off`, or text (one line or a `\|` block) | Preset or custom reminder, added as the last message of every model request |
|
|
84
82
|
| `on_error_command` | shell command, one line or a `\|` block | Run when a request fails with a connection error (server off), then retry |
|
|
85
83
|
| `safe_commands` | `none` (default: on) | Turn safe-command auto-allow off for this agent |
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
84
|
+
| `max_word_repeat` | `on` or `off` (default: off) | Stop the reply when the model repeats the same text |
|
|
85
|
+
| `max_tool_repeat` | whole number | Max times the same tool call may repeat in a row |
|
|
88
86
|
| `manual_green_light` | `on` or `off` (default: off) | Tools run only when your message ends with an approval word |
|
|
89
87
|
| `manual_green_light_words` | comma-separated words | The approval words for `manual_green_light` |
|
|
90
88
|
| `auto_green_light` | `on` or `off` (default: off) | The model checks itself before the first tool call of each turn |
|
|
91
89
|
| `temperature` | number | Request body |
|
|
92
|
-
| `top_p` | number | Request body |
|
|
93
|
-
| `top_k` | whole number | Request body |
|
|
94
|
-
| `min_p` | number | Request body |
|
|
95
|
-
| `presence_penalty` | number | Request body |
|
|
96
|
-
| `repeat_penalty` | number | Request body (llama.cpp) |
|
|
97
|
-
| `repetition_penalty` | number | Request body (vLLM, HF) |
|
|
98
90
|
| `max_completion_tokens` | whole number | Request body |
|
|
99
|
-
| `reasoning_budget_tokens` | whole number | Request body
|
|
91
|
+
| `reasoning_budget_tokens` | whole number | Request body |
|
|
100
92
|
| `reasoning_effort` | `none`, `minimal`, `low`, `medium`, `high` or `xhigh` | Request body |
|
|
101
93
|
| `enable_thinking` | `true` or `false` | Request body, under `chat_template_kwargs` |
|
|
94
|
+
| `tools_override` | path to a JSON file (relative to the agent file) | Replace tool descriptions with your own |
|
|
95
|
+
| `pondering` | `on` or `off` (default: off) | Run a quiet thinking request when the session goes idle |
|
|
96
|
+
| `misplaced_tag_filter` | `on` or `off` (default: off) | Replace leaked tag signs in thinking/message text |
|
|
97
|
+
| `clockwork` | `on` or `off` (default: off) | Run the agent hands-off with auto-continue |
|
|
102
98
|
|
|
103
99
|
Names are sent as written. A setting with a wrong value is not sent.
|
|
104
100
|
|
|
@@ -145,7 +141,7 @@ chunks, like llama.cpp with `--cache-reuse`, may recover part of it.
|
|
|
145
141
|
At start, a toast lists problems in agent files:
|
|
146
142
|
|
|
147
143
|
- misspelled keys, like `temprature → temperature`
|
|
148
|
-
- wrong values, like `
|
|
144
|
+
- wrong values, like `max_completion_tokens: must be a whole number`
|
|
149
145
|
|
|
150
146
|
Unknown keys that don't look like a misspelling are left alone, so other plugins can add their own keys.
|
|
151
147
|
With no problems, the toast says "agent-plus is loaded".
|
|
@@ -190,12 +186,12 @@ Turn it off for one agent with `safe_commands: none` in its frontmatter.
|
|
|
190
186
|
|
|
191
187
|
## Anti-repetition
|
|
192
188
|
|
|
193
|
-
With `
|
|
189
|
+
With `max_word_repeat: on`, agent-plus watches the model's reply as it streams. When the same stretch of text
|
|
194
190
|
repeats 5 or more times, the reply is cut and the session is interrupted, instead of filling up with garbage.
|
|
195
191
|
|
|
196
192
|
## Anti-loop
|
|
197
193
|
|
|
198
|
-
With `
|
|
194
|
+
With `max_tool_repeat: 5`, the same tool call (same tool, same arguments) may repeat at most 5 times in a row.
|
|
199
195
|
The 6th is denied with a message telling the model to stop. The count resets when you send a new message.
|
|
200
196
|
|
|
201
197
|
## Pondering
|
|
@@ -222,13 +218,37 @@ is always allowed. Set your own words with `manual_green_light_words: yes, do, g
|
|
|
222
218
|
With `auto_green_light: on`, the model checks itself before the first tool call of each turn: it must allow the call
|
|
223
219
|
and state its plan, or explain why it cannot. The check fires once per turn and is not saved in the chat history.
|
|
224
220
|
|
|
221
|
+
## Tool overrides
|
|
222
|
+
|
|
223
|
+
With `tools_override: <file>.json` (relative to the agent file), tool
|
|
224
|
+
descriptions are replaced with the ones from that file. The file maps tool
|
|
225
|
+
names to replacement descriptions:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"bash": "Run a shell command.",
|
|
230
|
+
"read": "Read a file."
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Tools not listed keep their original description. The file is re-read only when
|
|
235
|
+
it changes on disk, so the prompt cache stays warm.
|
|
236
|
+
|
|
225
237
|
## Clockwork
|
|
226
238
|
|
|
227
|
-
With `clockwork: on`, the agent runs hands-off. Every permission ask is denied
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
239
|
+
With `clockwork: on`, the agent runs hands-off. Every permission ask is denied.
|
|
240
|
+
After each finished turn a judge request reads the plan and the work so far and
|
|
241
|
+
replies with one word:
|
|
242
|
+
|
|
243
|
+
- `CONTINUE` — the plugin sends a fresh "keep going" message. Every 7–10 turns
|
|
244
|
+
it instead nudges the agent to re-read its plan document (PLAN.md, TODO.md,
|
|
245
|
+
etc.) and list remaining work.
|
|
246
|
+
- `WAIT` — the agent is waiting on a background job, so the plugin waits 30s
|
|
247
|
+
and judges again.
|
|
248
|
+
- `DONE` — the plugin sends a wrap-up message. The next `DONE` sends a final
|
|
249
|
+
"JOB COMPLETED" line and stops the loop.
|
|
250
|
+
|
|
251
|
+
Only agents with `clockwork: on` are affected.
|
|
232
252
|
|
|
233
253
|
## Notes
|
|
234
254
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-agent-plus",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "OpenCode plugin: safe-command auto-allow (no prompt for read-only calls), per-agent chat_template_kwargs (enable_thinking), sampling settings and system reminders from agent frontmatter. For llama.cpp, LiteLLM and OpenAI-compatible providers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Anoosh Ahmadi",
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"temperature",
|
|
29
29
|
"sampling",
|
|
30
30
|
"top_p",
|
|
31
|
-
"top_k",
|
|
32
31
|
"min_p",
|
|
33
32
|
"system-reminder",
|
|
34
33
|
"reminder",
|
package/src/clockwork.ts
CHANGED
|
@@ -15,10 +15,34 @@ const META =
|
|
|
15
15
|
"progress. Do not greet, do not ask questions, do not repeat prior work. " +
|
|
16
16
|
"Reply with that one sentence only."
|
|
17
17
|
|
|
18
|
+
const PLAN_META =
|
|
19
|
+
"You are nudging an autonomous coding agent that just stopped. Write ONE " +
|
|
20
|
+
"short imperative sentence telling it to read the project's plan document " +
|
|
21
|
+
"(PLAN.md, TODO.md, DESIGN.md or similar) and list the work that is still " +
|
|
22
|
+
"left. Do not greet, do not ask questions. Reply with that one sentence only."
|
|
23
|
+
|
|
24
|
+
const JUDGE_META =
|
|
25
|
+
"Review the plan and the work done so far. Reply with ONE word: DONE, WAIT, " +
|
|
26
|
+
"or CONTINUE. Say DONE if every plan item is complete and the acting agent is " +
|
|
27
|
+
"asking to conclude. Say WAIT if the agent is waiting for a background job or " +
|
|
28
|
+
"long task to finish. Otherwise say CONTINUE."
|
|
29
|
+
|
|
30
|
+
const WAIT_MS = 30_000
|
|
31
|
+
|
|
32
|
+
const WRAPUP = "Wrap up now: summarize what was done and stop."
|
|
33
|
+
|
|
34
|
+
const COMPLETED = "==================== CLOCKWORK: JOB COMPLETED ===================="
|
|
35
|
+
|
|
36
|
+
const nextTarget = () => 7 + Math.floor(Math.random() * 4) // 7, 8, 9 or 10
|
|
37
|
+
|
|
18
38
|
export async function clockwork(ctx: any, { settings }: { settings: (agent: string) => Promise<{ keys: Record<string, string> }> }) {
|
|
19
|
-
const shared = ((globalThis as any).__agentPlusClockwork ??= { running: new Set<string>(), denied: new Set<string>() })
|
|
39
|
+
const shared = ((globalThis as any).__agentPlusClockwork ??= { running: new Set<string>(), denied: new Set<string>(), stopped: new Set<string>(), wrapped: new Set<string>(), turns: new Map<string, number>(), targets: new Map<string, number>() })
|
|
20
40
|
const running = shared.running as Set<string> // a keep-going prompt is in flight
|
|
21
41
|
const denied = shared.denied as Set<string> // this turn had a denied ask
|
|
42
|
+
const stopped = shared.stopped as Set<string> // the judge said the work is done
|
|
43
|
+
const wrapped = shared.wrapped as Set<string> // already sent the wrap-up message
|
|
44
|
+
const turns = shared.turns as Map<string, number> // turns since last plan check
|
|
45
|
+
const targets = shared.targets as Map<string, number> // when the next plan check fires
|
|
22
46
|
|
|
23
47
|
// Deny every permission ask for clockwork agents.
|
|
24
48
|
await ctx.permission.hook("evaluate", async (event: any) => {
|
|
@@ -46,10 +70,44 @@ export async function clockwork(ctx: any, { settings }: { settings: (agent: stri
|
|
|
46
70
|
const session = await ctx.session.get({ sessionID })
|
|
47
71
|
const { keys } = await settings(session.agent)
|
|
48
72
|
if (keys.clockwork !== "on") continue
|
|
73
|
+
if (stopped.has(sessionID)) continue
|
|
49
74
|
running.add(sessionID)
|
|
50
75
|
const wasDenied = denied.delete(sessionID)
|
|
51
76
|
|
|
52
|
-
|
|
77
|
+
// Judge: is the work finished, or waiting on a job? Read-only, nothing saved.
|
|
78
|
+
// Empty reply means no verdict, so retry once. WAIT means pause and re-judge.
|
|
79
|
+
let verdict: unknown
|
|
80
|
+
for (;;) {
|
|
81
|
+
verdict = (await ctx.session.generate({ sessionID, prompt: JUDGE_META })).text
|
|
82
|
+
if (!String(verdict).trim()) {
|
|
83
|
+
log(`clockwork: judge empty, retrying session=${sessionID}`)
|
|
84
|
+
verdict = (await ctx.session.generate({ sessionID, prompt: JUDGE_META })).text
|
|
85
|
+
}
|
|
86
|
+
log(`clockwork: judge session=${sessionID} reply=${String(verdict).trim()}`)
|
|
87
|
+
if (!/\bWAIT\b/i.test(String(verdict))) break
|
|
88
|
+
log(`clockwork: waiting session=${sessionID} ${WAIT_MS}ms`)
|
|
89
|
+
await new Promise((r) => setTimeout(r, WAIT_MS))
|
|
90
|
+
}
|
|
91
|
+
if (/\bDONE\b/i.test(String(verdict))) {
|
|
92
|
+
if (!wrapped.has(sessionID)) {
|
|
93
|
+
wrapped.add(sessionID)
|
|
94
|
+
log(`clockwork: wrap-up session=${sessionID}`)
|
|
95
|
+
await ctx.session.prompt({ sessionID, text: WRAPUP, delivery: "steer" })
|
|
96
|
+
continue
|
|
97
|
+
}
|
|
98
|
+
stopped.add(sessionID)
|
|
99
|
+
log(`clockwork: finished session=${sessionID} verdict=${String(verdict).trim()}`)
|
|
100
|
+
await ctx.session.prompt({ sessionID, text: COMPLETED, delivery: "steer" })
|
|
101
|
+
continue
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const count = (turns.get(sessionID) ?? 0) + 1
|
|
105
|
+
const target = targets.get(sessionID) ?? nextTarget()
|
|
106
|
+
const checkPlan = count >= target
|
|
107
|
+
turns.set(sessionID, checkPlan ? 0 : count)
|
|
108
|
+
if (checkPlan) targets.set(sessionID, nextTarget())
|
|
109
|
+
|
|
110
|
+
const { text: next } = await ctx.session.generate({ sessionID, prompt: checkPlan ? PLAN_META : META })
|
|
53
111
|
const text = String(next).trim() || FALLBACK
|
|
54
112
|
|
|
55
113
|
const final = wasDenied ? `Request is rejected. ${text}` : text
|
package/src/frontmatter.test.ts
CHANGED
|
@@ -8,8 +8,6 @@ test("parses keys and | blocks", () => {
|
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
test("validates request values", () => {
|
|
11
|
-
expect(requestValue("top_k", "5")).toEqual({ value: 5 })
|
|
12
|
-
expect(requestValue("top_k", "1.5")).toEqual({ error: "top_k: must be a whole number" })
|
|
13
11
|
expect(requestValue("enable_thinking", "true")).toEqual({ value: true })
|
|
14
12
|
expect(requestValue("reasoning_effort", "bad")).toEqual({ error: "reasoning_effort: must be one of none, minimal, low, medium, high, xhigh" })
|
|
15
13
|
})
|
package/src/frontmatter.ts
CHANGED
|
@@ -14,7 +14,7 @@ export const BODY = [
|
|
|
14
14
|
"reasoning_effort",
|
|
15
15
|
]
|
|
16
16
|
export const TEMPLATE_KWARGS = ["enable_thinking"]
|
|
17
|
-
const WHOLE_NUMBERS = ["
|
|
17
|
+
const WHOLE_NUMBERS = ["max_completion_tokens", "reasoning_budget_tokens"]
|
|
18
18
|
// Safe value ranges for the sampling settings.
|
|
19
19
|
const RANGES: Record<string, [number, number]> = {
|
|
20
20
|
temperature: [0.2, 1.4],
|
|
@@ -37,7 +37,7 @@ const OPENCODE_KEYS = [
|
|
|
37
37
|
"disabled",
|
|
38
38
|
"request",
|
|
39
39
|
]
|
|
40
|
-
const KNOWN = new Set([...OPENCODE_KEYS, "reminder", "on_error_command", "safe_commands", "max_word_repeat", "max_tool_repeat", "manual_green_light", "manual_green_light_words", "auto_green_light", "pondering", "misplaced_tag_filter", "clockwork", ...BODY, ...TEMPLATE_KWARGS])
|
|
40
|
+
const KNOWN = new Set([...OPENCODE_KEYS, "reminder", "on_error_command", "safe_commands", "max_word_repeat", "max_tool_repeat", "manual_green_light", "manual_green_light_words", "auto_green_light", "pondering", "misplaced_tag_filter", "clockwork", "tools_override", ...BODY, ...TEMPLATE_KWARGS])
|
|
41
41
|
|
|
42
42
|
export const read = (file: string) => readFile(file, "utf8").catch(() => "")
|
|
43
43
|
|
|
@@ -167,11 +167,15 @@ export async function problems(file: string, keys: Record<string, string>) {
|
|
|
167
167
|
keys.clockwork && !["on", "off"].includes(keys.clockwork)
|
|
168
168
|
? [`clockwork: must be on or off`]
|
|
169
169
|
: []
|
|
170
|
+
const toolOverrides =
|
|
171
|
+
keys.tools_override !== undefined && !keys.tools_override.trim()
|
|
172
|
+
? [`tools_override: must name a JSON file`]
|
|
173
|
+
: []
|
|
170
174
|
const wrong = [...BODY, ...TEMPLATE_KWARGS]
|
|
171
175
|
.filter((k) => k in keys)
|
|
172
176
|
.flatMap((k) => {
|
|
173
177
|
const result = requestValue(k, keys[k])
|
|
174
178
|
return "error" in result ? [result.error] : []
|
|
175
179
|
})
|
|
176
|
-
return [...misspelledKeys(keys), ...wrong, ...safeCommands, ...maxWordRepeat, ...maxToolRepeat, ...greenLight, ...autoGreenLight, ...pondering, ...misplacedTagFilter, ...clockwork]
|
|
180
|
+
return [...misspelledKeys(keys), ...wrong, ...safeCommands, ...maxWordRepeat, ...maxToolRepeat, ...greenLight, ...autoGreenLight, ...pondering, ...misplacedTagFilter, ...clockwork, ...toolOverrides]
|
|
177
181
|
}
|
package/src/httprequest.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Request settings: adds the agent's sampling settings to the model request.
|
|
2
2
|
// Supported keys are listed in frontmatter.ts; a setting with a wrong value is not sent.
|
|
3
|
-
import { BODY, requestValue } from "./frontmatter"
|
|
3
|
+
import { BODY, TEMPLATE_KWARGS, requestValue } from "./frontmatter"
|
|
4
4
|
import { log } from "./log"
|
|
5
5
|
|
|
6
6
|
export interface HttpRequestOptions {
|
|
@@ -16,6 +16,13 @@ export async function httpRequest(event: any, options: HttpRequestOptions) {
|
|
|
16
16
|
const result = requestValue(k, keys[k])
|
|
17
17
|
if ("value" in result) extra[k] = result.value as number | string
|
|
18
18
|
}
|
|
19
|
+
const kwargs: Record<string, boolean> = {}
|
|
20
|
+
for (const k of TEMPLATE_KWARGS) {
|
|
21
|
+
if (!(k in keys)) continue
|
|
22
|
+
const result = requestValue(k, keys[k])
|
|
23
|
+
if ("value" in result) kwargs[k] = result.value as boolean
|
|
24
|
+
}
|
|
25
|
+
if (Object.keys(kwargs).length) extra.chat_template_kwargs = kwargs as any
|
|
19
26
|
log(`httprequest: agent=${event.agent} extra=${JSON.stringify(extra)}`)
|
|
20
27
|
event.options = { ...event.options, ...extra }
|
|
21
28
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { httpRequest } from "./httprequest"
|
|
|
10
10
|
import { pondering } from "./pondering"
|
|
11
11
|
import { misplacedTagFilter } from "./misplacedtag"
|
|
12
12
|
import { clockwork } from "./clockwork"
|
|
13
|
+
import { toolOverrides } from "./tooloverrides"
|
|
13
14
|
|
|
14
15
|
// Server half: adds the agent's reminders to every model request and its settings to the request body.
|
|
15
16
|
// The supported frontmatter keys are listed in frontmatter.ts and explained in README.md.
|
|
@@ -73,6 +74,7 @@ export default {
|
|
|
73
74
|
allowWake(event.sessionID)
|
|
74
75
|
const { keys } = await settings(event.agent)
|
|
75
76
|
await httpRequest(event, { settings })
|
|
77
|
+
await toolOverrides(event, { settings })
|
|
76
78
|
const text = await reminderText(directory, keys)
|
|
77
79
|
if (!text) return
|
|
78
80
|
appendBlock(event, "system-reminder", text)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Owns the `tools_override` setting: replaces tool descriptions with shorter
|
|
2
|
+
// ones from a JSON file named in the agent frontmatter (always next to the
|
|
3
|
+
// agent file). Off unless the key is set.
|
|
4
|
+
// Replacements are byte-stable (same file, same output every request), so the
|
|
5
|
+
// provider prompt cache is rebuilt once and then keeps hitting.
|
|
6
|
+
import { readFile, stat } from "node:fs/promises"
|
|
7
|
+
import path from "node:path"
|
|
8
|
+
import { log } from "./log"
|
|
9
|
+
|
|
10
|
+
// Parsed JSON per file, re-read only when the file changes on disk.
|
|
11
|
+
const cache = new Map<string, { mtimeMs: number; map: Record<string, string> }>()
|
|
12
|
+
|
|
13
|
+
async function load(file: string): Promise<Record<string, string> | undefined> {
|
|
14
|
+
const info = await stat(file).catch(() => undefined)
|
|
15
|
+
if (!info) return undefined
|
|
16
|
+
const hit = cache.get(file)
|
|
17
|
+
if (hit && hit.mtimeMs === info.mtimeMs) return hit.map
|
|
18
|
+
let map: Record<string, string>
|
|
19
|
+
try {
|
|
20
|
+
map = JSON.parse(await readFile(file, "utf8"))
|
|
21
|
+
} catch (e) {
|
|
22
|
+
log(`tools_override: bad JSON ${file}: ${e}`)
|
|
23
|
+
return undefined
|
|
24
|
+
}
|
|
25
|
+
cache.set(file, { mtimeMs: info.mtimeMs, map })
|
|
26
|
+
log(`tools_override: loaded ${file} tools=${Object.keys(map).join(",")}`)
|
|
27
|
+
return map
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Swap in the short descriptions for the tools listed in the file.
|
|
31
|
+
// Tools not listed (e.g. skill) keep their original description.
|
|
32
|
+
export async function toolOverrides(event: any, opts: { settings: (agent: string) => Promise<{ file: string; keys: Record<string, string> }> }) {
|
|
33
|
+
const { keys, file } = await opts.settings(event.agent)
|
|
34
|
+
if (!keys.tools_override || !file) return
|
|
35
|
+
const map = await load(path.join(path.dirname(file), keys.tools_override))
|
|
36
|
+
if (!map) {
|
|
37
|
+
log(`tools_override: file not found: ${keys.tools_override}`)
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
for (const [name, description] of Object.entries(map)) {
|
|
41
|
+
const tool = event.tools[name]
|
|
42
|
+
if (!tool) {
|
|
43
|
+
log(`tools_override: tool not sent to model, key does nothing: ${name}`)
|
|
44
|
+
continue
|
|
45
|
+
}
|
|
46
|
+
if (typeof description === "string") tool.description = description
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/tui.tsx
CHANGED
|
@@ -26,6 +26,7 @@ function sidebarLines(keys: Record<string, string>) {
|
|
|
26
26
|
lines.push(`pondering: ${onOff(keys.pondering)}`)
|
|
27
27
|
lines.push(`misplaced_tag_filter: ${onOff(keys.misplaced_tag_filter)}`)
|
|
28
28
|
lines.push(`clockwork: ${onOff(keys.clockwork)}`)
|
|
29
|
+
lines.push(`tools_override: ${keys.tools_override ? "on" : "off"}`)
|
|
29
30
|
if ("reasoning_effort" in keys && "value" in requestValue("reasoning_effort", keys.reasoning_effort))
|
|
30
31
|
lines.push(`reasoning_effort: ${keys.reasoning_effort}`)
|
|
31
32
|
for (const k of BODY) {
|
|
@@ -87,8 +88,17 @@ export default {
|
|
|
87
88
|
async ({ agent }) => sidebarLines(frontmatter((await agentFile(directory, agent)).text)),
|
|
88
89
|
)
|
|
89
90
|
// Live line: spinner while pondering, "on (idle)" when enabled and done, "off" when disabled.
|
|
91
|
+
const cacheLine = createMemo(() => {
|
|
92
|
+
const msgs = ctx.data.session.message.list(props.sessionID) ?? []
|
|
93
|
+
const last = [...msgs].reverse().find((m: any) => m.type === "assistant" && m.tokens)
|
|
94
|
+
if (!last) return "cache: -"
|
|
95
|
+
const t = last.tokens
|
|
96
|
+
const total = t.input + t.cache.read
|
|
97
|
+
const pct = total > 0 ? ((t.cache.read / total) * 100).toFixed(1) : "0.0"
|
|
98
|
+
return `cache: ${pct}% (cached: ${t.cache.read} token · new: ${t.input} token)`
|
|
99
|
+
})
|
|
90
100
|
const shown = createMemo(() => {
|
|
91
|
-
const ls = lines() ?? []
|
|
101
|
+
const ls = [...(lines() ?? []), cacheLine()]
|
|
92
102
|
if (!ls.includes("pondering: on")) return ls
|
|
93
103
|
const st = statuses()[props.sessionID]
|
|
94
104
|
const busy = st?.state === "busy"
|