agent-loft 0.2.99 → 0.2.101
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 +3 -2
- package/package.json +2 -1
- package/src/agents/claude/session.ts +1 -1
- package/src/agents/health.ts +73 -2
- package/src/agents/workbuddy/account.ts +98 -0
- package/src/agents/workbuddy/driver.ts +157 -0
- package/src/agents/workbuddy/errors.ts +34 -0
- package/src/agents/workbuddy/history.ts +237 -0
- package/src/agents/workbuddy/sdk.ts +156 -0
- package/src/agents/workbuddy/session.ts +484 -0
- package/src/channels/feishu/bot.ts +1 -1
- package/src/channels/web/api.ts +32 -0
- package/src/channels/web/experts-api.ts +3 -1
- package/src/channels/web/workspace-api.ts +3 -0
- package/src/core/builtin-agents.ts +1 -1
- package/src/core/command-catalog.ts +2 -1
- package/src/core/commands.ts +2 -1
- package/src/core/config.ts +20 -3
- package/src/core/experts.ts +5 -3
- package/src/core/git.ts +16 -0
- package/src/core/hub.ts +1 -1
- package/src/core/memory-curator.ts +2 -2
- package/src/core/memory.ts +2 -2
- package/src/core/permission.ts +1 -1
- package/src/core/users.ts +1 -1
- package/src/core/workspace-files.ts +2 -0
- package/src/main.ts +6 -2
- package/web/css/workspace.css +4 -0
- package/web/lib/dom.js +2 -0
- package/web/settings/agents.js +93 -9
- package/web/settings/commands.js +1 -1
- package/web/settings/experts.js +1 -1
- package/web/settings/memory.js +2 -1
- package/web/views/composer.js +1 -1
- package/web/views/interaction.js +1 -1
- package/web/views/sidebar.js +1 -1
- package/web/views/topbar.js +1 -1
- package/web/views/workspace.js +2 -2
package/src/core/config.ts
CHANGED
|
@@ -61,6 +61,21 @@ export type AppConfig = {
|
|
|
61
61
|
/** 生成会话名称用的模型,空 = Codex 默认模型 */
|
|
62
62
|
titleModel: string;
|
|
63
63
|
};
|
|
64
|
+
/** 腾讯 WorkBuddy(CodeBuddy Code):SDK 自带 CLI,登录在 设置 → Agent 里用浏览器完成 */
|
|
65
|
+
workbuddy: {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* 账号所在站点:workbuddy 用本机 WorkBuddy 桌面版的 CLI(www.workbuddy.cn);
|
|
69
|
+
* internal / external / ioa 用 SDK 自带的 CLI 连 CodeBuddy 国内版、国际版、腾讯内网
|
|
70
|
+
*/
|
|
71
|
+
environment: "workbuddy" | "internal" | "external" | "ioa";
|
|
72
|
+
/** WorkBuddy 桌面版里 CLI 的路径,空 = 在常见位置自动找 */
|
|
73
|
+
cliPath: string;
|
|
74
|
+
defaultModel: string;
|
|
75
|
+
/** WorkBuddy 没有思考程度,留着和别的 agent 同形 */
|
|
76
|
+
defaultEffort: string;
|
|
77
|
+
models: string[];
|
|
78
|
+
};
|
|
64
79
|
};
|
|
65
80
|
web: {
|
|
66
81
|
enabled: boolean;
|
|
@@ -80,7 +95,7 @@ export type AppConfig = {
|
|
|
80
95
|
quotaEnabled: boolean;
|
|
81
96
|
};
|
|
82
97
|
/** 输入「/」时命令列表的顺序和隐藏项,按 agent 分开(设置 → 命令) */
|
|
83
|
-
commands: { claude: CommandPrefs; codex: CommandPrefs };
|
|
98
|
+
commands: { claude: CommandPrefs; codex: CommandPrefs; workbuddy: CommandPrefs };
|
|
84
99
|
/** 远程控制:网页终端和远程桌面。管理员能用;成员要在 设置 → 用户 里单独开(users.json 的 remote) */
|
|
85
100
|
remote: {
|
|
86
101
|
terminal: boolean;
|
|
@@ -117,7 +132,7 @@ export type AppConfig = {
|
|
|
117
132
|
};
|
|
118
133
|
};
|
|
119
134
|
|
|
120
|
-
export const AGENT_IDS = ["claude", "codex"] as const;
|
|
135
|
+
export const AGENT_IDS = ["claude", "codex", "workbuddy"] as const;
|
|
121
136
|
|
|
122
137
|
export function defaultConfig(): AppConfig {
|
|
123
138
|
return {
|
|
@@ -137,9 +152,11 @@ export function defaultConfig(): AppConfig {
|
|
|
137
152
|
autoTitle: false,
|
|
138
153
|
titleModel: "",
|
|
139
154
|
},
|
|
155
|
+
// 默认不开:要先在设置里登录
|
|
156
|
+
workbuddy: { enabled: false, environment: "workbuddy", cliPath: "", defaultModel: "", defaultEffort: "", models: [] },
|
|
140
157
|
},
|
|
141
158
|
web: { enabled: true, host: "0.0.0.0", port: 8800, passwordHash: "", trustedProxies: ["127.0.0.1", "::1"], quotaRefreshMin: 10, quotaEnabled: true },
|
|
142
|
-
commands: { claude: { order: [], hidden: [], custom: [] }, codex: { order: [], hidden: [], custom: [] } },
|
|
159
|
+
commands: { claude: { order: [], hidden: [], custom: [] }, codex: { order: [], hidden: [], custom: [] }, workbuddy: { order: [], hidden: [], custom: [] } },
|
|
143
160
|
remote: {
|
|
144
161
|
terminal: true,
|
|
145
162
|
desktop: true,
|
package/src/core/experts.ts
CHANGED
|
@@ -16,8 +16,10 @@ import { canUseMcp, claudeMachineMcp, getMcp, isMachineId, machineName, specOf,
|
|
|
16
16
|
import { activeSkills, canSee, getSkill } from "./skills.js";
|
|
17
17
|
import { canUseResource, getUser } from "./users.js";
|
|
18
18
|
|
|
19
|
-
export type Engine = "claude" | "codex";
|
|
20
|
-
export const ENGINES: readonly Engine[] = ["claude", "codex"];
|
|
19
|
+
export type Engine = "claude" | "codex" | "workbuddy";
|
|
20
|
+
export const ENGINES: readonly Engine[] = ["claude", "codex", "workbuddy"];
|
|
21
|
+
/** 能建自定义专家的引擎。WorkBuddy 目前只有内置专家(工具名、子智能体还没对齐) */
|
|
22
|
+
export const EXPERT_ENGINES: readonly Engine[] = ["claude", "codex"];
|
|
21
23
|
|
|
22
24
|
/** 一级包含一级:能跑命令就等于能改任何文件 */
|
|
23
25
|
export type ExpertAccess = "web" | "read" | "edit" | "exec";
|
|
@@ -283,7 +285,7 @@ function validate(owner: string, input: ExpertInput, prev?: Expert, selfId?: str
|
|
|
283
285
|
const name = text(pick("name"), EXPERT_LIMITS.name, "名字");
|
|
284
286
|
if (!name) throw new Error("给专家起个名字");
|
|
285
287
|
const engine = pick("engine");
|
|
286
|
-
if (engine !== "claude" && engine !== "codex") throw new Error("引擎只能是 Claude 或 Codex");
|
|
288
|
+
if (engine !== "claude" && engine !== "codex") throw new Error(engine === "workbuddy" ? "WorkBuddy 暂不支持自定义专家,用内置的 WorkBuddy 就好" : "引擎只能是 Claude 或 Codex");
|
|
287
289
|
if (prev && prev.engine !== engine) throw new Error("建好之后不能换引擎(用这个专家的对话都是这个引擎的会话)");
|
|
288
290
|
const access = pick("access");
|
|
289
291
|
if (!ACCESS_LEVELS.includes(access as ExpertAccess)) throw new Error("权限不对");
|
package/src/core/git.ts
CHANGED
|
@@ -183,6 +183,22 @@ export async function findRepo(cwd: string): Promise<GitRepo> {
|
|
|
183
183
|
return { repo: true, root };
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/** 批量检查目录中的路径;非仓库、Git 不可用时不影响文件树。跟踪中的文件不会标成忽略。 */
|
|
187
|
+
export async function gitIgnoredPaths(cwd: string, paths: string[]): Promise<Set<string>> {
|
|
188
|
+
if (!paths.length) return new Set();
|
|
189
|
+
try {
|
|
190
|
+
if (!(await findRepo(cwd)).repo) return new Set();
|
|
191
|
+
// check-ignore 不运行 filter,直接复用安全配置即可。NUL 分隔兼容空格、换行和以 - 开头的文件名。
|
|
192
|
+
const out = await run(cwd, [...SAFE_CONFIG.flatMap((c) => ["-c", c]), "check-ignore", "-z", "--stdin"], STATUS_MAX_BYTES, {
|
|
193
|
+
input: `${paths.join("\0")}\0`,
|
|
194
|
+
});
|
|
195
|
+
if (out.code === 0 && !out.truncated) return new Set(out.stdout.split("\0").filter(Boolean));
|
|
196
|
+
} catch {
|
|
197
|
+
// 忽略标记只是辅助显示,失败仍然让用户正常浏览文件。
|
|
198
|
+
}
|
|
199
|
+
return new Set();
|
|
200
|
+
}
|
|
201
|
+
|
|
186
202
|
// ---------- status ----------
|
|
187
203
|
|
|
188
204
|
export type GitFileState = "modified" | "added" | "deleted" | "renamed" | "copied" | "typechange" | "untracked" | "conflicted";
|
package/src/core/hub.ts
CHANGED
|
@@ -2286,7 +2286,7 @@ class Hub extends EventEmitter<{ event: [EventEnvelope]; task: [TaskTurnEnd]; "p
|
|
|
2286
2286
|
...(channel ? { channel } : {}),
|
|
2287
2287
|
...(owner && getUser(owner)?.role !== "admin" ? { member: true } : {}),
|
|
2288
2288
|
});
|
|
2289
|
-
return { type: "commands", agent: conv.agent, commands: all.filter((c) => !c.hidden && (!["claude", "codex"].includes(c.name) || ctx.allowedExperts === undefined || ctx.allowedExperts.includes(c.name))) };
|
|
2289
|
+
return { type: "commands", agent: conv.agent, commands: all.filter((c) => !c.hidden && (!["claude", "codex", "workbuddy"].includes(c.name) || ctx.allowedExperts === undefined || ctx.allowedExperts.includes(c.name))) };
|
|
2290
2290
|
}
|
|
2291
2291
|
case "pwd":
|
|
2292
2292
|
return text(getConversation(key)!.cwd);
|
|
@@ -480,7 +480,7 @@ export function describeResult(r: CurateResult): string | undefined {
|
|
|
480
480
|
|
|
481
481
|
/** 按用户的设置挑 agent。指定的那个用不了就是 undefined(不悄悄换成另一个,免得用到他没想用的额度) */
|
|
482
482
|
export function pickDriver(settings: Pick<CurateSettings, "agent">): AgentDriver | undefined {
|
|
483
|
-
const usable = hub.enabledAgents().filter((d) => d.complete && agentAvailability(d.id as "claude" | "codex")?.available !== false);
|
|
483
|
+
const usable = hub.enabledAgents().filter((d) => d.complete && agentAvailability(d.id as "claude" | "codex" | "workbuddy")?.available !== false);
|
|
484
484
|
if (settings.agent !== "auto") return usable.find((d) => d.id === settings.agent);
|
|
485
485
|
return usable.find((d) => d.id === "claude") ?? usable[0];
|
|
486
486
|
}
|
|
@@ -525,7 +525,7 @@ export async function curateBatch(
|
|
|
525
525
|
const driver = opts.driver ?? pickDriver(memory.curate);
|
|
526
526
|
if (!driver) {
|
|
527
527
|
// 没有能用的 agent:留着,等它能用了再整理
|
|
528
|
-
log.error = memory.curate.agent === "auto" ? "没有能用的 agent" : `${
|
|
528
|
+
log.error = memory.curate.agent === "auto" ? "没有能用的 agent" : `${({ claude: "Claude", codex: "Codex", workbuddy: "WorkBuddy" } as Record<string, string>)[memory.curate.agent] ?? memory.curate.agent} 现在用不了(没启用、没装或没登录)`;
|
|
529
529
|
patchMeta(userId, { lastCuration: log });
|
|
530
530
|
return log;
|
|
531
531
|
}
|
package/src/core/memory.ts
CHANGED
|
@@ -102,7 +102,7 @@ export type CurateSettings = {
|
|
|
102
102
|
idleMinutes: number;
|
|
103
103
|
dailyHour: number;
|
|
104
104
|
/** auto:Claude 能用就用 Claude,否则 Codex */
|
|
105
|
-
agent: "auto" | "claude" | "codex";
|
|
105
|
+
agent: "auto" | "claude" | "codex" | "workbuddy";
|
|
106
106
|
/** 空 = 这个 agent 最省的默认(Claude 用 Haiku,Codex 用默认模型、思考程度 low) */
|
|
107
107
|
model: string;
|
|
108
108
|
};
|
|
@@ -120,7 +120,7 @@ function cleanCurate(raw: Partial<CurateSettings> | undefined, base: CurateSetti
|
|
|
120
120
|
: base.experts;
|
|
121
121
|
const idle = Math.round(Number(r.idleMinutes ?? base.idleMinutes));
|
|
122
122
|
const hour = Math.round(Number(r.dailyHour ?? base.dailyHour));
|
|
123
|
-
const agent = (["auto", "claude", "codex"] as const).find((a) => a === r.agent) ?? base.agent;
|
|
123
|
+
const agent = (["auto", "claude", "codex", "workbuddy"] as const).find((a) => a === r.agent) ?? base.agent;
|
|
124
124
|
const model = typeof r.model === "string" ? r.model.trim().slice(0, 100) : base.model;
|
|
125
125
|
return {
|
|
126
126
|
when,
|
package/src/core/permission.ts
CHANGED
|
@@ -31,7 +31,7 @@ export function isPermissionLevel(v: unknown): v is PermissionLevel {
|
|
|
31
31
|
return typeof v === "string" && (PERMISSION_LEVELS as readonly string[]).includes(v);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/** 这个引擎认不认这一级:自动判断只有 Claude
|
|
34
|
+
/** 这个引擎认不认这一级:自动判断只有 Claude 有(WorkBuddy 也按自动改文件算) */
|
|
35
35
|
export function engineSupports(agent: string, level: PermissionLevel): boolean {
|
|
36
36
|
return level !== "auto" || agent === "claude";
|
|
37
37
|
}
|
package/src/core/users.ts
CHANGED
|
@@ -204,7 +204,7 @@ function cleanPermissions(value: unknown, current: ResourcePermissions = {}): Re
|
|
|
204
204
|
for (const [kind, ids] of Object.entries(value)) {
|
|
205
205
|
if (!["experts", "agents", "servers"].includes(kind)) throw new Error("未知的使用权限");
|
|
206
206
|
if (ids !== null && (!Array.isArray(ids) || ids.length > 200 || ids.some((id) => typeof id !== "string" || !/^[\w-]{1,100}$/.test(id)))) throw new Error("使用权限必须是 ID 列表或 null");
|
|
207
|
-
if (kind === "agents" && ids?.some((id: string) => !["claude", "codex"].includes(id))) throw new Error("未知的内置 Agent");
|
|
207
|
+
if (kind === "agents" && ids?.some((id: string) => !["claude", "codex", "workbuddy"].includes(id))) throw new Error("未知的内置 Agent");
|
|
208
208
|
next[kind as ResourceKind] = ids === null ? null : [...new Set(ids as string[])];
|
|
209
209
|
}
|
|
210
210
|
return next;
|
package/src/main.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { flushStore, getConversation } from "./core/store.js";
|
|
|
5
5
|
import { backfillLibrary, startLibraryCapture, tidyLibrary } from "./core/library.js";
|
|
6
6
|
import { ClaudeDriver } from "./agents/claude/driver.js";
|
|
7
7
|
import { CodexDriver } from "./agents/codex/driver.js";
|
|
8
|
+
import { WorkBuddyDriver } from "./agents/workbuddy/driver.js";
|
|
8
9
|
import { agentHealth } from "./agents/health.js";
|
|
9
10
|
import { startFeishu, stopFeishu } from "./channels/feishu/index.js";
|
|
10
11
|
import { startWeixin, stopWeixin } from "./channels/weixin/index.js";
|
|
@@ -20,7 +21,7 @@ import { startScheduler, stopScheduler } from "./core/scheduled.js";
|
|
|
20
21
|
import { startTaskRunner, stopTaskRunner } from "./core/task-runner.js";
|
|
21
22
|
import { startTasksBridge, stopTasksBridge } from "./core/tasks-bridge.js";
|
|
22
23
|
|
|
23
|
-
async function startDriver(id: "claude" | "codex"): Promise<void> {
|
|
24
|
+
async function startDriver(id: "claude" | "codex" | "workbuddy"): Promise<void> {
|
|
24
25
|
const driver = hub.driver(id);
|
|
25
26
|
if (!driver) return;
|
|
26
27
|
try {
|
|
@@ -37,11 +38,14 @@ async function main(): Promise<void> {
|
|
|
37
38
|
|
|
38
39
|
hub.registerDriver(new ClaudeDriver());
|
|
39
40
|
hub.registerDriver(new CodexDriver());
|
|
41
|
+
hub.registerDriver(new WorkBuddyDriver());
|
|
40
42
|
if (config().agents.claude.enabled) await startDriver("claude");
|
|
41
43
|
if (config().agents.codex.enabled) await startDriver("codex");
|
|
42
|
-
|
|
44
|
+
if (config().agents.workbuddy.enabled) void startDriver("workbuddy");
|
|
45
|
+
// Web 上新启用了 Codex:现拉 app-server;WorkBuddy 预先加载 SDK
|
|
43
46
|
onConfigChange((next, prev) => {
|
|
44
47
|
if (next.agents.codex.enabled && !prev.agents.codex.enabled) void startDriver("codex");
|
|
48
|
+
if (next.agents.workbuddy.enabled && !prev.agents.workbuddy.enabled) void startDriver("workbuddy");
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
// 资料库:升级时把已有的附件收进来(只一次),再清掉对话没了的、上传了一直没发的
|
package/web/css/workspace.css
CHANGED
package/web/lib/dom.js
CHANGED
|
@@ -87,6 +87,8 @@ export const ICON = {
|
|
|
87
87
|
ICON.claude = '<svg viewBox="0 0 640 640"><path fill="#D97757" fill-rule="evenodd" d="M173 2C168 3 167 4 158 17C146 32 146 32 151 52C155 66 155 66 164 81C188 118 252 233 250 235C248 238 246 237 241 233C238 230 221 218 203 204C185 191 156 169 138 156C94 122 96 123 92 122C90 122 84 121 77 120L66 120 58 129L49 139 51 152C52 159 53 165 53 165C53 168 65 179 74 186C80 190 92 199 101 205C110 211 129 225 144 235C185 262 247 304 252 307C254 310 255 311 254 312C253 315 246 315 212 311C196 309 170 307 153 306C114 304 35 298 24 297L14 296 8 301C2 305 1 305 1 310C0 314 0 314 7 323L14 333 21 334C31 337 103 341 170 342C230 344 251 345 252 347C253 347 253 349 253 351C252 355 251 355 190 390C136 420 124 427 102 442C68 465 69 464 68 477L67 486 74 493C79 498 81 499 83 498C84 498 91 497 98 496L110 495 194 440C240 410 279 386 280 385C281 385 281 386 281 387C281 389 277 394 269 404C262 411 248 429 238 442C227 456 204 486 186 509C143 564 143 563 143 574L142 583 152 588L161 593 167 590C172 588 174 586 196 563C220 536 230 524 295 435C308 416 315 408 316 408C318 408 318 408 316 417C315 421 312 436 310 450C306 475 295 533 284 584L279 608 283 618C287 628 287 628 296 634L304 640 313 636C321 633 323 632 327 628L331 623 340 526C348 445 349 429 351 428C353 427 353 426 369 454C395 498 454 586 459 588C461 588 465 589 469 590C476 591 476 591 484 588C492 586 492 585 494 581L496 576 495 562L493 547 456 492C436 461 419 435 419 434C419 433 420 432 421 432C423 432 460 463 486 486C501 499 553 538 557 539C563 541 564 540 569 534L573 528 571 520C570 514 569 512 566 509C556 500 502 450 478 429C447 401 420 374 420 372C420 370 424 371 443 375C453 378 493 388 533 397L606 414 622 406L638 398 639 392L640 385 634 377C628 369 626 367 617 361L606 354 574 351C553 350 528 349 502 348C464 347 425 344 423 342C422 341 419 342 472 329C496 323 531 316 549 312C568 308 594 302 606 299L629 294 633 283C638 273 638 272 637 267L636 262 625 257L613 251 591 255C548 262 523 267 486 275C439 285 443 284 441 283C440 281 441 278 450 263C463 241 486 209 540 142C547 133 547 132 551 118C553 110 555 103 555 102C555 101 551 94 545 86L536 72 521 72L507 72 499 79C480 94 436 145 396 199C381 219 375 226 371 226C370 226 369 225 369 225C369 223 376 184 386 133C390 114 395 83 398 66L403 35 396 26C390 18 389 17 383 13C379 12 375 10 375 10C374 10 369 13 364 16L354 23 349 35C343 49 344 45 339 105C337 125 335 152 333 167C331 181 329 202 329 212C326 245 326 244 324 244C322 244 321 241 317 229C313 216 311 211 286 162C261 113 248 87 226 35C212 4 212 4 181 1C179 0 175 1 173 2"/></svg>';
|
|
88
88
|
/** OpenAI 的标志,也是内置专家 Codex 的头像。跟着文字颜色(深色模式下是白的) */
|
|
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
|
+
// WorkBuddy:自己画的简单标记(蓝底白色 W),不是官方 logo
|
|
91
|
+
ICON.workbuddy = '<svg viewBox="0 0 24 24"><rect x="1.5" y="1.5" width="21" height="21" rx="6" fill="#2F6BFF"/><path d="M6 8l2.6 8 3.4-6.2 3.4 6.2L18 8" fill="none" stroke="#fff" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
90
92
|
|
|
91
93
|
/**
|
|
92
94
|
* 星星加载动画(回复末尾、打开会话时用)。开屏那个带台面的完整 logo 动画直接写在 index.html 里。
|
package/web/settings/agents.js
CHANGED
|
@@ -8,6 +8,17 @@ import { renderEmpty } from "../views/messages.js";
|
|
|
8
8
|
import { field, saveButton, saveConfig } from "./common.js";
|
|
9
9
|
import { modelPicker } from "./commands.js";
|
|
10
10
|
|
|
11
|
+
const ENGINE_LABEL = { claude: "Claude Code", codex: "Codex", workbuddy: "WorkBuddy" };
|
|
12
|
+
const ENGINES = Object.keys(ENGINE_LABEL);
|
|
13
|
+
/** 设置里的默认权限「跟随」时实际是什么 */
|
|
14
|
+
const FOLLOW_LABEL = { claude: "跟随 Claude Code(逐次询问)", codex: "跟随沙箱设置", workbuddy: "跟随 WorkBuddy(逐次询问)" };
|
|
15
|
+
const WORKBUDDY_SITES = [
|
|
16
|
+
["workbuddy", "WorkBuddy(www.workbuddy.cn,用本机的 WorkBuddy 桌面版)"],
|
|
17
|
+
["internal", "CodeBuddy 国内版(copilot.tencent.com)"],
|
|
18
|
+
["external", "CodeBuddy 国际版(codebuddy.ai)"],
|
|
19
|
+
["ioa", "腾讯 iOA"],
|
|
20
|
+
];
|
|
21
|
+
|
|
11
22
|
/**
|
|
12
23
|
* 设置 → Agent:勾选哪些模型出现在输入框的模型列表里。
|
|
13
24
|
* 全部勾上存成空数组 = 「全部显示」,以后 agent 新增的模型也会自动出现;
|
|
@@ -115,13 +126,16 @@ function agentHealthSection() {
|
|
|
115
126
|
? h(
|
|
116
127
|
"div",
|
|
117
128
|
{ class: "health-fix" },
|
|
118
|
-
|
|
129
|
+
a.fix.web || !a.fix.commands.length
|
|
130
|
+
? h("div", {}, `${a.fix.title}:`)
|
|
131
|
+
: h("div", {}, `${a.fix.title}:在运行 agent-loft 的机器上打开终端执行${a.fix.commands.length > 1 ? "(任选一条)" : ""}`),
|
|
119
132
|
a.fix.commands.map((cmd) => {
|
|
120
133
|
const copy = h("button", { class: "btn small", onclick: () => copyText(cmd, copy) }, "复制");
|
|
121
134
|
return h("div", { class: "health-cmd" }, h("code", {}, cmd), copy);
|
|
122
135
|
}),
|
|
123
136
|
a.fix.note ? h("small", {}, a.fix.note) : null,
|
|
124
137
|
a.id === "codex" && a.fix.action === "install" ? installCodexButton(() => load(true)) : null,
|
|
138
|
+
a.id === "workbuddy" && a.fix.web ? workbuddyLoginButton(() => load(true)) : null,
|
|
125
139
|
)
|
|
126
140
|
: null,
|
|
127
141
|
);
|
|
@@ -157,6 +171,57 @@ function installCodexButton(after) {
|
|
|
157
171
|
return h("div", {}, btn);
|
|
158
172
|
}
|
|
159
173
|
|
|
174
|
+
/**
|
|
175
|
+
* WorkBuddy 网页登录:服务端拿到登录链接,在新标签页里打开(用的是你自己的浏览器,不是服务器的),
|
|
176
|
+
* 登录完这边轮询到结果就重新检查。弹窗被拦时把链接留在按钮下面,手动点
|
|
177
|
+
*/
|
|
178
|
+
function workbuddyLoginButton(after) {
|
|
179
|
+
const status = h("small", {});
|
|
180
|
+
const btn = h(
|
|
181
|
+
"button",
|
|
182
|
+
{
|
|
183
|
+
class: "btn small primary",
|
|
184
|
+
onclick: async () => {
|
|
185
|
+
// 先开空白页再填地址:等接口回来再 window.open 会被浏览器当成弹窗拦掉
|
|
186
|
+
const tab = window.open("", "_blank");
|
|
187
|
+
btn.disabled = true;
|
|
188
|
+
btn.textContent = "正在获取登录链接…";
|
|
189
|
+
try {
|
|
190
|
+
const { url } = await api("/api/agents/workbuddy/login", { method: "POST" });
|
|
191
|
+
if (tab) tab.location.href = url;
|
|
192
|
+
fill(status, "请在 1 分钟内在打开的页面里登录(超时要重新点),完成后这里会自动刷新。没弹出来的话点这里:", h("a", { href: url, target: "_blank", rel: "noopener" }, "打开登录页"));
|
|
193
|
+
btn.textContent = "等待登录…";
|
|
194
|
+
const started = Date.now();
|
|
195
|
+
const poll = async () => {
|
|
196
|
+
if (!btn.isConnected) return;
|
|
197
|
+
const st = await api("/api/agents/workbuddy/login").catch(() => null);
|
|
198
|
+
if (st?.status === "done") {
|
|
199
|
+
toast(`WorkBuddy 已登录:${st.user}`);
|
|
200
|
+
after();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (st?.status === "failed" || Date.now() - started > 3 * 60_000) {
|
|
204
|
+
fill(status, `登录没有完成:${st?.error ?? "超时"}。点「重新登录」再来一次,拿到链接后尽快登录`);
|
|
205
|
+
btn.disabled = false;
|
|
206
|
+
btn.textContent = "重新登录";
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
setTimeout(poll, 2000);
|
|
210
|
+
};
|
|
211
|
+
setTimeout(poll, 2000);
|
|
212
|
+
} catch (err) {
|
|
213
|
+
tab?.close();
|
|
214
|
+
toast(err.message, 6000);
|
|
215
|
+
btn.disabled = false;
|
|
216
|
+
btn.textContent = "登录 WorkBuddy";
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
"登录 WorkBuddy",
|
|
221
|
+
);
|
|
222
|
+
return h("div", {}, btn, status);
|
|
223
|
+
}
|
|
224
|
+
|
|
160
225
|
/** 个人默认工具单独保存,避免改服务器配置时覆盖尚未保存的个人选择。 */
|
|
161
226
|
function builtinDefaultsSections(targets) {
|
|
162
227
|
const load = async () => {
|
|
@@ -189,7 +254,7 @@ function builtinDefaultsSections(targets) {
|
|
|
189
254
|
if (section.parentElement?.dataset.personal) section.parentElement.hidden = true;
|
|
190
255
|
continue;
|
|
191
256
|
}
|
|
192
|
-
const label = engine
|
|
257
|
+
const label = ENGINE_LABEL[engine] ?? engine;
|
|
193
258
|
const skills = picker(`${label} 技能`, data.skills, prefs.skills, "全部已启用的个人技能(含以后新增)");
|
|
194
259
|
const machine = (data.machineMcp?.[engine] ?? []).map((name) => ({ id: `${data.machinePrefix}${name}`, name: `${name}(本机)` }));
|
|
195
260
|
const mcp = picker(`${label} MCP`, [...data.mcp, ...machine], prefs.mcp, data.machineMcp ? "沿用机器上的 MCP 配置" : null);
|
|
@@ -197,7 +262,7 @@ function builtinDefaultsSections(targets) {
|
|
|
197
262
|
// 成员最高到自动改文件;自动判断只有 Claude 有
|
|
198
263
|
const levels = DEFAULT_LEVELS.filter((l) => engineSupports(engine, l) && (l !== "auto" || isAdmin()));
|
|
199
264
|
const permission = h("select", { "aria-label": `${label} 默认权限` },
|
|
200
|
-
h("option", { value: "", selected: !prefs.permission }, engine
|
|
265
|
+
h("option", { value: "", selected: !prefs.permission }, FOLLOW_LABEL[engine] ?? "跟随默认"),
|
|
201
266
|
levels.map((l) => h("option", { value: l, selected: l === prefs.permission }, `${PERMISSIONS[l].label}:${PERMISSIONS[l].desc}`)));
|
|
202
267
|
fill(section, h("h4", {}, "默认权限"),
|
|
203
268
|
field("新对话的权限", permission, "没单独选过权限的对话都按这一级(输入框里的盾牌按钮可以随时改)。自定义专家也按它,但不会超过专家自己的权限;定时任务按任务里选的。「完全允许」不能设成默认。"),
|
|
@@ -227,19 +292,20 @@ function builtinDefaultsSections(targets) {
|
|
|
227
292
|
}
|
|
228
293
|
|
|
229
294
|
export function agentsTab(cfg, page) {
|
|
230
|
-
const targets = Object.fromEntries(
|
|
295
|
+
const targets = Object.fromEntries(ENGINES.map((engine) => [engine, h("div", { class: "builtin-agent-defaults", "data-form": "" }, h("span", { class: "spinner" }))]));
|
|
231
296
|
if (!cfg) {
|
|
232
|
-
for (const [engine, target] of Object.entries(targets)) page.append(h("div", { class: "section", "data-personal": "true", "data-agent": engine }, h("h4", {}, engine
|
|
297
|
+
for (const [engine, target] of Object.entries(targets)) page.append(h("div", { class: "section", "data-personal": "true", "data-agent": engine }, h("h4", {}, ENGINE_LABEL[engine]), target));
|
|
233
298
|
builtinDefaultsSections(targets);
|
|
234
299
|
return;
|
|
235
300
|
}
|
|
236
301
|
page.append(agentHealthSection());
|
|
237
302
|
const a = structuredClone(cfg.agents);
|
|
238
|
-
for (const engine of
|
|
239
|
-
const label = engine
|
|
303
|
+
for (const engine of ENGINES) {
|
|
304
|
+
const label = ENGINE_LABEL[engine];
|
|
240
305
|
const settings = a[engine];
|
|
306
|
+
if (!settings) continue;
|
|
241
307
|
const on = h("input", { type: "checkbox", checked: settings.enabled });
|
|
242
|
-
const pick = modelPicker(engine, settings.defaultModel, settings.defaultEffort, engine === "claude" ? "跟随 Claude Code 默认" : "跟随 config.toml");
|
|
308
|
+
const pick = modelPicker(engine, settings.defaultModel, settings.defaultEffort, engine === "claude" ? "跟随 Claude Code 默认" : engine === "workbuddy" ? "跟随 WorkBuddy 默认" : "跟随 config.toml");
|
|
243
309
|
const models = modelChecklist(engine, settings.models ?? []);
|
|
244
310
|
const config = h("div", { class: "agent-config", "data-form": "" },
|
|
245
311
|
h("h4", {}, label, h("span", { class: "grow" }), h("label", { class: "check" }, on, "启用")));
|
|
@@ -257,7 +323,24 @@ export function agentsTab(cfg, page) {
|
|
|
257
323
|
codex = { path, home, sandbox, titleOn, titlePick, titleModel };
|
|
258
324
|
config.append(field("codex 可执行文件", path, "以系统服务运行时 PATH 很短,建议写绝对路径"), field("CODEX_HOME", home), field("沙箱", sandbox, "workspace-write:目录内可读写,越界才弹授权。danger-full-access 等于关掉沙箱"));
|
|
259
325
|
}
|
|
260
|
-
|
|
326
|
+
let site = null;
|
|
327
|
+
let cliPath = null;
|
|
328
|
+
if (engine === "workbuddy") {
|
|
329
|
+
site = h("select", {}, WORKBUDDY_SITES.map(([value, name]) => h("option", { value, selected: value === (settings.environment || "workbuddy") }, name)));
|
|
330
|
+
cliPath = h("input", { value: settings.cliPath ?? "", placeholder: "留空自动找(如 /opt/WorkBuddy/resources/app.asar.unpacked/cli/bin/codebuddy)" });
|
|
331
|
+
const cliField = field("WorkBuddy CLI 路径", cliPath, "WorkBuddy 桌面版里自带的 CLI,装在常见位置时不用填");
|
|
332
|
+
const syncSite = () => { cliField.hidden = site.value !== "workbuddy"; };
|
|
333
|
+
site.addEventListener("change", syncSite);
|
|
334
|
+
syncSite();
|
|
335
|
+
config.append(
|
|
336
|
+
h("p", { class: "muted" }, "腾讯 WorkBuddy:调用这台服务器上 WorkBuddy 桌面版自带的 CLI;也可以改用 CodeBuddy 的账号(用 agent-loft 自带的 CLI)。启用并保存后,到上面「运行环境」里登录——桌面版里登录过也要在这里再登一次,同一个账号就行。暂不支持自定义专家和分叉。"),
|
|
337
|
+
field("账号站点", site, "登录和对话都走这个站点。换了站点要重新登录"),
|
|
338
|
+
cliField,
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
config.append(field("默认模型", pick.modelEl));
|
|
342
|
+
if (engine !== "workbuddy") config.append(field("默认思考程度", pick.effortEl));
|
|
343
|
+
config.append(h("div", { class: "field" }, h("span", {}, "输入框可选模型"), models.el));
|
|
261
344
|
if (codex) config.append(h("div", { class: "row title-row" }, h("label", { class: "check" }, codex.titleOn, "自动生成会话名称"), codex.titleModel));
|
|
262
345
|
config.append(h("div", { class: "row" }, saveButton(() => {
|
|
263
346
|
const selected = models.value();
|
|
@@ -267,6 +350,7 @@ export function agentsTab(cfg, page) {
|
|
|
267
350
|
}
|
|
268
351
|
return saveConfig(cfg, { agents: { [engine]: {
|
|
269
352
|
enabled: on.checked, defaultModel: pick.model(), defaultEffort: pick.effort(), models: selected,
|
|
353
|
+
...(site ? { environment: site.value, cliPath: cliPath.value.trim() } : {}),
|
|
270
354
|
...(codex ? { path: codex.path.value.trim() || "codex", home: codex.home.value.trim(), sandbox: codex.sandbox.value, autoTitle: codex.titleOn.checked, titleModel: codex.titlePick.model() } : {}),
|
|
271
355
|
} } });
|
|
272
356
|
}, `保存 ${label} 设置`)));
|
package/web/settings/commands.js
CHANGED
|
@@ -75,7 +75,7 @@ export function modelPicker(agent, model, effort, defaultLabel) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
/** agent-loft 内置命令名(和服务端 BUILTIN_COMMANDS 一致),自定义命令不能用 */
|
|
78
|
-
const BUILTIN_NAMES = ["new", "status", "stop", "model", "effort", "sessions", "resume", "fork", "agent", "claude", "codex", "cd", "pwd", "permission", "planmode", "autoedit", "web", "detach", "approve", "help"];
|
|
78
|
+
const BUILTIN_NAMES = ["new", "status", "stop", "model", "effort", "sessions", "resume", "fork", "agent", "claude", "codex", "workbuddy", "cd", "pwd", "permission", "planmode", "autoedit", "web", "detach", "approve", "help"];
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* 添加 / 编辑一条自定义命令。onSave 返回 true 才关窗;失败(比如服务端校验没过)留着让用户改。
|
package/web/settings/experts.js
CHANGED
|
@@ -10,7 +10,7 @@ import { changeCwd } from "../views/conv-actions.js";
|
|
|
10
10
|
// 专家 = 一份配置:引擎、提示词、权限、技能、MCP、子智能体。新建对话、定时任务时选,对话中途不能换。
|
|
11
11
|
// 内置的 Claude Code / Codex 不在这里改(就是 agent 原装的样子)。
|
|
12
12
|
|
|
13
|
-
const ENGINE_LABEL = { claude: "Claude", codex: "Codex" };
|
|
13
|
+
const ENGINE_LABEL = { claude: "Claude", codex: "Codex", workbuddy: "WorkBuddy" };
|
|
14
14
|
/** 权限的几项勾选。读文件 → 改文件 → 跑命令一级包含一级(跑命令就等于能改任何文件) */
|
|
15
15
|
const PERMS = [
|
|
16
16
|
{ id: "webSearch", label: "联网搜索", hint: "用搜索引擎查资料" },
|
package/web/settings/memory.js
CHANGED
|
@@ -519,6 +519,7 @@ function curateSection(mem, reload) {
|
|
|
519
519
|
["auto", "自动:有 Claude 就用 Claude,否则 Codex"],
|
|
520
520
|
["claude", "Claude Code"],
|
|
521
521
|
["codex", "Codex"],
|
|
522
|
+
["workbuddy", "WorkBuddy"],
|
|
522
523
|
],
|
|
523
524
|
(v) => save({ agent: v, model: "" }),
|
|
524
525
|
);
|
|
@@ -526,7 +527,7 @@ function curateSection(mem, reload) {
|
|
|
526
527
|
c.agent === "auto"
|
|
527
528
|
? null
|
|
528
529
|
: (() => {
|
|
529
|
-
const sel = h("select", { onchange: (e) => save({ model: e.target.value }) }, h("option", { value: "" }, c.agent === "claude" ? "默认:Haiku(最省)" : "默认模型,思考程度 low(最省)"));
|
|
530
|
+
const sel = h("select", { onchange: (e) => save({ model: e.target.value }) }, h("option", { value: "" }, c.agent === "claude" ? "默认:Haiku(最省)" : c.agent === "workbuddy" ? "默认模型" : "默认模型,思考程度 low(最省)"));
|
|
530
531
|
if (c.model) sel.append(h("option", { value: c.model, selected: true }, c.model));
|
|
531
532
|
agentCatalog(c.agent)
|
|
532
533
|
.then((models) => {
|
package/web/views/composer.js
CHANGED
|
@@ -359,7 +359,7 @@ export async function sendMessage() {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
/** 会改变当前会话(换会话、换目录、换 agent)的命令,执行完要重拉一遍 */
|
|
362
|
-
const RELOADING_COMMANDS = new Set(["new", "fork", "resume", "agent", "claude", "codex", "cd"]);
|
|
362
|
+
const RELOADING_COMMANDS = new Set(["new", "fork", "resume", "agent", "claude", "codex", "workbuddy", "cd"]);
|
|
363
363
|
|
|
364
364
|
/** agent-loft 命令的结果:只显示给发命令的这个页面,不进会话记录 */
|
|
365
365
|
async function showCommandReply(text, reply, info) {
|
package/web/views/interaction.js
CHANGED
|
@@ -101,7 +101,7 @@ export function renderInteraction(item) {
|
|
|
101
101
|
spec.allowSession
|
|
102
102
|
? h("button", { class: "btn primary", onclick: () => ixOp(ix.id, "decide", { decision: "allow-session" }) }, "本会话全部允许")
|
|
103
103
|
: null,
|
|
104
|
-
h("button", { class: `btn${spec.allowSession ? "" : "
|
|
104
|
+
h("button", { class: `btn${spec.allowSession ? "" : " primary"}`, onclick: () => ixOp(ix.id, "decide", { decision: "allow-once" }) }, spec.allowLabel ?? "允许一次"),
|
|
105
105
|
// 会落盘、对所有人生效的「总是允许」只给管理员
|
|
106
106
|
spec.alwaysLabel && (!spec.alwaysGlobal || isAdmin())
|
|
107
107
|
? h("button", { class: "btn", onclick: () => ixOp(ix.id, "decide", { decision: "allow-always" }) }, spec.alwaysLabel)
|
package/web/views/sidebar.js
CHANGED
|
@@ -238,7 +238,7 @@ function convExpertMark(c) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
function agentShort(id) {
|
|
241
|
-
return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id;
|
|
241
|
+
return id === "claude" ? "Claude" : id === "codex" ? "Codex" : id === "workbuddy" ? "WorkBuddy" : id;
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
/** 侧栏状态:order 混排目录路径和渠道分组,兼容原有的顺序。 */
|
package/web/views/topbar.js
CHANGED
|
@@ -48,7 +48,7 @@ export function renderTopbar() {
|
|
|
48
48
|
// ---------- 顶栏的专家头像和信息卡 ----------
|
|
49
49
|
|
|
50
50
|
const ACCESS_LABEL = { web: "只能联网", read: "能读文件", edit: "能改文件", exec: "能跑命令" };
|
|
51
|
-
const ENGINE_LABEL = { claude: "Claude", codex: "Codex" };
|
|
51
|
+
const ENGINE_LABEL = { claude: "Claude", codex: "Codex", workbuddy: "WorkBuddy" };
|
|
52
52
|
/** 鼠标停多久才弹、离开多久才收(从头像挪到卡片上的那一下不能收) */
|
|
53
53
|
const HOVER_OPEN_MS = 250;
|
|
54
54
|
const HOVER_CLOSE_MS = 200;
|
package/web/views/workspace.js
CHANGED
|
@@ -454,9 +454,9 @@ function treeRows(rel, depth) {
|
|
|
454
454
|
h(
|
|
455
455
|
"button",
|
|
456
456
|
{
|
|
457
|
-
class: `ws-row${entry.name.startsWith(".") ? " faint" : ""}`,
|
|
457
|
+
class: `ws-row${entry.name.startsWith(".") ? " faint" : ""}${entry.ignored ? " ignored" : ""}`,
|
|
458
458
|
style: { paddingLeft: `${12 + depth * 16}px` },
|
|
459
|
-
title: entry.path,
|
|
459
|
+
title: entry.ignored ? `${entry.path}(Git 已忽略)` : entry.path,
|
|
460
460
|
...(dir ? { "aria-expanded": open ? "true" : "false" } : {}),
|
|
461
461
|
onclick: () => (dir ? toggleDir(entry.path) : openDetail({ kind: "file", path: entry.path, from: null })),
|
|
462
462
|
},
|