MCPcopy Create free account
hub / github.com/browserwing/browserwing / Create

Method Create

backend/sdk/script.go:43–74  ·  view source on GitHub ↗

Create 创建脚本

(ctx context.Context, script *Script)

Source from the content-addressed store, hash-verified

41
42// Create 创建脚本
43func (sc *ScriptClient) Create(ctx context.Context, script *Script) (string, error) {
44 if sc.client.db == nil {
45 return "", fmt.Errorf("database not initialized")
46 }
47
48 if script.Name == "" {
49 return "", fmt.Errorf("script name is required")
50 }
51
52 // 生成脚本 ID
53 if script.ID == "" {
54 script.ID = uuid.New().String()
55 }
56
57 // 转换为内部模型
58 dbScript := &models.Script{
59 ID: script.ID,
60 Name: script.Name,
61 Description: script.Description,
62 URL: script.URL,
63 Actions: script.Actions,
64 Tags: script.Tags,
65 Group: script.Group,
66 }
67
68 // 保存到数据库
69 if err := sc.client.db.SaveScript(dbScript); err != nil {
70 return "", fmt.Errorf("failed to save script: %w", err)
71 }
72
73 return script.ID, nil
74}
75
76// Get 获取脚本
77func (sc *ScriptClient) Get(ctx context.Context, scriptID string) (*Script, error) {

Callers 4

convertFramesToGIFMethod · 0.80
downloadFileFromURLMethod · 0.80
mainFunction · 0.80
mainFunction · 0.80

Calls 1

SaveScriptMethod · 0.65

Tested by

no test coverage detected