refactor(sdk): update dragonscale sdk options, service ops
This commit is contained in:
parent
a0518f90ab
commit
7f64dd1cc5
5 changed files with 4 additions and 111 deletions
|
|
@ -164,10 +164,6 @@ type AgentDefaults struct {
|
||||||
MaxToolIterations int `json:"max_tool_iterations" env:"DRAGONSCALE_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
MaxToolIterations int `json:"max_tool_iterations" env:"DRAGONSCALE_AGENTS_DEFAULTS_MAX_TOOL_ITERATIONS"`
|
||||||
ContinuityRetention ContinuityRetentionConfig `json:"continuity_retention"`
|
ContinuityRetention ContinuityRetentionConfig `json:"continuity_retention"`
|
||||||
Compaction CompactionConfig `json:"compaction"`
|
Compaction CompactionConfig `json:"compaction"`
|
||||||
|
|
||||||
// Deprecated: Use Sandbox instead. Kept for backward compatibility during migration.
|
|
||||||
Workspace string `json:"workspace,omitempty" env:"DRAGONSCALE_AGENTS_DEFAULTS_WORKSPACE"`
|
|
||||||
RestrictToWorkspace bool `json:"restrict_to_workspace,omitempty" env:"DRAGONSCALE_AGENTS_DEFAULTS_RESTRICT_TO_WORKSPACE"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ChannelsConfig struct {
|
type ChannelsConfig struct {
|
||||||
|
|
@ -659,22 +655,11 @@ func (c *Config) SandboxPath() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// RestrictToSandbox returns whether tool file operations should be restricted
|
// RestrictToSandbox returns whether tool file operations should be restricted
|
||||||
// to the sandbox directory. Also checks the deprecated RestrictToWorkspace field.
|
// to the sandbox directory.
|
||||||
func (c *Config) RestrictToSandbox() bool {
|
func (c *Config) RestrictToSandbox() bool {
|
||||||
c.mu.RLock()
|
c.mu.RLock()
|
||||||
defer c.mu.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
return c.Agents.Defaults.RestrictToSandbox || c.Agents.Defaults.RestrictToWorkspace
|
return c.Agents.Defaults.RestrictToSandbox
|
||||||
}
|
|
||||||
|
|
||||||
// WorkspacePath returns the legacy workspace path for backward compatibility.
|
|
||||||
// Deprecated: callers should migrate to SandboxPath().
|
|
||||||
func (c *Config) WorkspacePath() string {
|
|
||||||
c.mu.RLock()
|
|
||||||
defer c.mu.RUnlock()
|
|
||||||
if c.Agents.Defaults.Workspace != "" {
|
|
||||||
return expandHome(c.Agents.Defaults.Workspace)
|
|
||||||
}
|
|
||||||
return c.SandboxPath()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DBPath returns the resolved database path.
|
// DBPath returns the resolved database path.
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,6 @@ type GatewayOptions struct {
|
||||||
Debug bool
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type MigrateOptions struct {
|
|
||||||
DryRun bool
|
|
||||||
ConfigOnly bool
|
|
||||||
WorkspaceOnly bool
|
|
||||||
Force bool
|
|
||||||
Refresh bool
|
|
||||||
OpenClawHome string
|
|
||||||
DragonscaleHome string
|
|
||||||
}
|
|
||||||
|
|
||||||
type CronAddOptions struct {
|
type CronAddOptions struct {
|
||||||
Name string
|
Name string
|
||||||
Message string
|
Message string
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ type CLIService interface {
|
||||||
SecretService
|
SecretService
|
||||||
DaemonService
|
DaemonService
|
||||||
MemoryService
|
MemoryService
|
||||||
MigrationService
|
|
||||||
StatusService
|
StatusService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,11 +129,6 @@ type StatusService interface {
|
||||||
Status(context.Context, io.Writer) error
|
Status(context.Context, io.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrationService defines migration operations.
|
|
||||||
type MigrationService interface {
|
|
||||||
Migrate(context.Context, MigrateOptions, io.Writer) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// AuthService defines auth lifecycle operations.
|
// AuthService defines auth lifecycle operations.
|
||||||
type AuthService interface {
|
type AuthService interface {
|
||||||
AuthLogin(context.Context, io.Reader, io.Writer, string, bool) error
|
AuthLogin(context.Context, io.Reader, io.Writer, string, bool) error
|
||||||
|
|
@ -178,7 +172,6 @@ type DaemonService interface {
|
||||||
|
|
||||||
// MemoryService defines memory system operations.
|
// MemoryService defines memory system operations.
|
||||||
type MemoryService interface {
|
type MemoryService interface {
|
||||||
MemoryMigrateSessions(context.Context, io.Writer) error
|
|
||||||
MemoryDBStatus(context.Context, io.Writer) error
|
MemoryDBStatus(context.Context, io.Writer) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,7 +182,6 @@ var (
|
||||||
_ AgentService = (*Service)(nil)
|
_ AgentService = (*Service)(nil)
|
||||||
_ GatewayService = (*Service)(nil)
|
_ GatewayService = (*Service)(nil)
|
||||||
_ StatusService = (*Service)(nil)
|
_ StatusService = (*Service)(nil)
|
||||||
_ MigrationService = (*Service)(nil)
|
|
||||||
_ AuthService = (*Service)(nil)
|
_ AuthService = (*Service)(nil)
|
||||||
_ CronService = (*Service)(nil)
|
_ CronService = (*Service)(nil)
|
||||||
_ SkillsService = (*Service)(nil)
|
_ SkillsService = (*Service)(nil)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/health"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/health"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/heartbeat"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/heartbeat"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/logger"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/logger"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/migrate"
|
|
||||||
dragonruntime "github.com/ZanzyTHEbar/dragonscale/pkg/runtime"
|
dragonruntime "github.com/ZanzyTHEbar/dragonscale/pkg/runtime"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/security"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/security"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/security/securebus"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/security/securebus"
|
||||||
|
|
@ -75,10 +74,6 @@ func (s *Service) Onboard(ctx context.Context, in io.Reader, out io.Writer) erro
|
||||||
return fmt.Errorf("error saving config: %w", err)
|
return fmt.Errorf("error saving config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if migErr := migrate.MigrateToXDG(""); migErr != nil {
|
|
||||||
fmt.Fprintf(out, "Warning: XDG migration failed: %v\n", migErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
s.createWorkspaceTemplates(cfg, out)
|
s.createWorkspaceTemplates(cfg, out)
|
||||||
|
|
||||||
fmt.Fprintf(out, "%s dragonscale is ready!\n", s.Logo)
|
fmt.Fprintf(out, "%s dragonscale is ready!\n", s.Logo)
|
||||||
|
|
@ -111,27 +106,6 @@ func (s *Service) Onboard(ctx context.Context, in io.Reader, out io.Writer) erro
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Migrate(ctx context.Context, opts MigrateOptions, out io.Writer) error {
|
|
||||||
_ = ctx
|
|
||||||
result, err := migrate.Run(migrate.Options{
|
|
||||||
DryRun: opts.DryRun,
|
|
||||||
ConfigOnly: opts.ConfigOnly,
|
|
||||||
WorkspaceOnly: opts.WorkspaceOnly,
|
|
||||||
Force: opts.Force,
|
|
||||||
Refresh: opts.Refresh,
|
|
||||||
OpenClawHome: opts.OpenClawHome,
|
|
||||||
DragonScaleHome: opts.DragonscaleHome,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !opts.DryRun {
|
|
||||||
migrate.PrintSummary(result)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) Agent(ctx context.Context, in io.Reader, out io.Writer, opts AgentOptions) error {
|
func (s *Service) Agent(ctx context.Context, in io.Reader, out io.Writer, opts AgentOptions) error {
|
||||||
if opts.Debug {
|
if opts.Debug {
|
||||||
logger.SetLevel(logger.DEBUG)
|
logger.SetLevel(logger.DEBUG)
|
||||||
|
|
@ -481,7 +455,7 @@ func (s *Service) Status(ctx context.Context, out io.Writer) error {
|
||||||
|
|
||||||
memDBPath := cfg.Memory.DBPath
|
memDBPath := cfg.Memory.DBPath
|
||||||
if memDBPath == "" {
|
if memDBPath == "" {
|
||||||
memDBPath = filepath.Join(cfg.WorkspacePath(), "memory", "dragonscale.db")
|
memDBPath = filepath.Join(cfg.SandboxPath(), "memory", "dragonscale.db")
|
||||||
}
|
}
|
||||||
if fi, err := os.Stat(memDBPath); err == nil {
|
if fi, err := os.Stat(memDBPath); err == nil {
|
||||||
fmt.Printf(" DB size: %.1f KB\n", float64(fi.Size())/1024)
|
fmt.Printf(" DB size: %.1f KB\n", float64(fi.Size())/1024)
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,9 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg"
|
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/config"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/config"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/itr"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/itr"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/logger"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/logger"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/memory"
|
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/memory/delegate"
|
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/security"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/security"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/security/securebus"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/security/securebus"
|
||||||
"github.com/ZanzyTHEbar/dragonscale/pkg/skills"
|
"github.com/ZanzyTHEbar/dragonscale/pkg/skills"
|
||||||
|
|
@ -96,11 +93,6 @@ func (s *Service) SkillsListBuiltin(ctx context.Context, out io.Writer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
legacyBuiltin := filepath.Join(filepath.Dir(s.getConfigPath()), "skills")
|
|
||||||
if err := s.printBuiltinFromPath(out, legacyBuiltin); err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Errorf(`no builtin skills source available`)
|
return fmt.Errorf(`no builtin skills source available`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -167,7 +159,7 @@ func (s *Service) SkillsInstallBuiltin(ctx context.Context, out io.Writer, works
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
workspace = cfg.WorkspacePath()
|
workspace = cfg.SandboxPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
target := filepath.Join(workspace, "skills")
|
target := filepath.Join(workspace, "skills")
|
||||||
|
|
@ -547,46 +539,6 @@ func (s *Service) DaemonStatus(ctx context.Context, out io.Writer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) MemoryMigrateSessions(ctx context.Context, out io.Writer) error {
|
|
||||||
cfg, err := s.LoadConfig()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
dbPath := cfg.Memory.DBPath
|
|
||||||
if dbPath == "" {
|
|
||||||
dbPath, err = config.DefaultDBPath()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate, err := delegate.NewLibSQLDelegate(dbPath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf(`memory delegate: %w`, err)
|
|
||||||
}
|
|
||||||
defer delegate.Close()
|
|
||||||
|
|
||||||
if err := delegate.Init(context.Background()); err != nil {
|
|
||||||
return fmt.Errorf(`initialize memory delegate: %w`, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := memory.MigrateFileSessions(ctx, delegate, pkg.NAME, filepath.Join(cfg.WorkspacePath(), ".sessions"))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if result == nil {
|
|
||||||
fmt.Fprintln(out, `No sessions to migrate.`)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Fprintf(out, `sessions_found=%d\n`, result.SessionsFound)
|
|
||||||
fmt.Fprintf(out, `sessions_migrated=%d\n`, result.SessionsMigrated)
|
|
||||||
fmt.Fprintf(out, `items_created=%d\n`, result.ItemsCreated)
|
|
||||||
fmt.Fprintf(out, `errors=%d\n`, result.Errors)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Service) MemoryDBStatus(ctx context.Context, out io.Writer) error {
|
func (s *Service) MemoryDBStatus(ctx context.Context, out io.Writer) error {
|
||||||
_ = ctx
|
_ = ctx
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue