@aiti-ai/aiti-acp-agent 0.3.9 → 0.3.10

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 CHANGED
@@ -1,38 +1,30 @@
1
1
  # @aiti-ai/aiti-acp-agent
2
2
 
3
- > 泛用 ACP 驱动 —— 一个适配器接所有 Agent Client Protocol agent(25 家内置自动探测 + 自定义后端面板 + 授权卡/队列/模型目录)
3
+ > A universal ACP driver — one adapter connects all Agent Client Protocol agents (25 built-in with auto-detection + custom backend panel + permission cards/queue/model catalog)
4
4
 
5
- ## 来源 · Origin
5
+ English · [简体中文](./README.zh-CN.md)
6
6
 
7
- 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
7
+ ## About aiti
8
8
 
9
9
  This package is part of the **aiti** ecosystem — a personal AI development workbench powered by [pi](https://pi.dev): **aiti-agent** (a self-hosted web workbench built on the open-source [pi-web](https://github.com/aiti-ai/pi-web)) plus debug injection into mainstream dev tools (aiti-devtools) and a rich extension system.
10
10
 
11
- - 工作台 / workbench: <https://github.com/aiti-ai/pi-web>
12
- - 生态仓库 / monorepo: <https://github.com/aiti-ai/aiti-ai>
13
- - 官网 / site: <https://aiti.pw>
11
+ - Workbench (aiti-agent, built on pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - Ecosystem monorepo: <https://github.com/aiti-ai/aiti-ai>
13
+ - Site: <https://aiti.pw>
14
14
 
15
- ## 功能定位(中文)
15
+ Category: Multi-agent backends · Tags: `acp` · `agent-client-protocol` · `session` · `multi-agent`
16
16
 
17
- 泛用 ACP 驱动 —— 一个适配器接所有 Agent Client Protocol agent(25 家内置自动探测 + 自定义后端面板 + 授权卡/队列/模型目录)
17
+ ## Install
18
18
 
19
- 多 agent 后端 · tags: `acp` · `agent-client-protocol` · `session` · `multi-agent`
19
+ Bundled with **aiti-agent** (`@aiti-ai/pi-web`) — enable it from the in-app extension manager (ExtMan / App Center).
20
20
 
21
- ## Positioning (English)
21
+ Manual install: place this package at `~/.pi/web/extensions/aiti-acp-agent/` and reload pi-web.
22
22
 
23
- A universal ACP driver — one adapter connects all Agent Client Protocol agents (25 built-in with auto-detection + custom backend panel + permission cards/queue/model catalog)
23
+ ## Documentation
24
24
 
25
- ## 安装 / 部署
26
-
27
- ```bash
28
- # 部署到 ~/.pi/web/extensions/aiti-acp-agent/ 后 reload
29
- ```
30
-
31
- ## 文档 · Documentation
32
-
33
- - 中文完整文档(aiti-docs): <https://aiti.pw/extensions/aiti-acp-agent.html>
34
- - English docs: <https://aiti.pw/en/extensions/aiti-acp-agent.html>
35
- - 扩展注册表 / registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
25
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-acp-agent.html>
26
+ - 文档(中文): <https://aiti.pw/extensions/aiti-acp-agent.html>
27
+ - Extension registry: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
36
28
 
37
29
  ## License
38
30
 
@@ -0,0 +1,31 @@
1
+ # @aiti-ai/aiti-acp-agent
2
+
3
+ > 泛用 ACP 驱动 —— 一个适配器接所有 Agent Client Protocol agent(25 家内置自动探测 + 自定义后端面板 + 授权卡/队列/模型目录)
4
+
5
+ [English](./README.md) · 简体中文
6
+
7
+ ## 关于 aiti
8
+
9
+ 本包是 **aiti** 生态的组成部分——以 [pi](https://pi.dev) 为引擎的个人 AI 开发工作台与本地调试注入生态:**aiti-agent**(自托管 Web 工作台,基于开源项目 [pi-web](https://github.com/aiti-ai/pi-web) 构建,浏览器为主操作面)+ 各开发工具内的调试注入(aiti-devtools)+ 丰富的扩展体系。
10
+
11
+ - 工作台(aiti-agent,基于 pi-web): <https://github.com/aiti-ai/pi-web>
12
+ - 生态仓库: <https://github.com/aiti-ai/aiti-ai>
13
+ - 官网: <https://aiti.pw>
14
+
15
+ 分类: 多 agent 后端 · tags: `acp` · `agent-client-protocol` · `session` · `multi-agent`
16
+
17
+ ## 安装
18
+
19
+ 随 **aiti-agent**(`@aiti-ai/pi-web`)捆绑发行——在工作台内的扩展管理器(ExtMan / 应用中心)启用即可。
20
+
21
+ 手动安装:把本包放到 `~/.pi/web/extensions/aiti-acp-agent/` 后 reload。
22
+
23
+ ## 文档
24
+
25
+ - 中文文档: <https://aiti.pw/extensions/aiti-acp-agent.html>
26
+ - Documentation (English): <https://aiti.pw/en/extensions/aiti-acp-agent.html>
27
+ - 扩展注册表: <https://aiti.pw/extensions.html> · machine-readable <https://aiti.pw/extensions.json>
28
+
29
+ ## 许可证
30
+
31
+ MIT
@@ -49,6 +49,14 @@ test("注册表含 codex + cursor 条目(2026-11-08 接入)", () => {
49
49
  assert.equal(cursor.agentKey, "cursor");
50
50
  });
51
51
 
52
+ test("pi 不 claim 原生 pi 的 agentKey(ACP 无 steer,接管会丢 steer/fork)", () => {
53
+ const pi = ACP_AGENTS.find((a) => a.name === "pi");
54
+ assert.ok(pi, "pi 后端存在");
55
+ assert.equal(pi.bin, "pi-acp");
56
+ assert.notEqual(pi.agentKey, "pi", "agentKey 必须避开原生 aiti-pi-agent 的 pi");
57
+ assert.equal(pi.agentKey, "pi-acp");
58
+ });
59
+
52
60
  test("注册表卫生:name 唯一,每条有 resolve 或 bin", () => {
53
61
  const names = ACP_AGENTS.map((a) => a.name);
54
62
  assert.equal(new Set(names).size, names.length, "name 不重复");
@@ -11,7 +11,7 @@
11
11
  */
12
12
 
13
13
  import { useState, useEffect } from "react";
14
- import { apiUrl } from "./host-shim";
14
+ import { apiUrl, t } from "./host-shim";
15
15
  import { ACP_KEY, PlugIcon, setDialogOpen } from "./common";
16
16
  // dock v3(P2 批):弹窗显隐收口展示状态机(左栏列表驻留,不接右栏);渲染门控 usePresent
17
17
  import { usePresent, DockBody, isSidebarDockState, sidebarZoneOf } from "../../../_shared/ext-float-dock";
@@ -109,9 +109,9 @@ function renderAcpDialog(face?: string) {
109
109
  {floating && (
110
110
  <div style={{ display: "flex", alignItems: "center", gap: 8, padding: "10px 14px", borderBottom: "1px solid var(--border)", cursor: "grab", userSelect: "none" }}>
111
111
  <span style={{ color: "var(--text-muted)", display: "flex" }}><PlugIcon size={15} /></span>
112
- <span style={{ fontSize: 13, fontWeight: 600, flex: 1 }}>ACP Backend Agents</span>
112
+ <span style={{ fontSize: 13, fontWeight: 600, flex: 1 }}>{t("acp.manage.dialog.label")}</span>
113
113
  <button
114
- title="Close" aria-label="Close"
114
+ title={t("acp.manage.close")} aria-label="Close"
115
115
  onClick={() => setDialogOpen(false)}
116
116
  style={{ background: "none", border: "none", color: "var(--text-muted)", cursor: "pointer", fontSize: 15, lineHeight: 1, padding: "2px 4px" }}
117
117
  >✕</button>
@@ -122,7 +122,7 @@ function renderAcpDialog(face?: string) {
122
122
  {!loaded ? (
123
123
  <div style={{ padding: "16px 0", color: "var(--text-dim)", fontSize: 12, textAlign: "center" }}>…</div>
124
124
  ) : agents.length === 0 ? (
125
- <div style={{ padding: "16px 0", color: "var(--text-dim)", fontSize: 12, textAlign: "center" }}>No ACP agents found on PATH.</div>
125
+ <div style={{ padding: "16px 0", color: "var(--text-dim)", fontSize: 12, textAlign: "center" }}>{t("acp.manage.empty")}</div>
126
126
  ) : agents.map((a) => (
127
127
  <div key={a.name} style={{ display: "flex", alignItems: "center", gap: 6, padding: "6px 0", borderBottom: "1px solid var(--border)", fontSize: 12 }}>
128
128
  <span style={{ width: 7, height: 7, borderRadius: "50%", background: a.registered ? "var(--ok, #22c55e)" : "#ef444455", flexShrink: 0 }} />
@@ -136,7 +136,7 @@ function renderAcpDialog(face?: string) {
136
136
  {!builtinSet.has(a.name) && (
137
137
  <button
138
138
  onClick={() => void doRemove(a.name)}
139
- title={`Remove ${a.name}`} aria-label={`Remove ${a.name}`}
139
+ title={t("acp.manage.remove", { name: a.name })} aria-label={t("acp.manage.remove", { name: a.name })}
140
140
  style={{ background: "none", border: "none", color: "var(--danger, #ef4444)", cursor: "pointer", fontSize: 13, padding: "0 2px" }}
141
141
  >✕</button>
142
142
  )}
@@ -154,11 +154,11 @@ function renderAcpDialog(face?: string) {
154
154
  style={{ width: 80, padding: "4px 7px", border: "1px solid var(--border)", borderRadius: 5, background: "var(--bg)", color: "var(--text)", fontSize: 11 }} />
155
155
  <button onClick={() => void doAdd()} disabled={busy}
156
156
  style={{ padding: "4px 12px", border: "none", borderRadius: 5, background: "var(--accent)", color: "#fff", cursor: "pointer", fontSize: 11, fontWeight: 600 }}>
157
- {busy ? "…" : "+ Add"}
157
+ {busy ? "…" : t("acp.manage.add")}
158
158
  </button>
159
159
  </div>
160
160
  <div style={{ marginTop: 5, fontSize: 10, color: "var(--text-dim)" }}>
161
- Reload extensions after adding to activate new backends.
161
+ {t("acp.manage.reloadHint")}
162
162
  </div>
163
163
  </div>
164
164
  </>
@@ -198,17 +198,17 @@ function renderAcpDialog(face?: string) {
198
198
  // 右栏 tab face(chrome="tab":无头行)
199
199
  if (face === "right") {
200
200
  return (
201
- <DockBody itemKey={ACP_KEY} zone="right-panel" title="ACP Backend Agents" chrome="tab"
201
+ <DockBody itemKey={ACP_KEY} zone="right-panel" title={t("acp.manage.dialog.label")} chrome="tab"
202
202
  zones={acpZones} defaultZone={sidebarZoneOf(ACP_KEY)}>{acpInner}</DockBody>
203
203
  );
204
204
  }
205
205
  // 左栏区块 face:统一头行(标题 + 业务按钮 + ⇱ detach + ⋮);zone 用规范值 sidebar:<key>
206
206
  const acpCount = typeof hs.count === "number" ? hs.count : 0;
207
207
  const actions: DockHeaderAction[] = [
208
- { id: "refresh", title: "刷新", icon: (<svg width={12} height={12} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>), visibility: "always", onClick: () => { requestDockCommand(ACP_KEY, "refresh"); } },
208
+ { id: "refresh", title: t("acp.manage.refresh"), icon: (<svg width={12} height={12} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /></svg>), visibility: "always", onClick: () => { requestDockCommand(ACP_KEY, "refresh"); } },
209
209
  ];
210
210
  return (
211
- <DockBody itemKey={ACP_KEY} title="ACP Backend Agents" chrome="section" kind="dockable"
211
+ <DockBody itemKey={ACP_KEY} title={t("acp.manage.dialog.label")} icon="plug" chrome="section" kind="dockable"
212
212
  count={acpCount > 0 ? acpCount : undefined}
213
213
  zones={acpZones} defaultZone={sidebarZoneOf(ACP_KEY)}
214
214
  headerActions={actions}>
@@ -12,9 +12,10 @@
12
12
  * 构建:node tools/build-client.mjs 部署:tools/deploy.mjs(先构建再整目录同步)
13
13
  */
14
14
 
15
- import { __setCtx } from "./host-shim";
15
+ import { __setCtx, t } from "./host-shim";
16
16
  import { ACP_KEY, setDialogOpen, acpDefaultZone } from "./common";
17
17
  import { usePresent, isSidebarDockState, seedDockDefault, declareDockZones } from "../../../_shared/ext-float-dock-lite";
18
+ import { dockIconDecl } from "../../../_shared/dock-icons";
18
19
  import { lazyExtView, createLazyModule } from "../../../_shared/ext-lazy";
19
20
 
20
21
  // 重模块单例:面板三面(float/right/left)与命令式入口共享一次 import
@@ -35,40 +36,46 @@ export function AcpDockLeftSlot() {
35
36
  return lazyExtView({ active: isSidebarDockState(st), load: acpManageRef, pick: "AcpDockLeft" });
36
37
  }
37
38
 
39
+ let localeListener: (() => void) | null = null;
40
+
38
41
  // 新会话欢迎页 Backend 下拉的扩展选项(不是后端条目:选中即打开管理弹窗,
39
42
  // 下拉值由宿主复位)——不再在 Backend 选择器外渲染按钮。
40
43
  export default function register(ctx: Record<string, unknown>) {
41
44
  // 重要:必须在任何 JSX 组件渲染前调用(host-shim 模块级持 ctx)
42
45
  __setCtx(ctx);
43
46
 
44
- // 所有入口恒注册;工具条条目的 feature 字段交给宿主统一门控(关 → 不渲染),
45
- // extman「打开」可经虚空创建触发
46
- // 懒加载 v2 M3批②:声明式条目(无 render);feature 门控仍在条目级(宿主统一过滤)
47
- ctx.registerItems?.("toolbar", [{
48
- id: "aiti-acp-manage-open",
49
- // meta.open:extman「打开」的直开钩子(tryDirectOpen 只认 meta.open 不认 onClick);
50
- // 本条目 feature 默认关 → DOM 无按钮、声明式无 render,虚空创建也走不通 → 必须带 open
51
- meta: { label: "ACP", title: "Manage ACP backend agents", icon: "icons/plug.svg", onClick: () => setDialogOpen(true), open: () => setDialogOpen(true) },
52
- feature: "behavior.showAcpManager",
53
- }]);
54
- ctx.registerItems?.("newSessionBackendOptions", [{
55
- id: "acp-manage-option",
56
- meta: { label: "Manage ACP Agents…", title: "Manage ACP backend agents", onClick: () => setDialogOpen(true) },
57
- }]);
58
- ctx.registerItems?.("dialogs", [{
59
- id: "acp-manage-dialog",
60
- render: AcpDialogSlot,
61
- meta: {
62
- label: "ACP Backend Agents",
63
- // 弹窗本体由展示状态机门控(非点击触发),extman「打开」需此钩子直开
64
- open: () => setDialogOpen(true),
65
- },
66
- }]);
47
+ // Declarative item labels are captured at registration time; re-register on the
48
+ // host locale-change event so the dropdown option follows the active language.
49
+ const registerEntries = () => {
50
+ ctx.registerItems?.("toolbar", [{
51
+ id: "aiti-acp-manage-open",
52
+ meta: { label: "ACP", title: t("acp.manage.title"), icon: "icons/plug.svg", onClick: () => setDialogOpen(true), open: () => setDialogOpen(true) },
53
+ feature: "behavior.showAcpManager",
54
+ }]);
55
+ ctx.registerItems?.("newSessionBackendOptions", [{
56
+ id: "acp-manage-option",
57
+ meta: { label: t("acp.manage.option.label"), title: t("acp.manage.title"), onClick: () => setDialogOpen(true) },
58
+ }]);
59
+ ctx.registerItems?.("dialogs", [{
60
+ id: "acp-manage-dialog",
61
+ render: AcpDialogSlot,
62
+ meta: {
63
+ label: t("acp.manage.dialog.label"),
64
+ open: () => setDialogOpen(true),
65
+ },
66
+ }]);
67
+ };
68
+ registerEntries();
69
+ if (typeof window !== "undefined") {
70
+ if (localeListener) window.removeEventListener("pi-web:locale-changed", localeListener);
71
+ localeListener = registerEntries;
72
+ window.addEventListener("pi-web:locale-changed", registerEntries);
73
+ }
67
74
  // aiti-float dock v3(P2 批):后端列表默认左栏(状态灯列表窄条)
68
75
  // zone 规范值 sidebar:<key>(v4;旧 sidebar-explorer 兼容读)
69
76
  seedDockDefault(ACP_KEY, acpDefaultZone());
70
77
  declareDockZones(ACP_KEY, [acpDefaultZone(), "right-panel"], acpDefaultZone());
71
- ctx.registerItems?.("rightFileDock", [{ id: "manage", render: AcpDockRightSlot, meta: { title: "ACP" } }]);
78
+ ctx.registerItems?.("rightFileDock", [{ id: "manage", render: AcpDockRightSlot, meta: { title: "ACP", icon: dockIconDecl("plug") } }]);
72
79
  ctx.registerItems?.("sidebarExplorerDock", [{ id: "manage", render: AcpDockLeftSlot, meta: { title: "ACP", priority: 3 } }]);
73
80
 
74
81
  console.log("[aiti-acp-agent] client 已注册(薄壳 + 懒弹窗 chunk)");
package/dev-pack.mjs CHANGED
@@ -77,7 +77,7 @@ export function agentsMdTemplate(extId) {
77
77
 
78
78
  /** 默认 tools/build.mjs(esbuild 单包零配置;扩展自带 tools/build.mjs 则不走到这里)。 */
79
79
  function buildMjsTemplate(extId, extRoot, clientOut, entryRel) {
80
- const repoHint = "/home/pi/workspace/pi-work"; // 现场构建探测源码仓 node_modules 用(三机各不同,缺失时走 npm exec)
80
+ // No hardcoded checkout path: candidates are resolved at run time (see repoCandidates below).
81
81
  return `/**
82
82
  * ${extId} · 现场构建入口(dev-pack 默认模板,esbuild 单包零配置)
83
83
  * 用法:node tools/build.mjs
@@ -96,12 +96,25 @@ const entryRel = ${JSON.stringify(entryRel || "")};
96
96
 
97
97
  // esbuild 解析:部署目录 node_modules → 源码仓 node_modules(本机开发场景)→ PATH 上的 esbuild → npm exec 现拉。
98
98
  // 注意:node_modules/esbuild/bin/esbuild 是原生二进制(ELF/Mach-O),必须直接执行(不能当 JS 跑)。
99
+ // Checkout roots are discovered by walking up from the extension dir (a root has node_modules/),
100
+ // plus AITI_REPO_ROOT when set — no machine-specific absolute paths baked into generated files.
101
+ function repoCandidates() {
102
+ const out = [];
103
+ if (process.env.AITI_REPO_ROOT) out.push(process.env.AITI_REPO_ROOT.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
104
+ let d = extRoot;
105
+ for (let i = 0; i < 8; i++) {
106
+ out.push(d.split(pathSep).join("/") + "/node_modules/esbuild/bin/esbuild");
107
+ const up = dirname(d);
108
+ if (up === d) break;
109
+ d = up;
110
+ }
111
+ return out;
112
+ }
99
113
  function findEsbuild() {
100
114
  const home = (process.env.HOME || process.env.USERPROFILE || "").split(pathSep).join("/");
101
115
  const candidates = [
102
116
  extRoot + "/node_modules/esbuild/bin/esbuild",
103
- home + "/workspace/pi-work/node_modules/esbuild/bin/esbuild",
104
- "D:/workspace/pi-work/node_modules/esbuild/bin/esbuild", // 155 win(源码在 D 盘)
117
+ ...repoCandidates(),
105
118
  ];
106
119
  for (const c of candidates) {
107
120
  if (!existsSync(c)) continue;