feat: add remote config and host metadata
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,6 +12,7 @@ type Config struct {
|
||||
Events Events `toml:"events"`
|
||||
Notify Notify `toml:"notify"`
|
||||
Inbox Inbox `toml:"inbox"`
|
||||
Remote Remote `toml:"remote"`
|
||||
}
|
||||
|
||||
type Events struct {
|
||||
@@ -38,6 +39,13 @@ type Inbox struct {
|
||||
TimeoutMS int `toml:"timeout_ms"`
|
||||
}
|
||||
|
||||
type Remote struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
URL string `toml:"url"`
|
||||
Token string `toml:"token"`
|
||||
TimeoutMS int `toml:"timeout_ms"`
|
||||
}
|
||||
|
||||
func Default() Config {
|
||||
return Config{
|
||||
Events: Events{Stop: true, Response: true, Idle: false, Tool: false},
|
||||
@@ -49,13 +57,17 @@ func Default() Config {
|
||||
BodyTool: "工具执行完成",
|
||||
},
|
||||
Inbox: Inbox{
|
||||
Enabled: true,
|
||||
Enabled: false,
|
||||
Socket: DefaultInboxSocket(),
|
||||
RemoteSocket: DefaultInboxRemoteSocket(),
|
||||
Addr: "127.0.0.1:17777",
|
||||
FallbackLocal: true,
|
||||
TimeoutMS: 500,
|
||||
},
|
||||
Remote: Remote{
|
||||
Enabled: false,
|
||||
TimeoutMS: 2000,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ func TestDefaultConfig(t *testing.T) {
|
||||
if cfg.Notify.Protocol != "osc777" {
|
||||
t.Fatalf("expected osc777, got %q", cfg.Notify.Protocol)
|
||||
}
|
||||
if !cfg.Inbox.Enabled {
|
||||
t.Fatal("expected inbox enabled by default")
|
||||
if cfg.Inbox.Enabled {
|
||||
t.Fatal("expected inbox disabled by default")
|
||||
}
|
||||
if cfg.Inbox.Addr != "127.0.0.1:17777" {
|
||||
t.Fatalf("expected default inbox addr, got %q", cfg.Inbox.Addr)
|
||||
@@ -104,6 +104,16 @@ func TestDefaultInboxSocketPrefersXDGRuntimeDir(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultRemoteDisabledInbox(t *testing.T) {
|
||||
cfg := Default()
|
||||
if cfg.Inbox.Enabled {
|
||||
t.Fatal("inbox should default disabled")
|
||||
}
|
||||
if cfg.Remote.TimeoutMS != 2000 {
|
||||
t.Fatalf("remote timeout: got %d", cfg.Remote.TimeoutMS)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEventEnabled(t *testing.T) {
|
||||
cfg := Default()
|
||||
if !cfg.EventEnabled("stop") {
|
||||
|
||||
Reference in New Issue
Block a user