Sync with sipeed/picoclaw upstream/main (~1095 commits since last merge), including major restructures: - Launcher migrated to web/backend (#1275): cmd/picoclaw-launcher/* removed. Our launcher is dropped (MagicForm doesn't use it; web/backend is the upstream replacement when needed). - Agent loop split (#2585,12d5421c): pkg/agent/loop.go deleted, replaced by pkg/agent/agent_*.go files. Multi-tenancy customizations to be forward-ported in follow-up commits on this branch. - Tool packages reorganized (4c133dc2): pkg/tools/{filesystem,web}.go moved to pkg/tools/{fs,integration}/. Customizations to be forward-ported. - Channels switched to map+Settings model: MagicFormConfig → MagicFormSettings registered in config_channel.go alongside other channels; channel constructor updated to (channelName, channelType, *Config, *MessageBus) factory pattern. - Config schema updates: removed deprecated AgentDefaults.Model field; removed Config.Bindings (legacy migration in upstream); SessionConfig now uses Dimensions instead of DMScope; ExecConfig adds AllowRemote. Conflicts resolved: - pkg/agent/loop.go + loop_test.go: accepted upstream deletion (split) - pkg/tools/{filesystem,web}.go: accepted upstream deletion (moved) - cmd/picoclaw-launcher/*: dropped (deps deleted upstream, unused by MagicForm) - cmd/picoclaw/internal/gateway/helpers.go: accepted upstream deletion - pkg/channels/manager.go: switched to upstream's map-driven channel init - pkg/config/config.go: merged AgentDefaults fields, kept WorkspaceRoot, removed deprecated Model - pkg/bus/types.go: merged OutboundMessage with upstream's new fields (Context, AgentID, SessionKey, Scope, ContextUsage) plus our magicform callback fields (Type, Metrics, Progress, Escalation) - pkg/tools/{cron,shell}.go: combined our customizations with upstream changes - pkg/skills/installer.go: dropped our LimitReader path (upstream now uses chunked DownloadToFile which is size-bounded) The magicform channel was rebuilt to match upstream's new API: - *config.MagicFormSettings (SecureString token) instead of MagicFormConfig - Send returns ([]string, error) per upstream Channel interface - InboundMessage built with Context (with Raw map for tenancy hints) instead of bus.Peer + Metadata field which were removed. Multi-tenancy hints (workspace_override, config_dir, allowed_tools, allowed_skills) are still flowing via Context.Raw — the agent loop side of the integration is forward-ported in a follow-up commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
32 lines
791 B
Go
32 lines
791 B
Go
package magicform
|
|
|
|
import (
|
|
"github.com/sipeed/picoclaw/pkg/bus"
|
|
"github.com/sipeed/picoclaw/pkg/channels"
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
func init() {
|
|
channels.RegisterFactory(
|
|
config.ChannelMagicForm,
|
|
func(channelName, channelType string, cfg *config.Config, b *bus.MessageBus) (channels.Channel, error) {
|
|
bc := cfg.Channels[channelName]
|
|
decoded, err := bc.GetDecoded()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
settings, ok := decoded.(*config.MagicFormSettings)
|
|
if !ok {
|
|
return nil, channels.ErrSendFailed
|
|
}
|
|
ch, err := NewMagicFormChannel(bc, settings, cfg.Agents.Defaults.WorkspaceRoot, b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if channelName != config.ChannelMagicForm {
|
|
ch.SetName(channelName)
|
|
}
|
|
return ch, nil
|
|
},
|
|
)
|
|
}
|