| 1802 | static const char CBM_SCOUT_PROFILE_ARGUMENT[] = "--tool-profile=scout"; |
| 1803 | |
| 1804 | static char *cbm_build_json_mcp_entry(const char *binary_path, cbm_json_mcp_schema_t schema, |
| 1805 | const char *argument) { |
| 1806 | yyjson_mut_doc *doc = yyjson_mut_doc_new(NULL); |
| 1807 | if (!doc) { |
| 1808 | return NULL; |
| 1809 | } |
| 1810 | yyjson_mut_val *root = yyjson_mut_obj(doc); |
| 1811 | bool command_is_array = cbm_json_mcp_command_is_array(schema); |
| 1812 | yyjson_mut_val *command = |
| 1813 | command_is_array ? yyjson_mut_arr(doc) : yyjson_mut_strcpy(doc, binary_path); |
| 1814 | bool ok = root && command; |
| 1815 | if (ok && command_is_array) { |
| 1816 | ok = yyjson_mut_arr_add_strcpy(doc, command, binary_path); |
| 1817 | } |
| 1818 | if (ok) { |
| 1819 | yyjson_mut_doc_set_root(doc, root); |
| 1820 | ok = yyjson_mut_obj_add_val(doc, root, "command", command); |
| 1821 | } |
| 1822 | if (ok && !command_is_array) { |
| 1823 | yyjson_mut_val *args = yyjson_mut_arr(doc); |
| 1824 | ok = args && (!argument || yyjson_mut_arr_add_strcpy(doc, args, argument)) && |
| 1825 | yyjson_mut_obj_add_val(doc, root, "args", args); |
| 1826 | } |
| 1827 | const char *type = cbm_json_mcp_required_type(schema); |
| 1828 | if (ok && type) { |
| 1829 | ok = yyjson_mut_obj_add_strcpy(doc, root, "type", type); |
| 1830 | } |
| 1831 | char *json = ok ? yyjson_mut_write(doc, YYJSON_WRITE_NOFLAG, NULL) : NULL; |
| 1832 | yyjson_mut_doc_free(doc); |
| 1833 | return json; |
| 1834 | } |
| 1835 | |
| 1836 | static size_t cbm_json_mcp_ownership_fields(cbm_json_mcp_schema_t schema, const char *argument, |
| 1837 | cbm_json_like_object_field_t fields[3]) { |
no test coverage detected