@aiti-ai/aiti-custom-agent 0.1.10 → 0.1.12

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.
@@ -288,6 +288,8 @@ export function detectPrefix(m) {
288
288
 
289
289
  export function registerCustomAgentClient(ctx, config) {
290
290
  const h = (...a) => ctx.h(...a);
291
+ // i18n: host ctx.t (index.ts ui.i18n entries, zh/en tables); falls back to the bare key on old hosts (same pattern as agent-manager)
292
+ const t = (k, p2) => { const fn = ctx.t; return typeof fn === "function" ? fn(k, p2) : k; };
291
293
  const useState = (v) => ctx.useState(v);
292
294
  const useEffect = (fn, deps) => ctx.useEffect(fn, deps);
293
295
  const api = (p, init) => fetch(ctx.apiUrl("/api/extensions/" + config.extId + p), { cache: "no-store", ...init });
@@ -296,8 +298,8 @@ export function registerCustomAgentClient(ctx, config) {
296
298
  ctx.registerItems("toolbar", [{
297
299
  id: `${config.extId}-panel`,
298
300
  meta: {
299
- label: "自定义 Agent",
300
- title: "自定义 Agent:注册自定义后端(命令/参数前缀/env/桥模式)",
301
+ label: "i18n:it.panel.label",
302
+ title: "i18n:it.panel.title",
301
303
  icon: "icons/bot.svg",
302
304
  onClick: () => {
303
305
  if (!moduleSetOpen) return;
@@ -323,7 +325,7 @@ export function registerCustomAgentClient(ctx, config) {
323
325
  const bridgeIsUrl = m.bridge && /^https?:\/\//i.test(m.bridge);
324
326
  const pfxDetected = detectPrefix(m);
325
327
  return {
326
- label: copy ? `${m.label}(副本)` : m.label,
328
+ label: copy ? `${m.label}${t("(副本)")}` : m.label,
327
329
  id: copy ? `${m.id}-copy` : m.id,
328
330
  idTouched: true,
329
331
  driver: m.driver || "generic",
@@ -420,15 +422,15 @@ export function registerCustomAgentClient(ctx, config) {
420
422
  display: "flex", flexDirection: "column", overflow: "hidden", fontSize: 13 },
421
423
  },
422
424
  h("div", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 8, flexShrink: 0 } },
423
- h("b", null, "自定义 Agent"),
424
- h("span", { style: { opacity: 0.6, fontSize: 11 } }, "新建会话后端注册中心 · 保存即热生效"),
425
+ h("b", null, t("自定义 Agent")),
426
+ h("span", { style: { opacity: 0.6, fontSize: 11 } }, t("新建会话后端注册中心 · 保存即热生效")),
425
427
  h("span", { style: { flex: 1 } }),
426
428
  view.mode === "list" && h("button", {
427
429
  disabled: busy != null,
428
430
  onClick: () => { setForm(emptyForm()); setView({ mode: "edit" }); },
429
- }, "+ 新增"),
430
- view.mode === "edit" && h("button", { onClick: () => setView({ mode: "list" }) }, "返回列表"),
431
- h("button", { onClick: () => setOpen(false), title: "关闭" }, "✕"),
431
+ }, t("+ 新增")),
432
+ view.mode === "edit" && h("button", { onClick: () => setView({ mode: "list" }) }, t("返回列表")),
433
+ h("button", { onClick: () => setOpen(false), title: t("关闭") }, "✕"),
432
434
  ),
433
435
  // 内容区:唯一滚动容器(aiti-float 约定 flex:1 + minHeight:0 + overflowY auto)
434
436
  h("div", { style: { flex: 1, minHeight: 0, overflowY: "auto", display: "flex", flexDirection: "column", gap: 6 } },
@@ -446,12 +448,12 @@ export function registerCustomAgentClient(ctx, config) {
446
448
  const warnings = data?.warnings ?? [];
447
449
  return h("div", null,
448
450
  !agents.length && h("div", { style: { opacity: 0.7, padding: "10px 0" } },
449
- data ? "还没有自定义后端——点「+ 新增」注册一条(如 docker 化的 CLI)。" : "加载中…"),
451
+ data ? t("还没有自定义后端——点「+ 新增」注册一条(如 docker 化的 CLI)。") : t("加载中…")),
450
452
  ...agents.map((m, i) => hRow(m, agents[i - 1], agents[i + 1])),
451
453
  !!warnings.length && h("div", { style: { marginTop: 8, color: "#d97706", fontSize: 11, whiteSpace: "pre-wrap" } },
452
- "配置警告:\n" + warnings.join("\n")),
454
+ t("配置警告:\n") + warnings.join("\n")),
453
455
  h("div", { style: { opacity: 0.55, marginTop: 10, fontSize: 11, lineHeight: "16px" } },
454
- "generic 驱动 = one-shot 任务型:任务文本写进 stdin,stdout 流式进会话;模型/权限等完整协议能力等 P2 协议委托。"),
456
+ t("generic 驱动 = one-shot 任务型:任务文本写进 stdin,stdout 流式进会话;模型/权限等完整协议能力等 P2 协议委托。")),
455
457
  );
456
458
  }
457
459
 
@@ -460,53 +462,53 @@ export function registerCustomAgentClient(ctx, config) {
460
462
  return h("div", { key: m.id, style: { borderTop: "1px solid rgba(128,128,128,.18)", padding: "8px 0" } },
461
463
  h("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" } },
462
464
  h("b", null, m.label),
463
- m.enabled === false && h("span", { style: { color: "#64748b", fontSize: 11 } }, "已停用"),
465
+ m.enabled === false && h("span", { style: { color: "#64748b", fontSize: 11 } }, t("已停用")),
464
466
  !m.enabled && null,
465
467
  m.enabled !== false && (m.registered
466
- ? h("span", { style: { color: "#16a34a", fontSize: 11 } }, "● 已注册")
467
- : h("span", { style: { color: "#d97706", fontSize: 11 } }, "○ 未注册(探活失败或停用)")),
468
+ ? h("span", { style: { color: "#16a34a", fontSize: 11 } }, t("● 已注册"))
469
+ : h("span", { style: { color: "#d97706", fontSize: 11 } }, t("○ 未注册(探活失败或停用)"))),
468
470
  probe && (probe.ok
469
- ? h("span", { title: probe.detail, style: { color: "#16a34a", fontSize: 11 } }, "探活")
470
- : h("span", { title: probe.detail, style: { color: "#dc2626", fontSize: 11 } }, "探活")),
471
+ ? h("span", { title: probe.detail, style: { color: "#16a34a", fontSize: 11 } }, t("探活"))
472
+ : h("span", { title: probe.detail, style: { color: "#dc2626", fontSize: 11 } }, t("探活"))),
471
473
  h("span", { style: { flex: 1 } }),
472
- h("button", { disabled: busy != null, onClick: () => { setForm(formOf(m)); setView({ mode: "edit" }); } }, "编辑"),
473
- h("button", { disabled: busy != null, onClick: () => { setForm(formOf(m, true)); setView({ mode: "edit" }); } }, "复制"),
474
+ h("button", { disabled: busy != null, onClick: () => { setForm(formOf(m)); setView({ mode: "edit" }); } }, t("编辑")),
475
+ h("button", { disabled: busy != null, onClick: () => { setForm(formOf(m, true)); setView({ mode: "edit" }); } }, t("复制")),
474
476
  h("button", {
475
477
  disabled: busy != null || !m.registered,
476
- title: "运行探活命令",
477
- onClick: () => post(`probe:${m.id}`, "/probe", { id: m.id }, (d) => `探活:${d.detail ?? (d.ok ? "可执行" : "失败")}`),
478
- }, "探活"),
478
+ title: t("运行探活命令"),
479
+ onClick: () => post(`probe:${m.id}`, "/probe", { id: m.id }, (d) => `${t("探活:")}${d.detail ?? (d.ok ? t("可执行") : t("失败"))}`),
480
+ }, t("探活")),
479
481
  h("button", {
480
482
  disabled: busy != null,
481
- onClick: () => post(`toggle:${m.id}`, `/agents/${m.id}`, { ...m, enabled: m.enabled === false }, "已更新"),
482
- }, m.enabled === false ? "启用" : "停用"),
483
+ onClick: () => post(`toggle:${m.id}`, `/agents/${m.id}`, { ...m, enabled: m.enabled === false }, t("已更新")),
484
+ }, m.enabled === false ? t("启用") : t("停用")),
483
485
  h("button", {
484
486
  disabled: busy != null || !prev,
485
- title: "上移(与上一位交换位次)",
487
+ title: t("上移(与上一位交换位次)"),
486
488
  onClick: () => swapOrder(m, prev),
487
489
  }, "↑"),
488
490
  h("button", {
489
491
  disabled: busy != null || !next,
490
- title: "下移(与下一位交换位次)",
492
+ title: t("下移(与下一位交换位次)"),
491
493
  onClick: () => swapOrder(m, next),
492
494
  }, "↓"),
493
495
  h("button", {
494
496
  disabled: busy != null,
495
497
  onClick: async () => {
496
- if (!window.confirm(`删除自定义后端「${m.label}」(${m.id})?`)) return;
497
- await call(`del:${m.id}`, `/agents/${m.id}`, { method: "DELETE" }, "已删除");
498
+ if (!window.confirm(`${t("删除自定义后端「")}${m.label}」(${m.id})?`)) return;
499
+ await call(`del:${m.id}`, `/agents/${m.id}`, { method: "DELETE" }, t("已删除"));
498
500
  },
499
- }, "删除"),
501
+ }, t("删除")),
500
502
  ),
501
503
  h("div", { style: { opacity: 0.65, fontSize: 11, margin: "2px 0 2px" } },
502
- `${m.id} · 驱动 ${m.driver}${m.serviceKey ? (m.serviceOk ? " · 服务 ✓" : " · 服务 ✗(基础扩展未部署/过旧)") : ""} · ${m.command || "(默认 CLI)"}${(m.argsPrefix || []).length ? " ▸ " + m.argsPrefix.join(" ") : ""}`),
504
+ `${m.id}${t(" · 驱动 ")}${m.driver}${m.serviceKey ? (m.serviceOk ? t(" · 服务 ✓") : t(" · 服务 ✗(基础扩展未部署/过旧)")) : ""} · ${m.command || t("(默认 CLI)")}${(m.argsPrefix || []).length ? " ▸ " + m.argsPrefix.join(" ") : ""}`),
503
505
  );
504
506
  }
505
507
 
506
508
  async function swapOrder(a, b) {
507
509
  if (!a || !b) return;
508
- await post(`swap:${a.id}`, `/agents/${a.id}`, { ...a, order: b.order }, "已调整位次");
509
- await post(`swap:${b.id}`, `/agents/${b.id}`, { ...b, order: a.order }, "已调整位次");
510
+ await post(`swap:${a.id}`, `/agents/${a.id}`, { ...a, order: b.order }, t("已调整位次"));
511
+ await post(`swap:${b.id}`, `/agents/${b.id}`, { ...b, order: a.order }, t("已调整位次"));
510
512
  }
511
513
 
512
514
  // ---------------- 前缀命令(开关 / 类型字段 / 生成同步) ----------------
@@ -527,27 +529,27 @@ export function registerCustomAgentClient(ctx, config) {
527
529
  /** 被包装真实 CLI 的输入提示:协议型驱动必须显式填(command 顶替后驱动不带自家 CLI 名) */
528
530
  function cliPlaceholder() {
529
531
  const def = DRIVER_DEFAULT_CLI[form.driver];
530
- if (form.driver !== "generic") return `必填:${def ?? "该驱动默认 CLI"}(command 已由包装命令顶替)`;
531
- return form.prefixKind === "docker" ? "留空 = 用镜像入口点;否则填真实 CLI(如 claude)" : "如 claude(可带参数)";
532
+ if (form.driver !== "generic") return `${t("必填:")}${def ?? t("该驱动默认 CLI")}${t("(command 已由包装命令顶替)")}`;
533
+ return form.prefixKind === "docker" ? t("留空 = 用镜像入口点;否则填真实 CLI(如 claude)") : t("如 claude(可带参数)");
532
534
  }
533
535
 
534
536
  /** 各包装类型的结构字段(生成 argsPrefix 的输入;docker 额外给常用前缀/选项下拉) */
535
537
  function hPrefixFields(p) {
536
538
  if (form.prefixKind === "docker") {
537
539
  return [
538
- hField("运行方式", h("select", { value: p.mode ?? "run-i", onChange: (e) => setPfx({ mode: e?.target?.value ?? "run-i" }) },
539
- ...DOCKER_MODES.map((o) => h("option", { key: o.value, value: o.value }, o.label)))),
540
- hField("镜像/容器", h("input", {
541
- value: p.image ?? "", size: 30, placeholder: "aiti/aiti:core(exec 模式填容器名)",
540
+ hField(t("运行方式"), h("select", { value: p.mode ?? "run-i", onChange: (e) => setPfx({ mode: e?.target?.value ?? "run-i" }) },
541
+ ...DOCKER_MODES.map((o) => h("option", { key: o.value, value: o.value }, t(o.label))))),
542
+ hField(t("镜像/容器"), h("input", {
543
+ value: p.image ?? "", size: 30, placeholder: t("aiti/aiti:core(exec 模式填容器名)"),
542
544
  onInput: (e) => setPfx({ image: e?.target?.value ?? "" }),
543
545
  })),
544
- hField("容器内命令", h("input", {
546
+ hField(t("容器内命令"), h("input", {
545
547
  value: p.cli ?? "", size: 34, placeholder: cliPlaceholder(),
546
548
  onInput: (e) => setPfx({ cli: e?.target?.value ?? "" }),
547
549
  })),
548
- hField("附加参数", h("span", null,
550
+ hField(t("附加参数"), h("span", null,
549
551
  h("textarea", {
550
- value: p.opts ?? "", rows: 4, cols: 50, placeholder: "每行一个参数:-v / ${cwd}:${cwd} / -w / ${cwd}",
552
+ value: p.opts ?? "", rows: 4, cols: 50, placeholder: t("每行一个参数:-v / ${cwd}:${cwd} / -w / ${cwd}"),
551
553
  onInput: (e) => setPfx({ opts: e?.target?.value ?? "" }),
552
554
  }), " ",
553
555
  h("select", {
@@ -560,43 +562,43 @@ export function registerCustomAgentClient(ctx, config) {
560
562
  if (extra) setPfx({ opts: [...linesOf(p.opts), ...extra.args].join("\n") });
561
563
  },
562
564
  },
563
- h("option", { key: "__pick__", value: "" }, "+ 常用选项…"),
564
- ...DOCKER_EXTRAS.map((o) => h("option", { key: o.value, value: o.value }, o.label))),
565
+ h("option", { key: "__pick__", value: "" }, t("+ 常用选项…")),
566
+ ...DOCKER_EXTRAS.map((o) => h("option", { key: o.value, value: o.value }, t(o.label)))),
565
567
  h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } },
566
- "容器内回连宿主桥:桥模式选 host.docker.internal 时补 --add-host=host.docker.internal:host-gateway,或直接用共享宿主网络的运行方式。"),
568
+ t("容器内回连宿主桥:桥模式选 host.docker.internal 时补 --add-host=host.docker.internal:host-gateway,或直接用共享宿主网络的运行方式。")),
567
569
  )),
568
570
  ];
569
571
  }
570
572
  if (form.prefixKind === "ssh") {
571
573
  return [
572
- hField("目标", h("input", {
574
+ hField(t("目标"), h("input", {
573
575
  value: p.target ?? "", size: 30, placeholder: "user@host",
574
576
  onInput: (e) => setPfx({ target: e?.target?.value ?? "" }),
575
577
  })),
576
- hField("端口", h("input", {
578
+ hField(t("端口"), h("input", {
577
579
  value: p.port ?? "", size: 6, placeholder: "22",
578
580
  onInput: (e) => setPfx({ port: e?.target?.value ?? "" }),
579
581
  })),
580
- hField("远端命令", h("input", {
582
+ hField(t("远端命令"), h("input", {
581
583
  value: p.cli ?? "", size: 34, placeholder: cliPlaceholder(),
582
584
  onInput: (e) => setPfx({ cli: e?.target?.value ?? "" }),
583
585
  })),
584
- hField("附加选项", h("span", null,
586
+ hField(t("附加选项"), h("span", null,
585
587
  h("textarea", {
586
- value: p.opts ?? "", rows: 3, cols: 50, placeholder: "每行一个参数,如 -t / -o / StrictHostKeyChecking=accept-new",
588
+ value: p.opts ?? "", rows: 3, cols: 50, placeholder: t("每行一个参数,如 -t / -o / StrictHostKeyChecking=accept-new"),
587
589
  onInput: (e) => setPfx({ opts: e?.target?.value ?? "" }),
588
590
  }),
589
- h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } }, "远端须免密登录(密钥 agent 已配好);-p 端口在上方位次之间自动插入。"),
591
+ h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } }, t("远端须免密登录(密钥 agent 已配好);-p 端口在上方位次之间自动插入。")),
590
592
  )),
591
593
  ];
592
594
  }
593
595
  if (form.prefixKind === "env") {
594
596
  return [
595
- hField("临时变量", h("textarea", {
596
- value: p.vars ?? "", rows: 3, cols: 50, placeholder: "每行一个 KEY=VALUE,如:\nHTTPS_PROXY=$HTTPS_PROXY\nFOO=bar",
597
+ hField(t("临时变量"), h("textarea", {
598
+ value: p.vars ?? "", rows: 3, cols: 50, placeholder: t("每行一个 KEY=VALUE,如:\nHTTPS_PROXY=$HTTPS_PROXY\nFOO=bar"),
597
599
  onInput: (e) => setPfx({ vars: e?.target?.value ?? "" }),
598
600
  })),
599
- hField("被包装命令", h("input", {
601
+ hField(t("被包装命令"), h("input", {
600
602
  value: p.cli ?? "", size: 34, placeholder: cliPlaceholder(),
601
603
  onInput: (e) => setPfx({ cli: e?.target?.value ?? "" }),
602
604
  })),
@@ -604,71 +606,71 @@ export function registerCustomAgentClient(ctx, config) {
604
606
  }
605
607
  if (form.prefixKind === "custom") {
606
608
  return [
607
- hField("附加参数", h("span", null,
609
+ hField(t("附加参数"), h("span", null,
608
610
  h("textarea", {
609
611
  value: p.opts ?? "", rows: 3, cols: 50,
610
- placeholder: "每行一个参数,如 nix-shell 的 --run / sudo 的 -E",
612
+ placeholder: t("每行一个参数,如 nix-shell 的 --run / sudo 的 -E"),
611
613
  onInput: (e) => setPfx({ opts: e?.target?.value ?? "" }),
612
614
  }),
613
615
  h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } },
614
- "包装命令填在下方「命令」框(任意可执行文件:sudo / nix-shell / podman / timeout / firejail …);这儿放它的参数。"),
616
+ t("包装命令填在下方「命令」框(任意可执行文件:sudo / nix-shell / podman / timeout / firejail …);这儿放它的参数。")),
615
617
  )),
616
- hField("被包装命令", h("input", {
618
+ hField(t("被包装命令"), h("input", {
617
619
  value: p.cli ?? "", size: 34, placeholder: cliPlaceholder(),
618
620
  onInput: (e) => setPfx({ cli: e?.target?.value ?? "" }),
619
621
  })),
620
622
  ];
621
623
  }
622
624
  return [
623
- hField("代理工具", h("select", { value: p.tool ?? "runsocks", onChange: (e) => setPfx({ tool: e?.target?.value ?? "runsocks" }) },
624
- ...SOCKS_TOOLS.map((o) => h("option", { key: o.value, value: o.value }, o.label)))),
625
- hField("附加参数", h("textarea", {
626
- value: p.opts ?? "", rows: 3, cols: 50, placeholder: "每行一个参数,如 proxychains 的 -f / 配置文件路径",
625
+ hField(t("代理工具"), h("select", { value: p.tool ?? "runsocks", onChange: (e) => setPfx({ tool: e?.target?.value ?? "runsocks" }) },
626
+ ...SOCKS_TOOLS.map((o) => h("option", { key: o.value, value: o.value }, t(o.label))))),
627
+ hField(t("附加参数"), h("textarea", {
628
+ value: p.opts ?? "", rows: 3, cols: 50, placeholder: t("每行一个参数,如 proxychains 的 -f / 配置文件路径"),
627
629
  onInput: (e) => setPfx({ opts: e?.target?.value ?? "" }),
628
630
  })),
629
- hField("被包装命令", h("input", {
631
+ hField(t("被包装命令"), h("input", {
630
632
  value: p.cli ?? "", size: 34, placeholder: cliPlaceholder(),
631
633
  onInput: (e) => setPfx({ cli: e?.target?.value ?? "" }),
632
634
  })),
633
- h("div", { style: { opacity: 0.6, fontSize: 11 } }, "socks 服务端地址在各工具自己的配置里(dante.conf / proxychains.conf),不在本表单。"),
635
+ h("div", { style: { opacity: 0.6, fontSize: 11 } }, t("socks 服务端地址在各工具自己的配置里(dante.conf / proxychains.conf),不在本表单。")),
634
636
  ];
635
637
  }
636
638
 
637
639
  // ---------------- 表单页 ----------------
638
640
  function hForm() {
639
641
  return h("div", { style: { display: "grid", gap: 8 } },
640
- hField("显示名", h("input", {
641
- value: form.label, size: 44, placeholder: "如 Claude Code (Docker)",
642
+ hField(t("显示名"), h("input", {
643
+ value: form.label, size: 44, placeholder: t("如 Claude Code (Docker)"),
642
644
  onInput: (e) => setForm((f) => ({ ...f, label: e?.target?.value ?? "", id: f.idTouched ? f.id : slugify(e?.target?.value ?? "") })),
643
645
  })),
644
- hField("标识 id", h("span", null,
646
+ hField(t("标识 id"), h("span", null,
645
647
  h("input", {
646
- value: form.id, size: 30, placeholder: "自动生成,可改",
648
+ value: form.id, size: 30, placeholder: t("自动生成,可改"),
647
649
  onInput: (e) => setForm((f) => ({ ...f, id: e?.target?.value ?? "", idTouched: true })),
648
650
  }),
649
- h("span", { style: { opacity: 0.6, fontSize: 11, marginLeft: 6 } }, "provider type(字母/数字/-_)")),
651
+ h("span", { style: { opacity: 0.6, fontSize: 11, marginLeft: 6 } }, t("provider type(字母/数字/-_)"))),
650
652
  ),
651
- hField("驱动类型", h("select", { value: form.driver, onChange: (e) => setForm((f) => ({ ...f, driver: e?.target?.value ?? "generic" })) },
652
- ...DRIVER_OPTIONS.map((o) => h("option", { key: o.value, value: o.value, disabled: !!o.disabled }, o.label)))),
653
- hField("前缀命令", h("span", null,
653
+ hField(t("驱动类型"), h("select", { value: form.driver, onChange: (e) => setForm((f) => ({ ...f, driver: e?.target?.value ?? "generic" })) },
654
+ ...DRIVER_OPTIONS.map((o) => h("option", { key: o.value, value: o.value, disabled: !!o.disabled }, t(o.label))))),
655
+ hField(t("前缀命令"), h("span", null,
654
656
  h("select", { value: form.prefixEnabled ? form.prefixKind : "", onChange: (e) => pickPrefixKind(e?.target?.value ?? "") },
655
657
  ...PREFIX_CHOICES.map((o) => h("option", { key: o.value || "__none__", value: o.value }, o.label))),
656
658
  h("span", { style: { opacity: 0.6, fontSize: 11, marginLeft: 6 } },
657
- "用 docker / ssh / env / proxychains 等包装真实 CLI——选中即顶替「命令」,真实 CLI 进参数前缀末尾"),
659
+ t("用 docker / ssh / env / proxychains 等包装真实 CLI——选中即顶替「命令」,真实 CLI 进参数前缀末尾")),
658
660
  )),
659
661
  form.prefixEnabled && h("div", { style: { border: "1px dashed rgba(128,128,128,.4)", borderRadius: 8, padding: "8px 10px", display: "grid", gap: 6 } },
660
662
  ...hPrefixFields(form.pfx?.[form.prefixKind] ?? {}),
661
663
  h("div", { style: { opacity: 0.7, fontSize: 11, lineHeight: "16px", wordBreak: "break-all" } },
662
- `实际执行:${[form.command, ...linesOf(form.argsPrefixText)].join(" ")}`),
664
+ `${t("实际执行:")}${[form.command, ...linesOf(form.argsPrefixText)].join(" ")}`),
663
665
  ),
664
- hField(form.prefixEnabled ? "包装命令" : "命令", h("span", null,
666
+ hField(form.prefixEnabled ? t("包装命令") : t("命令"), h("span", null,
665
667
  h("input", {
666
668
  value: form.command, size: 36,
667
669
  // 自定义包装的工具名写在这里(绕过下面的只读)——它是 command 本身
668
670
  disabled: form.prefixEnabled === true && form.prefixKind !== "custom",
669
671
  placeholder: form.prefixEnabled
670
- ? (form.prefixKind === "custom" ? "任意可执行文件:sudo / nix-shell / podman / timeout …" : "由包装类型决定(换 podman 等请选「自定义」)")
671
- : (form.driver === "generic" ? "如 docker(容器内 CLI 写进参数前缀末尾)" : "留空 = 用该驱动默认 CLI"),
672
+ ? (form.prefixKind === "custom" ? t("任意可执行文件:sudo / nix-shell / podman / timeout …") : t("由包装类型决定(换 podman 等请选「自定义」)"))
673
+ : (form.driver === "generic" ? t("如 docker(容器内 CLI 写进参数前缀末尾)") : t("留空 = 用该驱动默认 CLI")),
672
674
  onInput: (e) => {
673
675
  const v = e?.target?.value ?? "";
674
676
  if (form.prefixEnabled && form.prefixKind === "custom") setPfx({ tool: v });
@@ -678,35 +680,35 @@ export function registerCustomAgentClient(ctx, config) {
678
680
  h("button", {
679
681
  disabled: busy != null || !(form.probe || form.command).trim(),
680
682
  onClick: () => post("probe-form", "/probe", { command: form.command, probe: form.probe },
681
- (d) => `探测:${d.detail ?? (d.ok ? "可执行" : "失败")}`),
682
- }, busy === "probe-form" ? "探测中…" : "探测"),
683
+ (d) => `${t("探测:")}${d.detail ?? (d.ok ? t("可执行") : t("失败"))}`),
684
+ }, busy === "probe-form" ? t("探测中…") : t("探测")),
683
685
  )),
684
- hField("探活命令", h("input", {
685
- value: form.probe, size: 36, placeholder: "缺省 = 命令(可带空格分隔参数,如 docker version)",
686
+ hField(t("探活命令"), h("input", {
687
+ value: form.probe, size: 36, placeholder: t("缺省 = 命令(可带空格分隔参数,如 docker version)"),
686
688
  onInput: (e) => setForm((f) => ({ ...f, probe: e?.target?.value ?? "" })),
687
689
  })),
688
- hField("参数前缀", h("span", null,
690
+ hField(t("参数前缀"), h("span", null,
689
691
  h("textarea", {
690
692
  value: form.argsPrefixText, rows: 6, cols: 56,
691
- placeholder: "每行一个参数,如:\nrun\n--rm\n-i\n-v\n${cwd}:${cwd}\n-w\n${cwd}\nmy-image:latest\nclaude",
693
+ placeholder: t("每行一个参数,如:\nrun\n--rm\n-i\n-v\n${cwd}:${cwd}\n-w\n${cwd}\nmy-image:latest\nclaude"),
692
694
  onInput: (e) => setForm((f) => ({ ...f, argsPrefixText: e?.target?.value ?? "" })),
693
695
  }),
694
696
  h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } },
695
697
  form.prefixEnabled
696
- ? "由上方包装字段生成;改任一包装字段即按模板重写,这里可继续手改(每行一个参数,支持 $VAR / ${cwd})。"
697
- : "拼在驱动内置参数之前;支持 $VAR / ${cwd}(会话工作目录)。docker 配方建议 -v ${cwd}:${cwd} -w ${cwd} 同路径挂载。")),
698
+ ? t("由上方包装字段生成;改任一包装字段即按模板重写,这里可继续手改(每行一个参数,支持 $VAR / ${cwd})。")
699
+ : t("拼在驱动内置参数之前;支持 $VAR / ${cwd}(会话工作目录)。docker 配方建议 -v ${cwd}:${cwd} -w ${cwd} 同路径挂载。"))),
698
700
  ),
699
- hField("环境变量", h("div", { style: { display: "grid", gap: 4 } },
701
+ hField(t("环境变量"), h("div", { style: { display: "grid", gap: 4 } },
700
702
  ...form.envRows.map(([k, v], i) => h("div", { key: i, style: { display: "flex", gap: 4, alignItems: "center" } },
701
703
  h("input", { value: k, size: 16, placeholder: "KEY", onInput: (e) => setEnvRow(i, 0, e?.target?.value ?? "") }),
702
704
  h("span", null, "="),
703
- h("input", { value: v, size: 30, placeholder: "VALUE(支持 $VAR / ${cwd})", onInput: (e) => setEnvRow(i, 1, e?.target?.value ?? "") }),
705
+ h("input", { value: v, size: 30, placeholder: t("VALUE(支持 $VAR / ${cwd})"), onInput: (e) => setEnvRow(i, 1, e?.target?.value ?? "") }),
704
706
  h("button", { onClick: () => setForm((f) => ({ ...f, envRows: f.envRows.filter((_, j) => j !== i) })) }, "✕"),
705
707
  )),
706
- h("button", { onClick: () => setForm((f) => ({ ...f, envRows: [...f.envRows, ["", ""]] })) }, "+ 添加变量"),
707
- h("div", { style: { opacity: 0.6, fontSize: 11 } }, "成员级 env,优先级最高;密钥建议写 $VAR 引用父进程环境变量而非明文。"),
708
+ h("button", { onClick: () => setForm((f) => ({ ...f, envRows: [...f.envRows, ["", ""]] })) }, t("+ 添加变量")),
709
+ h("div", { style: { opacity: 0.6, fontSize: 11 } }, t("成员级 env,优先级最高;密钥建议写 $VAR 引用父进程环境变量而非明文。")),
708
710
  )),
709
- hField("桥模式", h("span", null,
711
+ hField(t("桥模式"), h("span", null,
710
712
  h("select", { value: form.bridge, onChange: (e) => setForm((f) => ({ ...f, bridge: e?.target?.value ?? "" })) },
711
713
  ...BRIDGE_OPTIONS.map((o) => h("option", { key: o.value, value: o.value }, o.label))),
712
714
  form.bridge === "__url__" && h("input", {
@@ -716,18 +718,18 @@ export function registerCustomAgentClient(ctx, config) {
716
718
  }),
717
719
  )),
718
720
  (data?.driverMembers ?? {})[form.driver]?.length
719
- ? hField("委托目标", h("span", null,
721
+ ? hField(t("委托目标"), h("span", null,
720
722
  h("select", { value: form.target, onChange: (e) => setForm((f) => ({ ...f, target: e?.target?.value ?? "" })) },
721
- h("option", { key: "__default__", value: "" }, "缺省成员"),
723
+ h("option", { key: "__default__", value: "" }, t("缺省成员")),
722
724
  ...data.driverMembers[form.driver].map((mm) => h("option", { key: mm.name, value: mm.name }, `${mm.label}(agentKey: ${mm.agentKey})`))),
723
- h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } }, "多成员驱动(如 ACP)指定委托到哪个成员;缺省由基础扩展决定。"),
725
+ h("div", { style: { opacity: 0.6, fontSize: 11, marginTop: 2 } }, t("多成员驱动(如 ACP)指定委托到哪个成员;缺省由基础扩展决定。")),
724
726
  ))
725
727
  : null,
726
- hField("排序", h("input", {
728
+ hField(t("排序"), h("input", {
727
729
  value: form.order, size: 8, placeholder: "1000",
728
730
  onInput: (e) => setForm((f) => ({ ...f, order: e?.target?.value ?? "" })),
729
731
  })),
730
- hField("启用", h("input", {
732
+ hField(t("启用"), h("input", {
731
733
  type: "checkbox", checked: form.enabled === true,
732
734
  onChange: (e) => setForm((f) => ({ ...f, enabled: e?.target?.checked ?? true })),
733
735
  })),
@@ -735,13 +737,13 @@ export function registerCustomAgentClient(ctx, config) {
735
737
  h("button", {
736
738
  disabled: busy != null || !form.label.trim() || (form.driver === "generic" && !form.command.trim()),
737
739
  onClick: async () => {
738
- const d = await post("save", "/agents", agentOfForm(form), () => "已保存并热生效");
740
+ const d = await post("save", "/agents", agentOfForm(form), () => t("已保存并热生效"));
739
741
  if (d && !d.error) { setView({ mode: "list" }); }
740
- if (d && d.problems && d.problems.length) setNotice({ kind: "err", text: "已保存,但以下成员未注册:\n" + d.problems.join("\n") });
741
- else if (d && d.warnings && d.warnings.length) setNotice({ kind: "err", text: "已保存,但有条目被跳过:\n" + d.warnings.join("\n") });
742
+ if (d && d.problems && d.problems.length) setNotice({ kind: "err", text: t("已保存,但以下成员未注册:\n") + d.problems.join("\n") });
743
+ else if (d && d.warnings && d.warnings.length) setNotice({ kind: "err", text: t("已保存,但有条目被跳过:\n") + d.warnings.join("\n") });
742
744
  },
743
- }, busy === "save" ? "保存中…" : "保存"),
744
- h("button", { onClick: () => setView({ mode: "list" }) }, "取消"),
745
+ }, busy === "save" ? t("保存中…") : t("保存")),
746
+ h("button", { onClick: () => setView({ mode: "list" }) }, t("取消")),
745
747
  ),
746
748
  );
747
749
  }