Skip to content

Commit

Permalink
fix: applying agent to orignal pointer is required during Unmarshalin…
Browse files Browse the repository at this point in the history
…g JSON
  • Loading branch information
Yeuoly committed Dec 9, 2024
1 parent 1aecaf9 commit 9be865f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions internal/core/plugin_manager/media_manager/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ func (m *MediaBucket) RemapAssets(declaration *plugin_entities.PluginDeclaration
}
}

if declaration.Agent != nil {
if declaration.Agent.Identity.Icon != "" {
declaration.Agent.Identity.Icon, err = remap(declaration.Agent.Identity.Icon)
if err != nil {
return nil, errors.Join(err, fmt.Errorf("failed to remap agent icon"))
}
}
}

if declaration.Icon != "" {
declaration.Icon, err = remap(declaration.Icon)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func autoMigrate() error {
models.AIModelInstallation{},
models.InstallTask{},
models.TenantStorage{},
models.AgentInstallation{},
)
}

Expand Down
8 changes: 8 additions & 0 deletions internal/types/entities/plugin_entities/plugin_declaration.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func (p *PluginDeclaration) UnmarshalJSON(data []byte) error {
Endpoint *EndpointProviderDeclaration `json:"endpoint,omitempty"`
Model *ModelProviderDeclaration `json:"model,omitempty"`
Tool *ToolProviderDeclaration `json:"tool,omitempty"`
Agent *AgentProviderDeclaration `json:"agent,omitempty"`
}

var extra PluginExtra
Expand All @@ -212,6 +213,7 @@ func (p *PluginDeclaration) UnmarshalJSON(data []byte) error {
p.Endpoint = extra.Endpoint
p.Model = extra.Model
p.Tool = extra.Tool
p.Agent = extra.Agent

return nil
}
Expand Down Expand Up @@ -251,6 +253,12 @@ func (p *PluginDeclaration) ManifestValidate() error {
return fmt.Errorf("model and endpoint cannot be provided at the same time")
}

if p.Agent != nil {
if p.Tool != nil || p.Model != nil || p.Endpoint != nil {
return fmt.Errorf("agent and tool, model, or endpoint cannot be provided at the same time")
}
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/types/models/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ type AgentInstallation struct {
Provider string `json:"provider" gorm:"column:provider;size:127;index;not null"`
PluginUniqueIdentifier string `json:"plugin_unique_identifier" gorm:"index;size:255"`
PluginID string `json:"plugin_id" gorm:"index;size:255"`
Declaration plugin_entities.AgentProviderDeclaration `json:"declaration" gorm:"serializer:json;type:text;size:65535;not null"`
Declaration plugin_entities.AgentProviderDeclaration `json:"declaration,inline" gorm:"serializer:json;type:text;size:65535;not null"`
}

0 comments on commit 9be865f

Please sign in to comment.