Documentation
¶
Index ¶
- Variables
- type EmbeddedOptions
- type PreparedBackground
- type Server
- func (s *Server) CancelDirectForwarding()
- func (s *Server) Done() <-chan struct{}
- func (s *Server) GetRelayLink() agentproxy.RelayLink
- func (s *Server) MountRoutes(router *gin.Engine)
- func (s *Server) NewTunnelTargetHandler(router http.Handler) *agenttunnel.TargetHandler
- func (s *Server) PrepareBackground(parentCtx context.Context) (*PreparedBackground, error)
- func (s *Server) ResourceCountsForTest() app.ResourceCounts
- func (s *Server) Run() error
- func (s *Server) RunBackground(ctx context.Context)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) SnapshotRemoteTarget(agentID string) (relayexec.RemoteTargetSnapshot, bool)
Constants ¶
This section is empty.
Variables ¶
var (
ErrAlreadyRunning = errors.New("agent server: already running")
)
Functions ¶
This section is empty.
Types ¶
type EmbeddedOptions ¶ added in v0.0.13
type EmbeddedOptions struct {
MetricsRegistry *prometheus.Registry
RelayMetrics *pkgmetrics.AgentRelayMetrics
}
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.
type PreparedBackground ¶ added in v0.0.13
type PreparedBackground struct {
// contains filtered or unexported fields
}
PreparedBackground owns a phase-A-ready embedded runtime. Commit only opens the phase-B gate; Cancel and Wait let the embedding server own its lifetime.
func (*PreparedBackground) Cancel ¶ added in v0.0.13
func (p *PreparedBackground) Cancel(cause error)
func (*PreparedBackground) Commit ¶ added in v0.0.13
func (p *PreparedBackground) Commit()
func (*PreparedBackground) Wait ¶ added in v0.0.13
func (p *PreparedBackground) Wait()
type Server ¶
type Server struct {
Cfg *config.AgentRuntimeConfig
Logger *zap.Logger
Bus app.EventBus
Router *gin.Engine
Creds *enrollment.Credentials
Store *cache.Store
BodyStore *bodypkg.Store
Reporter *reporter.Reporter
RouteObserver *agentroute.Observer
RouteReporter *agentroute.Reporter
Syncer *cache.Syncer
Listener net.Listener
MetricsRegistry *prometheus.Registry
RelayMetrics *pkgmetrics.AgentRelayMetrics
RouteSuppressor *diagnostics.Suppressor
Inflight *inflight.Registry
Breakers *resilience.Registry
LimiterStore *limiter.MemStore
TunnelManager *agenttunnel.Manager
// contains filtered or unexported fields
}
func NewEmbedded ¶
func NewEmbedded(cfg config.AgentRuntimeProvider, logger *zap.Logger, creds *enrollment.Credentials, options ...EmbeddedOptions) (*Server, error)
func (*Server) CancelDirectForwarding ¶ added in v0.0.13
func (s *Server) CancelDirectForwarding()
CancelDirectForwarding stops new direct admission and cancels active direct requests without waiting for handlers to drain.
func (*Server) GetRelayLink ¶ added in v0.0.13
func (s *Server) GetRelayLink() agentproxy.RelayLink
func (*Server) MountRoutes ¶
MountRoutes registers /v1/* relay routes on the given router. This is used by the embedded agent to share the master's router.
func (*Server) NewTunnelTargetHandler ¶ added in v0.0.13
func (s *Server) NewTunnelTargetHandler(router http.Handler) *agenttunnel.TargetHandler
NewTunnelTargetHandler binds committed tunnel requests to the same router used by direct agent traffic. Session ownership is added by the tunnel manager; this factory only supplies target identity, admission, and routing.
func (*Server) PrepareBackground ¶ added in v0.0.13
func (s *Server) PrepareBackground(parentCtx context.Context) (*PreparedBackground, error)
PrepareBackground completes all fallible subscriptions but keeps tunnel, control, full-sync, periodic, and heartbeat workers behind the phase-B gate.
func (*Server) ResourceCountsForTest ¶ added in v0.0.13
func (s *Server) ResourceCountsForTest() app.ResourceCounts
func (*Server) RunBackground ¶
RunBackground prepares and immediately commits an embedded runtime, then blocks until its parent context is cancelled.
func (*Server) SnapshotRemoteTarget ¶ added in v0.0.13
func (s *Server) SnapshotRemoteTarget(agentID string) (relayexec.RemoteTargetSnapshot, bool)
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. |
|
dataflow
Package dataflow 把 channel 内部"解码后请求 → 待发送上游 HTTP 请求"的处理 表达成一串独立的 Step,由 ChannelDataFlow 统一运行与描述。
|
Package dataflow 把 channel 内部"解码后请求 → 待发送上游 HTTP 请求"的处理 表达成一串独立的 Step,由 ChannelDataFlow 统一运行与描述。 |
|
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. |
|
internal/agent/reporter/reporter.go
|
internal/agent/reporter/reporter.go |