agent-loft 0.2.117 → 0.2.118

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-loft",
3
- "version": "0.2.117",
3
+ "version": "0.2.118",
4
4
  "type": "module",
5
5
  "description": "多个 agent 的工作台:把本机 Claude Code / Codex 放到一处统一管理,用飞书和 Web 页面随时驱动——会话、审批、模型切换都共用",
6
6
  "keywords": [
@@ -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 || (cli.trim() && !path.isAbsolute(cli.trim()))) throw new HttpError(400, "CLI 路径要写绝对路径,留空自动找");
356
- (patch as { cliPath: string }).cliPath = cli.trim();
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.trim();
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 要写绝对路径,留空用 ~/.dsh" : "patch 文件要写绝对路径,留空不加");
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");
@@ -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";
@@ -265,6 +266,16 @@ function normalizeCommands(cfg: AppConfig): void {
265
266
  for (const id of AGENT_IDS) cfg.commands[id].custom = cleanCustomCommands(cfg.commands[id].custom);
266
267
  }
267
268
 
269
+ /** 所有入口统一展开,启动、健康检查和技能扫描读取同一个路径。 */
270
+ function normalizeAgentPaths(cfg: AppConfig): void {
271
+ cfg.agents.codex.path = expandHomePath(cfg.agents.codex.path) || "codex";
272
+ cfg.agents.codex.home = expandHomePath(cfg.agents.codex.home);
273
+ cfg.agents.workbuddy.cliPath = expandHomePath(cfg.agents.workbuddy.cliPath);
274
+ cfg.agents.dsh.path = expandHomePath(cfg.agents.dsh.path) || "dsh";
275
+ cfg.agents.dsh.home = expandHomePath(cfg.agents.dsh.home);
276
+ cfg.agents.dsh.patch = expandHomePath(cfg.agents.dsh.patch);
277
+ }
278
+
268
279
  let current: AppConfig | null = null;
269
280
  const listeners = new Set<(next: AppConfig, prev: AppConfig) => void>();
270
281
 
@@ -273,6 +284,7 @@ export function loadConfig(): AppConfig {
273
284
  ensureDirs();
274
285
  const raw = readJson<unknown>(configPath, null);
275
286
  const merged = mergeDefaults(defaultConfig(), raw);
287
+ normalizeAgentPaths(merged);
276
288
  merged.workspaceRoot = path.resolve(merged.workspaceRoot);
277
289
  merged.feishu.bots = merged.feishu.bots.map(normalizeBot);
278
290
  normalizeCommands(merged);
@@ -300,6 +312,7 @@ function watchExternalEdits(): void {
300
312
  const raw = readJson<unknown>(configPath, null);
301
313
  if (!raw || !current) return;
302
314
  const next = mergeDefaults(defaultConfig(), raw);
315
+ normalizeAgentPaths(next);
303
316
  next.workspaceRoot = path.resolve(next.workspaceRoot);
304
317
  next.feishu.bots = next.feishu.bots.map(normalizeBot);
305
318
  normalizeCommands(next);
@@ -330,6 +343,7 @@ export function config(): AppConfig {
330
343
  export function saveConfig(next: AppConfig): AppConfig {
331
344
  const prev = config();
332
345
  const normalized = mergeDefaults(defaultConfig(), next);
346
+ normalizeAgentPaths(normalized);
333
347
  normalized.workspaceRoot = path.resolve(normalized.workspaceRoot);
334
348
  normalized.feishu.bots = normalized.feishu.bots.map(normalizeBot);
335
349
  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 = '<svg viewBox="0 0 64 64"><rect x="2" y="2" width="60" height="60" rx="14" fill="#4D6BFE"/><path fill="none" stroke="#fff" stroke-width="6" stroke-linecap="round" stroke-linejoin="round" d="M17 22l12 10-12 10M33 44h14"/></svg>';
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
 
@@ -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];
@@ -271,7 +272,7 @@ export function agentsTab(cfg, page) {
271
272
  if (engine === "dsh") {
272
273
  const path = h("input", { value: settings.path ?? "dsh", placeholder: "dsh" });
273
274
  const home = h("input", { value: settings.home ?? "", placeholder: "留空用 ~/.dsh" });
274
- const patch = h("input", { value: settings.patch ?? "", placeholder: "留空不加(绝对路径,如 /home/me/.dsh/loft.patch.yml)" });
275
+ const patch = h("input", { value: settings.patch ?? "", placeholder: "留空不加(如 ~/.dsh/loft.patch.yml)" });
275
276
  dsh = { path, home, patch };
276
277
  config.append(
277
278
  h("p", { class: "muted" }, "dsh(DeepSeek Harness):DeepSeek 官方的编程 agent,通过标准 ACP 协议接入,每个会话一个 dsh 进程(第一条消息要等 4~5 秒拉起)。用 dsh 自己的凭据(~/.dsh/.credentials.yaml 里的 DeepSeek API Key)和会话记录,dsh 网页里建的会话这里也能接着聊。权限用 dsh 的沙箱:逐次询问 = 只读、自动改文件 = 工作区可写、完全允许 = 不设沙箱;越界时弹授权卡。不支持自定义专家、分叉 / 回退、提问卡和图片直传(附件给路径);设成「调用前询问」的 MCP 不会挂上。"),