agent-loft 0.2.117 → 0.2.119
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/package.json +1 -1
- package/src/agents/pi/driver.ts +58 -2
- package/src/agents/pi/session.ts +4 -0
- package/src/channels/web/api.ts +7 -4
- package/src/core/config.ts +19 -1
- package/src/core/paths.ts +12 -0
- package/web/dsh.png +0 -0
- package/web/lib/dom.js +2 -2
- package/web/settings/agents.js +19 -10
package/package.json
CHANGED
package/src/agents/pi/driver.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// 会话怎么跑见 session.ts;会话列表 / 历史自己读 data/pi/sessions 下的 JSONL(history.ts)。
|
|
4
4
|
// 记录是树结构(id / parentId),分叉、回退都用 SDK 的 SessionManager 另存一条新会话,原会话不动。
|
|
5
|
+
import type { AgentSession as PiAgentSession } from "@earendil-works/pi-coding-agent";
|
|
5
6
|
import type { AgentCommand } from "../../core/command-catalog.js";
|
|
6
7
|
import { config } from "../../core/config.js";
|
|
7
8
|
import type {
|
|
@@ -38,8 +39,16 @@ export class PiDriver implements AgentDriver {
|
|
|
38
39
|
}
|
|
39
40
|
async stop(): Promise<void> {}
|
|
40
41
|
|
|
42
|
+
private sessions = new Map<string, PiAgentSession>();
|
|
43
|
+
private titled = new Set<string>();
|
|
44
|
+
private titling = new Map<string, Promise<string | undefined>>();
|
|
45
|
+
|
|
41
46
|
createSession(opts: SessionOptions, events: AgentEvents, host: InteractionHost): AgentSession {
|
|
42
|
-
return new PiSession(opts, events, host)
|
|
47
|
+
return new PiSession(opts, events, host, (session, active) => {
|
|
48
|
+
const id = session.sessionId;
|
|
49
|
+
if (active) this.sessions.set(id, session);
|
|
50
|
+
else if (this.sessions.get(id) === session) this.sessions.delete(id);
|
|
51
|
+
});
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
async listSessions(cwd: string | undefined, limit = 10): Promise<SessionSummary[]> {
|
|
@@ -56,7 +65,54 @@ export class PiDriver implements AgentDriver {
|
|
|
56
65
|
}
|
|
57
66
|
|
|
58
67
|
async sessionTitle(id: string): Promise<string | undefined> {
|
|
59
|
-
|
|
68
|
+
const name = sessionTitleOf(id);
|
|
69
|
+
if (name) return name;
|
|
70
|
+
const c = config().agents.pi;
|
|
71
|
+
if (!c.autoTitle) return undefined;
|
|
72
|
+
const pending = this.titling.get(id);
|
|
73
|
+
if (pending) return pending;
|
|
74
|
+
if (this.titled.has(id) || !sessionFile(id)) return undefined;
|
|
75
|
+
const history = readHistoryFile(id);
|
|
76
|
+
const first = history.findIndex((m) => m.role === "user" && m.text.trim());
|
|
77
|
+
if (first < 0) return undefined; // 空会话不消耗生成机会
|
|
78
|
+
this.titled.add(id); // 失败也不在每轮 / 同步重试时重复花 token
|
|
79
|
+
const task = this.generateTitle(id, c.titleModel, history.slice(first))
|
|
80
|
+
.catch((err) => {
|
|
81
|
+
console.error("[pi] 生成会话名称失败:", err instanceof Error ? err.message : err);
|
|
82
|
+
return undefined;
|
|
83
|
+
})
|
|
84
|
+
.finally(() => this.titling.delete(id));
|
|
85
|
+
this.titling.set(id, task);
|
|
86
|
+
return task;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 只发第一轮的问答,不带系统提示、工具结果或思考;后台调用不建新会话。 */
|
|
90
|
+
private async generateTitle(id: string, model: string, history: HistoryMessage[]): Promise<string | undefined> {
|
|
91
|
+
const file = sessionFile(id);
|
|
92
|
+
if (!file) return undefined;
|
|
93
|
+
const { pi } = await loadSdk();
|
|
94
|
+
const live = this.sessions.get(id);
|
|
95
|
+
const sm = live?.sessionManager ?? pi.SessionManager.open(file, SESSIONS_DIR);
|
|
96
|
+
const selected = sm.buildSessionContext().model;
|
|
97
|
+
const titleModel = model || (live?.model ? modelKey(live.model) : selected ? `${selected.provider}/${selected.modelId}` : "");
|
|
98
|
+
const answer = history[1]?.role === "assistant" ? history[1].text : undefined;
|
|
99
|
+
const out = (await this.complete({
|
|
100
|
+
system: "你给对话起标题。根据用户的第一条消息(和助手的回复)概括这次对话在做什么,输出一个简短的标题:和用户用同一种语言,中文不超过 15 个字,不加引号、句号和表情。",
|
|
101
|
+
prompt: `用户:\n${history[0]!.text.slice(0, 2000)}${answer ? `\n\n助手:\n${answer.slice(0, 1500)}` : ""}`,
|
|
102
|
+
schema: { type: "object", properties: { title: { type: "string" } }, required: ["title"], additionalProperties: false },
|
|
103
|
+
...(titleModel ? { model: titleModel } : {}),
|
|
104
|
+
timeoutMs: 60_000,
|
|
105
|
+
})) as { title?: unknown };
|
|
106
|
+
if (typeof out?.title !== "string") return undefined;
|
|
107
|
+
const title = out.title.replace(/\s+/g, " ").trim().replace(/^["'“”‘’「」《》]+|["'“”‘’「」《》。.]+$/g, "").trim().slice(0, 80);
|
|
108
|
+
if (!title || !config().agents.pi.autoTitle || sessionFile(id) !== file) return undefined;
|
|
109
|
+
// 生成期间可能已有名称、续聊或恢复:重新取活实例 / 重读文件,不能接在旧 leaf 上丢掉后续分支。
|
|
110
|
+
const existing = sessionTitleOf(id);
|
|
111
|
+
if (existing) return existing;
|
|
112
|
+
const current = this.sessions.get(id);
|
|
113
|
+
if (current) current.setSessionName(title);
|
|
114
|
+
else pi.SessionManager.open(file, SESSIONS_DIR).appendSessionInfo(title);
|
|
115
|
+
return title;
|
|
60
116
|
}
|
|
61
117
|
|
|
62
118
|
async readHistory(id: string): Promise<HistoryMessage[]> {
|
package/src/agents/pi/session.ts
CHANGED
|
@@ -219,6 +219,8 @@ export class PiSession implements AgentSession {
|
|
|
219
219
|
private readonly opts: SessionOptions,
|
|
220
220
|
private readonly events: AgentEvents,
|
|
221
221
|
private readonly host: InteractionHost,
|
|
222
|
+
/** 驱动写会话元数据时必须用活着的实例,不能另开一个持有旧 leaf 的 SessionManager */
|
|
223
|
+
private readonly onSession?: (session: PiAgentSession, active: boolean) => void,
|
|
222
224
|
) {
|
|
223
225
|
this.allowAll = opts.permission === "full";
|
|
224
226
|
if (opts.model) this.runtime.model = opts.model;
|
|
@@ -313,6 +315,7 @@ export class PiSession implements AgentSession {
|
|
|
313
315
|
this.syncPlanTool(session);
|
|
314
316
|
if (fork) this.forked = true;
|
|
315
317
|
this.session = session;
|
|
318
|
+
this.onSession?.(session, true);
|
|
316
319
|
this.runtime = { model: modelKey(model), ...(session.supportsThinking() ? { effort: session.thinkingLevel } : {}) };
|
|
317
320
|
return session;
|
|
318
321
|
}
|
|
@@ -560,6 +563,7 @@ export class PiSession implements AgentSession {
|
|
|
560
563
|
private drop(session: PiAgentSession): void {
|
|
561
564
|
if (this.session !== session) return;
|
|
562
565
|
this.session = null;
|
|
566
|
+
this.onSession?.(session, false);
|
|
563
567
|
try {
|
|
564
568
|
session.dispose();
|
|
565
569
|
} catch {
|
package/src/channels/web/api.ts
CHANGED
|
@@ -4,6 +4,7 @@ import fs from "node:fs";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
6
6
|
import { AGENT_IDS, config, listWorkspaceDirs, resolveWorkspacePath, saveConfig, type AppConfig } from "../../core/config.js";
|
|
7
|
+
import { expandHomePath } from "../../core/paths.js";
|
|
7
8
|
import { cleanCustomCommands } from "../../core/command-catalog.js";
|
|
8
9
|
import { hub } from "../../core/hub.js";
|
|
9
10
|
import { interactions } from "../../core/interactions.js";
|
|
@@ -352,8 +353,10 @@ function applyConfig(input: Partial<AppConfig>, selfOrigin?: string): void {
|
|
|
352
353
|
}
|
|
353
354
|
if (id === "workbuddy" && "cliPath" in patch) {
|
|
354
355
|
const cli = (patch as { cliPath?: unknown }).cliPath;
|
|
355
|
-
if (typeof cli !== "string" || cli.length > 500
|
|
356
|
-
|
|
356
|
+
if (typeof cli !== "string" || cli.length > 500) throw new HttpError(400, "CLI 路径要写绝对路径(支持 ~/),留空自动找");
|
|
357
|
+
const expanded = expandHomePath(cli);
|
|
358
|
+
if (expanded && !path.isAbsolute(expanded)) throw new HttpError(400, "CLI 路径要写绝对路径(支持 ~/),留空自动找");
|
|
359
|
+
(patch as { cliPath: string }).cliPath = expanded;
|
|
357
360
|
}
|
|
358
361
|
if (id === "pi" && "defaultEffort" in patch && !["", "off", "minimal", "low", "medium", "high", "xhigh", "max"].includes(String((patch as { defaultEffort?: unknown }).defaultEffort))) {
|
|
359
362
|
throw new HttpError(400, "pi 的思考程度只能是 off / minimal / low / medium / high / xhigh / max");
|
|
@@ -365,9 +368,9 @@ function applyConfig(input: Partial<AppConfig>, selfOrigin?: string): void {
|
|
|
365
368
|
if (!(key in p)) continue;
|
|
366
369
|
const v = p[key];
|
|
367
370
|
if (typeof v !== "string" || v.length > 500) throw new HttpError(400, "路径不对");
|
|
368
|
-
const t = v
|
|
371
|
+
const t = expandHomePath(v);
|
|
369
372
|
// dsh 可执行文件可以只写命令名(按 PATH 找),另外两个要么留空、要么绝对路径
|
|
370
|
-
if (t && key !== "path" && !path.isAbsolute(t)) throw new HttpError(400, key === "home" ? "DSH_HOME
|
|
373
|
+
if (t && key !== "path" && !path.isAbsolute(t)) throw new HttpError(400, key === "home" ? "DSH_HOME 要写绝对路径(支持 ~/),留空用 ~/.dsh" : "patch 文件要写绝对路径(支持 ~/),留空不加");
|
|
371
374
|
p[key] = key === "path" ? t || "dsh" : t;
|
|
372
375
|
}
|
|
373
376
|
if ("defaultEffort" in p && !["", "off", "low", "high", "max"].includes(String(p.defaultEffort))) throw new HttpError(400, "dsh 的思考程度只能是 off / low / high / max");
|
package/src/core/config.ts
CHANGED
|
@@ -8,6 +8,7 @@ import crypto from "node:crypto";
|
|
|
8
8
|
import { configPath, ensureDirs, readJson, writeJsonAtomic } from "../home.js";
|
|
9
9
|
import { cleanCustomCommands, type CommandPrefs } from "./command-catalog.js";
|
|
10
10
|
import { normalizeOrigin, validServerId } from "./servers.js";
|
|
11
|
+
import { expandHomePath } from "./paths.js";
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
export type SandboxMode = "read-only" | "workspace-write" | "danger-full-access";
|
|
@@ -87,6 +88,10 @@ export type AppConfig = {
|
|
|
87
88
|
/** 思考程度(off / minimal / low / medium / high / xhigh),空 = pi 默认 */
|
|
88
89
|
defaultEffort: string;
|
|
89
90
|
models: string[];
|
|
91
|
+
/** SDK 不自动起名,由 agent-loft 在第一轮后后台生成一次 */
|
|
92
|
+
autoTitle: boolean;
|
|
93
|
+
/** 空 = 跟随会话模型 */
|
|
94
|
+
titleModel: string;
|
|
90
95
|
};
|
|
91
96
|
/**
|
|
92
97
|
* dsh(DeepSeek Harness,npm i -g @deepseek-ai/dsh):每个会话一个 `dsh --profile acp` 进程。
|
|
@@ -185,7 +190,7 @@ export function defaultConfig(): AppConfig {
|
|
|
185
190
|
// 默认不开:要先在设置里登录
|
|
186
191
|
workbuddy: { enabled: false, environment: "workbuddy", cliPath: "", defaultModel: "", defaultEffort: "", models: [] },
|
|
187
192
|
// 默认不开:要先填一家服务商的 API Key
|
|
188
|
-
pi: { enabled: false, defaultModel: "", defaultEffort: "", models: [] },
|
|
193
|
+
pi: { enabled: false, defaultModel: "", defaultEffort: "", models: [], autoTitle: true, titleModel: "" },
|
|
189
194
|
// 默认不开:要先装 dsh、配 DeepSeek API Key
|
|
190
195
|
dsh: { enabled: false, path: "dsh", home: "", patch: "", defaultModel: "", defaultEffort: "", models: [] },
|
|
191
196
|
},
|
|
@@ -265,6 +270,16 @@ function normalizeCommands(cfg: AppConfig): void {
|
|
|
265
270
|
for (const id of AGENT_IDS) cfg.commands[id].custom = cleanCustomCommands(cfg.commands[id].custom);
|
|
266
271
|
}
|
|
267
272
|
|
|
273
|
+
/** 所有入口统一展开,启动、健康检查和技能扫描读取同一个路径。 */
|
|
274
|
+
function normalizeAgentPaths(cfg: AppConfig): void {
|
|
275
|
+
cfg.agents.codex.path = expandHomePath(cfg.agents.codex.path) || "codex";
|
|
276
|
+
cfg.agents.codex.home = expandHomePath(cfg.agents.codex.home);
|
|
277
|
+
cfg.agents.workbuddy.cliPath = expandHomePath(cfg.agents.workbuddy.cliPath);
|
|
278
|
+
cfg.agents.dsh.path = expandHomePath(cfg.agents.dsh.path) || "dsh";
|
|
279
|
+
cfg.agents.dsh.home = expandHomePath(cfg.agents.dsh.home);
|
|
280
|
+
cfg.agents.dsh.patch = expandHomePath(cfg.agents.dsh.patch);
|
|
281
|
+
}
|
|
282
|
+
|
|
268
283
|
let current: AppConfig | null = null;
|
|
269
284
|
const listeners = new Set<(next: AppConfig, prev: AppConfig) => void>();
|
|
270
285
|
|
|
@@ -273,6 +288,7 @@ export function loadConfig(): AppConfig {
|
|
|
273
288
|
ensureDirs();
|
|
274
289
|
const raw = readJson<unknown>(configPath, null);
|
|
275
290
|
const merged = mergeDefaults(defaultConfig(), raw);
|
|
291
|
+
normalizeAgentPaths(merged);
|
|
276
292
|
merged.workspaceRoot = path.resolve(merged.workspaceRoot);
|
|
277
293
|
merged.feishu.bots = merged.feishu.bots.map(normalizeBot);
|
|
278
294
|
normalizeCommands(merged);
|
|
@@ -300,6 +316,7 @@ function watchExternalEdits(): void {
|
|
|
300
316
|
const raw = readJson<unknown>(configPath, null);
|
|
301
317
|
if (!raw || !current) return;
|
|
302
318
|
const next = mergeDefaults(defaultConfig(), raw);
|
|
319
|
+
normalizeAgentPaths(next);
|
|
303
320
|
next.workspaceRoot = path.resolve(next.workspaceRoot);
|
|
304
321
|
next.feishu.bots = next.feishu.bots.map(normalizeBot);
|
|
305
322
|
normalizeCommands(next);
|
|
@@ -330,6 +347,7 @@ export function config(): AppConfig {
|
|
|
330
347
|
export function saveConfig(next: AppConfig): AppConfig {
|
|
331
348
|
const prev = config();
|
|
332
349
|
const normalized = mergeDefaults(defaultConfig(), next);
|
|
350
|
+
normalizeAgentPaths(normalized);
|
|
333
351
|
normalized.workspaceRoot = path.resolve(normalized.workspaceRoot);
|
|
334
352
|
normalized.feishu.bots = normalized.feishu.bots.map(normalizeBot);
|
|
335
353
|
normalizeServers(normalized);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
/** 配置里的家目录缩写按服务用户展开;命令名、空值和其他路径保持原意。 */
|
|
5
|
+
export function expandHomePath(input: string): string {
|
|
6
|
+
const value = input.trim();
|
|
7
|
+
if (value === "~") return os.homedir();
|
|
8
|
+
if (value.startsWith("~/") || (process.platform === "win32" && value.startsWith("~\\"))) {
|
|
9
|
+
return path.join(os.homedir(), value.slice(2));
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
package/web/dsh.png
ADDED
|
Binary file
|
package/web/lib/dom.js
CHANGED
|
@@ -89,8 +89,8 @@ ICON.claude = '<svg viewBox="0 0 640 640"><path fill="#D97757" fill-rule="evenod
|
|
|
89
89
|
ICON.codex = '<svg viewBox="0 0 640 640"><path fill="currentColor" fill-rule="evenodd" d="M253 1C193 8 141 51 122 109C120 115 118 121 117 123C117 127 117 127 108 130C31 154 -16 240 6 321C12 346 26 370 45 391L53 399 52 407C43 448 51 491 75 527C83 539 104 560 116 569C156 596 205 604 250 591L257 589 264 595C284 613 307 624 335 631C351 635 382 635 399 631C461 618 506 575 523 511C523 508 524 508 534 504C587 485 625 442 637 384C640 369 640 341 637 325C631 293 616 266 594 244L587 236 588 228C606 142 552 60 466 41C442 36 412 37 390 44L384 46 375 38C340 9 297 -4 253 1M259 39C258 39 253 39 249 40C206 46 169 78 156 119C150 137 150 139 150 224L150 302 153 305C156 308 206 338 207 338C208 338 208 296 208 245C208 181 208 150 209 148C211 140 215 138 280 100C314 80 343 64 343 63C345 61 322 48 308 44C293 39 272 37 259 39M405 78C385 82 385 82 309 126C271 148 249 161 248 163C246 166 245 168 245 198C245 220 245 230 246 230C247 230 283 209 326 184C412 134 410 135 416 135C422 135 421 135 489 174C524 195 552 211 553 211C554 209 554 196 553 186C547 133 512 92 462 79C448 76 418 75 405 78M103 173C62 194 36 238 38 284C40 316 53 346 75 368C86 379 88 380 145 413C171 428 199 444 206 448C217 454 221 456 224 456C227 456 281 427 281 425C281 425 245 403 201 378C157 353 120 331 119 329C112 323 113 327 112 244L112 169 103 173M385 194C370 202 358 209 358 209C358 210 394 231 438 256C482 281 519 303 521 305C522 306 525 309 526 311C528 316 528 316 528 390C528 444 528 465 529 465C531 465 547 456 554 451C612 407 618 321 566 267C554 256 553 255 497 222C416 176 420 178 416 178C413 178 406 181 385 194M282 252L246 273 246 317L246 362 282 382C303 394 320 403 320 403C321 403 388 365 393 362L395 361 395 317L394 273 358 252C337 240 320 231 320 231C320 231 303 240 282 252M432 389C432 453 432 484 431 486C429 494 425 497 360 535C325 554 297 571 297 571C295 572 307 580 317 585C336 593 353 597 374 596C432 593 475 558 489 502C491 490 492 336 489 331C488 328 483 325 460 312C445 303 433 296 432 296C432 296 432 338 432 389M376 414C367 419 331 440 297 460C230 498 228 500 222 499C217 498 220 500 150 459C117 440 89 424 88 424C87 424 86 440 87 450C91 492 115 527 153 545C183 561 223 563 254 551C264 547 388 476 391 472L394 469 394 436C394 419 394 404 394 404C394 404 386 408 376 414"/></svg>';
|
|
90
90
|
/** WorkBuddy 的头像(青绿渐变猫脸),沿用 SVG 容器适配各处的图标尺寸 */
|
|
91
91
|
ICON.workbuddy = `<svg viewBox="0 0 320 320"><image href="${new URL("../workbuddy.png", import.meta.url).href}" width="320" height="320"/></svg>`;
|
|
92
|
-
/** dsh
|
|
93
|
-
ICON.dsh =
|
|
92
|
+
/** dsh 的头像(蓝色鲸鱼),沿用 SVG 容器适配各处的图标尺寸 */
|
|
93
|
+
ICON.dsh = `<svg viewBox="0 0 320 320"><image href="${new URL("../dsh.png", import.meta.url).href}" width="320" height="320"/></svg>`;
|
|
94
94
|
/** pi 的头像:圆角方块里一个 π,跟着文字颜色(深色模式下反过来) */
|
|
95
95
|
ICON.pi = '<svg viewBox="0 0 64 64"><rect x="2" y="2" width="60" height="60" rx="14" fill="currentColor"/><path fill="none" stroke="var(--bg, #fff)" stroke-width="6" stroke-linecap="round" d="M15 21h34M25 21v24M40 21v18c0 4 2 6 6 6"/></svg>';
|
|
96
96
|
|
package/web/settings/agents.js
CHANGED
|
@@ -222,6 +222,7 @@ function workbuddyLoginButton(after) {
|
|
|
222
222
|
/** 设置 → Agent(管理员):运行环境、启用、引擎自己的配置、输入框可选模型。默认模型 / 权限 / 加载在「专家」里各内置 Agent 的「设置」 */
|
|
223
223
|
export function agentsTab(cfg, page) {
|
|
224
224
|
page.append(agentHealthSection());
|
|
225
|
+
page.append(h("p", { class: "muted" }, "路径支持 ~ 和 ~/,代表运行 agent-loft 服务的用户家目录。"));
|
|
225
226
|
const a = structuredClone(cfg.agents);
|
|
226
227
|
for (const engine of ENGINES) {
|
|
227
228
|
const label = ENGINE_LABEL[engine];
|
|
@@ -236,15 +237,19 @@ export function agentsTab(cfg, page) {
|
|
|
236
237
|
const path = h("input", { value: settings.path });
|
|
237
238
|
const home = h("input", { value: settings.home, placeholder: "留空用 ~/.codex" });
|
|
238
239
|
const sandbox = h("select", {}, ["read-only", "workspace-write", "danger-full-access"].map((mode) => h("option", { value: mode, selected: mode === settings.sandbox }, mode)));
|
|
239
|
-
|
|
240
|
-
const titlePick = modelPicker("codex", settings.titleModel ?? "", "", "跟随 config.toml");
|
|
241
|
-
const titleModel = h("div", { class: "grow field" }, titlePick.modelEl);
|
|
242
|
-
const syncTitle = () => { titleModel.hidden = !titleOn.checked; };
|
|
243
|
-
titleOn.addEventListener("change", syncTitle);
|
|
244
|
-
syncTitle();
|
|
245
|
-
codex = { path, home, sandbox, titleOn, titlePick, titleModel };
|
|
240
|
+
codex = { path, home, sandbox };
|
|
246
241
|
config.append(field("codex 可执行文件", path, "以系统服务运行时 PATH 很短,建议写绝对路径"), field("CODEX_HOME", home), field("沙箱", sandbox, "workspace-write:目录内可读写,越界才弹授权。danger-full-access 等于关掉沙箱"));
|
|
247
242
|
}
|
|
243
|
+
let titles = null;
|
|
244
|
+
if (engine === "codex" || engine === "pi") {
|
|
245
|
+
const on = h("input", { type: "checkbox", checked: settings.autoTitle ?? engine === "pi" });
|
|
246
|
+
const pick = modelPicker(engine, settings.titleModel ?? "", "", engine === "pi" ? "跟随会话模型" : "跟随 config.toml");
|
|
247
|
+
const model = h("div", { class: "grow field" }, pick.modelEl);
|
|
248
|
+
const sync = () => { model.hidden = !on.checked; };
|
|
249
|
+
on.addEventListener("change", sync);
|
|
250
|
+
sync();
|
|
251
|
+
titles = { on, pick, model };
|
|
252
|
+
}
|
|
248
253
|
let site = null;
|
|
249
254
|
let cliPath = null;
|
|
250
255
|
if (engine === "workbuddy") {
|
|
@@ -271,7 +276,7 @@ export function agentsTab(cfg, page) {
|
|
|
271
276
|
if (engine === "dsh") {
|
|
272
277
|
const path = h("input", { value: settings.path ?? "dsh", placeholder: "dsh" });
|
|
273
278
|
const home = h("input", { value: settings.home ?? "", placeholder: "留空用 ~/.dsh" });
|
|
274
|
-
const patch = h("input", { value: settings.patch ?? "", placeholder: "
|
|
279
|
+
const patch = h("input", { value: settings.patch ?? "", placeholder: "留空不加(如 ~/.dsh/loft.patch.yml)" });
|
|
275
280
|
dsh = { path, home, patch };
|
|
276
281
|
config.append(
|
|
277
282
|
h("p", { class: "muted" }, "dsh(DeepSeek Harness):DeepSeek 官方的编程 agent,通过标准 ACP 协议接入,每个会话一个 dsh 进程(第一条消息要等 4~5 秒拉起)。用 dsh 自己的凭据(~/.dsh/.credentials.yaml 里的 DeepSeek API Key)和会话记录,dsh 网页里建的会话这里也能接着聊。权限用 dsh 的沙箱:逐次询问 = 只读、自动改文件 = 工作区可写、完全允许 = 不设沙箱;越界时弹授权卡。不支持自定义专家、分叉 / 回退、提问卡和图片直传(附件给路径);设成「调用前询问」的 MCP 不会挂上。"),
|
|
@@ -282,7 +287,10 @@ export function agentsTab(cfg, page) {
|
|
|
282
287
|
}
|
|
283
288
|
config.append(h("small", { class: "muted" }, "默认模型、思考程度、权限和默认加载的技能 / MCP,在「设置 → 专家」里这个 Agent 的「设置」中修改。"));
|
|
284
289
|
config.append(h("div", { class: "field" }, h("span", {}, "输入框可选模型"), models.el));
|
|
285
|
-
if (
|
|
290
|
+
if (titles) {
|
|
291
|
+
config.append(h("div", { class: "row title-row" }, h("label", { class: "check" }, titles.on, "自动生成会话名称"), titles.model));
|
|
292
|
+
if (engine === "pi") config.append(h("small", { class: "muted" }, "第一轮回复后在后台生成一次,会额外调用模型;留空跟随会话模型,可另选低成本模型。手动改名不会被覆盖。"));
|
|
293
|
+
}
|
|
286
294
|
config.append(h("div", { class: "row" }, saveButton(() => {
|
|
287
295
|
const selected = models.value();
|
|
288
296
|
if (!selected) {
|
|
@@ -293,7 +301,8 @@ export function agentsTab(cfg, page) {
|
|
|
293
301
|
enabled: on.checked, models: selected,
|
|
294
302
|
...(site ? { environment: site.value, cliPath: cliPath.value.trim() } : {}),
|
|
295
303
|
...(dsh ? { path: dsh.path.value.trim() || "dsh", home: dsh.home.value.trim(), patch: dsh.patch.value.trim() } : {}),
|
|
296
|
-
...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value
|
|
304
|
+
...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value } : {}),
|
|
305
|
+
...(titles ? { autoTitle: titles.on.checked, titleModel: titles.pick.model() } : {}),
|
|
297
306
|
} } });
|
|
298
307
|
}, `保存 ${label} 设置`)));
|
|
299
308
|
page.append(h("div", { class: "section", "data-agent": engine }, config));
|