diff --git a/apps/apps.go b/apps/apps.go index 2db3d0fa..c2b1da83 100644 --- a/apps/apps.go +++ b/apps/apps.go @@ -549,7 +549,10 @@ func handleNew(w http.ResponseWriter, r *http.Request) { sb.WriteString(``) sb.WriteString(`

`) sb.WriteString(`
`) + sb.WriteString(`

`) + sb.WriteString(`
`) sb.WriteString(`
`) + sb.WriteString(`

Set a price and earn 90% of every sale. Free apps cost nothing to use.

`) sb.WriteString(``) sb.WriteString(``) @@ -1517,7 +1520,7 @@ func GetApp(slug string) *App { // UpdateApp updates an existing app's fields. Only non-empty values are applied. // Returns the updated app or an error. -func UpdateApp(slug, name, description, tags, html, icon string) (*App, error) { +func UpdateApp(slug, name, description, tags, html, icon string, price int) (*App, error) { mutex.Lock() a, ok := apps[slug] if !ok { @@ -1544,6 +1547,12 @@ func UpdateApp(slug, name, description, tags, html, icon string) (*App, error) { } a.HTML = html } + if price >= 0 { + if price > 1000 { + price = 1000 + } + a.Price = price + } if changed { snapshotVersion(a, "") } diff --git a/main.go b/main.go index 3bf8247d..eeb7e6a2 100644 --- a/main.go +++ b/main.go @@ -369,11 +369,12 @@ func main() { {Name: "description", Type: "string", Description: "Short description of what the app does", Required: true}, {Name: "tags", Type: "string", Description: "Comma-separated tags (optional)", Required: false}, {Name: "html", Type: "string", Description: "The app's HTML content (can include inline CSS and JavaScript, max 256KB)", Required: true}, + {Name: "price", Type: "number", Description: "Credits charged per use (0 = free, max 1000)", Required: false}, }, }) api.RegisterTool(api.Tool{ Name: "apps_edit", - Description: "Edit an existing app — update its name, description, tags, icon, or HTML code", + Description: "Edit an existing app — update its name, description, tags, icon, HTML code, or price", Params: []api.ToolParam{ {Name: "slug", Type: "string", Description: "The app's URL slug (e.g. pomodoro-timer)", Required: true}, {Name: "name", Type: "string", Description: "New app name", Required: false}, @@ -381,6 +382,7 @@ func main() { {Name: "tags", Type: "string", Description: "New comma-separated tags", Required: false}, {Name: "html", Type: "string", Description: "New HTML content (max 256KB)", Required: false}, {Name: "icon", Type: "string", Description: "New SVG icon", Required: false}, + {Name: "price", Type: "number", Description: "Credits charged per use (0 = free, max 1000)", Required: false}, }, Handle: func(args map[string]any) (string, error) { slug, _ := args["slug"].(string) @@ -392,7 +394,11 @@ func main() { tags, _ := args["tags"].(string) html, _ := args["html"].(string) icon, _ := args["icon"].(string) - a, err := apps.UpdateApp(slug, name, description, tags, html, icon) + price := -1 // -1 means "not set" + if p, ok := args["price"].(float64); ok { + price = int(p) + } + a, err := apps.UpdateApp(slug, name, description, tags, html, icon, price) if err != nil { return fmt.Sprintf(`{"error":"%s"}`, err.Error()), err }