package steprun import ( stdio "git.novox.be/novox/mesh-sdk/go" ) // SeatTools are a build seat's verbs on one node, as its holder serves them (novox/hq ADR 0525 ยง10; mesh-sdk catalogue // buildSeatVerbs): `.current` (what the node runs, its capacity, whether it is paused), `.pause` and // `.resume`, the pause kept on the node's pause key by the puller. what names the asks in the descriptions ("Go"). func SeatTools(seat, what string, p *Puller) []stdio.Tool { verb := func(name, description string, run func() (any, error)) stdio.Tool { return stdio.Tool{Name: seat + "." + name, Description: description, Input: map[string]any{"type": "object", "properties": map[string]any{}}, Run: func(map[string]any) (any, error) { return run() }} } current := func() (any, error) { c := p.CapacityDetail() return map[string]any{"node": p.Node, "capacity": c.Effective, "capacity_why": c.Why, "capacity_detail": c, "running": p.Running(), "paused": p.Paused()}, nil } drop := stdio.Tool{Name: seat + ".drop", Description: "End an " + what + " ask its caller no longer waits for: it is kept as dropped on this node " + "(so a bus that gives it again has it refused), and a step running here for it is ended, written refused naming who dropped it and why.", Input: map[string]any{"type": "object", "required": []string{"id", "why"}, "properties": map[string]any{ "id": map[string]any{"type": "string", "description": "the ask's id"}, "by": map[string]any{"type": "string", "description": "who drops it"}, "why": map[string]any{"type": "string", "description": "why the caller no longer waits"}}}, Run: func(args map[string]any) (any, error) { str := func(k string) string { s, _ := args[k].(string); return s } if err := p.Drop(str("id"), str("by"), str("why")); err != nil { return nil, err } return map[string]any{}, nil }} return []stdio.Tool{drop, verb("current", "The "+what+" asks this node runs now (each one's id, kind and when it started), its build capacity (the configured one, "+ "bounded by the cores its node's build slice gives over the cores a step needs) and why, "+ "and whether it is paused.", current), verb("pause", "Take no new "+what+" ask on this node until resumed; an ask running here ends in its place. Kept "+ "across a restart (the node's pause key).", func() (any, error) { if err := p.Pause("the seat's pause verb"); err != nil { return nil, err } return current() }), verb("resume", "Take "+what+" asks again on this node.", func() (any, error) { if err := p.Resume("the seat's resume verb"); err != nil { return nil, err } return current() }), } }