mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-04 07:57:28 +08:00
fix package
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/browser"
|
||||
"github.com/YspCoder/clawgo/pkg/browser"
|
||||
)
|
||||
|
||||
type BrowserTool struct {
|
||||
|
||||
@@ -46,13 +46,13 @@ func (t *CameraTool) Execute(ctx context.Context, args map[string]interface{}) (
|
||||
} else {
|
||||
filename = fmt.Sprintf("snap_%d.jpg", time.Now().Unix())
|
||||
}
|
||||
|
||||
|
||||
// Ensure filename is safe and within workspace
|
||||
filename = filepath.Clean(filename)
|
||||
if filepath.IsAbs(filename) {
|
||||
return "", fmt.Errorf("filename must be relative to workspace")
|
||||
}
|
||||
|
||||
|
||||
outputPath := filepath.Join(t.workspace, filename)
|
||||
|
||||
// Check if video device exists
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"clawgo/pkg/cron"
|
||||
"github.com/YspCoder/clawgo/pkg/cron"
|
||||
)
|
||||
|
||||
type CronTool struct {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
const mcpProtocolVersion = "2025-06-18"
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
func TestMCPToolListServers(t *testing.T) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"clawgo/pkg/bus"
|
||||
"github.com/YspCoder/clawgo/pkg/bus"
|
||||
)
|
||||
|
||||
type SendCallback func(channel, chatID, action, content, media, messageID, emoji string, buttons [][]bus.Button) error
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/nodes"
|
||||
"github.com/YspCoder/clawgo/pkg/nodes"
|
||||
)
|
||||
|
||||
// NodesTool provides an OpenClaw-style control surface for paired nodes.
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/events"
|
||||
"github.com/YspCoder/clawgo/pkg/events"
|
||||
)
|
||||
|
||||
type processSession struct {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/logger"
|
||||
"github.com/YspCoder/clawgo/pkg/logger"
|
||||
)
|
||||
|
||||
type ToolRegistry struct {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/cron"
|
||||
"github.com/YspCoder/clawgo/pkg/cron"
|
||||
)
|
||||
|
||||
type RemindTool struct {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"clawgo/pkg/cron"
|
||||
"github.com/YspCoder/clawgo/pkg/cron"
|
||||
)
|
||||
|
||||
func TestRemindTool_UsesToolContextForDeliveryTarget(t *testing.T) {
|
||||
@@ -15,7 +15,7 @@ func TestRemindTool_UsesToolContextForDeliveryTarget(t *testing.T) {
|
||||
tool.SetContext("telegram", "chat-123")
|
||||
|
||||
_, err := tool.Execute(context.Background(), map[string]interface{}{
|
||||
"message": "喝水",
|
||||
"message": "鍠濇按",
|
||||
"time_expr": "10m",
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/providers"
|
||||
"github.com/YspCoder/clawgo/pkg/providers"
|
||||
)
|
||||
|
||||
type SessionInfo struct {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
type ExecTool struct {
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
)
|
||||
|
||||
type SkillExecTool struct {
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/bus"
|
||||
"clawgo/pkg/ekg"
|
||||
"clawgo/pkg/providers"
|
||||
"github.com/YspCoder/clawgo/pkg/bus"
|
||||
"github.com/YspCoder/clawgo/pkg/ekg"
|
||||
"github.com/YspCoder/clawgo/pkg/providers"
|
||||
)
|
||||
|
||||
type SubagentTask struct {
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"clawgo/pkg/configops"
|
||||
"clawgo/pkg/runtimecfg"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/configops"
|
||||
"github.com/YspCoder/clawgo/pkg/runtimecfg"
|
||||
)
|
||||
|
||||
func DraftConfigSubagent(description, agentIDHint string) map[string]interface{} {
|
||||
@@ -287,11 +287,11 @@ func normalizeKeywords(items []string) []string {
|
||||
|
||||
func inferDraftRole(lower string) string {
|
||||
switch {
|
||||
case containsDraftKeyword(lower, "test", "regression", "qa", "回归", "测试", "验证"):
|
||||
case containsDraftKeyword(lower, "test", "regression", "qa", "鍥炲綊", "娴嬭瘯", "楠岃瘉"):
|
||||
return "testing"
|
||||
case containsDraftKeyword(lower, "doc", "docs", "readme", "文档", "说明"):
|
||||
case containsDraftKeyword(lower, "doc", "docs", "readme", "鏂囨。", "璇存槑"):
|
||||
return "docs"
|
||||
case containsDraftKeyword(lower, "research", "investigate", "analyze", "调研", "分析", "研究"):
|
||||
case containsDraftKeyword(lower, "research", "investigate", "analyze", "璋冪爺", "鍒嗘瀽", "鐮旂┒"):
|
||||
return "research"
|
||||
default:
|
||||
return "coding"
|
||||
@@ -301,7 +301,7 @@ func inferDraftRole(lower string) string {
|
||||
func inferDraftAgentID(role, lower string) string {
|
||||
switch role {
|
||||
case "testing":
|
||||
if containsDraftKeyword(lower, "review", "审查", "reviewer") {
|
||||
if containsDraftKeyword(lower, "review", "瀹℃煡", "reviewer") {
|
||||
return "reviewer"
|
||||
}
|
||||
return "tester"
|
||||
@@ -310,10 +310,10 @@ func inferDraftAgentID(role, lower string) string {
|
||||
case "research":
|
||||
return "researcher"
|
||||
default:
|
||||
if containsDraftKeyword(lower, "frontend", "ui", "前端") {
|
||||
if containsDraftKeyword(lower, "frontend", "ui", "鍓嶇") {
|
||||
return "frontend-coder"
|
||||
}
|
||||
if containsDraftKeyword(lower, "backend", "api", "后端") {
|
||||
if containsDraftKeyword(lower, "backend", "api", "鍚庣") {
|
||||
return "backend-coder"
|
||||
}
|
||||
return "coder"
|
||||
@@ -356,19 +356,19 @@ func inferDraftKeywords(role, lower string) []string {
|
||||
seed := []string{}
|
||||
switch role {
|
||||
case "testing":
|
||||
seed = []string{"test", "regression", "verify", "回归", "测试", "验证"}
|
||||
seed = []string{"test", "regression", "verify", "鍥炲綊", "娴嬭瘯", "楠岃瘉"}
|
||||
case "docs":
|
||||
seed = []string{"docs", "readme", "document", "文档", "说明"}
|
||||
seed = []string{"docs", "readme", "document", "鏂囨。", "璇存槑"}
|
||||
case "research":
|
||||
seed = []string{"research", "analyze", "investigate", "调研", "分析", "研究"}
|
||||
seed = []string{"research", "analyze", "investigate", "璋冪爺", "鍒嗘瀽", "鐮旂┒"}
|
||||
default:
|
||||
seed = []string{"code", "implement", "fix", "refactor", "代码", "实现", "修复", "重构"}
|
||||
seed = []string{"code", "implement", "fix", "refactor", "浠g爜", "瀹炵幇", "淇", "閲嶆瀯"}
|
||||
}
|
||||
if containsDraftKeyword(lower, "frontend", "前端", "ui") {
|
||||
seed = append(seed, "frontend", "ui", "前端")
|
||||
if containsDraftKeyword(lower, "frontend", "鍓嶇", "ui") {
|
||||
seed = append(seed, "frontend", "ui", "鍓嶇")
|
||||
}
|
||||
if containsDraftKeyword(lower, "backend", "后端", "api") {
|
||||
seed = append(seed, "backend", "api", "后端")
|
||||
if containsDraftKeyword(lower, "backend", "鍚庣", "api") {
|
||||
seed = append(seed, "backend", "api", "鍚庣")
|
||||
}
|
||||
return normalizeKeywords(seed)
|
||||
}
|
||||
@@ -376,13 +376,13 @@ func inferDraftKeywords(role, lower string) []string {
|
||||
func inferDraftSystemPrompt(role, description string) string {
|
||||
switch role {
|
||||
case "testing":
|
||||
return "你负责测试、验证、回归检查与风险反馈。任务描述:" + description
|
||||
return "浣犺礋璐f祴璇曘€侀獙璇併€佸洖褰掓鏌ヤ笌椋庨櫓鍙嶉銆備换鍔℃弿杩帮細" + description
|
||||
case "docs":
|
||||
return "你负责文档编写、结构整理和说明补全。任务描述:" + description
|
||||
return "浣犺礋璐f枃妗g紪鍐欍€佺粨鏋勬暣鐞嗗拰璇存槑琛ュ叏銆備换鍔℃弿杩帮細" + description
|
||||
case "research":
|
||||
return "你负责调研、分析、比较方案,并输出结论与依据。任务描述:" + description
|
||||
return "浣犺礋璐h皟鐮斻€佸垎鏋愩€佹瘮杈冩柟妗堬紝骞惰緭鍑虹粨璁轰笌渚濇嵁銆備换鍔℃弿杩帮細" + description
|
||||
default:
|
||||
return "你负责代码实现与重构,输出具体修改建议和变更结果。任务描述:" + description
|
||||
return "浣犺礋璐d唬鐮佸疄鐜颁笌閲嶆瀯锛岃緭鍑哄叿浣撲慨鏀瑰缓璁拰鍙樻洿缁撴灉銆備换鍔℃弿杩帮細" + description
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"clawgo/pkg/runtimecfg"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/runtimecfg"
|
||||
)
|
||||
|
||||
func TestSubagentConfigToolUpsert(t *testing.T) {
|
||||
@@ -34,7 +34,7 @@ func TestSubagentConfigToolUpsert(t *testing.T) {
|
||||
"role": "testing",
|
||||
"notify_main_policy": "internal_only",
|
||||
"display_name": "Review Agent",
|
||||
"description": "负责回归与评审",
|
||||
"description": "handles review and regression checks",
|
||||
"system_prompt_file": "agents/reviewer/AGENT.md",
|
||||
"routing_keywords": []interface{}{"review", "regression"},
|
||||
"tool_allowlist": []interface{}{"shell", "sessions"},
|
||||
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"clawgo/pkg/nodes"
|
||||
"clawgo/pkg/runtimecfg"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/nodes"
|
||||
"github.com/YspCoder/clawgo/pkg/runtimecfg"
|
||||
)
|
||||
|
||||
type SubagentProfile struct {
|
||||
|
||||
@@ -6,9 +6,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/config"
|
||||
"clawgo/pkg/nodes"
|
||||
"clawgo/pkg/runtimecfg"
|
||||
"github.com/YspCoder/clawgo/pkg/config"
|
||||
"github.com/YspCoder/clawgo/pkg/nodes"
|
||||
"github.com/YspCoder/clawgo/pkg/runtimecfg"
|
||||
)
|
||||
|
||||
func TestSubagentProfileStoreNormalization(t *testing.T) {
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/bus"
|
||||
"clawgo/pkg/providers"
|
||||
"github.com/YspCoder/clawgo/pkg/bus"
|
||||
"github.com/YspCoder/clawgo/pkg/providers"
|
||||
)
|
||||
|
||||
func TestSubagentSpawnEnforcesTaskQuota(t *testing.T) {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/logger"
|
||||
"github.com/YspCoder/clawgo/pkg/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user