feat(headless): Add suggest endpoint to handle game action/content suggestions in headless player API

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-05-20 18:12:13 -07:00
parent d19db31ccd
commit 383f58c2da

View file

@ -475,6 +475,21 @@ func _handle_request(req: Dictionary) -> void:
"view":
var view_json: String = String(_api.view_json(target_slot))
_emit_response_with_view(rid_int, has_id, view_json)
"suggest":
# Stage 6.1.6 — read-only "what would the in-box AI do here".
# `suggest_json` returns a full `{"ok":...,"actions":[...]}`
# envelope; splice in the request id and forward verbatim.
# Side-effect-free: no state mutation, no turn advance.
var suggest_str: String = String(_api.suggest_json(target_slot))
var suggest_env: Dictionary = JSON.parse_string(suggest_str) as Dictionary
if suggest_env.is_empty():
_emit_response_error(
rid_int, has_id, "internal", "gdext returned non-JSON suggest envelope"
)
return
if has_id:
suggest_env["id"] = rid_int
_write_line(JSON.stringify(suggest_env))
"act":
var action_payload: Dictionary = req.get("action", {}) as Dictionary
if action_payload.is_empty():