| 1606 | static const char CBM_SCOUT_PROFILE_ARGUMENT[] = "--tool-profile=scout"; |
| 1607 | |
| 1608 | static char *cbm_build_json_mcp_entry(const char *binary_path, cbm_json_mcp_schema_t schema, |
| 1609 | const char *argument) { |
| 1610 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 1611 | if (!doc) { |
| 1612 | return NULL; |
| 1613 | } |
| 1614 | yyjson_mut_val *root = yyjson_mut_obj(doc); |
| 1615 | bool command_is_array = cbm_json_mcp_command_is_array(schema); |
| 1616 | yyjson_mut_val *command = |
| 1617 | command_is_array ? yyjson_mut_arr(doc) : yyjson_mut_strcpy(doc, binary_path); |
| 1618 | bool ok = root && command; |
| 1619 | if (ok && command_is_array) { |
| 1620 | ok = yyjson_mut_arr_add_strcpy(doc, command, binary_path); |
| 1621 | } |
| 1622 | if (ok) { |
| 1623 | yyjson_mut_doc_set_root(doc, root); |
| 1624 | ok = yyjson_mut_obj_add_val(doc, root, "command", command); |
| 1625 | } |
| 1626 | if (ok && !command_is_array) { |
| 1627 | yyjson_mut_val *args = yyjson_mut_arr(doc); |
| 1628 | ok = args && (!argument || yyjson_mut_arr_add_strcpy(doc, args, argument)) && |
| 1629 | yyjson_mut_obj_add_val(doc, root, "args", args); |
| 1630 | } |
| 1631 | const char *type = cbm_json_mcp_required_type(schema); |
| 1632 | if (ok && type) { |
| 1633 | ok = yyjson_mut_obj_add_strcpy(doc, root, "type", type); |
| 1634 | } |
| 1635 | char *json = ok ? yyjson_mut_write(doc, YYJSON_WRITE_NOFLAG, NULL) : NULL; |
| 1636 | yyjson_mut_doc_free(doc); |
| 1637 | return json; |
| 1638 | } |
| 1639 | |
| 1640 | static size_t cbm_json_mcp_ownership_fields(cbm_json_mcp_schema_t schema, const char *argument, |
| 1641 | cbm_json_like_object_field_t fields[3]) { |
no test coverage detected