examples/

directory
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: Apache-2.0

README

Examples

这些示例只使用 v1 的最终根包 API。除 threads/codec 和部分 profile 同步模式外,它们都会调用本机真实的 Codex、Claude、Cursor 或 CodeBuddy CLI;请先安装并登录对应 CLI。

通用选择参数:

go run ./examples/quickstart -agent=claude
go run ./examples/quickstart -agent=cursor -command=/absolute/path/to/agent

也可通过 AGENT_ADAPTOR_EXAMPLE_AGENTCODEX_COMMANDCLAUDE_COMMANDCURSOR_COMMANDCODEBUDDY_COMMAND 及对应的 *_MODEL 环境变量选择 provider。

Core

  • quickstart:最小 Driver → Agent → Run → Result 路径。
  • structured-output:用 adaptor.RunAs[T] 推导 schema、校验并解码类型化结果。
  • inspect:构造多个 Agent,读取 Environment、Models、ConfigSchema、Quota、Skills 等只读探针。
  • threads:continue-or-start、resume-only 和 fork。
  • threads/codec:不启动 CLI,查看 Driver 的 SessionCodec 与稳定 fingerprint 输入。
  • skills:skill 发现、选择、单次 required skill 与 approval handler。
  • profiles:完整 profile materialization;保留 hook/mcpserver/ 辅助进程。
  • profiles/resources:profile-scoped resources 与 per-call 覆盖。
  • streaming:一条 typed Event 流、Result 收尾与取消。
  • streaming/chat:基于 Thread 的 typed-event 终端聊天;文本粒度取决于 Driver capability。

Protocol bridges

  • web-chat:最小 AG-UI SSE server 与原生浏览器页面。
  • web-chat/aguiclient:Vite + @ag-ui/client 直连 Go SSE bridge。
  • web-chat/copilotkit:CopilotKit、approval responder 与 typed Event recorder。
  • a2a-server:本机 Agent 的 A2A server、streaming client 与 contextID→Thread 映射。

adapter.stream.v1 是已冻结的 wire schema 名称;A2A 示例中的 DecodeAdapterEventV1 因此有意保留 V1,它不是迁移期 Go API。

Showcase

showcases/team-agent-workflow 是 live-only、多 Agent 委派示例,会产生多次付费模型调用,因此不进入自动 smoke。

Smoke

./examples/run_examples.ps1 -Agent codex

runner 总会先执行不启动 CLI 的 threads/codec。若所选 CLI 的 --help 不健康,其余 live 示例会明确跳过;健康时会按同一 provider 执行所有非 server 示例。profiles -run=false -probe=false 只同步并检查本地 profile,不调用模型。

所有目录可统一做编译与 fake 测试:

go test ./examples/...
go test ./examples/web-chat/copilotkit

Directories

Path Synopsis
a2a-server starts an in-process A2A server around a real local Agent, then calls it through the A2A client.
a2a-server starts an in-process A2A server around a real local Agent, then calls it through the A2A client.
inspect demonstrates read-only Driver probes and Agent inspection.
inspect demonstrates read-only Driver probes and Agent inspection.
internal
profiles materializes a complete provider profile — skills, MCP, hooks, sub-agent, instructions — and then proves on disk that the selected CLI really sees it.
profiles materializes a complete provider profile — skills, MCP, hooks, sub-agent, instructions — and then proves on disk that the selected CLI really sees it.
hook command
mcpserver command
resources command
profiles/resources shows the resource half of the profile vocabulary: not only *where* the provider profile lives, but *what must exist inside it*.
profiles/resources shows the resource half of the profile vocabulary: not only *where* the provider profile lives, but *what must exist inside it*.
quickstart constructs an Agent from a Driver, asks one question, and reads one Result.
quickstart constructs an Agent from a Driver, asks one question, and reads one Result.
showcases
team-agent-workflow command
Host-side scaffolding for the team-agent-workflow showcase: the temporary task fixture, the workspace stage audit, the terminal renderer, and the protocol text handed to the leader.
Host-side scaffolding for the team-agent-workflow showcase: the temporary task fixture, the workspace stage audit, the terminal renderer, and the protocol text handed to the leader.
skills proves runtime skill injection end-to-end with a real local CLI: the agent is given a write-proof skill and only follows it if the skill actually reached the provider's skill directory.
skills proves runtime skill injection end-to-end with a real local CLI: the agent is given a write-proof skill and only follows it if the skill actually reached the provider's skill directory.
streaming shows the unified typed event channel for one run, consumed with a single for-range + type switch, closed out by Result().
streaming shows the unified typed event channel for one run, consumed with a single for-range + type switch, closed out by Result().
chat command
streaming/chat is a minimal typed-event chat UI in pure Go.
streaming/chat is a minimal typed-event chat UI in pure Go.
structured-output derives a JSON schema from a Go type, asks the Driver for structured output, validates it, and returns the decoded value with Result.
structured-output derives a JSON schema from a Go type, asks the Driver for structured output, validates it, and returns the decoded value with Result.
threads demonstrates persistent, resume-only, and forked conversation Threads on host-owned keys.
threads demonstrates persistent, resume-only, and forked conversation Threads on host-owned keys.
codec command
threads/codec looks underneath the Thread abstraction at the driver-owned session codec.
threads/codec looks underneath the Thread abstraction at the driver-owned session codec.
tools gives a local coding agent one host-defined typed Go function.
tools gives a local coding agent one host-defined typed Go function.
web-chat exposes an Agent over AG-UI Server-Sent Events with a single bridge call.
web-chat exposes an Agent over AG-UI Server-Sent Events with a single bridge call.
aguiclient command
web-chat/aguiclient is the minimal-middleware AG-UI demo:
web-chat/aguiclient is the minimal-middleware AG-UI demo:
copilotkit command
web-chat/copilotkit combines the SDK's unified Event stream with CopilotKit's React UI through the AG-UI protocol.
web-chat/copilotkit combines the SDK's unified Event stream with CopilotKit's React UI through the AG-UI protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL