Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions docs/acp_kiro.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@

## 步驟零:為 acpx 套用 kiro patch

原版 acpx 不支援 kiro-cli,需要兩處修改後重新 build 並部署。
原版 acpx 不支援 kiro-cli,需要修改後重新 build 並部署。

> **Upstream fix pending**:[openclaw/acpx#40](https://github.com/openclaw/acpx/pull/40) 正在 review 中,合併後官方 acpx 即內建 kiro,步驟零可省略,直接用 `npm install -g acpx` 即可。
> **Upstream fix pending**:[openclaw/acpx#42](https://github.com/openclaw/acpx/pull/42) 正在 review 中,合併後官方 acpx 即內建 kiro 且修復 process leak,步驟零可省略,直接用 `npm install -g acpx` 即可。

### 原因

acpx 的 agent registry 沒有內建 kiro,無法用 `acpx kiro` 指令。此外 openclaw health check 需要 acpx 有版本號。
acpx 的 agent registry 沒有內建 kiro,無法用 `acpx kiro` 指令。

此外,`kiro-cli acp` 是一個 wrapper binary,實際 ACP server 是它 fork 出來的 `kiro-cli-chat acp`。舊版 acpx 的 `terminateAgentProcess()` 只 kill wrapper,導致 `kiro-cli-chat` 成為 orphan process,每次 `/new` 都會洩漏一個進程。

> **注意**:kiro-cli 1.26.2 的 ACP 輸出格式完全符合標準(`session/update` JSON-RPC 2.0),無需任何格式轉換。

Expand All @@ -49,19 +51,23 @@ acpx 的 agent registry 沒有內建 kiro,無法用 `acpx kiro` 指令。此
kiro: "kiro-cli acp",
```

**2. `src/cli-core.ts` — 加入版本號(openclaw health check 需要)**
**2. `src/client.ts` — 修復 process group kill(防止 orphan)**
```typescript
.version("0.1.13", "--version", "Print version")
// spawn with detached:true → kiro-cli 成為新 process group leader
const child = spawn(command, args, { stdio: [...], detached: true });

// terminateAgentProcess: kill 整個 process group
process.kill(-child.pid, "SIGTERM"); // 包含 kiro-cli-chat
```

完整實作見:https://github.com/thepagent/acpx/tree/feat/kiro-agent
完整實作見:https://github.com/openclaw/acpx/pull/42

### Build 與部署

```bash
git clone https://github.com/thepagent/acpx.git ~/repo/acpx
cd ~/repo/acpx
git checkout feat/kiro-agent
git checkout fix/kill-agent-on-queue-owner-exit

npm install
npm run build
Expand All @@ -75,9 +81,15 @@ cp dist/cli.js "$ACPX_DIST"

```bash
ACPX=$(find ~/.npm-global -path "*/extensions/acpx/node_modules/.bin/acpx" | head -1)
$ACPX --version # 應顯示 0.1.13
$ACPX kiro sessions new --name test 2>&1 | tail -2
systemctl --user restart openclaw-gateway.service

# 驗證無 process leak:/new 前後 count 應相同
before=$(ps aux | grep "kiro-cli-chat acp" | grep -v grep | wc -l)
$ACPX kiro sessions close test 2>/dev/null
$ACPX kiro sessions new --name test 2>/dev/null
after=$(ps aux | grep "kiro-cli-chat acp" | grep -v grep | wc -l)
echo "before=$before after=$after" # 應相等
```

---
Expand Down