• 简体中文
  • v6.5.1
  • OPEN SOURCE · EMBEDDABLE AGENT RUNTIME

    把 A3S Code接进现有产品

    A3S Code 提供 Agent 会话、工具调用、权限确认、事件流和任务恢复。你可以直接使用 a3s code,也可以通过 Rust、Node.js、Python 或 Go SDK 嵌入现有应用。

    a3s codeCLI
    curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/A3S-Lab/a3s/main/install.sh | sh
    a3s code
    a3s code~/workspace/a3s

    a3s-code v6.6.0·openai/gpt-5·12 skills·~/workspace/a3s

    Type a message · / for commands · Shift+Tab cycles mode · Ctrl+C twice to exit

    You

    不联网检查这个仓库的发布风险,并生成报告

    ArtifactHTML · 18.4 KB
    release-risk-report/index.htmlOpen viewRemoteUI
    RemoteUIready
    发布风险报告2 risks · 12 checks
    A3S Code

    检查完成。3 个子智能体并行完成;报告制品已生成,可通过 RemoteUI 打开。

    1. 读取项目约束与发布配置

    2. 并行检查代码、测试与文档

    3. 生成报告制品并打开 RemoteUI

    ◇ high

    defaultctx:12%a3sgit:(main)gpt-5 (128k context)
    WHY A3S CODE

    工具执行之前,先检查参数、权限和确认状态

    模型给出的工具调用不会直接落到文件系统或 Shell。Runtime 先完成检查,再把执行事件和结果交给应用。

    01

    统一检查文件、Shell、Git 与外部请求

    模型提交工具参数后,Runtime 依次检查参数、Workspace 能力和权限规则。需要用户确认的调用会先暂停,不会直接执行。

    policyHITLsandbox
    02

    大输出保存为 Artifact

    文件、搜索、命令和网页结果都支持范围或游标。超过限制的内容会写入 Artifact,模型只收到预览、大小、哈希和取回地址。

    cursorartifacthash
    03

    界面订阅 AgentEvent

    文本、工具调用、计划、确认和生命周期变化都有明确的事件类型。终端、IDE 和网页可以消费同一条事件流。

    AgentEventEventEnvelopeV1
    04

    SessionSnapshotV1 保存恢复数据

    会话、Run、Artifact、Trace、验证结果和子任务记录按同一代快照提交。恢复时直接读取已保存状态。

    snapshotreplayverification
    A3S CODE / DISTINCTIVE CAPABILITIES

    五个关键瞬间,看懂一次任务如何安全地变聪明

    从执行前确认到代码语义,从按需发现平台能力到找回过去会话:选择一个场景,查看真实 A3S Code TUI 中的交互顺序与边界。

    查看完整 TUI 指南
    a3s code~/workspace/a3s

    测试通过后,将 main 分支推送到 origin

    Preparinggit push origin main
    ◇ high

    default modectx:12%a3sgit:(main)gpt-5 (128k context)
    HOW IT RUNS

    用 Python 走完一次执行

    示例使用仓库中实际提供的 a3s_code API。滚动或点击步骤,代码会逐步加入 Session、上下文限制、权限、事件流和持久化。

    查看架构说明
    当前负责的层接入方式
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import Agent
    workspace = str(Path.cwd())
    with closing(Agent.create("agent.acl")) as agent:
    pass
    当前负责的层Agent 与 Session
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import Agent, LocalWorkspaceBackend, SessionOptions
    workspace = str(Path.cwd())
    options = SessionOptions()
    options.planning_mode = "disabled"
    options.workspace_backend = LocalWorkspaceBackend(workspace)
    with closing(Agent.create("agent.acl")) as agent:
    with closing(agent.session(workspace, options)) as session:
    pass
    当前负责的层上下文、记忆与模型
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import Agent, LocalWorkspaceBackend, SessionOptions
    workspace = str(Path.cwd())
    options = SessionOptions()
    options.planning_mode = "disabled"
    options.auto_compact = True
    options.auto_compact_threshold = 0.8
    options.max_context_tokens = 128_000
    options.workspace_backend = LocalWorkspaceBackend(workspace)
    with closing(Agent.create("agent.acl")) as agent:
    with closing(agent.session(workspace, options)) as session:
    pass
    当前负责的层权限与执行检查
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import (
    Agent,
    LocalWorkspaceBackend,
    PermissionPolicy,
    SessionOptions,
    )
    workspace = str(Path.cwd())
    options = SessionOptions()
    options.planning_mode = "disabled"
    options.auto_compact = True
    options.auto_compact_threshold = 0.8
    options.max_context_tokens = 128_000
    options.permission_policy = PermissionPolicy(
    allow=["read*", "ls*", "glob*", "grep*", "code_*"],
    deny=["write*", "edit*", "patch*", "bash*", "git*"],
    default_decision="deny",
    )
    options.workspace_backend = LocalWorkspaceBackend(workspace)
    with closing(Agent.create("agent.acl")) as agent:
    with closing(agent.session(workspace, options)) as session:
    pass
    当前负责的层项目文件与工具
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import (
    Agent,
    EventType,
    LocalWorkspaceBackend,
    PermissionPolicy,
    SessionOptions,
    )
    workspace = str(Path.cwd())
    options = SessionOptions()
    options.planning_mode = "disabled"
    options.auto_compact = True
    options.auto_compact_threshold = 0.8
    options.max_context_tokens = 128_000
    options.permission_policy = PermissionPolicy(
    allow=["read*", "ls*", "glob*", "grep*", "code_*"],
    deny=["write*", "edit*", "patch*", "bash*", "git*"],
    default_decision="deny",
    )
    options.workspace_backend = LocalWorkspaceBackend(workspace)
    with closing(Agent.create("agent.acl")) as agent:
    with closing(agent.session(workspace, options)) as session:
    for event in session.stream(
    "Find the authentication entry points. Do not change files."
    ):
    if event.type == EventType.TEXT_DELTA and event.text:
    print(event.text, end="", flush=True)
    elif event.type == EventType.TOOL_START:
    print(f"\n {event.tool_name or 'tool'}")
    elif event.type == EventType.ERROR:
    raise RuntimeError(event.error or "A3S Code run failed")
    当前负责的层事件、记录与恢复
    runtime.pyPYTHON
    from contextlib import closing
    from pathlib import Path
    from a3s_code import (
    Agent,
    EventType,
    FileSessionStore,
    LocalWorkspaceBackend,
    PermissionPolicy,
    SessionOptions,
    )
    workspace = str(Path.cwd())
    options = SessionOptions()
    options.planning_mode = "disabled"
    options.auto_compact = True
    options.auto_compact_threshold = 0.8
    options.max_context_tokens = 128_000
    options.permission_policy = PermissionPolicy(
    allow=["read*", "ls*", "glob*", "grep*", "code_*"],
    deny=["write*", "edit*", "patch*", "bash*", "git*"],
    default_decision="deny",
    )
    options.workspace_backend = LocalWorkspaceBackend(workspace)
    options.session_store = FileSessionStore(".a3s/sessions")
    with closing(Agent.create("agent.acl")) as agent:
    with closing(agent.session(workspace, options)) as session:
    for event in session.stream(
    "Find the authentication entry points. Do not change files."
    ):
    if event.type == EventType.TEXT_DELTA and event.text:
    print(event.text, end="", flush=True)
    elif event.type == EventType.TOOL_START:
    print(f"\n {event.tool_name or 'tool'}")
    elif event.type == EventType.ERROR:
    raise RuntimeError(event.error or "A3S Code run failed")
    runs = session.runs()
    if runs:
    current = runs[-1]
    print(f"\nrun={current['id']} status={current['status']}")
    session.save()
    WHAT YOU GET

    Runtime 提供的五类能力

    工具、模型、任务记录、扩展接口和 Workspace 各自独立。应用可以只配置当前场景需要的部分。

    工具调用

    工具列表由 Workspace 和权限共同确定

    文件、搜索、Shell、Git、Web、Batch、QuickJS、结构化输出和子任务,只有在当前 Workspace 支持且规则允许时才会提供给模型。

    filesshellgitwebprogramtask
    模型

    更换模型适配器,不改 Session API

    支持 Anthropic、智谱、OpenAI-compatible API,也可以注入自己的 LlmClient。

    streamingtoolsstructured output
    任务记录

    Run、事件与快照使用稳定格式

    一次任务可以保存 Snapshot、事件、Trace、Artifact、验证结果和 Checkpoint;应用可以据此查询、审计或恢复。

    atomicreplayableauditable
    扩展

    工具、上下文与存储都有扩展接口

    MCP、Skills、ContextProvider、MemoryStore、SessionStore、Workspace 服务和自定义工具都可以替换或扩展。

    MCPSkillstraits
    工作区

    本地、S3 与远程 Workspace 分开声明能力

    代码导航与文件工具都来自你选择的 Workspace。远程或对象存储后端不能运行本地命令时,Bash 和 Git 就不会暴露给模型。

    symbolsdiagnosticslocal / S3 / remote
    USE IT YOUR WAY

    直接运行 CLI,或使用四种 SDK

    终端版用于直接操作项目;Rust crate、Node.js 包、Python 包和 Go module 用于 IDE、Runner、服务端或自有界面。

    Terminal

    a3s code

    开箱即用的终端界面,可以查看推理、工具调用、确认提示、任务进度和 Diff。

    a3s code
    Rust

    a3s-code-core

    完整的异步 Runtime API,以及用于接入自定义能力的公共 Trait。

    cargo add a3s-code-core
    Node.js

    @a3s-lab/code

    通过 N-API 提供原生绑定,覆盖会话、事件流、工具、存储、编排和 MCP。

    npm install @a3s-lab/code
    Python

    a3s-code

    通过 PyO3 提供原生包,同时支持同步和异步 API。

    python -m pip install a3s-code
    Go

    sdk/go/v6

    纯 Go API 通过长驻桥接进程提供会话、事件流、工具、验证和 MCP,无需 CGO。

    go get github.com/A3S-Lab/Code/sdk/go/v6
    WHAT STAYS YOURS

    Runtime 负责执行;应用负责账号、凭据和界面

    • A3S Code Core 提供 Agent Runtime,不提供托管服务,也不规定界面应该长什么样。
    • a3s code 的终端界面由独立的 A3S CLI 提供。
    • 账号、凭据、部署方式,以及哪些应用工具可以直接调用,仍由你的应用决定。
    查看架构说明
    TRY IT

    从一个只读任务开始

    安装 a3s code 后,在已有仓库里执行一次检查;需要嵌入时再选择 Rust、Node.js、Python 或 Go SDK。