ChatPaper.aiChatPaper

語碼框架:將AI編碼代理解耦為可編程、可嵌入的基礎設施

Sema Code: Decoupling AI Coding Agents into Programmable, Embeddable Infrastructure

April 13, 2026
作者: Huacan Wang, Jie Zhou, Ningyan Zhu, Shuo Zhang, Feiyu Chen, Jiarou Wu, Ge Chen, Chen Liu, Wangyi Chen, Xiaofeng Mou, Yi Xu
cs.AI

摘要

AI編程代理已成為開發者工作流程的核心,然而現有解決方案皆將其推理能力侷限於特定交付形式中,例如CLI、IDE外掛或網頁應用程式。這種限制在企業試圖跨異質工程環境複用這些能力時,會形成系統性障礙。為解決此挑戰,我們推出Sema Code——一個基於可嵌入、可插拔、框架優先原則構建的開放式AI編程框架。Sema Code將核心代理引擎與所有客戶端層完全解耦,將其發布為獨立的npm套件,可供任何運行時透過程式化方式驅動。圍繞此架構,我們設計了八大關鍵機制:多租戶引擎隔離、具安全會話重建功能的FIFO輸入佇列、自適應上下文壓縮、多代理協作調度、基於Todo的智慧流程管理、四層非同步權限控制、涵蓋MCP/Skills/Plugins的三級生態整合,以及具執行與觀察權限分離的後台任務框架。這些機制共同解決了將複雜代理引擎轉化為可共享、可編程核心的工程難題。為展現其架構靈活性,同一套Sema Core引擎同時驅動了VSCode擴充功能與名為SemaClaw的多通道訊息網關,後者可統一處理Telegram、飛書等平台的代理互動。這兩個產品形式雖共享完全相同的推理內核,僅在客戶端層存在差異,卻展現了截然不同的產品形態。
English
AI coding agents have become central to developer workflows, yet every existing solution locks its reasoning capabilities within a specific delivery form, such as a CLI, IDE plugin, or web application. This limitation creates systemic barriers when enterprises attempt to reuse these capabilities across heterogeneous engineering environments. To address this challenge, we present Sema Code, an open AI coding framework built on the principle of being embeddable, pluggable, and framework-first. Sema Code completely decouples the core agent engine from all client layers, publishing it as a standalone npm library that any runtime can drive programmatically. Built around this architecture, we designed eight key mechanisms: multi-tenant engine isolation, FIFO input queuing with safe session reconstruction, adaptive context compression, multi-agent collaborative scheduling, intelligent Todo-based process management, four-layer asynchronous permission control, three-tier ecosystem integration spanning MCP, Skills, and Plugins, and a background task framework with separated execution and observation privileges. These mechanisms collectively address the engineering challenges of transforming a complex agent engine into a shared, programmable core. Demonstrating its architectural versatility, the same Sema Core engine simultaneously powers a VSCode extension and a multi-channel messaging gateway, which we name SemaClaw, to unify agent interactions across platforms such as Telegram and Feishu. These represent two fundamentally different product forms sharing an identical reasoning kernel, differing only at the client layer.
PDF181April 17, 2026