| 1 | package builtin |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "encoding/json" |
| 6 | |
| 7 | "reasonix/internal/tool" |
| 8 | ) |
| 9 | |
| 10 | func init() { tool.RegisterBuiltin(getGoal{}) } |
| 11 | |
| 12 | type getGoal struct{} |
| 13 | |
| 14 | func (getGoal) Name() string { return "get_goal" } |
| 15 | func (getGoal) Description() string { |
| 16 | return "Read the current same-session goal, including its exact id/revision, objective, phase, admitted rounds, optional round limit, blocker reason, and live activation. Call this before update_goal." |
| 17 | } |
| 18 | func (getGoal) Schema() json.RawMessage { |
| 19 | return json.RawMessage(`{"type":"object","additionalProperties":false,"properties":{}}`) |
| 20 | } |
| 21 | func (getGoal) ReadOnly() bool { return true } |
| 22 | func (getGoal) PlanModeSafe() bool { return true } |
| 23 | func (getGoal) ProviderVisible(ctx context.Context) bool { |
| 24 | _, ok := tool.GoalLifecycleFromContext(ctx) |
| 25 | return ok |
| 26 | } |
| 27 | func (getGoal) Execute(ctx context.Context, args json.RawMessage) (string, error) { |
| 28 | var input struct{} |
| 29 | if err := decodeGoalArgs(args, &input, "get_goal"); err != nil { |
| 30 | return "", err |
| 31 | } |
| 32 | binding, err := goalBinding(ctx) |
| 33 | if err != nil { |
| 34 | return "", err |
| 35 | } |
| 36 | view, err := binding.Owner.GetGoal(ctx) |
| 37 | if err != nil { |
| 38 | return "", goalToolError("get_goal", err) |
| 39 | } |
| 40 | return goalToolResult(view) |
| 41 | } |
| 42 |