feat: LLM 录制开关、模型列表第三方回退、命令页改为工具执行

在 review PR5 基础上的三处改进:

1. LLM 录制开关(默认关,settings.llm_record)
   - 录制页数据大小下拉框旁加开关;关闭时 Recorder.Stream 直接透传,
     不序列化、不累积、不写库,零开销。切换即时生效,无需重建 agent。

2. 模型列表拉取支持 Anthropic 兼容第三方
   - pgListModels 改为按序尝试多个候选端点:anthropic 的 /v1/models 拿不到时,
     剥掉 /anthropic 回退到 OpenAI 式 /models(自动切 Bearer 头)。
     修复 DeepSeek(anthropic) 加载模型 404。

3. 命令页改为「工具执行」列表
   - ListCommands 去掉 tool='Bash' 过滤,覆盖所有 tool_use;返回工具名列,
     搜索匹配工具名或参数。前端加「工具」列、标题/侧边栏改为「工具执行」。

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Autumn-27andClaude Opus 4.8 committed 2026-08-07 09:32:01 -04:00
1 parent 10f891a21d
commit ad9f14f140
12 files changed
+225 -83

No files matched your search

+15 -8
View File
@@ -18,16 +18,18 @@ import (
// Recorder wraps an llm.Provider and records every completion call.
type Recorder struct {
inner llm.Provider
pg *db.DB
model string // model name (from config, not in CompletionRequest)
prof string // LLM profile name (from llm_profiles)
inner llm.Provider
pg *db.DB
model string // model name (from config, not in CompletionRequest)
prof string // LLM profile name (from llm_profiles)
enabled func() bool // reports whether recording is currently on; nil = always record
}
// Wrap returns a Provider that records all calls to pg.
// profName is the LLM profile name (e.g. "default"); may be empty.
func Wrap(inner llm.Provider, pg *db.DB, model, profName string) *Recorder {
return &Recorder{inner: inner, pg: pg, model: model, prof: profName}
// Wrap returns a Provider that records calls to pg when enabled() reports true.
// profName is the LLM profile name (e.g. "default"); may be empty. A nil enabled
// predicate records unconditionally (backward-compatible default).
func Wrap(inner llm.Provider, pg *db.DB, model, profName string, enabled func() bool) *Recorder {
return &Recorder{inner: inner, pg: pg, model: model, prof: profName, enabled: enabled}
}
// parseSession extracts task id and worker role from session strings like
@@ -61,6 +63,11 @@ func parseSession(s string) (taskID, worker string) {
// harness via transcript.WithSessionID; reading it per-call is race-free even when
// planner and multiple workers share one Recorder instance.
func (r *Recorder) Stream(ctx context.Context, req llm.CompletionRequest) iter.Seq2[llm.StreamEvent, error] {
// Recording off → passthrough with zero overhead: no request serialization,
// no response accumulation, no DB insert.
if r.enabled != nil && !r.enabled() {
return r.inner.Stream(ctx, req)
}
start := time.Now()
session := transcript.SessionIDFrom(ctx)
taskID, worker := parseSession(session)