agent

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Cfg      *config.AgentRuntimeConfig
	Logger   *zap.Logger
	Bus      app.EventBus
	Router   *gin.Engine
	Creds    *enrollment.Credentials
	Store    *cache.Store
	Reporter *reporter.Reporter
	Syncer   *cache.Syncer
	Listener net.Listener

	Inflight *inflight.Registry
	// contains filtered or unexported fields
}

func New

func New(cfg config.AgentRuntimeProvider, logger *zap.Logger) (*Server, error)

func NewEmbedded

func NewEmbedded(cfg config.AgentRuntimeProvider, logger *zap.Logger, creds *enrollment.Credentials) (*Server, error)

NewEmbedded creates an agent server for embedding inside master. It skips enrollment and accepts pre-configured credentials. The returned server has no Router — use MountRoutes() to attach relay routes to an external router.

func (*Server) MountRoutes

func (s *Server) MountRoutes(router *gin.Engine)

MountRoutes registers /v1/* relay routes on the given router. This is used by the embedded agent to share the master's router.

func (*Server) Run

func (s *Server) Run() error

func (*Server) RunBackground

func (s *Server) RunBackground(ctx context.Context)

RunBackground starts agent background goroutines (Reporter, Syncer, connectLoop, heartbeat) without starting an HTTP server. It blocks until ctx is cancelled.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Directories

Path Synopsis
Package app 装配 agent 端服务到 app.AgentApplication 接口。
Package app 装配 agent 端服务到 app.AgentApplication 接口。
entitycache
Package entitycache 提供通用实体缓存抽象。
Package entitycache 提供通用实体缓存抽象。
loaders
Package loaders 提供 entitycache.Loader 的具体实现(每实体一个文件)。
Package loaders 提供 entitycache.Loader 的具体实现(每实体一个文件)。
affinity
Package affinity 实现 agent 本地的渠道缓存粘性:把 (用户, 真实模型) 上次发生 缓存活动的上游 channel 记下来,供 plan 阶段优先选用。
Package affinity 实现 agent 本地的渠道缓存粘性:把 (用户, 真实模型) 上次发生 缓存活动的上游 channel 记下来,供 plan 阶段优先选用。
backend
Package backend defines the Backend contract and the Dispatcher that routes each Attempt to one of native / passthrough / legacy implementations based on Attempt.Mode.
Package backend defines the Backend contract and the Dispatcher that routes each Attempt to one of native / passthrough / legacy implementations based on Attempt.Mode.
backend/common
Package common 提供 backend(native / passthrough)共用的工具。
Package common 提供 backend(native / passthrough)共用的工具。
codec
Package codec defines the Intermediate Representation (IR) types and Codec interfaces used by the native protocol conversion layer.
Package codec defines the Intermediate Representation (IR) types and Codec interfaces used by the native protocol conversion layer.
codec/claude
Package claude implements the Anthropic Claude Messages API protocol codec.
Package claude implements the Anthropic Claude Messages API protocol codec.
codec/openai
Package openai implements the OpenAI Chat Completions protocol codec.
Package openai implements the OpenAI Chat Completions protocol codec.
inflight
Package inflight 跟踪 agent 当前在途的 relay 请求,供看门狗告警与 master 远程诊断。
Package inflight 跟踪 agent 当前在途的 relay 请求,供看门狗告警与 master 远程诊断。
modelview
Package modelview 计算"当前 caller 在 /v1/models 中应见的模型列表"。
Package modelview 计算"当前 caller 在 /v1/models 中应见的模型列表"。
pipeline/ctxbuild
Package ctxbuild 是 relay pipeline 的 Phase 1:把 *gin.Context 装配成 state.RelayContext.Input 的请求级 immutable 输入。
Package ctxbuild 是 relay pipeline 的 Phase 1:把 *gin.Context 装配成 state.RelayContext.Input 的请求级 immutable 输入。
pipeline/publish
Package publish 是 relay pipeline 的第 4 阶段(最末端):把累加好的 RelayContext 状态 一次性收成 protocol.UsageLogEntry 并经 EventBus 发布 usage.completed。
Package publish 是 relay pipeline 的第 4 阶段(最末端):把累加好的 RelayContext 状态 一次性收成 protocol.UsageLogEntry 并经 EventBus 发布 usage.completed。
resilience
Package resilience 给单次 channel dispatch 套重试/熔断/超时。
Package resilience 给单次 channel dispatch 套重试/熔断/超时。
script
Package script 实现管理员动态 goja 脚本的编译与执行。
Package script 实现管理员动态 goja 脚本的编译与执行。
state
Package state 是 relay 子包之间共享的叶子包,承载跨包共享的数据结构、 pipeline phase 枚举、relay mode 枚举、Dispatcher 接口以及哨兵 error。
Package state 是 relay 子包之间共享的叶子包,承载跨包共享的数据结构、 pipeline phase 枚举、relay mode 枚举、Dispatcher 接口以及哨兵 error。
transform
Package transform provides IR-level request transformers (system prompt injection, role mapping, thinking pass-through/strip) that the relay pipeline applies between inbound decode and outbound encode.
Package transform provides IR-level request transformers (system prompt injection, role mapping, thinking pass-through/strip) that the relay pipeline applies between inbound decode and outbound encode.

Jump to

Keyboard shortcuts

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