利用 Claude Managed Agents 建立 Linear 專案代理的橋接範例
AI 中文摘要Claude 生成
利用 Claude Managed Agents 建立 Linear 專案代理的橋接範例。
此專案提供一個橋接伺服器,能將 Claude Managed Agents 整合至 Linear 的 Agent Platform,讓使用者透過 @mention 即可與 Agent 互動。
專案定位與限制
此專案僅為示範性質,開發者需特別注意,官方明確標示該專案「不適用於生產環境」,僅適合作為技術驗證或參考使用。
運作機制
當使用者在 Linear 的 Issue 或評論中 @mention Agent 時,系統會透過以下流程運作:
- Linear 發送
AgentSessionEventwebhook 至伺服器。 - 伺服器必須在 10 秒內回覆「thinking」活動以確認請求。
- 系統隨即建立 Claude Managed Agent 工作階段,並將 Issue 的上下文帶入。
- Claude 的串流回應將被轉發回 Linear,並以 Agent 活動形式呈現給使用者。
部署需求與設定
若要部署此橋接服務,需滿足以下條件:
- 執行環境:需安裝 Bun runtime。
- 必要憑證:需準備 Anthropic API key、Claude Managed Agent ID 與環境 ID。
- Linear 設定:需具備管理員權限的 Linear 工作區,並建立 OAuth 應用程式以獲取 Client ID、Client Secret 及 Webhook Signing Secret。
- 環境變數:需配置
.env.local檔案,填入包含 API 金鑰、URL 設定及 Linear 相關憑證等必要資訊。
專案結構與介面
該專案的程式碼結構清晰,主要分為以下模組:
main.ts:負責處理 Webhook、OAuth 及健康檢查路由。oauth.ts:處理 Linear OAuth 流程(actor=app)以及 token 更新。agent.ts:負責 Claude Managed Agent 工作階段的橋接邏輯。- 介面端點:包含
/(健康檢查)、/oauth/authorize(啟動 Linear OAuth 安裝流程)、/oauth/callback(OAuth 回呼並交換 token) 以及/webhook(接收 Linear Agent 工作階段事件)。
Claude Managed Agents is a very nice API for rolling your own custom agents and it works great with Linear's Agents SDK. Claude helped me pull together (one-shot!) a sample how to deploy a custom agent on your Linear instance https://t.co/7SC7QqT3ES
— Jori Lallo (@jorilallo) April 9, 2026
